mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
perf: image and auth
This commit is contained in:
@@ -7,7 +7,8 @@ import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
const unAuthPage: { [key: string]: boolean } = {
|
||||
'/': true,
|
||||
'/login': true
|
||||
'/login': true,
|
||||
'/model/share': true
|
||||
};
|
||||
|
||||
const Auth = ({ children }: { children: JSX.Element }) => {
|
||||
|
@@ -20,18 +20,19 @@ const navbarList = [
|
||||
link: '/',
|
||||
activeLink: ['/']
|
||||
},
|
||||
{
|
||||
label: '模型',
|
||||
icon: 'model',
|
||||
link: '/model/list',
|
||||
activeLink: ['/model/list', '/model/detail']
|
||||
},
|
||||
{
|
||||
label: '共享',
|
||||
icon: 'shareMarket',
|
||||
link: '/model/share',
|
||||
activeLink: ['/model/share']
|
||||
},
|
||||
{
|
||||
label: '模型',
|
||||
icon: 'model',
|
||||
link: '/model/list',
|
||||
activeLink: ['/model/list', '/model/detail']
|
||||
},
|
||||
|
||||
{
|
||||
label: '账号',
|
||||
icon: 'user',
|
||||
|
@@ -21,7 +21,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||
data: collections
|
||||
.map((item: any) => ({
|
||||
_id: item.modelId?._id,
|
||||
avatar: item.modelId?.avatar || '',
|
||||
avatar: item.modelId?.avatar || '/icon/logo.png',
|
||||
name: item.modelId?.name || '',
|
||||
userId: item.modelId?.userId || '',
|
||||
share: item.modelId?.share || {},
|
||||
@@ -31,8 +31,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||
});
|
||||
} catch (err) {
|
||||
jsonRes(res, {
|
||||
code: 500,
|
||||
error: err
|
||||
data: []
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -8,9 +8,6 @@ import type { ShareModelItem } from '@/types/model';
|
||||
/* 获取模型列表 */
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
|
||||
try {
|
||||
// 凭证校验
|
||||
await authToken(req.headers.authorization);
|
||||
|
||||
const {
|
||||
searchText = '',
|
||||
pageNum = 1,
|
||||
@@ -28,7 +25,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||
]
|
||||
};
|
||||
|
||||
// 根据分享的模型
|
||||
// 获取被分享的模型
|
||||
const [models, total] = await Promise.all([
|
||||
Model.find(where, '_id avatar name userId share')
|
||||
.sort({
|
||||
@@ -45,7 +42,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||
pageSize,
|
||||
data: models.map((item) => ({
|
||||
_id: item._id,
|
||||
avatar: item.avatar,
|
||||
avatar: item.avatar || '/icon/logo.png',
|
||||
name: item.name,
|
||||
userId: item.userId,
|
||||
share: item.share,
|
||||
|
@@ -470,8 +470,12 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => {
|
||||
<Menu autoSelect={false}>
|
||||
<MenuButton as={Box} mr={media(4, 1)} cursor={'pointer'}>
|
||||
<Image
|
||||
src={item.obj === 'Human' ? '/icon/human.png' : chatData.avatar}
|
||||
alt="/icon/logo.png"
|
||||
src={
|
||||
item.obj === 'Human'
|
||||
? '/icon/human.png'
|
||||
: chatData.avatar || '/icon/logo.png'
|
||||
}
|
||||
alt="avatar"
|
||||
width={media(30, 20)}
|
||||
height={media(30, 20)}
|
||||
/>
|
||||
|
@@ -78,14 +78,14 @@ const ModelEditForm = ({
|
||||
头像:
|
||||
</Box>
|
||||
<Image
|
||||
src={getValues('avatar')}
|
||||
src={getValues('avatar') || '/icon/logo.png'}
|
||||
alt={'avatar'}
|
||||
w={['28px', '36px']}
|
||||
h={['28px', '36px']}
|
||||
objectFit={'cover'}
|
||||
cursor={'pointer'}
|
||||
cursor={isOwner ? 'pointer' : 'default'}
|
||||
title={'点击切换头像'}
|
||||
onClick={onOpenSelectFile}
|
||||
onClick={() => isOwner && onOpenSelectFile()}
|
||||
/>
|
||||
</Flex>
|
||||
<FormControl mt={4}>
|
||||
|
@@ -85,7 +85,7 @@ const ModelDetail = ({ modelId }: { modelId: string }) => {
|
||||
try {
|
||||
await putModelById(data._id, {
|
||||
name: data.name,
|
||||
avatar: data.avatar,
|
||||
avatar: data.avatar || '/icon/logo.png',
|
||||
systemPrompt: data.systemPrompt,
|
||||
temperature: data.temperature,
|
||||
search: data.search,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Card, Box, Flex, Image, Button } from '@chakra-ui/react';
|
||||
import { Box, Flex, Image, Button } from '@chakra-ui/react';
|
||||
import type { ShareModelItem } from '@/types/model';
|
||||
import { useRouter } from 'next/router';
|
||||
import MyIcon from '@/components/Icon';
|
||||
|
Reference in New Issue
Block a user