mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? some chunk method pictures are not in English #437 feat: set the height of both html and body to 100% feat: add SharedChat feat: add shared hooks ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -4,7 +4,7 @@ import {
|
||||
IStats,
|
||||
IToken,
|
||||
} from '@/interfaces/database/chat';
|
||||
import { useCallback } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useDispatch, useSelector } from 'umi';
|
||||
|
||||
export const useFetchDialogList = () => {
|
||||
@ -248,3 +248,78 @@ export const useSelectStats = () => {
|
||||
};
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region shared chat
|
||||
|
||||
export const useCreateSharedConversation = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const createSharedConversation = useCallback(
|
||||
(userId?: string) => {
|
||||
return dispatch<any>({
|
||||
type: 'chatModel/createExternalConversation',
|
||||
payload: { userId },
|
||||
});
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
return createSharedConversation;
|
||||
};
|
||||
|
||||
export const useFetchSharedConversation = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const fetchSharedConversation = useCallback(
|
||||
(conversationId: string) => {
|
||||
return dispatch<any>({
|
||||
type: 'chatModel/getExternalConversation',
|
||||
payload: conversationId,
|
||||
});
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
return fetchSharedConversation;
|
||||
};
|
||||
|
||||
export const useCompleteSharedConversation = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const completeSharedConversation = useCallback(
|
||||
(payload: any) => {
|
||||
return dispatch<any>({
|
||||
type: 'chatModel/completeExternalConversation',
|
||||
payload: payload,
|
||||
});
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
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