mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 15:13:55 +08:00
完成“编辑模型配置”功能开发
This commit is contained in:
@@ -159,5 +159,23 @@ export default {
|
||||
})
|
||||
}).send()
|
||||
},
|
||||
|
||||
// 更新模型配置
|
||||
updateModel(params, callback) {
|
||||
const { modelType, provideCode, id, formData } = params;
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/models/${modelType}/${provideCode}/${id}`)
|
||||
.method('PUT')
|
||||
.data(formData)
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('更新模型失败:', err);
|
||||
this.$message.error(err.msg || '更新模型失败');
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.updateModel(params, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div style="font-size: 30px; color: #3d4566; margin-top: -10px; margin-bottom: 10px; text-align: center;">
|
||||
添加模型
|
||||
</div>
|
||||
|
||||
|
||||
<button class="custom-close-btn" @click="handleClose">
|
||||
×
|
||||
</button>
|
||||
|
||||
@@ -94,7 +94,6 @@
|
||||
import Api from '@/apis/api';
|
||||
|
||||
const DEFAULT_CONFIG_JSON = {
|
||||
provider: "",
|
||||
type: "",
|
||||
base_url: "",
|
||||
model_name: "",
|
||||
@@ -102,8 +101,8 @@ const DEFAULT_CONFIG_JSON = {
|
||||
raw: {},
|
||||
config: {
|
||||
keyComparator: {},
|
||||
ignoreError: 0,
|
||||
ignoreCase: 0,
|
||||
ignoreError: false,
|
||||
ignoreCase: false,
|
||||
dateFormat: "",
|
||||
ignoreNullValue: false,
|
||||
transientSupport: false,
|
||||
@@ -267,7 +266,10 @@ export default {
|
||||
}
|
||||
},
|
||||
handleSave() {
|
||||
const provideCode = this.form.configJson.type;
|
||||
const { provider, ...restConfigJson } = this.form.configJson;
|
||||
const formData = {
|
||||
id: this.form.id,
|
||||
modelCode: this.form.modelCode,
|
||||
modelName: this.form.modelName,
|
||||
isDefault: this.form.isDefault ? 1 : 0,
|
||||
@@ -276,12 +278,15 @@ export default {
|
||||
remark: this.form.remark,
|
||||
sort: this.form.sort || 0,
|
||||
configJson: {
|
||||
...this.form.configJson,
|
||||
type: this.form.configJson.type || this.modelType
|
||||
...restConfigJson,
|
||||
config: {
|
||||
...restConfigJson.config,
|
||||
ignoreError: !!restConfigJson.config?.ignoreError,
|
||||
ignoreCase: !!restConfigJson.config?.ignoreCase,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.$emit("save", formData);
|
||||
this.$emit("save", { provideCode, formData });
|
||||
this.dialogVisible = false;
|
||||
},
|
||||
loadProviders() {
|
||||
|
||||
@@ -301,9 +301,21 @@ export default {
|
||||
// TODO: 导出配置
|
||||
console.log('导出配置');
|
||||
},
|
||||
handleModelSave(formData) {
|
||||
// TODO: 保存模型数据
|
||||
console.log('保存的模型数据:', formData);
|
||||
handleModelSave({ provideCode, formData }) {
|
||||
const modelType = this.activeTab;
|
||||
const id = formData.id;
|
||||
Api.model.updateModel(
|
||||
{ modelType, provideCode, id, formData },
|
||||
({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success('保存成功');
|
||||
this.loadData();
|
||||
this.editDialogVisible = false;
|
||||
} else {
|
||||
this.$message.error(data.msg || '保存失败');
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
selectAll() {
|
||||
if (this.isAllSelected) {
|
||||
|
||||
Reference in New Issue
Block a user