wujingjing
2024-09-12 495d1510f9a9ebf1f488569f6ca24a6be56bc9f3
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();