diff --git a/dashboard/src/stores/personaStore.ts b/dashboard/src/stores/personaStore.ts index 4c4387154..1e0110eeb 100644 --- a/dashboard/src/stores/personaStore.ts +++ b/dashboard/src/stores/personaStore.ts @@ -338,11 +338,9 @@ export const usePersonaStore = defineStore({ const response = await axios.post('/api/persona/create', { persona_id: data.persona_id, system_prompt: data.system_prompt, - begin_dialogs: data.begin_dialogs, + begin_dialogs: data.begin_dialogs || [], tools: data.tools, skills: data.skills, - folder_id: data.folder_id ?? this.currentFolderId, - sort_order: data.sort_order ?? 0, }); if (response.data.status !== 'ok') { diff --git a/dashboard/src/views/persona/PersonaManager.vue b/dashboard/src/views/persona/PersonaManager.vue index cb5834073..0e3024179 100644 --- a/dashboard/src/views/persona/PersonaManager.vue +++ b/dashboard/src/views/persona/PersonaManager.vue @@ -506,11 +506,11 @@ export default defineComponent({ // 白名单过滤 const whitelist = ['persona_id', 'system_prompt', 'begin_dialogs', 'tools', 'skills', 'folder_id']; - const filteredData: Partial = {}; + const filteredData: any = {}; for (const key of whitelist) { if (key in data) { - filteredData[key as keyof Persona] = data[key]; + filteredData[key] = data[key]; } } @@ -520,10 +520,25 @@ export default defineComponent({ } // 执行导入 - await (this as any).importPersona(filteredData); + await this.importPersona(filteredData); this.showSuccess(this.tm('persona.messages.importSuccess')); } catch (error: any) { - this.showError(error.message || this.tm('persona.messages.importError')); + console.error('导入人格失败:', error); + + // 构建详细的错误消息 + let errorMessage = this.tm('persona.messages.importError'); + if (error.response) { + // 后端返回的错误 + errorMessage += `: ${error.response.data?.message || error.response.statusText}`; + } else if (error.request) { + // 请求发送但没有收到响应 + errorMessage += ': 无法连接到服务器'; + } else if (error.message) { + // 其他错误 + errorMessage += `: ${error.message}`; + } + + this.showError(errorMessage); } };