perf: unlogin user fetch data (#3775)

* model config

* feat: normalization embedding

* perf: unlogin user fetch data
This commit is contained in:
Archer
2025-02-13 13:36:33 +08:00
committed by GitHub
parent 1094c65f2b
commit d3641c877c
13 changed files with 104 additions and 43 deletions

View File

@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React, { useEffect, useMemo } from 'react';
import { Box, Flex } from '@chakra-ui/react';
import { useRouter } from 'next/router';
import { useLoading } from '@fastgpt/web/hooks/useLoading';
@@ -12,6 +12,8 @@ import { useI18nLng } from '@fastgpt/web/hooks/useI18n';
import Auth from './auth';
import { useSystem } from '@fastgpt/web/hooks/useSystem';
import { useMount } from 'ahooks';
import { useTranslation } from 'next-i18next';
import { useToast } from '@fastgpt/web/hooks/useToast';
const Navbar = dynamic(() => import('./navbar'));
const NavbarPhone = dynamic(() => import('./navbarPhone'));
@@ -50,8 +52,11 @@ export const navbarWidth = '64px';
const Layout = ({ children }: { children: JSX.Element }) => {
const router = useRouter();
const { t } = useTranslation();
const { toast } = useToast();
const { Loading } = useLoading();
const { loading, feConfigs, notSufficientModalType } = useSystemStore();
const { loading, feConfigs, notSufficientModalType, llmModelList, embeddingModelList } =
useSystemStore();
const { isPc } = useSystem();
const { userInfo, isUpdateNotification, setIsUpdateNotification } = useUserStore();
const { setUserDefaultLng } = useI18nLng();
@@ -82,6 +87,20 @@ const Layout = ({ children }: { children: JSX.Element }) => {
setUserDefaultLng();
});
// Check model invalid
useEffect(() => {
if (
userInfo?.username === 'root' &&
(llmModelList.length === 0 || embeddingModelList.length === 0)
) {
toast({
status: 'warning',
title: t('login:model_not_config')
});
router.push('/account/model');
}
}, [embeddingModelList.length, llmModelList.length, router, t, toast, userInfo?.username]);
return (
<>
<Box h={'100%'} bg={'myGray.100'}>