Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
ca8e940c
authored
Apr 28, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: image and auth
parent
75073a64
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
22 deletions
+24
-22
src/components/Layout/auth.tsx
+2
-1
src/components/Layout/index.tsx
+7
-6
src/pages/api/model/share/getCollection.ts
+2
-3
src/pages/api/model/share/getModels.ts
+2
-5
src/pages/chat/index.tsx
+6
-2
src/pages/model/detail/components/ModelEditForm.tsx
+3
-3
src/pages/model/detail/index.tsx
+1
-1
src/pages/model/share/components/list.tsx
+1
-1
No files found.
src/components/Layout/auth.tsx
View file @
ca8e940c
...
...
@@ -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
})
=>
{
...
...
src/components/Layout/index.tsx
View file @
ca8e940c
...
...
@@ -21,18 +21,19 @@ const navbarList = [
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'
,
link
:
'/number/setting'
,
...
...
src/pages/api/model/share/getCollection.ts
View file @
ca8e940c
...
...
@@ -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
:
[]
});
}
}
src/pages/api/model/share/getModels.ts
View file @
ca8e940c
...
...
@@ -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
,
...
...
src/pages/chat/index.tsx
View file @
ca8e940c
...
...
@@ -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
)
}
/>
...
...
src/pages/model/detail/components/ModelEditForm.tsx
View file @
ca8e940c
...
...
@@ -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
}
>
...
...
src/pages/model/detail/index.tsx
View file @
ca8e940c
...
...
@@ -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
,
...
...
src/pages/model/share/components/list.tsx
View file @
ca8e940c
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'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment