mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-25 20:02:47 +00:00
* Revert "lafAccount add pat & re request when token invalid (#76)" (#77) This reverts commit 83d85dfe37adcaef4833385ea52ee79fd84720be. * perf: workflow ux * system config * Newflow (#89) * docs: Add doc for Xinference (#1266) Signed-off-by: Carson Yang <yangchuansheng33@gmail.com> * Revert "lafAccount add pat & re request when token invalid (#76)" (#77) This reverts commit 83d85dfe37adcaef4833385ea52ee79fd84720be. * perf: workflow ux * system config * Revert "lafAccount add pat & re request when token invalid (#76)" (#77) This reverts commit 83d85dfe37adcaef4833385ea52ee79fd84720be. * Revert "lafAccount add pat & re request when token invalid (#76)" (#77) This reverts commit 83d85dfe37adcaef4833385ea52ee79fd84720be. * Revert "lafAccount add pat & re request when token invalid (#76)" (#77) This reverts commit 83d85dfe37adcaef4833385ea52ee79fd84720be. * rename code * move code * update flow * input type selector * perf: workflow runtime * feat: node adapt newflow * feat: adapt plugin * feat: 360 connection * check workflow * perf: flow 性能 * change plugin input type (#81) * change plugin input type * plugin label mode * perf: nodecard * debug * perf: debug ui * connection ui * change workflow ui (#82) * feat: workflow debug * adapt openAPI for new workflow (#83) * adapt openAPI for new workflow * i18n * perf: plugin debug * plugin input ui * delete * perf: global variable select * fix rebase * perf: workflow performance * feat: input render type icon * input icon * adapt flow (#84) * adapt newflow * temp * temp * fix * feat: app schedule trigger * feat: app schedule trigger * perf: schedule ui * feat: ioslatevm run js code * perf: workflow varialbe table ui * feat: adapt simple mode * feat: adapt input params * output * feat: adapt tamplate * fix: ts * add if-else module (#86) * perf: worker * if else node * perf: tiktoken worker * fix: ts * perf: tiktoken * fix if-else node (#87) * fix if-else node * type * fix * perf: audio render * perf: Parallel worker * log * perf: if else node * adapt plugin * prompt * perf: reference ui * reference ui * handle ux * template ui and plugin tool * adapt v1 workflow * adapt v1 workflow completions * perf: time variables * feat: workflow keyboard shortcuts * adapt v1 workflow * update workflow example doc (#88) * fix: simple mode select tool --------- Signed-off-by: Carson Yang <yangchuansheng33@gmail.com> Co-authored-by: Carson Yang <yangchuansheng33@gmail.com> Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com> * doc * perf: extract node * extra node field * update plugin version * doc * variable * change doc & fix prompt editor (#90) * fold workflow code * value type label --------- Signed-off-by: Carson Yang <yangchuansheng33@gmail.com> Co-authored-by: Carson Yang <yangchuansheng33@gmail.com> Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
129 lines
4.1 KiB
TypeScript
129 lines
4.1 KiB
TypeScript
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';
|
|
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
|
import { throttle } from 'lodash';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { useUserStore } from '@/web/support/user/useUserStore';
|
|
import { getUnreadCount } from '@/web/support/user/inform/api';
|
|
import dynamic from 'next/dynamic';
|
|
|
|
import Auth from './auth';
|
|
const Navbar = dynamic(() => import('./navbar'));
|
|
const NavbarPhone = dynamic(() => import('./navbarPhone'));
|
|
const UpdateInviteModal = dynamic(() => import('@/components/support/user/team/UpdateInviteModal'));
|
|
const NotSufficientModal = dynamic(() => import('@/components/support/wallet/NotSufficientModal'));
|
|
const SystemMsgModal = dynamic(() => import('@/components/support/user/inform/SystemMsgModal'));
|
|
const ImportantInform = dynamic(() => import('@/components/support/user/inform/ImportantInform'));
|
|
|
|
const pcUnShowLayoutRoute: Record<string, boolean> = {
|
|
'/': true,
|
|
'/login': true,
|
|
'/login/provider': true,
|
|
'/login/fastlogin': true,
|
|
'/chat/share': true,
|
|
'/chat/team': true,
|
|
'/app/edit': true,
|
|
'/chat': true,
|
|
'/tools/price': true,
|
|
'/price': true
|
|
};
|
|
const phoneUnShowLayoutRoute: Record<string, boolean> = {
|
|
'/': true,
|
|
'/login': true,
|
|
'/login/provider': true,
|
|
'/login/fastlogin': true,
|
|
'/chat/share': true,
|
|
'/chat/team': true,
|
|
'/tools/price': true,
|
|
'/price': true
|
|
};
|
|
|
|
const Layout = ({ children }: { children: JSX.Element }) => {
|
|
const router = useRouter();
|
|
const { Loading } = useLoading();
|
|
const { loading, setScreenWidth, isPc, feConfigs, isNotSufficientModal } = useSystemStore();
|
|
const { userInfo } = useUserStore();
|
|
|
|
const isChatPage = useMemo(
|
|
() => router.pathname === '/chat' && Object.values(router.query).join('').length !== 0,
|
|
[router.pathname, router.query]
|
|
);
|
|
|
|
// listen screen width
|
|
useEffect(() => {
|
|
const resize = throttle(() => {
|
|
setScreenWidth(document.documentElement.clientWidth);
|
|
}, 300);
|
|
|
|
window.addEventListener('resize', resize);
|
|
|
|
resize();
|
|
|
|
return () => {
|
|
window.removeEventListener('resize', resize);
|
|
};
|
|
}, [setScreenWidth]);
|
|
|
|
const { data, refetch: refetchUnRead } = useQuery(['getUnreadCount'], getUnreadCount, {
|
|
enabled: !!userInfo && !!feConfigs.isPlus,
|
|
refetchInterval: 10000
|
|
});
|
|
const unread = data?.unReadCount || 0;
|
|
const importantInforms = data?.importantInforms || [];
|
|
|
|
const isHideNavbar = !!pcUnShowLayoutRoute[router.pathname];
|
|
|
|
return (
|
|
<>
|
|
<Box h={'100%'} bg={'myGray.100'}>
|
|
{isPc === true && (
|
|
<>
|
|
{isHideNavbar ? (
|
|
<Auth>{children}</Auth>
|
|
) : (
|
|
<>
|
|
<Box h={'100%'} position={'fixed'} left={0} top={0} w={'64px'}>
|
|
<Navbar unread={unread} />
|
|
</Box>
|
|
<Box h={'100%'} ml={'70px'} overflow={'overlay'}>
|
|
<Auth>{children}</Auth>
|
|
</Box>
|
|
</>
|
|
)}
|
|
</>
|
|
)}
|
|
{isPc === false && (
|
|
<>
|
|
<Box h={'100%'} display={['block', 'none']}>
|
|
{phoneUnShowLayoutRoute[router.pathname] || isChatPage ? (
|
|
<Auth>{children}</Auth>
|
|
) : (
|
|
<Flex h={'100%'} flexDirection={'column'}>
|
|
<Box flex={'1 0 0'} h={0}>
|
|
<Auth>{children}</Auth>
|
|
</Box>
|
|
<Box h={'50px'} borderTop={'1px solid rgba(0,0,0,0.1)'}>
|
|
<NavbarPhone unread={unread} />
|
|
</Box>
|
|
</Flex>
|
|
)}
|
|
</Box>
|
|
</>
|
|
)}
|
|
|
|
{!!userInfo && <UpdateInviteModal />}
|
|
{isNotSufficientModal && !isHideNavbar && <NotSufficientModal />}
|
|
{!!userInfo && <SystemMsgModal />}
|
|
{!!userInfo && importantInforms.length > 0 && (
|
|
<ImportantInform informs={importantInforms} refetch={refetchUnRead} />
|
|
)}
|
|
</Box>
|
|
<Loading loading={loading} zIndex={999999} />
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default Layout;
|