mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-18 02:00:09 +08:00
修复bug 405
This commit is contained in:
@@ -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') {
|
||||
|
||||
@@ -506,11 +506,11 @@ export default defineComponent({
|
||||
|
||||
// 白名单过滤
|
||||
const whitelist = ['persona_id', 'system_prompt', 'begin_dialogs', 'tools', 'skills', 'folder_id'];
|
||||
const filteredData: Partial<Persona> = {};
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user