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
391332c8
authored
Jun 13, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: ssr
parent
89e7c1ab
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
46 deletions
+53
-46
client/src/components/Radio/index.tsx
+1
-0
client/src/constants/theme.ts
+1
-2
client/src/pages/_error.tsx
+7
-9
client/src/pages/model/components/ModelList.tsx
+7
-2
client/src/pages/model/components/detail/components/ModelEditForm.tsx
+27
-30
client/src/pages/model/components/detail/index.tsx
+7
-1
client/src/pages/model/index.tsx
+1
-1
client/src/styles/reset.scss
+2
-1
No files found.
client/src/components/Radio/index.tsx
View file @
391332c8
...
@@ -25,6 +25,7 @@ const Radio = ({ list, value, onChange, ...props }: Props) => {
...
@@ -25,6 +25,7 @@ const Radio = ({ list, value, onChange, ...props }: Props) => {
mr
:
1
,
mr
:
1
,
borderRadius
:
'16px'
,
borderRadius
:
'16px'
,
transition
:
'0.2s'
,
transition
:
'0.2s'
,
boxSizing
:
'border-box'
,
...(
value
===
item
.
value
...(
value
===
item
.
value
?
{
?
{
border
:
'5px solid'
,
border
:
'5px solid'
,
...
...
client/src/constants/theme.ts
View file @
391332c8
...
@@ -11,8 +11,6 @@ const { definePartsStyle: switchPart, defineMultiStyleConfig: switchMultiStyle }
...
@@ -11,8 +11,6 @@ const { definePartsStyle: switchPart, defineMultiStyleConfig: switchMultiStyle }
createMultiStyleConfigHelpers
(
switchAnatomy
.
keys
);
createMultiStyleConfigHelpers
(
switchAnatomy
.
keys
);
const
{
definePartsStyle
:
selectPart
,
defineMultiStyleConfig
:
selectMultiStyle
}
=
const
{
definePartsStyle
:
selectPart
,
defineMultiStyleConfig
:
selectMultiStyle
}
=
createMultiStyleConfigHelpers
(
selectAnatomy
.
keys
);
createMultiStyleConfigHelpers
(
selectAnatomy
.
keys
);
const
{
definePartsStyle
:
checkboxPart
,
defineMultiStyleConfig
:
checkboxMultiStyle
}
=
createMultiStyleConfigHelpers
(
checkboxAnatomy
.
keys
);
// modal 弹窗
// modal 弹窗
const
ModalTheme
=
defineMultiStyleConfig
({
const
ModalTheme
=
defineMultiStyleConfig
({
...
@@ -69,6 +67,7 @@ const Button = defineStyleConfig({
...
@@ -69,6 +67,7 @@ const Button = defineStyleConfig({
backgroundImage
:
backgroundImage
:
'linear-gradient(to bottom right, #2152d9 0%,#3370ff 40%, #4e83fd 100%) !important'
,
'linear-gradient(to bottom right, #2152d9 0%,#3370ff 40%, #4e83fd 100%) !important'
,
color
:
'white'
,
color
:
'white'
,
border
:
'none'
,
_hover
:
{
_hover
:
{
filter
:
'brightness(115%)'
filter
:
'brightness(115%)'
},
},
...
...
client/src/pages/_error.tsx
View file @
391332c8
function
Error
({
errStr
}:
{
errStr
:
string
})
{
function
Error
()
{
return
<
p
>
{
errStr
}
</
p
>;
return
(
<
p
>
部分系统不兼容,导致页面崩溃。如果可以,请联系作者,反馈下具体操作和页面。大部分是 苹果 的
safari 浏览器导致,可以尝试更换 chrome 浏览器。
</
p
>
);
}
}
Error
.
getInitialProps
=
({
res
,
err
}:
{
res
:
any
;
err
:
any
})
=>
{
console
.
log
(
err
);
return
{
errStr
:
`部分系统不兼容,导致页面崩溃。如果可以,请联系作者,反馈下具体操作和页面。大部分是 苹果 的 safari 浏览器导致,可以尝试更换 chrome 浏览器。`
};
};
export
default
Error
;
export
default
Error
;
client/src/pages/model/components/ModelList.tsx
View file @
391332c8
...
@@ -9,9 +9,14 @@ import { useToast } from '@/hooks/useToast';
...
@@ -9,9 +9,14 @@ import { useToast } from '@/hooks/useToast';
import
{
useQuery
}
from
'@tanstack/react-query'
;
import
{
useQuery
}
from
'@tanstack/react-query'
;
import
{
useUserStore
}
from
'@/store/user'
;
import
{
useUserStore
}
from
'@/store/user'
;
import
{
MyModelsTypeEnum
}
from
'@/constants/user'
;
import
{
MyModelsTypeEnum
}
from
'@/constants/user'
;
import
dynamic
from
'next/dynamic'
;
import
Avatar
from
'@/components/Avatar'
;
const
Avatar
=
dynamic
(()
=>
import
(
'@/components/Avatar'
),
{
import
Tabs
from
'@/components/Tabs'
;
ssr
:
true
});
const
Tabs
=
dynamic
(()
=>
import
(
'@/components/Tabs'
),
{
ssr
:
true
});
const
ModelList
=
({
modelId
}:
{
modelId
:
string
})
=>
{
const
ModelList
=
({
modelId
}:
{
modelId
:
string
})
=>
{
const
[
currentTab
,
setCurrentTab
]
=
useState
(
MyModelsTypeEnum
.
my
);
const
[
currentTab
,
setCurrentTab
]
=
useState
(
MyModelsTypeEnum
.
my
);
...
...
client/src/pages/model/components/detail/components/ModelEditForm.tsx
View file @
391332c8
...
@@ -47,10 +47,10 @@ import { defaultShareChat } from '@/constants/model';
...
@@ -47,10 +47,10 @@ import { defaultShareChat } from '@/constants/model';
import
type
{
ShareChatEditType
}
from
'@/types/model'
;
import
type
{
ShareChatEditType
}
from
'@/types/model'
;
import
type
{
ModelSchema
}
from
'@/types/mongoSchema'
;
import
type
{
ModelSchema
}
from
'@/types/mongoSchema'
;
import
{
formatTimeToChatTime
,
useCopyData
,
getErrText
}
from
'@/utils/tools'
;
import
{
formatTimeToChatTime
,
useCopyData
,
getErrText
}
from
'@/utils/tools'
;
import
MyIcon
from
'@/components/Icon'
;
import
{
useGlobalStore
}
from
'@/store/global'
;
import
{
useGlobalStore
}
from
'@/store/global'
;
import
{
useUserStore
}
from
'@/store/user'
;
import
{
useUserStore
}
from
'@/store/user'
;
import
Avatar
from
'@/components/Avatar'
;
import
Avatar
from
'@/components/Avatar'
;
import
MyIcon
from
'@/components/Icon'
;
const
ModelEditForm
=
({
const
ModelEditForm
=
({
formHooks
,
formHooks
,
...
@@ -174,32 +174,6 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
...
@@ -174,32 +174,6 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
// init kb select list
// init kb select list
const
{
data
:
kbList
=
[]
}
=
useQuery
([
'loadKbList'
],
()
=>
loadKbList
());
const
{
data
:
kbList
=
[]
}
=
useQuery
([
'loadKbList'
],
()
=>
loadKbList
());
const
RenderSelectedKbList
=
useCallback
(()
=>
{
const
kbs
=
getValues
(
'chat.relatedKbs'
)?.
map
((
id
)
=>
kbList
.
find
((
kb
)
=>
kb
.
_id
===
id
))
||
[];
return
(
<>
{
kbs
.
map
((
item
)
=>
item
?
(
<
Card
key=
{
item
.
_id
}
p=
{
3
}
mt=
{
3
}
cursor=
{
'pointer'
}
onClick=
{
()
=>
router
.
push
(
`/kb?kbId=${item._id}`
)
}
>
<
Flex
alignItems=
{
'center'
}
>
<
Avatar
src=
{
item
.
avatar
}
w=
{
'20px'
}
h=
{
'20px'
}
></
Avatar
>
<
Box
ml=
{
3
}
fontWeight=
{
'bold'
}
>
{
item
.
name
}
</
Box
>
</
Flex
>
</
Card
>
)
:
null
)
}
</>
);
},
[
getValues
,
kbList
,
router
]);
return
(
return
(
<>
<>
...
@@ -353,7 +327,6 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
...
@@ -353,7 +327,6 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
</
Select
>
</
Select
>
</
Flex
>
</
Flex
>
)
}
)
}
<
Box
mt=
{
4
}
>
<
Box
mt=
{
4
}
>
<
Box
mb=
{
1
}
>
系统提示词
</
Box
>
<
Box
mb=
{
1
}
>
系统提示词
</
Box
>
<
Textarea
<
Textarea
...
@@ -408,7 +381,32 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
...
@@ -408,7 +381,32 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
选择
选择
</
Button
>
</
Button
>
</
Flex
>
</
Flex
>
<
RenderSelectedKbList
/>
{
(()
=>
{
const
kbs
=
getValues
(
'chat.relatedKbs'
)?.
map
((
id
)
=>
kbList
.
find
((
kb
)
=>
kb
.
_id
===
id
))
||
[];
return
(
<>
{
kbs
.
map
((
item
)
=>
item
?
(
<
Card
key=
{
item
.
_id
}
p=
{
3
}
mt=
{
3
}
cursor=
{
'pointer'
}
onClick=
{
()
=>
router
.
push
(
`/kb?kbId=${item._id}`
)
}
>
<
Flex
alignItems=
{
'center'
}
>
<
Avatar
src=
{
item
.
avatar
}
w=
{
'20px'
}
h=
{
'20px'
}
></
Avatar
>
<
Box
ml=
{
3
}
fontWeight=
{
'bold'
}
>
{
item
.
name
}
</
Box
>
</
Flex
>
</
Card
>
)
:
null
)
}
</>
);
})()
}
</
Card
>
</
Card
>
</>
</>
)
}
)
}
...
@@ -586,7 +584,6 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
...
@@ -586,7 +584,6 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
isChecked=
{
getValues
(
'chat.relatedKbs'
)?.
includes
(
item
.
_id
)
}
isChecked=
{
getValues
(
'chat.relatedKbs'
)?.
includes
(
item
.
_id
)
}
onChange=
{
(
e
)
=>
{
onChange=
{
(
e
)
=>
{
const
ids
=
getValues
(
'chat.relatedKbs'
);
const
ids
=
getValues
(
'chat.relatedKbs'
);
// toggle to true
if
(
e
.
target
.
checked
)
{
if
(
e
.
target
.
checked
)
{
setValue
(
'chat.relatedKbs'
,
ids
.
concat
(
item
.
_id
));
setValue
(
'chat.relatedKbs'
,
ids
.
concat
(
item
.
_id
));
}
else
{
}
else
{
...
...
client/src/pages/model/components/detail/index.tsx
View file @
391332c8
...
@@ -8,7 +8,13 @@ import { useForm } from 'react-hook-form';
...
@@ -8,7 +8,13 @@ import { useForm } from 'react-hook-form';
import
{
useQuery
}
from
'@tanstack/react-query'
;
import
{
useQuery
}
from
'@tanstack/react-query'
;
import
{
useUserStore
}
from
'@/store/user'
;
import
{
useUserStore
}
from
'@/store/user'
;
import
{
useLoading
}
from
'@/hooks/useLoading'
;
import
{
useLoading
}
from
'@/hooks/useLoading'
;
import
ModelEditForm
from
'./components/ModelEditForm'
;
import
Loading
from
'@/components/Loading'
;
import
dynamic
from
'next/dynamic'
;
const
ModelEditForm
=
dynamic
(()
=>
import
(
'./components/ModelEditForm'
),
{
loading
:
()
=>
<
Loading
fixed=
{
false
}
/>,
ssr
:
false
});
const
ModelDetail
=
({
modelId
,
isPc
}:
{
modelId
:
string
;
isPc
:
boolean
})
=>
{
const
ModelDetail
=
({
modelId
,
isPc
}:
{
modelId
:
string
;
isPc
:
boolean
})
=>
{
const
{
toast
}
=
useToast
();
const
{
toast
}
=
useToast
();
...
...
client/src/pages/model/index.tsx
View file @
391332c8
...
@@ -10,7 +10,7 @@ import SideBar from '@/components/SideBar';
...
@@ -10,7 +10,7 @@ import SideBar from '@/components/SideBar';
const
ModelDetail
=
dynamic
(()
=>
import
(
'./components/detail/index'
),
{
const
ModelDetail
=
dynamic
(()
=>
import
(
'./components/detail/index'
),
{
loading
:
()
=>
<
Loading
fixed=
{
false
}
/>,
loading
:
()
=>
<
Loading
fixed=
{
false
}
/>,
ssr
:
fals
e
ssr
:
tru
e
});
});
const
Model
=
({
modelId
}:
{
modelId
:
string
})
=>
{
const
Model
=
({
modelId
}:
{
modelId
:
string
})
=>
{
...
...
client/src/styles/reset.scss
View file @
391332c8
...
@@ -65,13 +65,14 @@ textarea::placeholder {
...
@@ -65,13 +65,14 @@ textarea::placeholder {
-webkit-tap-highlight-color
:
rgba
(
0
,
0
,
0
,
0
);
-webkit-tap-highlight-color
:
rgba
(
0
,
0
,
0
,
0
);
-webkit-focus-ring-color
:
rgba
(
0
,
0
,
0
,
0
);
-webkit-focus-ring-color
:
rgba
(
0
,
0
,
0
,
0
);
outline
:
none
;
outline
:
none
;
box-sizing
:
border-box
;
}
}
#__next
{
#__next
{
height
:
100%
;
height
:
100%
;
}
}
#nprogress
.bar
{
#nprogress
.bar
{
background
:
'#
85b1ff
'
!
important
;
//自定义颜色
background
:
'#
1237b3
'
!
important
;
//自定义颜色
}
}
.textEllipsis
{
.textEllipsis
{
...
...
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