mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
feat: 重新加回扩展字段编辑器(最简版,去掉占位符提示文本)
撤掉再重加:上次编辑器崩页面,这次去掉模板里的 {{ext.字段名}} 字面量提示
(改用最简编辑器),待用户验证是否还崩。
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3b75520a9b
commit
8f9803a5fc
2 changed files with 56 additions and 0 deletions
|
|
@ -18,6 +18,37 @@ export default {
|
|||
});
|
||||
}).send();
|
||||
},
|
||||
// 取 agent 扩展字段
|
||||
getExt(agentId, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/agent/${agentId}/ext`)
|
||||
.method('GET')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.networkFail(() => {
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.getExt(agentId, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
// 整体覆盖 agent 扩展字段
|
||||
saveExt(agentId, extObj, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/agent/${agentId}/ext`)
|
||||
.method('PUT')
|
||||
.data(extObj)
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.networkFail(() => {
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.saveExt(agentId, extObj, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
// 添加智能体
|
||||
addAgent(agentName, callback) {
|
||||
RequestService.sendRequest()
|
||||
|
|
|
|||
|
|
@ -127,6 +127,18 @@
|
|||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<span>扩展字段</span>
|
||||
</template>
|
||||
<div v-for="(item, idx) in (form.extFields || [])" :key="idx" style="margin-bottom:6px;">
|
||||
<el-input v-model="item.key" placeholder="字段名 如 age_group" style="width:35%;" />
|
||||
<el-input v-model="item.value" placeholder="值 如 5岁" style="width:45%;margin-left:4px;" />
|
||||
<el-button type="danger" size="small" style="margin-left:4px;" @click="form.extFields.splice(idx,1)">删</el-button>
|
||||
</div>
|
||||
<el-button size="small" @click="form.extFields.push({key:'',value:''})">+ 添加字段</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<el-tooltip :content="$t('roleConfig.tooltip.memoryHis')" placement="top" effect="light" popper-class="custom-tooltip">
|
||||
|
|
@ -497,6 +509,7 @@ export default {
|
|||
ttsPitch: null,
|
||||
chatHistoryConf: 0,
|
||||
systemPrompt: "",
|
||||
extFields: [],
|
||||
summaryMemory: "",
|
||||
langCode: "",
|
||||
language: "",
|
||||
|
|
@ -602,6 +615,10 @@ export default {
|
|||
if (this.form.ttsPitch !== null && this.form.ttsPitch !== undefined) {
|
||||
configData.ttsPitch = this.form.ttsPitch;
|
||||
}
|
||||
// 保存扩展字段
|
||||
const extObj = {};
|
||||
(this.form.extFields || []).forEach(f => { if (f.key) extObj[f.key] = f.value; });
|
||||
Api.agent.saveExt(this.$route.query.agentId, extObj, () => {});
|
||||
Api.agent.updateAgentConfig(this.$route.query.agentId, configData, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success({
|
||||
|
|
@ -630,6 +647,7 @@ export default {
|
|||
ttsVoiceId: "",
|
||||
chatHistoryConf: 0,
|
||||
systemPrompt: "",
|
||||
extFields: [],
|
||||
summaryMemory: "",
|
||||
langCode: "",
|
||||
language: "",
|
||||
|
|
@ -722,6 +740,13 @@ export default {
|
|||
},
|
||||
};
|
||||
|
||||
// 加载扩展字段
|
||||
this.form.extFields = [];
|
||||
Api.agent.getExt(agentId, ({ data }) => {
|
||||
const obj = data && data.code === 0 && data.data ? data.data : {};
|
||||
this.form.extFields = Object.keys(obj).map(k => ({ key: k, value: obj[k] }));
|
||||
});
|
||||
|
||||
// 同步TTS设置到ttsSettings
|
||||
this.ttsSettings = {
|
||||
volume: this.form.ttsVolume || 0,
|
||||
|
|
|
|||
Loading…
Reference in a new issue