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
fc315283
authored
May 17, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【增加】AI Chat 应道页面
parent
48b3b08f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
4 deletions
+93
-4
src/views/ai/chat/ChatEmpty.vue
+84
-0
src/views/ai/chat/index.vue
+9
-4
No files found.
src/views/ai/chat/ChatEmpty.vue
0 → 100644
View file @
fc315283
<
template
>
<div
class=
"chat-empty"
>
<!-- title -->
<div
class=
"center-container"
>
<div
class=
"title"
>
芋艿 AI
</div>
<div
class=
"role-list"
>
<div
class=
"role-item"
v-for=
"prompt in promptList"
:key=
"prompt.prompt"
@
click=
"handlerPromptClick(prompt)"
>
{{
prompt
.
prompt
}}
</div>
</div>
</div>
</div>
</
template
>
<
script
setup
lang=
"ts"
>
const
router
=
useRouter
()
const
promptList
=
ref
<
any
[]
>
()
// 角色列表
promptList
.
value
=
[
{
"prompt"
:
"今天天气怎么样?"
,
},
{
"prompt"
:
"写一首好听的诗歌?"
,
}
]
const
emits
=
defineEmits
([
'onPrompt'
])
const
handlerPromptClick
=
async
({
prompt
})
=>
{
emits
(
'onPrompt'
,
prompt
)
}
onMounted
(
async
()
=>
{
})
</
script
>
<
style
scoped
lang=
"scss"
>
.chat-empty
{
position
:
relative
;
display
:
flex
;
flex-direction
:
row
;
justify-content
:
center
;
width
:
100%
;
height
:
100%
;
.center-container
{
display
:
flex
;
flex-direction
:
column
;
justify-content
:
center
;
.title
{
font-size
:
28px
;
font-weight
:
bold
;
text-align
:
center
;
}
.role-list
{
display
:
flex
;
flex-direction
:
row
;
flex-wrap
:
wrap
;
align-items
:
center
;
justify-content
:
center
;
width
:
460px
;
margin-top
:
20px
;
.role-item
{
display
:
flex
;
justify-content
:
center
;
width
:
180px
;
line-height
:
50px
;
border
:
1px
solid
#e4e4e4
;
border-radius
:
10px
;
margin
:
10px
;
cursor
:
pointer
;
}
.role-item
:hover
{
background-color
:
rgba
(
243
,
243
,
243
,
0.73
);
}
}
}
}
</
style
>
src/views/ai/chat/index.vue
View file @
fc315283
...
...
@@ -31,12 +31,15 @@
</div>
</el-header>
<!--
main
-->
<!--
main
-->
<el-main
class=
"main-container"
>
<div
class=
"message-container"
>
<Message
ref=
"messageRef"
:list=
"list"
@
onDeleteSuccess=
"handlerMessageDelete"
/>
<Message
v-if=
"list.length > 0"
ref=
"messageRef"
:list=
"list"
@
on-delete-success=
"handlerMessageDelete"
/>
<ChatEmpty
v-if=
"list.length === 0"
@
on-prompt=
"onSend"
/>
</div>
</el-main>
<!-- 底部 -->
<el-footer
class=
"footer-container"
>
<form
@
submit
.
prevent=
"onSend"
class=
"prompt-from"
>
<textarea
...
...
@@ -84,10 +87,12 @@
<
script
setup
lang=
"ts"
>
import
Conversation
from
'./Conversation.vue'
import
Message
from
'./Message.vue'
import
ChatEmpty
from
'./ChatEmpty.vue'
import
{
ChatMessageApi
,
ChatMessageVO
}
from
'@/api/ai/chat/message'
import
{
ChatConversationApi
,
ChatConversationVO
}
from
'@/api/ai/chat/conversation'
import
{
useClipboard
}
from
'@vueuse/core'
import
ChatConversationUpdateForm
from
"@/views/ai/chat/components/ChatConversationUpdateForm.vue"
;
import
{
send
}
from
"vite"
;
const
route
=
useRoute
()
// 路由
const
message
=
useMessage
()
// 消息弹窗
...
...
@@ -153,7 +158,7 @@ const onPromptInput = (event) => {
/**
* 发送消息
*/
const
onSend
=
async
()
=>
{
const
onSend
=
async
(
val
?:
string
)
=>
{
// 判断用户是否在输入
if
(
isComposing
.
value
)
{
return
...
...
@@ -162,7 +167,7 @@ const onSend = async () => {
if
(
conversationInProgress
.
value
)
{
return
}
const
content
=
prompt
.
value
?.
trim
()
+
''
const
content
=
(
val
?
val
:
prompt
.
value
?.
trim
())
as
string
if
(
content
.
length
<
2
)
{
ElMessage
({
message
:
'请输入内容!'
,
...
...
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