From 159b54f5a1fbeaafda37b3d4178efb912a82c55b Mon Sep 17 00:00:00 2001 From: cc500 <2014434568@qq.com> Date: Thu, 23 Jan 2025 15:10:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E4=BA=A7=E5=BA=93=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/dialogue/dialogueView.vue | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/views/dialogue/dialogueView.vue b/src/views/dialogue/dialogueView.vue index ba388af..d9b16f1 100644 --- a/src/views/dialogue/dialogueView.vue +++ b/src/views/dialogue/dialogueView.vue @@ -9,11 +9,10 @@ import Copilot from './Copilot.vue'; import { useChangeThemeStore } from 'src/store'; import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'; import { api } from 'src/apis'; -import { fa } from 'element-plus/es/locale'; import { ElMessage } from 'element-plus'; -import { apiKeyApi } from 'srcapis/paths'; import { watch } from 'vue'; import i18n from 'src/i18n' +import { reactive } from 'vue'; // 挂载全局事件 window.onHtmlEventDispatch = onHtmlEventDispatch as any; @@ -42,7 +41,7 @@ export interface ModelForm { [property: string]: any; } const kb_id = localStorage.getItem("kb_id")||""; -const ruleForm = ref({ +const ruleForm = reactive({ kb_id: kb_id, }); const rules = ref(); @@ -138,13 +137,14 @@ const lang = computed(() => (language.value === 'EN' ? 'English' : '简体中文 const handleConfirmCreateModel = async (formData: any | undefined) => { const [_, res] = await api.updateKnowledgeList({ - kb_id: ruleForm.value.kb_id || "", + kb_id: ruleForm.kb_id || "", }) if(!_&&res){ - localStorage.setItem('kb_id', ruleForm.value.kb_id || "") + localStorage.setItem('kb_id', ruleForm.kb_id || "") ElMessage.success("成功"); KnowledgeVisible.value = false; }else { + ruleForm.kb_id = ""; ElMessage.error("失败"); KnowledgeVisible.value = false; } @@ -165,15 +165,18 @@ onMounted(() => { api.getKnowledgeList().then((res) => { ruleForm.value = res; }); + if(localStorage.getItem('kb_id')){ + ruleForm.kb_id = localStorage.getItem('kb_id'); + } }); watch( ruleForm, () => { let flag = false; - Object.keys(ruleForm.value).forEach((item) => { + Object.keys(ruleForm).forEach((item) => { if (rules.value?.[item]?.[0]?.required) { - if (!ruleForm.value?.[item]?.toString()?.length) { + if (!ruleForm?.[item]?.toString()?.length) { flag = true; } } @@ -278,7 +281,6 @@ watch( >