From 13461f925b10ea7236afe396ce3abd8079775872 Mon Sep 17 00:00:00 2001 From: Sjshi763 Date: Sat, 17 Jan 2026 19:20:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BB=85=E7=99=BD=E5=90=8D=E5=8D=95?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=8F=AF=E4=BB=A5=E4=BD=9C=E4=B8=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/src/views/PersonaPage.vue | 47 +++++++++++++++++------------ 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/dashboard/src/views/PersonaPage.vue b/dashboard/src/views/PersonaPage.vue index 9c447f54b..b23ae7e12 100644 --- a/dashboard/src/views/PersonaPage.vue +++ b/dashboard/src/views/PersonaPage.vue @@ -331,28 +331,37 @@ export default { try { const text = await file.text(); - const parsedData = JSON.parse(text); - - console.log("Parsed Data:", parsedData); + const parsedData = JSON.parse(text); + + console.log("Parsed Data:", parsedData); - // 验证必需字段 - if (!parsedData.persona_id || !parsedData.system_prompt) { - this.showError('人格 JSON 缺少必需字段喵!'); - event.target.value = ''; - return; - } + // 验证必需字段 + if (!parsedData.persona_id || !parsedData.system_prompt) { + this.showError('人格 JSON 缺少必需字段喵!'); + event.target.value = ''; + return; + } - // 检查重复 ID - const id = parsedData.persona_id; - const exists = this.personas.some(persona => persona.persona_id === id); - if (exists) { - this.showError('人格 ID [' + id + '] 已存在喵!'); - event.target.value = ''; - return; - } + // 检查重复 ID + const id = parsedData.persona_id; + const exists = this.personas.some(persona => persona.persona_id === id); + if (exists) { + this.showError('人格 ID [' + id + '] 已存在喵!'); + event.target.value = ''; + return; + } - // 调用 API 保存(使用正确的端点) - const response = await axios.post('/api/persona/create', parsedData); + // 白名单过滤字段 + const allowedFields = ['persona_id', 'system_prompt', 'begin_dialogs', 'tools']; + const filteredData = {}; + allowedFields.forEach(field => { + if (parsedData.hasOwnProperty(field)) { + filteredData[field] = parsedData[field]; + } + }); + + // 调用 API 保存(使用正确的端点) + const response = await axios.post('/api/persona/create', filteredData); if (response.data.status === 'ok') { this.showSuccess(response.data.message || '导入成功喵!');