Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
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
Commit
44f322bb
authored
Jul 07, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【代码优化】AI:聊天对话 index.vue 代码梳理 30%
parent
1064bbe5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
13 additions
and
14 deletions
+13
-14
src/api/ai/chat/message/index.ts
+3
-3
src/views/ai/chat/index/components/conversation/ConversationList.vue
+1
-1
src/views/ai/chat/index/components/message/MessageList.vue
+3
-3
src/views/ai/chat/index/components/message/MessageListEmpty.vue
+0
-0
src/views/ai/chat/index/components/message/MessageLoading.vue
+0
-0
src/views/ai/chat/index/components/message/MessageNewConversation.vue
+5
-6
src/views/ai/chat/index/components/role/RoleCategoryList.vue
+0
-0
src/views/ai/chat/index/components/role/RoleList.vue
+0
-0
src/views/ai/chat/index/components/role/index.vue
+1
-1
src/views/ai/chat/index/index.vue
+0
-0
No files found.
src/api/ai/chat/message/index.ts
View file @
44f322bb
...
...
@@ -30,7 +30,7 @@ export const ChatMessageApi = {
// 发送 Stream 消息
// 为什么不用 axios 呢?因为它不支持 SSE 调用
sendStream
:
async
(
send
ChatMessage
Stream
:
async
(
conversationId
:
number
,
content
:
string
,
ctrl
,
...
...
@@ -60,11 +60,11 @@ export const ChatMessageApi = {
},
// 删除消息
delete
:
async
(
id
:
string
)
=>
{
delete
ChatMessage
:
async
(
id
:
string
)
=>
{
return
await
request
.
delete
({
url
:
`/ai/chat/message/delete?id=
${
id
}
`
})
},
// 删除
消息 - 对话所有
消息
// 删除
指定对话的
消息
deleteByConversationId
:
async
(
conversationId
:
number
)
=>
{
return
await
request
.
delete
({
url
:
`/ai/chat/message/delete-by-conversation-id?conversationId=
${
conversationId
}
`
...
...
src/views/ai/chat/index/components/conversation/ConversationList.vue
View file @
44f322bb
...
...
@@ -98,7 +98,7 @@
<
script
setup
lang=
"ts"
>
import
{
ChatConversationApi
,
ChatConversationVO
}
from
'@/api/ai/chat/conversation'
import
{
ref
}
from
'vue'
import
Role
from
'../
../
role/index.vue'
import
Role
from
'../role/index.vue'
import
{
Bottom
,
Top
}
from
'@element-plus/icons-vue'
import
roleAvatarDefaultImg
from
'@/assets/ai/gpt.svg'
...
...
src/views/ai/chat/index/
Message
.vue
→
src/views/ai/chat/index/
components/message/MessageList
.vue
View file @
44f322bb
...
...
@@ -17,7 +17,7 @@
<el-button
class=
"btn-cus"
link
@
click=
"noCopy(item.content)"
>
<img
class=
"btn-image"
src=
"@/assets/ai/copy.svg"
/>
</el-button>
<el-button
class=
"btn-cus"
link
@
click=
"onDelete(item.id)"
>
<el-button
v-if=
"item.id > 0"
class=
"btn-cus"
link
@
click=
"onDelete(item.id)"
>
<img
class=
"btn-image"
src=
"@/assets/ai/delete.svg"
style=
"height: 17px"
/>
</el-button>
</div>
...
...
@@ -70,7 +70,7 @@ import { useClipboard } from '@vueuse/core'
import
{
PropType
}
from
'vue'
import
{
ArrowDownBold
,
Edit
,
RefreshRight
}
from
'@element-plus/icons-vue'
import
{
ChatConversationVO
}
from
'@/api/ai/chat/conversation'
import
{
useUserStore
}
from
'@/store/modules/user'
;
import
{
useUserStore
}
from
'@/store/modules/user'
import
userAvatarDefaultImg
from
'@/assets/imgs/avatar.gif'
import
roleAvatarDefaultImg
from
'@/assets/ai/gpt.svg'
...
...
@@ -138,7 +138,7 @@ const noCopy = async (content) => {
*/
const
onDelete
=
async
(
id
)
=>
{
// 删除 message
await
ChatMessageApi
.
delete
(
id
)
await
ChatMessageApi
.
delete
ChatMessage
(
id
)
ElMessage
({
message
:
'删除成功!'
,
type
:
'success'
...
...
src/views/ai/chat/index/
Cha
tEmpty.vue
→
src/views/ai/chat/index/
components/message/MessageLis
tEmpty.vue
View file @
44f322bb
File moved
src/views/ai/chat/index/MessageLoading.vue
→
src/views/ai/chat/index/
components/message/
MessageLoading.vue
View file @
44f322bb
File moved
src/views/ai/chat/index/
MessageNewChat
.vue
→
src/views/ai/chat/index/
components/message/MessageNewConversation
.vue
View file @
44f322bb
<!--
message
新增对话 -->
<!--
无聊天对话时,在 message 区域,可以
新增对话 -->
<
template
>
<div
class=
"new-chat"
>
<div
class=
"box-center"
>
...
...
@@ -11,14 +11,13 @@
</
template
>
<
script
setup
lang=
"ts"
>
// 定义钩子
const
emits
=
defineEmits
([
'onNewChat'
])
const
emits
=
defineEmits
([
'onNewConversation'
])
/**
* 新建 c
hat
* 新建 c
onversation 聊天对话
*/
const
handlerNewChat
=
async
()
=>
{
await
emits
(
'onNewChat
'
)
const
handlerNewChat
=
()
=>
{
emits
(
'onNewConversation
'
)
}
</
script
>
<
style
scoped
lang=
"scss"
>
...
...
src/views/ai/chat/index/role/RoleCategoryList.vue
→
src/views/ai/chat/index/
components/
role/RoleCategoryList.vue
View file @
44f322bb
File moved
src/views/ai/chat/index/role/RoleList.vue
→
src/views/ai/chat/index/
components/
role/RoleList.vue
View file @
44f322bb
File moved
src/views/ai/chat/index/role/index.vue
→
src/views/ai/chat/index/
components/
role/index.vue
View file @
44f322bb
...
...
@@ -68,7 +68,7 @@
<
script
setup
lang=
"ts"
>
import
{
ref
}
from
'vue'
import
Header
from
'.
/../components
/Header.vue'
import
Header
from
'.
.
/Header.vue'
import
RoleList
from
'./RoleList.vue'
import
ChatRoleForm
from
'@/views/ai/model/chatRole/ChatRoleForm.vue'
import
RoleCategoryList
from
'./RoleCategoryList.vue'
...
...
src/views/ai/chat/index/index.vue
View file @
44f322bb
This diff is collapsed.
Click to expand it.
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