### What problem does this PR solve? Embed the chat window into other websites through iframe #345 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
||||
IStats,
|
||||
IToken,
|
||||
} from '@/interfaces/database/chat';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useCallback } from 'react';
|
||||
import { useDispatch, useSelector } from 'umi';
|
||||
|
||||
export const useFetchDialogList = () => {
|
||||
@@ -299,27 +299,4 @@ export const useCompleteSharedConversation = () => {
|
||||
return completeSharedConversation;
|
||||
};
|
||||
|
||||
export const useCreatePublicUrlToken = (dialogId: string, visible: boolean) => {
|
||||
const [token, setToken] = useState();
|
||||
const createToken = useCreateToken(dialogId);
|
||||
const { protocol, host } = window.location;
|
||||
|
||||
const urlWithToken = `${protocol}//${host}/chat/share?shared_id=${token}`;
|
||||
|
||||
const createUrlToken = useCallback(async () => {
|
||||
if (visible) {
|
||||
const data = await createToken();
|
||||
const urlToken = data.data?.token;
|
||||
if (urlToken) {
|
||||
setToken(urlToken);
|
||||
}
|
||||
}
|
||||
}, [createToken, visible]);
|
||||
|
||||
useEffect(() => {
|
||||
createUrlToken();
|
||||
}, [createUrlToken]);
|
||||
|
||||
return { token, createUrlToken, urlWithToken };
|
||||
};
|
||||
//#endregion
|
||||
|
||||
Reference in New Issue
Block a user