|
|
@@ -6,6 +6,7 @@ import { useAppStore, useChatStore,useSettingStore } from '@/store'
|
|
|
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
|
|
import { debounce } from '@/utils/functions/debounce'
|
|
|
import { fetchGetMask } from '@/api'
|
|
|
+import { useChat } from '../../hooks/useChat'
|
|
|
|
|
|
const { isMobile } = useBasicLayout()
|
|
|
|
|
|
@@ -15,12 +16,28 @@ const chatStore = useChatStore()
|
|
|
const dataSources = computed(() => chatStore.history)
|
|
|
|
|
|
const settingStore = useSettingStore()
|
|
|
+const { addChat } = useChat()
|
|
|
async function handleSelect({ uuid, maskId }: Chat.History) {
|
|
|
if (maskId) {
|
|
|
fetchGetMask(maskId).then((res: any) => {
|
|
|
settingStore.updateSetting({
|
|
|
systemMessage: res.describe
|
|
|
})
|
|
|
+ if (res.welcomeMessage) {
|
|
|
+ let chats = chatStore.chat.find(item => {
|
|
|
+ return item.uuid == uuid
|
|
|
+ })?.data
|
|
|
+ if (chats?.length === 0) {
|
|
|
+ addChat(+uuid, {
|
|
|
+ dateTime: new Date().toLocaleString(),
|
|
|
+ text: res.welcomeMessage,
|
|
|
+ inversion: false,
|
|
|
+ error: false,
|
|
|
+ conversationOptions: null,
|
|
|
+ requestOptions: { prompt: res.welcomeMessage, options: null }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
} else {
|
|
|
settingStore.resetSetting()
|