mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-21 11:43:56 +00:00
4.8.5 perf app ui (#1845)
* list ui and layout * rename token key * app ui * ssr
This commit is contained in:
@@ -22,7 +22,7 @@ export const connectPg = async (): Promise<Pool> => {
|
||||
});
|
||||
|
||||
global.pgClient.on('error', async (err) => {
|
||||
console.log(err);
|
||||
addLog.error(`pg error`, err);
|
||||
global.pgClient?.end();
|
||||
global.pgClient = null;
|
||||
|
||||
@@ -36,6 +36,7 @@ export const connectPg = async (): Promise<Pool> => {
|
||||
console.log('pg connected');
|
||||
return global.pgClient;
|
||||
} catch (error) {
|
||||
addLog.error(`pg connect error`, error);
|
||||
global.pgClient?.end();
|
||||
global.pgClient = null;
|
||||
|
||||
|
@@ -85,7 +85,7 @@ export async function parseHeaderCert({
|
||||
async function authCookieToken(cookie?: string, token?: string) {
|
||||
// 获取 cookie
|
||||
const cookies = Cookie.parse(cookie || '');
|
||||
const cookieToken = token || cookies.token;
|
||||
const cookieToken = token || cookies[TokenName];
|
||||
|
||||
if (!cookieToken) {
|
||||
return Promise.reject(ERROR_ENUM.unAuthorization);
|
||||
@@ -198,12 +198,16 @@ export async function parseHeaderCert({
|
||||
}
|
||||
|
||||
/* set cookie */
|
||||
export const TokenName = 'fastgpt_token';
|
||||
export const setCookie = (res: NextApiResponse, token: string) => {
|
||||
res.setHeader('Set-Cookie', `token=${token}; Path=/; HttpOnly; Max-Age=604800; Samesite=Strict;`);
|
||||
res.setHeader(
|
||||
'Set-Cookie',
|
||||
`${TokenName}=${token}; Path=/; HttpOnly; Max-Age=604800; Samesite=Strict;`
|
||||
);
|
||||
};
|
||||
/* clear cookie */
|
||||
export const clearCookie = (res: NextApiResponse) => {
|
||||
res.setHeader('Set-Cookie', 'token=; Path=/; Max-Age=0');
|
||||
res.setHeader('Set-Cookie', `${TokenName}=; Path=/; Max-Age=0`);
|
||||
};
|
||||
|
||||
/* file permission */
|
||||
|
@@ -1,3 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 13" >
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.765 0.172234C5.92006 0.140343 6.07999 0.140343 6.23505 0.172234C6.41429 0.209098 6.5745 0.298831 6.70186 0.370168C6.71373 0.376812 6.7253 0.383296 6.73658 0.389563L11.0532 2.78771C11.0652 2.79434 11.0775 2.80111 11.0901 2.80805C11.2249 2.88232 11.3944 2.97569 11.5246 3.11696C11.6372 3.2391 11.7224 3.38386 11.7745 3.54157C11.8347 3.72398 11.834 3.91751 11.8335 4.07144C11.8334 4.08583 11.8334 4.09986 11.8334 4.11352V8.8485C11.8334 8.86215 11.8334 8.87619 11.8335 8.89057C11.834 9.0445 11.8347 9.23804 11.7745 9.42045C11.7224 9.57815 11.6372 9.72291 11.5246 9.84505C11.3944 9.98632 11.2249 10.0797 11.0901 10.154C11.0775 10.1609 11.0652 10.1677 11.0532 10.1743L6.73658 12.5725C6.7253 12.5787 6.71372 12.5852 6.70186 12.5918C6.57449 12.6632 6.41429 12.7529 6.23505 12.7898C6.07999 12.8217 5.92006 12.8217 5.765 12.7898C5.58575 12.7529 5.42554 12.6632 5.29818 12.5918C5.28632 12.5852 5.27474 12.5787 5.26346 12.5725L0.946797 10.1743C0.934865 10.1677 0.92257 10.1609 0.909971 10.154C0.775143 10.0797 0.605615 9.98632 0.475427 9.84505C0.362873 9.72291 0.277694 9.57815 0.225587 9.42045C0.165319 9.23804 0.166024 9.0445 0.166585 8.89057C0.166637 8.87619 0.166688 8.86215 0.166688 8.8485V4.11352C0.166688 4.09987 0.166637 4.08583 0.166585 4.07144C0.166024 3.91752 0.165319 3.72398 0.225587 3.54157C0.277694 3.38386 0.362872 3.2391 0.475427 3.11696C0.605613 2.97569 0.775138 2.88232 0.909965 2.80806C0.922566 2.80112 0.934863 2.79434 0.946797 2.78771L5.26346 0.389563C5.27474 0.383296 5.28632 0.376813 5.29818 0.370169C5.42555 0.298831 5.58575 0.209098 5.765 0.172234ZM6.00002 1.31792C5.99913 1.31834 5.9982 1.31878 5.99723 1.31925C5.96357 1.33549 5.91845 1.3603 5.83005 1.40941L1.95119 3.56434L6 5.81368L10.0488 3.56433L6.17 1.40941C6.0816 1.3603 6.03647 1.33549 6.00281 1.31925C6.00184 1.31878 6.00091 1.31834 6.00002 1.31792ZM10.6667 4.5557V8.8485C10.6667 8.95523 10.6664 9.00986 10.6641 9.04942C10.664 9.05059 10.6639 9.0517 10.6639 9.05277C10.663 9.05335 10.662 9.05395 10.661 9.05458C10.6276 9.07587 10.58 9.10262 10.4867 9.15445L6.58335 11.323L6.58334 6.82422L10.6667 4.5557ZM5.41667 6.82422L1.33336 4.55572V8.8485C1.33336 8.95523 1.3336 9.00986 1.33598 9.04942C1.33605 9.05059 1.33612 9.0517 1.33619 9.05277C1.33709 9.05335 1.33803 9.05395 1.33901 9.05458C1.37244 9.07587 1.42007 9.10262 1.51338 9.15445L5.41669 11.323L5.41667 6.82422Z"/>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.76503 0.691246C6.92009 0.659355 7.08002 0.659355 7.23508 0.691246C7.41432 0.728111 7.57453 0.817843 7.70189 0.889181C7.71376 0.895824 7.72533 0.902308 7.73661 0.908575L12.0533 3.30672C12.0652 3.31335 12.0775 3.32013 12.0901 3.32707C12.2249 3.40133 12.3945 3.4947 12.5246 3.63597C12.6372 3.75811 12.7224 3.90288 12.7745 4.06058C12.8348 4.24299 12.8341 4.43653 12.8335 4.59045C12.8334 4.60484 12.8334 4.61888 12.8334 4.63253V9.36751C12.8334 9.38116 12.8334 9.3952 12.8335 9.40959C12.8341 9.56351 12.8348 9.75705 12.7745 9.93946C12.7224 10.0972 12.6372 10.2419 12.5246 10.3641C12.3945 10.5053 12.2249 10.5987 12.0901 10.673C12.0775 10.6799 12.0652 10.6867 12.0533 10.6933L7.73661 13.0915C7.72533 13.0977 7.71375 13.1042 7.70189 13.1109C7.57453 13.1822 7.41432 13.2719 7.23508 13.3088C7.08002 13.3407 6.92009 13.3407 6.76503 13.3088C6.58578 13.2719 6.42558 13.1822 6.29821 13.1109C6.28635 13.1042 6.27477 13.0977 6.26349 13.0915L1.94683 10.6933C1.9349 10.6867 1.9226 10.6799 1.91 10.673C1.77517 10.5987 1.60565 10.5053 1.47546 10.3641C1.3629 10.2419 1.27772 10.0972 1.22562 9.93946C1.16535 9.75705 1.16605 9.56351 1.16662 9.40959C1.16667 9.3952 1.16672 9.38116 1.16672 9.36751V4.63253C1.16672 4.61888 1.16667 4.60484 1.16662 4.59045C1.16605 4.43653 1.16535 4.24299 1.22562 4.06058C1.27772 3.90288 1.3629 3.75811 1.47546 3.63597C1.60564 3.4947 1.77517 3.40133 1.91 3.32707C1.9226 3.32013 1.93489 3.31335 1.94683 3.30672L6.26349 0.908575C6.27477 0.902309 6.28635 0.895825 6.29821 0.889182C6.42558 0.817844 6.58578 0.728111 6.76503 0.691246ZM7.00005 1.83693C6.99917 1.83735 6.99823 1.8378 6.99727 1.83826C6.9636 1.8545 6.91848 1.87931 6.83008 1.92843L2.95122 4.08335L7.00003 6.33269L11.0489 4.08334L7.17003 1.92843C7.08163 1.87931 7.0365 1.8545 7.00284 1.83826C7.00187 1.8378 7.00094 1.83735 7.00005 1.83693ZM11.6667 5.07471V9.36751C11.6667 9.47425 11.6665 9.52888 11.6641 9.56843C11.664 9.5696 11.664 9.57071 11.6639 9.57178C11.663 9.57236 11.662 9.57296 11.6611 9.57359C11.6276 9.59488 11.58 9.62163 11.4867 9.67346L7.58338 11.842L7.58337 7.34324L11.6667 5.07471ZM6.4167 7.34324L2.33339 5.07473V9.36751C2.33339 9.47425 2.33363 9.52888 2.33601 9.56844C2.33608 9.5696 2.33615 9.57071 2.33622 9.57178C2.33712 9.57236 2.33806 9.57296 2.33905 9.57359C2.37247 9.59488 2.42011 9.62163 2.51341 9.67346L6.41672 11.842L6.4167 7.34324Z" />
|
||||
</svg>
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
18541
pnpm-lock.yaml
generated
18541
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,6 @@ 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'));
|
||||
@@ -79,7 +78,7 @@ const Layout = ({ children }: { children: JSX.Element }) => {
|
||||
return (
|
||||
<>
|
||||
<Box h={'100%'} bg={'myGray.100'}>
|
||||
{isPc ? (
|
||||
{isPc === true && (
|
||||
<>
|
||||
{isHideNavbar ? (
|
||||
<Auth>{children}</Auth>
|
||||
@@ -94,22 +93,21 @@ const Layout = ({ children }: { children: JSX.Element }) => {
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
)}
|
||||
{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>
|
||||
{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>
|
||||
|
@@ -88,7 +88,7 @@ const Navbar = ({ unread }: { unread: number }) => {
|
||||
{/* logo */}
|
||||
<Box
|
||||
flex={'0 0 auto'}
|
||||
mb={5}
|
||||
mb={3}
|
||||
border={'2px solid #fff'}
|
||||
borderRadius={'50%'}
|
||||
overflow={'hidden'}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { PermissionTypeEnum, PermissionTypeMap } from '@fastgpt/global/support/permission/constant';
|
||||
import { Box, Flex, FlexProps } from '@chakra-ui/react';
|
||||
import { Box, StackProps, HStack } from '@chakra-ui/react';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { PermissionValueType } from '@fastgpt/global/support/permission/type';
|
||||
@@ -15,7 +15,7 @@ const PermissionIconText = ({
|
||||
}: {
|
||||
permission?: `${PermissionTypeEnum}`;
|
||||
defaultPermission?: PermissionValueType;
|
||||
} & FlexProps) => {
|
||||
} & StackProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const per = useMemo(() => {
|
||||
@@ -30,12 +30,10 @@ const PermissionIconText = ({
|
||||
}, [defaultPermission, permission]);
|
||||
|
||||
return PermissionTypeMap[per] ? (
|
||||
<Flex alignItems={'center'} fontSize={fontSize} {...props}>
|
||||
<HStack spacing={1} fontSize={fontSize} {...props}>
|
||||
<MyIcon name={PermissionTypeMap[per]?.iconLight as any} w={w} />
|
||||
<Box ml={'2px'} lineHeight={1}>
|
||||
{t(PermissionTypeMap[per]?.label)}
|
||||
</Box>
|
||||
</Flex>
|
||||
<Box lineHeight={1}>{t(PermissionTypeMap[per]?.label)}</Box>
|
||||
</HStack>
|
||||
) : null;
|
||||
};
|
||||
|
||||
|
@@ -71,7 +71,7 @@ const AppCard = () => {
|
||||
<Box px={6} py={4} position={'relative'}>
|
||||
<Flex alignItems={'center'}>
|
||||
<Avatar src={appDetail.avatar} borderRadius={'md'} w={'28px'} />
|
||||
<Box ml={3} fontWeight={'bold'} fontSize={'md'} flex={'1 0 0'}>
|
||||
<Box ml={3} fontWeight={'bold'} fontSize={'md'} flex={'1 0 0'} color={'myGray.900'}>
|
||||
{appDetail.name}
|
||||
</Box>
|
||||
</Flex>
|
||||
|
@@ -35,7 +35,7 @@ const ChatTest = ({ appForm }: { appForm: AppSimpleEditFormType }) => {
|
||||
return (
|
||||
<Flex position={'relative'} flexDirection={'column'} h={'100%'} py={4}>
|
||||
<Flex px={[2, 5]}>
|
||||
<Box fontSize={['md', 'lg']} fontWeight={'bold'} flex={1}>
|
||||
<Box fontSize={['md', 'lg']} fontWeight={'bold'} flex={1} color={'myGray.900'}>
|
||||
{appT('Chat Debug')}
|
||||
</Box>
|
||||
<MyTooltip label={t('core.chat.Restart')}>
|
||||
|
@@ -103,8 +103,14 @@ const ListItem = () => {
|
||||
return (
|
||||
<>
|
||||
<Grid
|
||||
py={[4, 6]}
|
||||
gridTemplateColumns={['1fr', 'repeat(2,1fr)', 'repeat(3,1fr)', 'repeat(4,1fr)']}
|
||||
py={4}
|
||||
gridTemplateColumns={[
|
||||
'1fr',
|
||||
'repeat(2,1fr)',
|
||||
'repeat(3,1fr)',
|
||||
'repeat(3,1fr)',
|
||||
'repeat(4,1fr)'
|
||||
]}
|
||||
gridGap={5}
|
||||
alignItems={'stretch'}
|
||||
>
|
||||
@@ -126,14 +132,14 @@ const ListItem = () => {
|
||||
isLoading={loadingAppId === app._id}
|
||||
lineHeight={1.5}
|
||||
h="100%"
|
||||
pt={4}
|
||||
pt={5}
|
||||
pb={3}
|
||||
px={5}
|
||||
cursor={'pointer'}
|
||||
border={'base'}
|
||||
boxShadow={'2'}
|
||||
bg={'white'}
|
||||
borderRadius={'md'}
|
||||
borderRadius={'lg'}
|
||||
userSelect={'none'}
|
||||
position={'relative'}
|
||||
display={'flex'}
|
||||
@@ -171,24 +177,24 @@ const ListItem = () => {
|
||||
<AppTypeTag type={app.type} />
|
||||
</Box> */}
|
||||
<HStack>
|
||||
<Avatar src={app.avatar} borderRadius={'md'} w={'1.3rem'} />
|
||||
<Box flex={'1'} wordBreak={'break-all'}>
|
||||
<Avatar src={app.avatar} borderRadius={'md'} w={'1.5rem'} />
|
||||
<Box flex={'1 0 0'} fontSize={'1.125rem'}>
|
||||
{app.name}
|
||||
</Box>
|
||||
<Box alignSelf={'flex-start'} mr={'-1.25rem'}>
|
||||
<Box mr={'-1.25rem'}>
|
||||
<AppTypeTag type={app.type} />
|
||||
</Box>
|
||||
</HStack>
|
||||
<Box
|
||||
flex={'1'}
|
||||
className={'textEllipsis3'}
|
||||
my={2}
|
||||
flex={'1 0 80px'}
|
||||
mt={3}
|
||||
pr={8}
|
||||
textAlign={'justify'}
|
||||
wordBreak={'break-all'}
|
||||
fontSize={'mini'}
|
||||
color={'myGray.600'}
|
||||
minH={'32px'}
|
||||
fontSize={'xs'}
|
||||
color={'myGray.500'}
|
||||
>
|
||||
{app.intro || '还没写介绍~'}
|
||||
<Box className={'textEllipsis2'}>{app.intro || '还没写介绍~'}</Box>
|
||||
</Box>
|
||||
<Flex
|
||||
h={'24px'}
|
||||
@@ -198,16 +204,16 @@ const ListItem = () => {
|
||||
color={'myGray.500'}
|
||||
>
|
||||
<HStack spacing={3.5}>
|
||||
{/* {owner && (
|
||||
{owner && (
|
||||
<HStack spacing={1}>
|
||||
<Avatar src={owner.avatar} w={'0.9rem'} />
|
||||
<Avatar src={owner.avatar} w={'0.875rem'} />
|
||||
<Box maxW={'150px'} className="textEllipsis">
|
||||
{owner.memberName}
|
||||
</Box>
|
||||
</HStack>
|
||||
)} */}
|
||||
)}
|
||||
|
||||
<PermissionIconText defaultPermission={app.defaultPermission} />
|
||||
<PermissionIconText defaultPermission={app.defaultPermission} w={'0.875rem'} />
|
||||
</HStack>
|
||||
|
||||
<HStack>
|
||||
@@ -222,7 +228,7 @@ const ListItem = () => {
|
||||
<IconButton
|
||||
size={'xsSquare'}
|
||||
variant={'transparentBase'}
|
||||
icon={<MyIcon name={'more'} w={'0.8rem'} />}
|
||||
icon={<MyIcon name={'more'} w={'0.875rem'} color={'myGray.500'} />}
|
||||
aria-label={''}
|
||||
/>
|
||||
}
|
||||
|
@@ -40,15 +40,15 @@ const AppTypeTag = ({ type }: { type: AppTypeEnum }) => {
|
||||
|
||||
return data ? (
|
||||
<Flex
|
||||
bg={data.bg}
|
||||
color={data.color}
|
||||
bg={'myGray.100'}
|
||||
color={'myGray.600'}
|
||||
py={0.5}
|
||||
pl={2}
|
||||
pr={2}
|
||||
pr={3}
|
||||
borderLeftRadius={'md'}
|
||||
whiteSpace={'nowrap'}
|
||||
>
|
||||
<MyIcon name={data.icon as any} w={'0.8rem'} />
|
||||
<MyIcon name={data.icon as any} w={'0.8rem'} color={'myGray.500'} />
|
||||
<Box ml={1} fontSize={'mini'}>
|
||||
{data.label}
|
||||
</Box>
|
||||
|
@@ -144,6 +144,7 @@ const MyApps = () => {
|
||||
gap={5}
|
||||
display={'flex'}
|
||||
alignItems={'center'}
|
||||
fontSize={'md'}
|
||||
onChange={(e) => {
|
||||
router.push({
|
||||
query: {
|
||||
|
@@ -12,6 +12,7 @@ import { serviceSideProps } from '@/web/common/utils/i18n';
|
||||
import { clearToken, setToken } from '@/web/support/user/auth';
|
||||
import Script from 'next/script';
|
||||
import Loading from '@fastgpt/web/components/common/MyLoading';
|
||||
import { useMount } from 'ahooks';
|
||||
|
||||
const RegisterForm = dynamic(() => import('./components/RegisterForm'));
|
||||
const ForgetPasswordForm = dynamic(() => import('./components/ForgetPasswordForm'));
|
||||
@@ -61,10 +62,11 @@ const Login = () => {
|
||||
feConfigs?.oauth?.wechat ? LoginPageTypeEnum.wechat : LoginPageTypeEnum.passwordLogin
|
||||
);
|
||||
}, [feConfigs.oauth]);
|
||||
useEffect(() => {
|
||||
|
||||
useMount(() => {
|
||||
clearToken();
|
||||
router.prefetch('/app/list');
|
||||
}, []);
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@@ -11,6 +11,7 @@ import Loading from '@fastgpt/web/components/common/MyLoading';
|
||||
import { serviceSideProps } from '@/web/common/utils/i18n';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useMount } from 'ahooks';
|
||||
|
||||
const provider = ({ code, state, error }: { code: string; state: string; error?: string }) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -51,6 +52,7 @@ const provider = ({ code, state, error }: { code: string; state: string; error?:
|
||||
callbackUrl: `${location.origin}/login/provider`,
|
||||
inviterId: localStorage.getItem('inviterId') || undefined
|
||||
});
|
||||
|
||||
if (!res) {
|
||||
toast({
|
||||
status: 'warning',
|
||||
@@ -74,7 +76,7 @@ const provider = ({ code, state, error }: { code: string; state: string; error?:
|
||||
[loginStore, loginSuccess, router, toast]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
useMount(() => {
|
||||
clearToken();
|
||||
router.prefetch('/app/list');
|
||||
if (error) {
|
||||
@@ -98,7 +100,7 @@ const provider = ({ code, state, error }: { code: string; state: string; error?:
|
||||
return;
|
||||
}
|
||||
authCode(code);
|
||||
}, []);
|
||||
});
|
||||
|
||||
return <Loading />;
|
||||
};
|
||||
|
@@ -7,6 +7,13 @@
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
.textEllipsis2 {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.textEllipsis3 {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
|
Reference in New Issue
Block a user