Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
saas-dml
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
saas-dml
Commits
501beebb
提交
501beebb
authored
4月 10, 2024
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: update
上级
9feeb73f
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
28 行增加
和
8 行删除
+28
-8
Aside.vue
src/components/layout/Aside.vue
+3
-3
AIChat.vue
src/modules/material/all/components/AIChat.vue
+21
-2
useChat.ts
src/modules/material/all/composables/useChat.ts
+3
-3
types.ts
src/modules/material/all/types.ts
+1
-0
没有找到文件。
src/components/layout/Aside.vue
浏览文件 @
501beebb
...
...
@@ -14,7 +14,7 @@ const currentMenu = computed(() => {
})
const
currentSubmenu
=
computed
(()
=>
{
return
currentMenu
.
value
?.
children
?
findMenu
(
route
.
p
ath
,
currentMenu
.
value
.
children
)
:
null
return
currentMenu
.
value
?.
children
?
findMenu
(
route
.
fullP
ath
,
currentMenu
.
value
.
children
)
:
null
})
function
findMenu
(
path
:
string
,
menus
:
IMenuItem
[])
{
...
...
@@ -22,13 +22,13 @@ function findMenu(path: string, menus: IMenuItem[]) {
if
(
item
.
children
&&
item
.
children
.
find
(
item
=>
{
const
regExp
=
new
RegExp
(
`^
${
item
.
path
}
`
)
const
regExp
=
new
RegExp
(
`^
${
item
.
path
.
replaceAll
(
'?'
,
'
\\
?'
)
}
`
)
return
regExp
.
test
(
path
)
})
)
{
return
item
}
const
regExp
=
new
RegExp
(
`^
${
item
.
path
}
`
)
const
regExp
=
new
RegExp
(
`^
${
item
.
path
.
replaceAll
(
'?'
,
'
\\
?'
)
}
`
)
return
regExp
.
test
(
path
)
})
}
...
...
src/modules/material/all/components/AIChat.vue
浏览文件 @
501beebb
...
...
@@ -32,6 +32,9 @@ const { usages, messages, post, isLoading } = useChat({ experiment_id: route.que
onMounted
(()
=>
{
messages
.
value
.
push
({
role
:
'system'
,
content
:
welcomeMessage
.
value
})
if
(
form
.
value
.
content
)
{
messages
.
value
.
push
({
role
:
'bot'
,
content
:
form
.
value
.
content
})
}
})
// 设置为最后一条ai回复的内容
...
...
@@ -57,6 +60,18 @@ async function handleSend(event) {
}
async
function
handleSendType
(
type
,
context
)
{
switch
(
type
)
{
case
2
:
context
=
`请帮我创作一个,
${
context
}
`
break
case
3
:
context
=
`请帮我润色一个,
${
context
}
`
break
case
4
:
context
=
`请帮我扩写一个,
${
context
}
`
break
}
post
({
type
,
context
})
}
...
...
@@ -69,6 +84,10 @@ function scrollToBottom() {
watch
(
messages
.
value
,
()
=>
nextTick
(()
=>
scrollToBottom
()))
const
{
copy
}
=
useClipboard
()
function
parseHtml
(
content
)
{
return
content
.
replaceAll
(
'
\
n'
,
'<br/>'
)
}
</
script
>
<
template
>
...
...
@@ -80,10 +99,10 @@ const { copy } = useClipboard()
<IconAI
v-else
/>
</div>
<div
class=
"chat-message-main"
>
<div
class=
"chat-message-content"
v-html=
"
item.content
"
></div>
<div
class=
"chat-message-content"
v-html=
"
parseHtml(item.content)
"
></div>
<div
class=
"chat-message-extra"
v-if=
"item.role !== 'user'"
>
<el-button
size=
"small"
type=
"primary"
@
click=
"copy(item.content)"
>
复制
</el-button>
<el-button
size=
"small"
type=
"primary"
@
click=
"handleSendType(5, item.content)"
v-if=
"item.role == 'bot'"
<el-button
size=
"small"
type=
"primary"
@
click=
"handleSendType(5, item.
input || item.
content)"
v-if=
"item.role == 'bot'"
>
刷新(
{{
usages
.
ai_refresh_count
}}
/
{{
usages
.
ai_refresh_max_count
}}
)
</el-button
>
<el-button
size=
"small"
type=
"primary"
@
click=
"handleSendType(2, item.content)"
...
...
src/modules/material/all/composables/useChat.ts
浏览文件 @
501beebb
...
...
@@ -56,10 +56,10 @@ export function useChat(options: any) {
chatId
.
value
=
message
.
chatId
+
''
const
conversationId
=
message
.
conversationId
const
messageIndex
=
messages
.
value
.
findIndex
(
session
=>
session
.
conversationId
===
conversationId
)
le
t
content
=
message
.
content
||
''
if
(
message
.
content
===
'
\
n'
)
content
=
'<br/>'
cons
t
content
=
message
.
content
||
''
//
if (message.content === '\n') content = '<br/>'
if
(
messageIndex
===
-
1
)
{
messages
.
value
.
push
({
conversationId
,
role
:
'bot'
,
content
})
messages
.
value
.
push
({
conversationId
,
role
:
'bot'
,
content
,
input
:
data
.
context
})
}
else
{
messages
.
value
[
messageIndex
].
content
=
messages
.
value
[
messageIndex
].
content
+
content
}
...
...
src/modules/material/all/types.ts
浏览文件 @
501beebb
...
...
@@ -32,4 +32,5 @@ export interface Message {
complete
?:
boolean
finish
?:
boolean
type
?:
string
input
?:
string
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论