[Feature] 人格设定支持导出/导入。

Fixes #4409

- 导出的json
This commit is contained in:
Sjshi763
2026-01-17 12:35:23 +08:00
parent 1a7e8456ab
commit 2e90c259ea
3 changed files with 36 additions and 2 deletions

View File

@@ -7,6 +7,7 @@
"createFirst": "Create First Persona",
"edit": "Edit",
"delete": "Delete",
"copy": "Copy JSON",
"cancel": "Cancel",
"save": "Save",
"addDialogPair": "Add Dialog Pair"
@@ -62,6 +63,7 @@
"saveError": "Save failed",
"deleteConfirm": "Are you sure you want to delete persona \"{id}\"? This action cannot be undone.",
"deleteSuccess": "Deleted successfully",
"deleteError": "Delete failed"
"deleteError": "Delete failed",
"copySuccess": "Copied to clipboard"
}
}

View File

@@ -7,6 +7,7 @@
"createFirst": "创建第一个人格",
"edit": "编辑",
"delete": "删除",
"copy": "复制 JSON",
"cancel": "取消",
"save": "保存",
"addDialogPair": "添加对话对"
@@ -62,6 +63,7 @@
"saveError": "保存失败",
"deleteConfirm": "确定要删除人格 \"{id}\" 吗?此操作不可撤销。",
"deleteSuccess": "删除成功",
"deleteError": "删除失败"
"deleteError": "删除失败",
"copySuccess": "已复制到剪贴板"
}
}

View File

@@ -40,6 +40,12 @@
{{ tm('buttons.edit') }}
</v-list-item-title>
</v-list-item>
<v-list-item @click.stop="copyPersonaJson(persona)">
<v-list-item-title>
<v-icon class="mr-2" size="small">mdi-content-copy</v-icon>
{{ tm('buttons.copy') || '复制 JSON' }}
</v-list-item-title>
</v-list-item>
<v-list-item @click="deletePersona(persona)" class="text-error">
<v-list-item-title>
<v-icon class="mr-2" size="small">mdi-delete</v-icon>
@@ -270,6 +276,30 @@ export default {
this.message = message;
this.messageType = 'error';
this.showMessage = true;
},
async copyPersonaJson(persona) {
try {
// 创建清洁副本,排除系统字段
const cleanPersona = {
persona_id: persona.persona_id,
system_prompt: persona.system_prompt,
begin_dialogs: persona.begin_dialogs,
tools: persona.tools
};
// 格式化 JSON
const jsonString = JSON.stringify(cleanPersona, null, 4);
// 复制到剪贴板
await navigator.clipboard.writeText(jsonString);
// 显示成功消息
this.showSuccess(this.tm('messages.copySuccess') || 'Copied to clipboard');
} catch (error) {
// 显示错误消息
this.showError(error.message || this.tm('messages.copyError') || 'Failed to copy JSON');
}
}
}
}