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
340de071
authored
May 12, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: home;perf: phone adapt
parent
1226c3ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
75 deletions
+111
-75
docs/dev/README.md
+1
-1
src/pages/chat/index.tsx
+76
-49
src/pages/index.tsx
+34
-25
No files found.
docs/dev/README.md
View file @
340de071
# FastGpt 本地开发
# FastGpt 本地开发
第一次开发,请先
[
部署教程
](
docs
/deploy/docker.md
)
,需要部署数据库.
第一次开发,请先
[
部署教程
](
..
/deploy/docker.md
)
,需要部署数据库.
## 环境变量配置
## 环境变量配置
...
...
src/pages/chat/index.tsx
View file @
340de071
...
@@ -359,26 +359,26 @@ const Chat = ({
...
@@ -359,26 +359,26 @@ const Chat = ({
]);
]);
// 删除一句话
// 删除一句话
const
delChatRecord
=
useCallback
(
async
()
=>
{
const
delChatRecord
=
useCallback
(
if
(
!
messageContextMenuData
)
return
;
async
(
index
:
number
,
historyId
:
string
)
=>
{
setIsLoading
(
true
);
if
(
!
messageContextMenuData
)
return
;
const
index
=
chatData
.
history
.
findIndex
(
setIsLoading
(
true
);
(
item
)
=>
item
.
_id
===
messageContextMenuData
.
message
.
_id
);
try
{
try
{
// 删除数据库最后一句
// 删除数据库最后一句
await
delChatRecordByIndex
(
chatId
,
messageContextMenuData
.
message
.
_i
d
);
await
delChatRecordByIndex
(
chatId
,
historyI
d
);
setChatData
((
state
)
=>
({
setChatData
((
state
)
=>
({
...
state
,
...
state
,
history
:
state
.
history
.
filter
((
_
,
i
)
=>
i
!==
index
)
history
:
state
.
history
.
filter
((
_
,
i
)
=>
i
!==
index
)
}));
}));
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
);
console
.
log
(
err
);
}
}
setIsLoading
(
false
);
setIsLoading
(
false
);
},
[
chatData
.
history
,
chatId
,
messageContextMenuData
,
setChatData
,
setIsLoading
]);
},
[
chatId
,
messageContextMenuData
,
setChatData
,
setIsLoading
]
);
// 复制内容
// 复制内容
const
onclickCopy
=
useCallback
(
const
onclickCopy
=
useCallback
(
...
@@ -485,7 +485,7 @@ const Chat = ({
...
@@ -485,7 +485,7 @@ const Chat = ({
}
}
setMessageContextMenuData({
setMessageContextMenuData({
left: e.clientX,
left: e.clientX
- 20
,
top: e.clientY,
top: e.clientY,
message
message
});
});
...
@@ -686,35 +686,51 @@ const Chat = ({
...
@@ -686,35 +686,51 @@ const Chat = ({
<Flex key={item._id} alignItems={'flex-start'} py={2} px={[2, 4]}>
<Flex key={item._id} alignItems={'flex-start'} py={2} px={[2, 4]}>
{item.obj === 'Human' && <Box flex={1} />}
{item.obj === 'Human' && <Box flex={1} />}
{/* avatar */}
{/* avatar */}
<Box
<Menu autoSelect={false} isLazy>
{...(item.obj === 'AI'
<MenuButton
? {
as={Box}
order: 1,
{...(item.obj === 'AI'
mr: ['6px', 4],
? {
cursor: 'pointer',
order: 1,
onClick: () => router.push(`/model?modelId=${chatData.modelId}`)
mr: ['6px', 4],
}
cursor: 'pointer',
: {
onClick: () => isPc && router.push(`/model?modelId=${chatData.modelId}`)
order: 3,
}
ml: ['6px', 4]
: {
})}
order: 3,
>
ml: ['6px', 4]
<Tooltip label={item.obj === 'AI' ? 'AI助手详情' : ''}>
})}
<Image
>
className="
avatar
"
<Tooltip label={item.obj === 'AI' ? 'AI助手详情' : ''}>
src={
<Image
item.obj === 'Human'
className="
avatar
"
? userInfo?.avatar
src={
: chatData.model.avatar || LOGO_ICON
item.obj === 'Human'
}
? userInfo?.avatar
alt="
avatar
"
: chatData.model.avatar || LOGO_ICON
w={['20px', '34px']}
}
h={['20px', '34px']}
alt="
avatar
"
borderRadius={'50%'}
w={['20px', '34px']}
objectFit={'contain'}
h={['20px', '34px']}
/>
borderRadius={'50%'}
</Tooltip>
objectFit={'contain'}
</Box>
/>
</Tooltip>
</MenuButton>
{!isPc && (
<MenuList fontSize={'sm'} minW={'100px !important'}>
{chatData.model.canUse && item.obj === 'AI' && (
<MenuItem
onClick={() => router.push(`/model?modelId=${chatData.modelId}`)}
>
AI助手详情
</MenuItem>
)}
<MenuItem onClick={() => onclickCopy(item.value)}>复制</MenuItem>
<MenuItem onClick={() => delChatRecord(index, item._id)}>删除</MenuItem>
</MenuList>
)}
</Menu>
{/* message */}
{/* message */}
<Flex order={2} maxW={['calc(100% - 50px)', '80%']}>
<Flex order={2} maxW={['calc(100% - 50px)', '80%']}>
{item.obj === 'AI' ? (
{item.obj === 'AI' ? (
...
@@ -898,7 +914,18 @@ const Chat = ({
...
@@ -898,7 +914,18 @@ const Chat = ({
<
MenuItem
onClick=
{
()
=>
onclickCopy
(
messageContextMenuData
.
message
.
value
)
}
>
<
MenuItem
onClick=
{
()
=>
onclickCopy
(
messageContextMenuData
.
message
.
value
)
}
>
复制
复制
</
MenuItem
>
</
MenuItem
>
<
MenuItem
onClick=
{
delChatRecord
}
>
删除
</
MenuItem
>
<
MenuItem
onClick=
{
()
=>
delChatRecord
(
chatData
.
history
.
findIndex
(
(
item
)
=>
item
.
_id
===
messageContextMenuData
.
message
.
_id
),
messageContextMenuData
.
message
.
_id
)
}
>
删除
</
MenuItem
>
</
MenuList
>
</
MenuList
>
</
Menu
>
</
Menu
>
</
Box
>
</
Box
>
...
...
src/pages/index.tsx
View file @
340de071
...
@@ -140,37 +140,46 @@ const Home = () => {
...
@@ -140,37 +140,46 @@ const Home = () => {
position=
{
'relative'
}
position=
{
'relative'
}
flexDirection=
{
'column'
}
flexDirection=
{
'column'
}
alignItems=
{
'center'
}
alignItems=
{
'center'
}
pt=
{
'20vh
'
}
h=
{
'100%
'
}
overflow=
{
'overlay'
}
overflow=
{
'overlay'
}
>
>
<
Box
id=
{
'particles-js'
}
position=
{
'absolute'
}
top=
{
0
}
left=
{
0
}
right=
{
0
}
bottom=
{
0
}
/>
<
Box
id=
{
'particles-js'
}
position=
{
'absolute'
}
top=
{
0
}
left=
{
0
}
right=
{
0
}
bottom=
{
0
}
/>
<
Image
src=
"/icon/logo.png"
w=
{
[
'70px'
,
'120px'
]
}
h=
{
[
'70px'
,
'120px'
]
}
alt=
{
''
}
></
Image
>
<
Box
fontWeight=
{
'bold'
}
fontSize=
{
[
'40px'
,
'70px'
]
}
letterSpacing=
{
'5px'
}
color=
{
'myBlue.600'
}
>
FastGpt
</
Box
>
<
Box
color=
{
'myBlue.600'
}
fontSize=
{
[
'30px'
,
'50px'
]
}
>
三分钟
</
Box
>
<
Box
color=
{
'myBlue.600'
}
fontSize=
{
[
'30px'
,
'50px'
]
}
>
搭建 AI 知识库
</
Box
>
<
Button
<
Flex
my=
{
5
}
flexDirection=
{
'column'
}
fontSize=
{
[
'xl'
,
'3xl'
]
}
alignItems=
{
'center'
}
h=
{
'auto
'
}
mt=
{
'22vh
'
}
p
y=
{
[
2
,
3
]
}
p
osition=
{
'absolute'
}
onClick=
{
()
=>
router
.
push
(
`/model`
)
}
userSelect=
{
'none'
}
>
>
点击开始
<
Image
src=
"/icon/logo.png"
w=
{
[
'70px'
,
'120px'
]
}
h=
{
[
'70px'
,
'120px'
]
}
alt=
{
''
}
></
Image
>
</
Button
>
<
Box
fontWeight=
{
'bold'
}
fontSize=
{
[
'40px'
,
'70px'
]
}
letterSpacing=
{
'5px'
}
color=
{
'myBlue.600'
}
>
FastGpt
</
Box
>
<
Box
color=
{
'myBlue.600'
}
fontSize=
{
[
'30px'
,
'50px'
]
}
>
三分钟
</
Box
>
<
Box
color=
{
'myBlue.600'
}
fontSize=
{
[
'30px'
,
'50px'
]
}
>
搭建 AI 知识库
</
Box
>
<
Button
my=
{
5
}
fontSize=
{
[
'xl'
,
'3xl'
]
}
h=
{
'auto'
}
py=
{
[
2
,
3
]
}
onClick=
{
()
=>
router
.
push
(
`/model`
)
}
>
点击开始
</
Button
>
</
Flex
>
<
Box
mt=
{
'20vh'
}
w=
{
'100%'
}
p
=
{
[
5
,
10
]
}
>
<
Box
w=
{
'100%'
}
mt=
{
'100vh'
}
px=
{
[
5
,
10
]
}
pb
=
{
[
5
,
10
]
}
>
<
Card
p=
{
5
}
lineHeight=
{
2
}
>
<
Card
p=
{
5
}
lineHeight=
{
2
}
>
<
Markdown
source=
{
data
}
isChatting=
{
false
}
/>
<
Markdown
source=
{
data
}
isChatting=
{
false
}
/>
</
Card
>
</
Card
>
...
...
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