unauth refresh

This commit is contained in:
archer 2025-12-24 14:10:01 +08:00
parent 77d4c2dea8
commit 85d910de52
No known key found for this signature in database
GPG Key ID: 4446499B846D4A9E
5 changed files with 18 additions and 9 deletions

View File

@ -17,12 +17,14 @@ export function useLinkedScroll<
pageSize = 10,
params = {},
currentData,
defaultScroll = 'top'
defaultScroll = 'top',
showErrorToast = true
}: {
pageSize?: number;
params?: Record<string, any>;
currentData?: { id: string; anchor?: any };
defaultScroll?: 'top' | 'bottom';
showErrorToast?: boolean;
}
) {
const { t } = useTranslation();
@ -105,7 +107,8 @@ export function useLinkedScroll<
onFinally() {
isInit.current = true;
},
manual: false
manual: false,
errorToast: showErrorToast ? undefined : ''
}
);
useEffect(() => {
@ -153,7 +156,8 @@ export function useLinkedScroll<
return response;
},
{
refreshDeps: [hasMorePrev, isLoading, params, pageSize]
refreshDeps: [hasMorePrev, isLoading, params, pageSize],
errorToast: showErrorToast ? undefined : ''
}
);
@ -188,7 +192,8 @@ export function useLinkedScroll<
return response;
},
{
refreshDeps: [hasMoreNext, isLoading, params, pageSize]
refreshDeps: [hasMoreNext, isLoading, params, pageSize],
errorToast: showErrorToast ? undefined : ''
}
);

View File

@ -269,7 +269,7 @@ export function useScrollPagination<
} catch (error: any) {
if (showErrorToast) {
toast({
title: getErrText(error, t('common:core.chat.error.data_error')),
title: t(getErrText(error, t('common:core.chat.error.data_error'))),
status: 'error'
});
}

View File

@ -26,6 +26,7 @@ import ChatSliderMobileDrawer from '@/pageComponents/chat/slider/ChatSliderMobil
import dynamic from 'next/dynamic';
import { getNanoid } from '@fastgpt/global/common/string/tools';
import { ChatErrEnum } from '@fastgpt/global/common/error/code/chat';
import { AppErrEnum } from '@fastgpt/global/common/error/code/app';
const CustomPluginRunBox = dynamic(() => import('@/pageComponents/chat/CustomPluginRunBox'));
@ -79,6 +80,9 @@ const AppChatWindow = () => {
onChangeChatId();
return;
}
if (e?.statusText === AppErrEnum.unAuthApp) {
refreshRecentlyUsed();
}
handlePaneChange(ChatSidebarPaneEnum.TEAM_APPS);
}
},

View File

@ -81,7 +81,7 @@ async function handler(
}
};
} catch (error: any) {
if (error === AppErrEnum.unAuthApp) {
if (error === AppErrEnum.unAuthApp && appId) {
const { tmbId } = await authCert({
req,
authToken: true,

View File

@ -67,8 +67,7 @@ const ChatRecordContextProvider = ({
setDataList: setChatRecords,
ScrollData,
isLoading,
itemRefs,
loadInitData
itemRefs
} = useLinkedScroll(
async (
data: LinkedPaginationProps<GetChatRecordsProps>
@ -94,7 +93,8 @@ const ChatRecordContextProvider = ({
pageSize: 10,
params,
currentData,
defaultScroll: 'bottom'
defaultScroll: 'bottom',
showErrorToast: false
}
);