PersonaForm.vue - savePersona 方法添加了白名单字段过滤

This commit is contained in:
Sjshi763
2026-01-17 19:33:32 +08:00
parent 13461f925b
commit ec3d25c55b

View File

@@ -378,16 +378,26 @@ export default {
}
this.saving = true;
try {
const url = this.editingPersona ? '/api/persona/update' : '/api/persona/create';
const response = await axios.post(url, this.personaForm);
if (response.data.status === 'ok') {
this.$emit('saved', response.data.message || this.tm('messages.saveSuccess'));
this.closeDialog();
} else {
this.$emit('error', response.data.message || this.tm('messages.saveError'));
try {
const url = this.editingPersona ? '/api/persona/update' : '/api/persona/create';
// 白名单过滤字段
const allowedFields = ['persona_id', 'system_prompt', 'begin_dialogs', 'tools'];
const filteredData = {};
allowedFields.forEach(field => {
if (this.personaForm.hasOwnProperty(field)) {
filteredData[field] = this.personaForm[field];
}
});
const response = await axios.post(url, filteredData);
if (response.data.status === 'ok') {
this.$emit('saved', response.data.message || this.tm('messages.saveSuccess'));
this.closeDialog();
} else {
this.$emit('error', response.data.message || this.tm('messages.saveError'));
}
} catch (error) {
this.$emit('error', error.response?.data?.message || this.tm('messages.saveError'));
}
@@ -533,4 +543,4 @@ export default {
.v-virtual-scroll {
padding-bottom: 16px;
}
</style>
</style>