fix:修复了"模型配置"问题

This commit is contained in:
CGD
2025-04-12 22:53:41 +08:00
parent 5d69ba0796
commit e3928ffbcc
2 changed files with 25 additions and 26 deletions
+18 -15
View File
@@ -1,7 +1,6 @@
import { getServiceUrl } from '../api';
import RequestService from '../httpRequest';
export default {
// 获取模型配置列表
getModelList(params, callback) {
@@ -162,21 +161,25 @@ export default {
// 更新模型配置
updateModel(params, callback) {
const { modelType, provideCode, id, formData } = params;
const payload = {
...formData,
configJson: formData.configJson
};
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();
.url(`${getServiceUrl()}/models/${modelType}/${provideCode}/${id}`)
.method('PUT')
.data(payload)
.success((res) => {
RequestService.clearRequestTime();
callback(res);
})
.fail((err) => {
console.error('更新模型失败:', err);
this.$message.error(err.msg || '更新模型失败');
RequestService.reAjaxFun(() => {
this.updateModel(params, callback);
});
}).send();
},
// 设置默认模型
setDefaultModel(id, callback) {
@@ -94,14 +94,6 @@
<script>
import Api from '@/apis/api';
const DEFAULT_CONFIG_JSON = {
type: "",
base_url: "",
model_name: "",
api_key: "",
empty: false
};
export default {
name: "ModelEditDialog",
props: {
@@ -132,7 +124,7 @@ export default {
docLink: "",
remark: "",
sort: 0,
configJson: JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON))
configJson: {}
}
};
},
@@ -183,8 +175,11 @@ export default {
docLink: "",
remark: "",
sort: 0,
configJson: JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON))
configJson: {}
};
this.dynamicCallInfoFields.forEach(field => {
this.$set(this.form.configJson, field.prop, '');
});
},
resetProviders() {
this.providers = [];
@@ -266,6 +261,8 @@ export default {
this.dynamicCallInfoFields.forEach(field => {
if (!configJson.hasOwnProperty(field.prop)) {
configJson[field.prop] = '';
} else if (typeof configJson[field.prop] !== 'string') {
configJson[field.prop] = String(configJson[field.prop]);
}
});
@@ -280,7 +277,6 @@ export default {
remark: model.remark,
sort: Number(model.sort) || 0,
configJson: {
...DEFAULT_CONFIG_JSON,
...configJson
}
};