提交 501beebb authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 9feeb73f
...@@ -14,7 +14,7 @@ const currentMenu = computed(() => { ...@@ -14,7 +14,7 @@ const currentMenu = computed(() => {
}) })
const currentSubmenu = computed(() => { const currentSubmenu = computed(() => {
return currentMenu.value?.children ? findMenu(route.path, currentMenu.value.children) : null return currentMenu.value?.children ? findMenu(route.fullPath, currentMenu.value.children) : null
}) })
function findMenu(path: string, menus: IMenuItem[]) { function findMenu(path: string, menus: IMenuItem[]) {
...@@ -22,13 +22,13 @@ function findMenu(path: string, menus: IMenuItem[]) { ...@@ -22,13 +22,13 @@ function findMenu(path: string, menus: IMenuItem[]) {
if ( if (
item.children && item.children &&
item.children.find(item => { item.children.find(item => {
const regExp = new RegExp(`^${item.path}`) const regExp = new RegExp(`^${item.path.replaceAll('?', '\\?')}`)
return regExp.test(path) return regExp.test(path)
}) })
) { ) {
return item return item
} }
const regExp = new RegExp(`^${item.path}`) const regExp = new RegExp(`^${item.path.replaceAll('?', '\\?')}`)
return regExp.test(path) return regExp.test(path)
}) })
} }
......
...@@ -32,6 +32,9 @@ const { usages, messages, post, isLoading } = useChat({ experiment_id: route.que ...@@ -32,6 +32,9 @@ const { usages, messages, post, isLoading } = useChat({ experiment_id: route.que
onMounted(() => { onMounted(() => {
messages.value.push({ role: 'system', content: welcomeMessage.value }) messages.value.push({ role: 'system', content: welcomeMessage.value })
if (form.value.content) {
messages.value.push({ role: 'bot', content: form.value.content })
}
}) })
// 设置为最后一条ai回复的内容 // 设置为最后一条ai回复的内容
...@@ -57,6 +60,18 @@ async function handleSend(event) { ...@@ -57,6 +60,18 @@ async function handleSend(event) {
} }
async function handleSendType(type, context) { 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 }) post({ type, context })
} }
...@@ -69,6 +84,10 @@ function scrollToBottom() { ...@@ -69,6 +84,10 @@ function scrollToBottom() {
watch(messages.value, () => nextTick(() => scrollToBottom())) watch(messages.value, () => nextTick(() => scrollToBottom()))
const { copy } = useClipboard() const { copy } = useClipboard()
function parseHtml(content) {
return content.replaceAll('\n', '<br/>')
}
</script> </script>
<template> <template>
...@@ -80,10 +99,10 @@ const { copy } = useClipboard() ...@@ -80,10 +99,10 @@ const { copy } = useClipboard()
<IconAI v-else /> <IconAI v-else />
</div> </div>
<div class="chat-message-main"> <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'"> <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="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 >刷新({{ usages.ai_refresh_count }}/{{ usages.ai_refresh_max_count }})</el-button
> >
<el-button size="small" type="primary" @click="handleSendType(2, item.content)" <el-button size="small" type="primary" @click="handleSendType(2, item.content)"
......
...@@ -56,10 +56,10 @@ export function useChat(options: any) { ...@@ -56,10 +56,10 @@ export function useChat(options: any) {
chatId.value = message.chatId + '' chatId.value = message.chatId + ''
const conversationId = message.conversationId const conversationId = message.conversationId
const messageIndex = messages.value.findIndex(session => session.conversationId === conversationId) const messageIndex = messages.value.findIndex(session => session.conversationId === conversationId)
let content = message.content || '' const content = message.content || ''
if (message.content === '\n') content = '<br/>' // if (message.content === '\n') content = '<br/>'
if (messageIndex === -1) { if (messageIndex === -1) {
messages.value.push({ conversationId, role: 'bot', content }) messages.value.push({ conversationId, role: 'bot', content, input: data.context })
} else { } else {
messages.value[messageIndex].content = messages.value[messageIndex].content + content messages.value[messageIndex].content = messages.value[messageIndex].content + content
} }
......
...@@ -32,4 +32,5 @@ export interface Message { ...@@ -32,4 +32,5 @@ export interface Message {
complete?: boolean complete?: boolean
finish?: boolean finish?: boolean
type?: string type?: string
input?: string
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论