mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-28 01:53:53 +08:00
完成”新增模型配置“API
This commit is contained in:
@@ -26,7 +26,7 @@ export default {
|
|||||||
})
|
})
|
||||||
}).send()
|
}).send()
|
||||||
},
|
},
|
||||||
// 获取模型供应器列表
|
// 获取模型供应器列表
|
||||||
getModelProviders(modelType, callback) {
|
getModelProviders(modelType, callback) {
|
||||||
RequestService.sendRequest()
|
RequestService.sendRequest()
|
||||||
.url(`${getServiceUrl()}/api/v1/models/${modelType}/provideTypes`)
|
.url(`${getServiceUrl()}/api/v1/models/${modelType}/provideTypes`)
|
||||||
@@ -42,6 +42,37 @@ export default {
|
|||||||
this.getModelProviders(modelType, callback)
|
this.getModelProviders(modelType, callback)
|
||||||
})
|
})
|
||||||
}).send()
|
}).send()
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// 新增模型配置
|
||||||
|
addModel(params, callback) {
|
||||||
|
const { modelType, provideCode, formData } = params;
|
||||||
|
const postData = {
|
||||||
|
modelCode: formData.modelCode,
|
||||||
|
modelName: formData.modelName,
|
||||||
|
isDefault: formData.isDefault ? 1 : 0,
|
||||||
|
isEnabled: formData.isEnabled ? 1 : 0,
|
||||||
|
configJson: JSON.stringify(formData.configJson),
|
||||||
|
docLink: formData.docLink,
|
||||||
|
remark: formData.remark,
|
||||||
|
sort: formData.sort || 0
|
||||||
|
};
|
||||||
|
|
||||||
|
RequestService.sendRequest()
|
||||||
|
.url(`${getServiceUrl()}/api/v1/models/models/${modelType}/${provideCode}`)
|
||||||
|
.method('POST')
|
||||||
|
.data(postData)
|
||||||
|
.success((res) => {
|
||||||
|
RequestService.clearRequestTime()
|
||||||
|
callback(res)
|
||||||
|
})
|
||||||
|
.fail((err) => {
|
||||||
|
console.error('新增模型失败:', err)
|
||||||
|
this.$message.error(err.msg || '新增模型失败')
|
||||||
|
RequestService.reAjaxFun(() => {
|
||||||
|
this.addModel(params, callback)
|
||||||
|
})
|
||||||
|
}).send()
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import model from '@/apis/module/model'
|
import model from '@/apis/module/model'
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
name: 'AddModelDialog',
|
name: 'AddModelDialog',
|
||||||
props: {
|
props: {
|
||||||
visible: {type: Boolean, required: true},
|
visible: {type: Boolean, required: true},
|
||||||
@@ -130,7 +129,6 @@ export default {
|
|||||||
return
|
return
|
||||||
|
|
||||||
model.getModelProviders(this.modelType, (data) => {
|
model.getModelProviders(this.modelType, (data) => {
|
||||||
console.log("data", data)
|
|
||||||
this.providers = data.map(item => ({
|
this.providers = data.map(item => ({
|
||||||
label: item.name,
|
label: item.name,
|
||||||
value: item.providerCode
|
value: item.providerCode
|
||||||
@@ -147,7 +145,8 @@ export default {
|
|||||||
|
|
||||||
this.$emit('confirm', {
|
this.$emit('confirm', {
|
||||||
...this.formData,
|
...this.formData,
|
||||||
provideType: this.formData.supplier
|
provideType: this.formData.supplier,
|
||||||
|
configJson: this.formData.configJson
|
||||||
});
|
});
|
||||||
this.$emit('update:visible', false);
|
this.$emit('update:visible', false);
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ export default {
|
|||||||
};
|
};
|
||||||
this.editDialogVisible = true;
|
this.editDialogVisible = true;
|
||||||
},
|
},
|
||||||
|
// 删除模型配置
|
||||||
deleteModel(model) {
|
deleteModel(model) {
|
||||||
this.$confirm(`确定要删除模型 ${model.candidateName} 吗?`, '提示', {
|
this.$confirm(`确定要删除模型 ${model.candidateName} 吗?`, '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
@@ -279,8 +280,27 @@ export default {
|
|||||||
this.isAllSelected = false;
|
this.isAllSelected = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 新增模型配置
|
||||||
handleAddConfirm(newModel) {
|
handleAddConfirm(newModel) {
|
||||||
console.log('新增模型数据:', newModel);
|
const params = {
|
||||||
|
modelType: this.activeTab,
|
||||||
|
provideCode: newModel.supplier,
|
||||||
|
formData: {
|
||||||
|
...newModel,
|
||||||
|
isDefault: newModel.isDefault ? 1 : 0,
|
||||||
|
isEnabled: newModel.isEnabled ? 1 : 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ModelApi.addModel(params, ({data}) => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.$message.success('新增成功');
|
||||||
|
this.loadData();
|
||||||
|
} else {
|
||||||
|
this.$message.error(data.msg || '新增失败');
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 分页器
|
// 分页器
|
||||||
|
|||||||
Reference in New Issue
Block a user