mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 15:13:55 +08:00
Merge branch 'hot-fix' of https://github.com/xinnan-tech/xiaozhi-esp32-server into hot-fix
This commit is contained in:
@@ -26,5 +26,71 @@ export default {
|
||||
})
|
||||
}).send()
|
||||
},
|
||||
// 获取模型供应器列表
|
||||
getModelProviders(modelType, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/api/v1/models/${modelType}/provideTypes`)
|
||||
.method('GET')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res.data?.data || [])
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('获取供应器列表失败:', err)
|
||||
this.$message.error('获取供应器列表失败')
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.getModelProviders(modelType, callback)
|
||||
})
|
||||
}).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()
|
||||
},
|
||||
// 删除模型配置
|
||||
deleteModel(modelType, provideCode, id, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/api/v1/models/models/${modelType}/${provideCode}/${id}`)
|
||||
.method('DELETE')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('删除模型失败:', err)
|
||||
this.$message.error(err.msg || '删除模型失败')
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.deleteModel(modelType, provideCode, id, callback)
|
||||
})
|
||||
}).send()
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:visible.sync="visible"
|
||||
width="975px"
|
||||
center
|
||||
custom-class="custom-dialog"
|
||||
:show-close="false"
|
||||
class="center-dialog"
|
||||
|
||||
>
|
||||
<el-dialog :visible.sync="visible" width="975px" center custom-class="custom-dialog" :show-close="false" class="center-dialog">
|
||||
<div style="margin: 0 18px; text-align: left; padding: 10px; border-radius: 10px;">
|
||||
<div style="font-size: 30px; color: #3d4566; margin-top: -10px; margin-bottom: 10px; text-align: center;">
|
||||
添加模型
|
||||
@@ -34,51 +26,28 @@
|
||||
</div>
|
||||
|
||||
<div style="height: 2px; background: #e9e9e9; margin-bottom: 22px;"></div>
|
||||
|
||||
<el-form :model="formData" label-width="100px" label-position="left" class="custom-form">
|
||||
<!-- 第一行:模型名称和模型编码 -->
|
||||
<div style="display: flex; gap: 20px; margin-bottom: 0;">
|
||||
<el-form-item label="模型名称" prop="modelName" style="flex: 1;">
|
||||
<el-input
|
||||
v-model="formData.modelName"
|
||||
placeholder="请输入模型名称"
|
||||
class="custom-input-bg"
|
||||
></el-input>
|
||||
<el-input v-model="formData.modelName" placeholder="请输入模型名称" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="模型编码" prop="modelCode" style="flex: 1;">
|
||||
<el-input
|
||||
v-model="formData.modelCode"
|
||||
placeholder="请输入模型编码"
|
||||
class="custom-input-bg"
|
||||
></el-input>
|
||||
<el-input v-model="formData.modelCode" placeholder="请输入模型编码" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<!-- 第二行:供应器和排序号 -->
|
||||
<div style="display: flex; gap: 20px; margin-bottom: 0;">
|
||||
<el-form-item label="供应器" prop="supplier" style="flex: 1;">
|
||||
<el-select
|
||||
v-model="formData.supplier"
|
||||
placeholder="请选择"
|
||||
class="custom-select custom-input-bg"
|
||||
style="width: 100%;"
|
||||
>
|
||||
<el-option label="硅基流动" value="硅基流动"></el-option>
|
||||
<el-option label="智脑科技" value="智脑科技"></el-option>
|
||||
<el-option label="云智科技" value="云智科技"></el-option>
|
||||
<el-option label="其他" value="其他"></el-option>
|
||||
<el-select v-model="formData.supplier" placeholder="请选择" class="custom-select custom-input-bg" style="width: 100%;" @focus="loadProviders" filterable>
|
||||
<el-option v-for="item in providers" :key="item.value" :label="item.label" :value="item.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序号" prop="sortOrder" style="flex: 1;">
|
||||
<el-input
|
||||
v-model="formData.sort"
|
||||
placeholder="请输入排序号"
|
||||
class="custom-input-bg"
|
||||
></el-input>
|
||||
<el-input v-model="formData.sort" placeholder="请输入排序号" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<!-- 文档地址 -->
|
||||
|
||||
<el-form-item label="文档地址" prop="docLink" style="margin-bottom: 27px;">
|
||||
<el-input
|
||||
v-model="formData.docLink"
|
||||
@@ -87,7 +56,6 @@
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 备注 -->
|
||||
<el-form-item label="备注" prop="remark" class="prop-remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
@@ -99,48 +67,27 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 调用信息部分 -->
|
||||
<div style="font-size: 20px; font-weight: bold; color: #3d4566; margin-bottom: 15px;">调用信息</div>
|
||||
<div style="height: 2px; background: #e9e9e9; margin-bottom: 15px;"></div>
|
||||
|
||||
<el-form :model="formData" label-width="100px" label-position="left" class="custom-form">
|
||||
<!-- 第一行:模型名称和接口地址 -->
|
||||
<div style="display: flex; gap: 10px; margin-bottom: 15px;">
|
||||
<el-form-item label="模型名称" prop="param1" style="flex: 0.5; margin-bottom: 0;">
|
||||
<el-input
|
||||
v-model="formData.configJson.param1"
|
||||
placeholder="请输入model_name"
|
||||
class="custom-input-bg"
|
||||
></el-input>
|
||||
<el-input v-model="formData.configJson.param1" placeholder="请输入model_name" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="接口地址" prop="param2" style="flex: 1; margin-bottom: 0;">
|
||||
<el-input
|
||||
v-model="formData.configJson.param2"
|
||||
placeholder="请输入base_url"
|
||||
class="custom-input-bg"
|
||||
></el-input>
|
||||
<el-input v-model="formData.configJson.param2" placeholder="请输入base_url" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<!-- 秘钥信息 -->
|
||||
<el-form-item label="秘钥信息" prop="apiKey">
|
||||
<el-input
|
||||
v-model="formData.configJson.apiKey"
|
||||
placeholder="请输入api_key"
|
||||
show-password
|
||||
class="custom-input-bg"
|
||||
></el-input>
|
||||
<el-input v-model="formData.configJson.apiKey" placeholder="请输入api_key" show-password class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<!-- 保存按钮 -->
|
||||
<div style="display: flex;justify-content: center;">
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="confirm"
|
||||
class="save-btn"
|
||||
>
|
||||
<el-button type="primary" @click="confirm" class="save-btn">
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
@@ -148,6 +95,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import model from '@/apis/module/model'
|
||||
export default {
|
||||
name: 'AddModelDialog',
|
||||
props: {
|
||||
@@ -156,6 +104,8 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
providers: [],
|
||||
providersLoaded: false,
|
||||
formData: {
|
||||
modelName: '',
|
||||
modelCode: '',
|
||||
@@ -174,6 +124,18 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadProviders() {
|
||||
if (this.providersLoaded)
|
||||
return
|
||||
|
||||
model.getModelProviders(this.modelType, (data) => {
|
||||
this.providers = data.map(item => ({
|
||||
label: item.name,
|
||||
value: item.providerCode
|
||||
}))
|
||||
this.providersLoaded = true
|
||||
})
|
||||
},
|
||||
confirm() {
|
||||
if (!this.formData.modelName || !this.formData.modelCode || !this.formData.supplier ||
|
||||
!this.formData.configJson.param1 || !this.formData.configJson.param2 || !this.formData.configJson.apiKey) {
|
||||
@@ -183,7 +145,8 @@ export default {
|
||||
|
||||
this.$emit('confirm', {
|
||||
...this.formData,
|
||||
provideType: this.formData.supplier
|
||||
provideType: this.formData.supplier,
|
||||
configJson: this.formData.configJson
|
||||
});
|
||||
this.$emit('update:visible', false);
|
||||
this.resetForm();
|
||||
@@ -204,6 +167,9 @@ export default {
|
||||
apiKey: ''
|
||||
}
|
||||
};
|
||||
// 重置加载状态
|
||||
this.providers = [];
|
||||
this.providersLoaded = false;
|
||||
},
|
||||
handleClose() {
|
||||
this.resetForm();
|
||||
@@ -297,7 +263,7 @@ export default {
|
||||
}
|
||||
|
||||
.custom-form .el-form-item {
|
||||
margin-bottom: 20px; /* 统一设置所有表单项的间距 */
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.custom-form .el-form-item__label {
|
||||
@@ -312,13 +278,12 @@ export default {
|
||||
margin-top: -4px;
|
||||
}
|
||||
|
||||
/* 修改placeholder颜色 */
|
||||
.custom-input-bg .el-input__inner::-webkit-input-placeholder,
|
||||
.custom-input-bg .el-textarea__inner::-webkit-input-placeholder {
|
||||
color: #9c9f9e;
|
||||
}
|
||||
|
||||
/* 输入框背景色 */
|
||||
|
||||
.custom-input-bg .el-input__inner,
|
||||
.custom-input-bg .el-textarea__inner {
|
||||
background-color: #f6f8fc;
|
||||
@@ -342,13 +307,12 @@ export default {
|
||||
}
|
||||
|
||||
|
||||
/* 修改开关样式 */
|
||||
.custom-switch .el-switch__core {
|
||||
border-radius: 20px;
|
||||
height: 23px;
|
||||
background-color: #c0ccda;
|
||||
width: 35px;
|
||||
padding: 0 20px; /* 调整左右内边距 */
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.custom-switch .el-switch__core:after {
|
||||
@@ -363,7 +327,7 @@ export default {
|
||||
.custom-switch.is-checked .el-switch__core {
|
||||
border-color: #b5bcf0;
|
||||
background-color: #cfd7fa;
|
||||
padding: 0 20px; /* 确保启用状态也有相同的间隔 */
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.custom-switch.is-checked .el-switch__core:after {
|
||||
@@ -373,14 +337,12 @@ export default {
|
||||
}
|
||||
|
||||
|
||||
/* 调整flex布局的gap */
|
||||
[style*="display: flex"] {
|
||||
gap: 20px; /* 扩大flex项间距 */
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
/* 调整输入框高度 */
|
||||
.custom-input-bg .el-input__inner {
|
||||
height: 32px; /* 固定输入框高度 */
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,92 +1,101 @@
|
||||
<template>
|
||||
<el-dialog :visible.sync="dialogVisible" width="800px" center>
|
||||
<el-form :model="form" ref="form" label-width="70px">
|
||||
<el-row :gutter="20" class="form-row">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="模型编码">
|
||||
<el-input v-model="form.code" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="模型名称">
|
||||
<el-input v-model="form.name" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 供应商 -->
|
||||
<el-row :gutter="20" class="form-row">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="供应器">
|
||||
<el-select v-model="form.supplier" placeholder="请选择">
|
||||
<el-option label="openai" value="openai" />
|
||||
<el-option label="dify" value="dify" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item>
|
||||
<div style="display: flex; align-items: center;">
|
||||
<span class="el-form-item__label" style="width: 70px;">设成默认</span>
|
||||
<el-switch v-model="form.isDefault" style="margin-right: 20px;" />
|
||||
<span class="el-form-item__label" style="width: 70px;">是否启用</span>
|
||||
<el-switch v-model="form.isEnable" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 文档 -->
|
||||
<el-row :gutter="20" class="form-row">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="文档地址">
|
||||
<el-input v-model="form.docUrl" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="排序号">
|
||||
<el-input-number v-model="form.sort" :min="1" :max="999" controls-position="right" placeholder="123"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 备注 -->
|
||||
<el-form-item label="备注" class="form-row">
|
||||
<el-input type="textarea" v-model="form.remark" :rows="2" placeholder="请输入"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<div class="vertical-fields">
|
||||
<el-form-item label="接口地址">
|
||||
<el-input v-model="form.apiUrl" placeholder="请输入base_url" />
|
||||
</el-form-item>
|
||||
<el-form-item label="模型名称">
|
||||
<el-input v-model="form.modelName" placeholder="请输入model_name" />
|
||||
</el-form-item>
|
||||
<el-form-item label="密钥信息">
|
||||
<el-input v-model="form.apiKey" placeholder="请输入api_key" show-password/>
|
||||
</el-form-item>
|
||||
<el-dialog :visible.sync="dialogVisible" width="975px" center custom-class="custom-dialog" :show-close="false" class="center-dialog">
|
||||
<div style="margin: 0 18px; text-align: left; padding: 10px; border-radius: 10px;">
|
||||
<div style="font-size: 30px; color: #3d4566; margin-top: -10px; margin-bottom: 10px; text-align: center;">
|
||||
修改模型
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="handleSave">保存</el-button>
|
||||
<el-button @click="dialogVisible = false">关闭</el-button>
|
||||
<button class="custom-close-btn" @click="dialogVisible = false">
|
||||
×
|
||||
</button>
|
||||
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
|
||||
<div style="font-size: 20px; font-weight: bold; color: #3d4566;">模型信息</div>
|
||||
<div style="display: flex; align-items: center; gap: 20px;">
|
||||
<div style="display: flex; align-items: center;">
|
||||
<span style="margin-right: 8px;">是否启用</span>
|
||||
<el-switch v-model="form.isEnable" class="custom-switch"></el-switch>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center;">
|
||||
<span style="margin-right: 8px;">设为默认</span>
|
||||
<el-switch v-model="form.isDefault" class="custom-switch"></el-switch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="height: 2px; background: #e9e9e9; margin-bottom: 22px;"></div>
|
||||
|
||||
<el-form :model="form" ref="form" label-width="100px" label-position="left" class="custom-form">
|
||||
<div style="display: flex; gap: 20px; margin-bottom: 0;">
|
||||
<el-form-item label="模型名称" prop="name" style="flex: 1;">
|
||||
<el-input v-model="form.name" placeholder="请输入模型名称" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="模型编码" prop="code" style="flex: 1;">
|
||||
<el-input v-model="form.code" placeholder="请输入模型编码" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 20px; margin-bottom: 0;">
|
||||
<el-form-item label="供应器" prop="supplier" style="flex: 1;">
|
||||
<el-select v-model="form.supplier" placeholder="请选择" class="custom-select custom-input-bg" style="width: 100%;" @focus="loadProviders" filterable>
|
||||
<el-option v-for="item in providers" :key="item.value" :label="item.label" :value="item.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序号" prop="sort" style="flex: 1;">
|
||||
<el-input v-model="form.sort" placeholder="请输入排序号" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<el-form-item label="文档地址" prop="docUrl" style="margin-bottom: 27px;">
|
||||
<el-input v-model="form.docUrl" placeholder="请输入文档地址" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注" prop="remark" class="prop-remark">
|
||||
<el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入模型备注" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div style="font-size: 20px; font-weight: bold; color: #3d4566; margin-bottom: 15px;">调用信息</div>
|
||||
<div style="height: 2px; background: #e9e9e9; margin-bottom: 15px;"></div>
|
||||
|
||||
<el-form :model="form" label-width="100px" label-position="left" class="custom-form">
|
||||
<div style="display: flex; gap: 10px; margin-bottom: 15px;">
|
||||
<el-form-item label="模型名称" prop="modelName" style="flex: 0.5; margin-bottom: 0;">
|
||||
<el-input v-model="form.modelName" placeholder="请输入model_name" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="接口地址" prop="apiUrl" style="flex: 1; margin-bottom: 0;">
|
||||
<el-input v-model="form.apiUrl" placeholder="请输入base_url" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<el-form-item label="秘钥信息" prop="apiKey">
|
||||
<el-input v-model="form.apiKey" placeholder="请输入api_key" show-password class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div style="display: flex;justify-content: center;">
|
||||
<el-button type="primary" @click="handleSave" class="save-btn">
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import model from '@/apis/module/model'
|
||||
export default {
|
||||
name: "ModelConfigDialog",
|
||||
props: {
|
||||
visible: { type: Boolean, default: false },
|
||||
configData: { type: Object, default: () => ({}) }
|
||||
configData: { type: Object, default: () => ({}) },
|
||||
modelType: { type: String, required: true }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: this.visible,
|
||||
providers: [],
|
||||
providersLoaded: false,
|
||||
form: {
|
||||
code: "",
|
||||
name: "",
|
||||
@@ -103,57 +112,213 @@ export default {
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
modelType() {
|
||||
this.resetProviders()
|
||||
},
|
||||
dialogVisible(val) {
|
||||
this.$emit('update:visible', val);
|
||||
if (!val) {
|
||||
this.form = {
|
||||
code: "",
|
||||
name: "",
|
||||
supplier: "",
|
||||
};
|
||||
}
|
||||
},
|
||||
visible(val) {
|
||||
this.dialogVisible = val;
|
||||
if (val) this.form = { ...this.form, ...this.configData };
|
||||
}
|
||||
if (val) {
|
||||
this.form = JSON.parse(JSON.stringify({
|
||||
...this.form,
|
||||
...this.configData
|
||||
}));
|
||||
this.resetProviders();
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
resetProviders() {
|
||||
this.providers = []
|
||||
this.providersLoaded = false
|
||||
},
|
||||
handleSave() {
|
||||
this.$emit("submit", this.form);
|
||||
this.dialogVisible = false;
|
||||
}
|
||||
},
|
||||
|
||||
loadProviders() {
|
||||
if (this.providersLoaded) return
|
||||
|
||||
model.getModelProviders(this.modelType, (data) => {
|
||||
this.providers = data.map(item => ({
|
||||
label: item.name,
|
||||
value: item.providerCode
|
||||
}))
|
||||
this.providersLoaded = true
|
||||
})
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dialog-footer {
|
||||
margin-top: -30px;
|
||||
text-align: center;
|
||||
}
|
||||
.el-form-item {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.el-input-number {
|
||||
width: 100%;
|
||||
}
|
||||
.form-row {
|
||||
margin-bottom: 12px;
|
||||
.custom-dialog {
|
||||
position: relative;
|
||||
border-radius: 20px;
|
||||
overflow: hidden;
|
||||
background: white;
|
||||
padding-bottom: 17px;
|
||||
}
|
||||
|
||||
.vertical-fields {
|
||||
margin-top: 8px;
|
||||
.custom-dialog .el-dialog__header {
|
||||
padding: 0;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
margin-top: -10px;
|
||||
text-align: center;
|
||||
.center-dialog {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.el-input-number {
|
||||
|
||||
.center-dialog .el-dialog {
|
||||
margin: 4% 0 auto !important;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.custom-close-btn {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid #cfcfcf;
|
||||
background: none;
|
||||
font-size: 30px;
|
||||
font-weight: lighter;
|
||||
color: #cfcfcf;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1;
|
||||
padding: 0;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.custom-close-btn:hover {
|
||||
color: #409EFF;
|
||||
border-color: #409EFF;
|
||||
}
|
||||
|
||||
.custom-select .el-input__suffix {
|
||||
background: #e6e8ea;
|
||||
right: 6px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
top: 9px;
|
||||
}
|
||||
|
||||
.custom-select .el-input__suffix-inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.el-input__inner {
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
.custom-select .el-icon-arrow-up:before {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
border-top: 7px solid #c0c4cc;
|
||||
position: relative;
|
||||
top: -2px;
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.el-form-item__label {
|
||||
text-align: left;
|
||||
padding-right: 10px;
|
||||
.custom-form .el-form-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.custom-form .el-form-item__label {
|
||||
color: #3d4566;
|
||||
font-weight: normal;
|
||||
text-align: right;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.custom-form .el-form-item.prop-remark .el-form-item__label {
|
||||
margin-top: -4px;
|
||||
}
|
||||
|
||||
.custom-input-bg .el-input__inner::-webkit-input-placeholder,
|
||||
.custom-input-bg .el-textarea__inner::-webkit-input-placeholder {
|
||||
color: #9c9f9e;
|
||||
}
|
||||
|
||||
.custom-input-bg .el-input__inner,
|
||||
.custom-input-bg .el-textarea__inner {
|
||||
background-color: #f6f8fc;
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
background: #e6f0fd;
|
||||
color: #237ff4;
|
||||
border: 1px solid #b3d1ff;
|
||||
width: 150px;
|
||||
height: 40px;
|
||||
font-size: 16px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.save-btn:hover {
|
||||
background: linear-gradient(to right, #237ff4, #9c40d5);
|
||||
color: white;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.custom-switch .el-switch__core {
|
||||
border-radius: 20px;
|
||||
height: 23px;
|
||||
background-color: #c0ccda;
|
||||
width: 35px;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.custom-switch .el-switch__core:after {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background-color: white;
|
||||
top: 3px;
|
||||
left: 4px;
|
||||
transition: all .3s;
|
||||
}
|
||||
|
||||
.custom-switch.is-checked .el-switch__core {
|
||||
border-color: #b5bcf0;
|
||||
background-color: #cfd7fa;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.custom-switch.is-checked .el-switch__core:after {
|
||||
left: 100%;
|
||||
margin-left: -18px;
|
||||
background-color: #1b47ee;
|
||||
}
|
||||
|
||||
[style*="display: flex"] {
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.custom-input-bg .el-input__inner {
|
||||
height: 32px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<div class="content-area">
|
||||
<div class="title-bar">
|
||||
<div class="title-wrapper">
|
||||
<h2 class="model-title">大语言模型(LLM)</h2>
|
||||
<h2 class="model-title">{{ modelTypeText }}</h2>
|
||||
<el-button type="primary" size="small" @click="addModel" class="add-btn">
|
||||
添加
|
||||
</el-button>
|
||||
@@ -63,12 +63,18 @@
|
||||
|
||||
<el-table ref="modelTable" style="width: 100%" :header-cell-style="{background: 'transparent'}" :data="modelList" class="data-table" header-row-class-name="table-header" :header-cell-class-name="headerCellClassName" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center"></el-table-column>
|
||||
<el-table-column label="模型名称" prop="candidateName" align="center"></el-table-column>
|
||||
<el-table-column label="模型编码" prop="code" align="center"></el-table-column>
|
||||
<el-table-column label="提供商" prop="supplier" align="center"></el-table-column>
|
||||
<el-table-column label="模型名称" prop="modelName" align="center"></el-table-column>
|
||||
<el-table-column label="模型编码" prop="modelCode" align="center"></el-table-column>
|
||||
<el-table-column label="提供商" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.configJson?.provider || '未知' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否启用" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-switch v-model="scope.row.isApplied" class="custom-switch" :active-color="null" :inactive-color="null"/>
|
||||
<el-switch v-model="scope.row.isEnabled" class="custom-switch"
|
||||
:active-value="1" :inactive-value="0"
|
||||
:active-color="null" :inactive-color="null"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="activeTab === 'tts'" label="音色管理" align="center">
|
||||
@@ -112,7 +118,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ModelEditDialog :visible.sync="editDialogVisible" :modelData="editModelData" @save="handleModelSave"/>
|
||||
<ModelEditDialog :modelType="activeTab" :visible.sync="editDialogVisible" :modelData="editModelData" @save="handleModelSave"/>
|
||||
<TtsModel :visible.sync="ttsDialogVisible" />
|
||||
<AddModelDialog :modelType="activeTab" :visible.sync="addDialogVisible" @confirm="handleAddConfirm"/>
|
||||
</div>
|
||||
@@ -128,6 +134,7 @@ import HeaderBar from "@/components/HeaderBar.vue";
|
||||
import ModelEditDialog from "@/components/ModelEditDialog.vue";
|
||||
import TtsModel from "@/components/TtsModel.vue";
|
||||
import AddModelDialog from "@/components/AddModelDialog.vue";
|
||||
import ModelApi from "@/apis/module/model";
|
||||
|
||||
export default {
|
||||
components: { HeaderBar, ModelEditDialog, TtsModel, AddModelDialog },
|
||||
@@ -139,20 +146,34 @@ export default {
|
||||
editDialogVisible: false,
|
||||
editModelData: {},
|
||||
ttsDialogVisible: false,
|
||||
modelList: [
|
||||
{ code: 'DeepSeek', candidateName: '深度求索', isApplied: true, supplier: '硅基流动' },
|
||||
{ code: 'SmartAssist', candidateName: '智能助手', isApplied: false, supplier: '智脑科技' },
|
||||
{ code: 'CogEngine', candidateName: '认知引擎', isApplied: true, supplier: '云智科技' },
|
||||
],
|
||||
modelList: [],
|
||||
currentPage: 1,
|
||||
pageSize: 4,
|
||||
total: 20,
|
||||
pageSize: 5,
|
||||
total: 0,
|
||||
selectedModels: [],
|
||||
isAllSelected: false
|
||||
};
|
||||
},
|
||||
|
||||
created() {
|
||||
this.loadData();
|
||||
},
|
||||
|
||||
computed: {
|
||||
|
||||
modelTypeText() {
|
||||
const map = {
|
||||
vad: '语言活动检测模型(VAD)',
|
||||
asr: '语音识别模型(ASR)',
|
||||
llm: '大语言模型(LLM)',
|
||||
intent: '意图识别模型(Intent)',
|
||||
tts: '语音合成模型(TTS)',
|
||||
memory: '记忆模型(Memory)'
|
||||
}
|
||||
return map[this.activeTab] || '模型配置'
|
||||
},
|
||||
|
||||
|
||||
pageCount() {
|
||||
return Math.ceil(this.total / this.pageSize);
|
||||
},
|
||||
@@ -182,51 +203,77 @@ export default {
|
||||
},
|
||||
handleMenuSelect(index) {
|
||||
this.activeTab = index;
|
||||
this.currentPage = 1;
|
||||
this.loadData();
|
||||
},
|
||||
handleSearch() {
|
||||
console.log('查询:', this.search);
|
||||
},
|
||||
// 批量删除
|
||||
batchDelete() {
|
||||
if (this.selectedModels.length === 0) {
|
||||
this.$message.warning('请先选择要删除的模型');
|
||||
return;
|
||||
this.$message.warning('请先选择要删除的模型')
|
||||
return
|
||||
}
|
||||
|
||||
this.$confirm('确定要删除选中的模型吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
const selectedIds = this.selectedModels.map(model => model.code);
|
||||
this.modelList = this.modelList.filter(model => !selectedIds.includes(model.code));
|
||||
this.$message.success('删除成功');
|
||||
this.selectedModels = [];
|
||||
this.isAllSelected = false;
|
||||
const deletePromises = this.selectedModels.map(model =>
|
||||
new Promise(resolve => {
|
||||
ModelApi.deleteModel(
|
||||
this.activeTab,
|
||||
model.configJson?.provider || '',
|
||||
model.id,
|
||||
({data}) => resolve(data.code === 0)
|
||||
)
|
||||
})
|
||||
)
|
||||
|
||||
Promise.all(deletePromises).then(results => {
|
||||
if (results.every(Boolean)) {
|
||||
this.$message.success('批量删除成功')
|
||||
this.loadData()
|
||||
} else {
|
||||
this.$message.error('部分删除失败')
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message.info('已取消删除');
|
||||
});
|
||||
},
|
||||
this.$message.info('已取消删除')
|
||||
})
|
||||
},
|
||||
addModel() {
|
||||
this.addDialogVisible = true;
|
||||
},
|
||||
editModel(model) {
|
||||
this.editModelData = {
|
||||
code: model.code,
|
||||
name: model.candidateName,
|
||||
supplier: model.supplier,
|
||||
};
|
||||
this.editModelData = JSON.parse(JSON.stringify(model));
|
||||
this.editDialogVisible = true;
|
||||
},
|
||||
// 删除单个模型
|
||||
deleteModel(model) {
|
||||
this.$confirm(`确定要删除模型 ${model.candidateName} 吗?`, '提示', {
|
||||
this.$confirm('确定要删除该模型吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.modelList = this.modelList.filter(item => item.code !== model.code);
|
||||
this.$message.success('删除成功');
|
||||
ModelApi.deleteModel(
|
||||
this.activeTab,
|
||||
model.configJson?.provider || '', // 从configJson获取provider
|
||||
model.id,
|
||||
({data}) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success('删除成功')
|
||||
this.loadData()
|
||||
} else {
|
||||
this.$message.error(data.msg || '删除失败')
|
||||
}
|
||||
}
|
||||
)
|
||||
}).catch(() => {
|
||||
this.$message.info('已取消删除');
|
||||
});
|
||||
this.$message.info('已取消删除')
|
||||
})
|
||||
},
|
||||
handleCurrentChange(page) {
|
||||
this.currentPage = page;
|
||||
@@ -256,8 +303,27 @@ export default {
|
||||
this.isAllSelected = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 新增模型配置
|
||||
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 || '新增失败');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 分页器
|
||||
@@ -281,8 +347,24 @@ export default {
|
||||
this.currentPage = page;
|
||||
this.loadData();
|
||||
},
|
||||
|
||||
// 获取模型配置列表
|
||||
loadData() {
|
||||
console.log('加载数据,当前页:', this.currentPage);
|
||||
const params = {
|
||||
modelType: this.activeTab,
|
||||
modelName: this.search,
|
||||
page: this.currentPage,
|
||||
limit: this.pageSize
|
||||
};
|
||||
|
||||
ModelApi.getModelList(params, ({data}) => {
|
||||
if (data.code === 0) {
|
||||
this.modelList = data.data.list;
|
||||
this.total = data.data.total;
|
||||
} else {
|
||||
this.$message.error(data.msg || '获取模型列表失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -637,7 +719,6 @@ export default {
|
||||
margin-top: 15px;
|
||||
|
||||
/* 导航按钮样式 (首页、上一页、下一页) */
|
||||
|
||||
.pagination-btn:first-child,
|
||||
.pagination-btn:nth-child(2),
|
||||
.pagination-btn:nth-last-child(2) {
|
||||
@@ -663,7 +744,6 @@ export default {
|
||||
}
|
||||
|
||||
/* 数字按钮样式 */
|
||||
|
||||
.pagination-btn:not(:first-child):not(:nth-child(2)):not(:nth-last-child(2)) {
|
||||
min-width: 28px;
|
||||
height: 32px;
|
||||
|
||||
@@ -127,10 +127,10 @@ export default {
|
||||
models: [
|
||||
{label: '大语言模型(LLM)', key: 'llmModelId'},
|
||||
{label: '语音识别(ASR)', key: 'asrModelId'},
|
||||
{label: '语音活动检测模型(VAD)', key: 'vadModelId'},
|
||||
{label: '语音合成模型(TTS)', key: 'ttsModelId'},
|
||||
{label: '意图识别模型(Intent)', key: 'intentModelId'},
|
||||
{label: '记忆模型(Memory)', key: 'memModelId'}
|
||||
{label: '语音活动检测(VAD)', key: 'vadModelId'},
|
||||
{label: '语音合成(TTS)', key: 'ttsModelId'},
|
||||
{label: '意图识别(Intent)', key: 'intentModelId'},
|
||||
{label: '记忆(Memory)', key: 'memModelId'}
|
||||
],
|
||||
templates: ['湾湾小何', '星际游子', '英语老师', '好奇男孩', '汪汪队长'],
|
||||
loadingTemplate: false
|
||||
|
||||
Reference in New Issue
Block a user