mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-24 08:03:53 +08:00
update:server连接api (#747)
* update:server连接manager-api * update:读取智能体模型配置 * update:添加默认模型的按钮 * update:优化配置读取方式 * update:server兼容manager接口改造 * update:优化私有配置加载 * update:加载私有模型配置
This commit is contained in:
@@ -142,40 +142,57 @@ export default {
|
||||
})
|
||||
}).send()
|
||||
},
|
||||
// 启用/禁用模型状态
|
||||
updateModelStatus(id, status, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/models/enable/${id}/${status}`)
|
||||
.method('PUT')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
// 启用/禁用模型状态
|
||||
updateModelStatus(id, status, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/models/enable/${id}/${status}`)
|
||||
.method('PUT')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('更新模型状态失败:', err)
|
||||
this.$message.error(err.msg || '更新模型状态失败')
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.updateModelStatus(id, status, callback)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('更新模型状态失败:', err)
|
||||
this.$message.error(err.msg || '更新模型状态失败')
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.updateModelStatus(id, status, callback)
|
||||
})
|
||||
}).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);
|
||||
}).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();
|
||||
},
|
||||
// 设置默认模型
|
||||
setDefaultModel(id, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/models/default/${id}`)
|
||||
.method('PUT')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('设置默认模型失败:', err)
|
||||
this.$message.error(err.msg || '设置默认模型失败')
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.setDefaultModel(id, callback)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('更新模型失败:', err);
|
||||
this.$message.error(err.msg || '更新模型失败');
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.updateModel(params, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
}).send()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,16 +4,6 @@
|
||||
|
||||
<div class="operation-bar">
|
||||
<h2 class="page-title">{{ modelTypeText }}</h2>
|
||||
<!-- <div class="right-operations">-->
|
||||
<!-- <el-button plain size="small" @click="handleImport" style="background: #7b9de5; color: white;">-->
|
||||
<!-- <img loading="lazy" alt="" src="@/assets/model/inner_conf.png">-->
|
||||
<!-- 导入配置-->
|
||||
<!-- </el-button>-->
|
||||
<!-- <el-button plain size="small" @click="handleExport" style="background: #71c9d1; color: white;">-->
|
||||
<!-- <img loading="lazy" alt="" src="@/assets/model/output_conf.png">-->
|
||||
<!-- 导出配置-->
|
||||
<!-- </el-button>-->
|
||||
<!-- </div>-->
|
||||
<div class="action-group">
|
||||
<div class="search-group">
|
||||
<el-input
|
||||
@@ -76,13 +66,15 @@
|
||||
@change="handleStatusChange(scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否默认" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-switch v-model="scope.row.isDefault" class="custom-switch" :active-value="1" :inactive-value="0"
|
||||
@change="handleDefaultChange(scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="activeTab === 'tts'" label="音色管理" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
@click="openTtsDialog(scope.row)"
|
||||
class="voice-management-btn">
|
||||
<el-button type="text" size="mini" @click="openTtsDialog(scope.row)" class="voice-management-btn">
|
||||
音色管理
|
||||
</el-button>
|
||||
</template>
|
||||
@@ -130,7 +122,7 @@
|
||||
|
||||
<ModelEditDialog :modelType="activeTab" :visible.sync="editDialogVisible" :modelData="editModelData"
|
||||
@save="handleModelSave" />
|
||||
<TtsModel :visible.sync="ttsDialogVisible" :ttsModelId="selectedTtsModelId"/>
|
||||
<TtsModel :visible.sync="ttsDialogVisible" :ttsModelId="selectedTtsModelId" />
|
||||
<AddModelDialog :modelType="activeTab" :visible.sync="addDialogVisible" @confirm="handleAddConfirm" />
|
||||
</div>
|
||||
|
||||
@@ -304,14 +296,6 @@ export default {
|
||||
this.currentPage = page;
|
||||
this.$refs.modelTable.clearSelection();
|
||||
},
|
||||
handleImport() {
|
||||
// TODO: 导入配置
|
||||
console.log('导入配置');
|
||||
},
|
||||
handleExport() {
|
||||
// TODO: 导出配置
|
||||
console.log('导出配置');
|
||||
},
|
||||
handleModelSave({ provideCode, formData }) {
|
||||
const modelType = this.activeTab;
|
||||
const id = formData.id;
|
||||
@@ -412,11 +396,11 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
// 处理启用/禁用状态变更
|
||||
// 处理启用/禁用状态变更
|
||||
handleStatusChange(model) {
|
||||
const newStatus = model.isEnabled ? 1 : 0
|
||||
const originalStatus = model.isEnabled
|
||||
|
||||
|
||||
model.isEnabled = !model.isEnabled
|
||||
|
||||
Api.model.updateModelStatus(
|
||||
@@ -434,12 +418,24 @@ export default {
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
handleDefaultChange(model) {
|
||||
Api.model.setDefaultModel(model.id, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success('设置默认模型成功')
|
||||
this.loadData()
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-switch {
|
||||
height: 23px;
|
||||
}
|
||||
|
||||
::v-deep .el-table tr {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
@@ -564,6 +564,7 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-table .el-button--text) {
|
||||
color: #7079aa !important;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user