feat: translate EmbedModal #345 (#455)

### 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:
balibabu
2024-04-19 16:55:23 +08:00
committed by GitHub
parent 962c66714e
commit cda7b607cb
14 changed files with 314 additions and 106 deletions

View File

@@ -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