From 96d13ee431fef2fb5eaba05654cd7e0216ce36ab Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期五, 28 六月 2024 16:53:26 +0800 Subject: [PATCH] 新建聊天室 --- src/components/chat/Chat.vue | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index b0d66bc..cf387e6 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -44,6 +44,8 @@ import { md } from './libs/markdown'; import { RoleEnum, roleImageMap, type ChatMessage } from './types'; import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue'; +import { activeChatRoom } from '/@/stores/chatRoom'; +import router from '/@/router'; let apiKey = ''; let isConfig = ref(false); @@ -71,8 +73,13 @@ if (getAPIKey()) { switchConfigStatus(); } - const inputValue = history.state.inputValue; - messageContent.value = inputValue; + if (!activeChatRoom.value) { + router.replace({ + name: 'Home', + }); + return; + } + messageContent.value = activeChatRoom.value.title; sendOrSave(); }); @@ -144,6 +151,10 @@ const sendOrSave = () => { if (!messageContent.value.length) return; + if (activeChatRoom.value.isInitial) { + activeChatRoom.value.title = messageContent.value; + activeChatRoom.value.isInitial = false; + } if (isConfig.value) { if (saveAPIKey(messageContent.value.trim())) { switchConfigStatus(); -- Gitblit v1.9.3