mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-25 04:29:51 +01:00
* 统一管理后台弹框更舒展 把 CustomDialog 默认宽度从 600 加到 720,正文给到至少 360 的高度, 默认弹框就不再显得局促。参数编辑弹框也跟着加宽。智能体历史版 本那条列表、对比和恢复预览都给到至少 420 的最小高度,避免内容 少时框太矮看起来小气。其他像添加智能体、绑定设备这些原本就合适 的弹框没动。 * 弹框外观统一收口 原本几个弹框长得参差不齐:标题字号、按钮文案、留白高度各管各的。这次把新建智能体、新建设备、改模型、改参数这几个弹框接到同一个底座上,按钮统一成「确定」「取消」,输入框字号高度对齐,遮罩背景加了模糊,弹框太高就内部滚动,四个弹框看起来一个模子 * 修复弹框关掉后再点不开 之前几个弹框改用新底座的时候,关闭那一路少了一段转发:父页面用双向绑定来收弹框关闭的信号,子页面应该再把关闭事件抛上去告诉父页面。这一段被删了,下次再点添加按钮时父页面那边状态没复位,弹框就拉不开来。现在把这段补回去。 * 弹框宽度和高度统一收口 同一批弹框的尺寸还是各管各的:模型配置里改参数那个是跟着窗口大小按比例伸缩,历史提示词的源编辑弹框是 900 像素,参数管理里又是 720 像素,智能体变更详情那个上下还留了一大块空白。这次收到同一个共用底子上:宽度都对齐到 720 像素,弹框默认上下贴齐屏幕边、内容多时中间滚动,变更详情那个高度撑到接近屏幕顶到底。 * 管理后台弹框按大小分类统一外观 管理后台里的弹框按大小分成两类来收口。占整页的大弹框(历史版本、变更详情、模型修改、模型参数修正等)撑满整个浏览器高度,下面不再留白;小弹框(添加智能体、添加设备、知识库、字典、角色模板等)改成对齐屏幕正中,不再顶在屏幕上沿。修改模型那条弹框也加宽到 960,左右留白加大到 40,跟历史版本对齐,看起来更舒展。 * 大弹框上下留白收口到十像素并按三档统一宽度 大弹框上下各留十像素让边框和圆角清晰可见。宽度按用途分三档:表单 960、含代码 1080、表格 80% 加宽度上限。供应器、上下文供应器、音色克隆都改 960;TTS 从 90% 改 80%;角色模板从 1200 改 1080;缓存查看从 70% 改 80%。新增模板的大文本框改成自适应高度。 * 弹框样式与文案收口处理 AddDeviceDialog 确认后关闭弹框;CustomDialog 去掉 :global 与紧邻选择器,合并 el-dialog__body 样式块;删除未使用的 --dialog-form/--dialog-code;AddWisdomBodyDialog 的 cancel/handleClose 委托到同一个实现;多语言文案同步去冒号与双点。 * 弹框遮罩样式移到全局作用域 scoped 块里的 ::v-deep .v-modal 打不到 body 层的遮罩,改在 global.scss 用全局选择器。 * 弹框 wrapper 居中样式移到全局作用域 scoped 块里的 ::v-deep .el-dialog__wrapper 同样打不到 element-ui 自渲染的 wrapper,跟 .v-modal 一起挪到 global.scss。 * 弹框提交状态异常收口 设备激活码错误路径不再卡 loading;Provider 与固件弹框补 loading 兜底。 * 弹框视觉异常收口 首页删除确认弹框 wrapper 居中;历史版本弹框去掉内层多余滚动条。 * 设备 API 链式返回修复 bindDevice 等方法补上 return,让 .fail() 兜底回调能正常注册到请求对象上。 * 设备 API 错误回调参数补全 device.js 六个方法加 failCallback 参数;user.js login 网络重试补 failCallback;AddDeviceDialog 改四参数签名。 * 设备状态 API 失败回调引用修复 getDeviceStatus 的 .fail() 块把函数体内 callback(res) 改成与签名一致的 if (failCallback) failCallback(err),避免业务错误时抛 ReferenceError。
509 lines
15 KiB
Vue
509 lines
15 KiB
Vue
<template>
|
||
<div class="welcome">
|
||
<HeaderBar />
|
||
<div class="main-wrapper">
|
||
<div class="content-panel">
|
||
<div class="content-area">
|
||
<el-card class="provider-card" shadow="never">
|
||
<div class="operation-header">
|
||
<h2 class="page-title">{{ $t('header.providerManagement') }}</h2>
|
||
<div class="right-operations">
|
||
<el-input :placeholder="$t('providerManagement.searchPlaceholder')" v-model="searchName" class="search-input"
|
||
@keyup.enter.native="handleSearch" clearable />
|
||
<el-dropdown trigger="click" @command="handleSelectModelType" @visible-change="handleDropdownVisibleChange">
|
||
<CustomButton>
|
||
{{ $t('providerManagement.categoryFilter') }}{{ selectedModelTypeLabel }}<i class="el-icon-arrow-down el-icon--right"
|
||
:class="{ 'rotate-down': DropdownVisible }"></i>
|
||
</CustomButton>
|
||
<el-dropdown-menu slot="dropdown">
|
||
<el-dropdown-item command="">{{ $t('common.all') }}</el-dropdown-item>
|
||
<el-dropdown-item v-for="item in translatedModelTypes" :key="item.value" :command="item.value">
|
||
{{ item.label }}
|
||
</el-dropdown-item>
|
||
</el-dropdown-menu>
|
||
</el-dropdown>
|
||
<CustomButton icon="el-icon-search" type="confirm" @click="handleSearch">{{ $t('common.search') }}</CustomButton>
|
||
</div>
|
||
</div>
|
||
<CustomTable
|
||
ref="providersTable"
|
||
:data="filteredProvidersList"
|
||
:columns="tableColumns"
|
||
:loading="loading"
|
||
:show-selection="true"
|
||
:show-operations="true"
|
||
:operations-label="$t('common.action')"
|
||
:total="total"
|
||
:current-page="currentPage"
|
||
:page-size="pageSize"
|
||
:page-size-options="pageSizeOptions"
|
||
@size-change="handlePageSizeChange"
|
||
@page-change="goToPage"
|
||
>
|
||
<template slot="selection" slot-scope="scope">
|
||
<el-checkbox v-model="scope.row.selected"></el-checkbox>
|
||
</template>
|
||
<template slot="modelType" slot-scope="scope">
|
||
<el-tag :type="getModelTypeTag(scope.row.modelType)">
|
||
{{ getModelTypeLabel(scope.row.modelType) }}
|
||
</el-tag>
|
||
</template>
|
||
<template slot="fields" slot-scope="scope">
|
||
<el-popover placement="top-start" width="400" trigger="hover">
|
||
<div v-for="field in scope.row.fields" :key="field.key" class="field-item">
|
||
<span class="field-label">{{ field.label }}:</span>
|
||
<span class="field-type">{{ field.type }}</span>
|
||
<span v-if="isSensitiveField(field.key)" class="sensitive-tag">{{ $t('common.sensitive') }}</span>
|
||
</div>
|
||
<el-button slot="reference" size="mini" type="text">{{ $t('providerManagement.viewFields') }}</el-button>
|
||
</el-popover>
|
||
</template>
|
||
<template slot="operations" slot-scope="scope">
|
||
<el-button size="mini" type="text" @click="editProvider(scope.row)">{{ $t('common.edit') }}</el-button>
|
||
<el-button size="mini" type="text" @click="deleteProvider(scope.row)">{{ $t('common.delete') }}</el-button>
|
||
</template>
|
||
<template slot="footer-btns">
|
||
<div class="ctrl_btn">
|
||
<CustomButton :icon="isAllSelected ? 'el-icon-circle-close' : 'el-icon-circle-check'" size="small" @click="handleSelectAll">
|
||
{{ isAllSelected ? $t('common.deselectAll') : $t('common.selectAll') }}
|
||
</CustomButton>
|
||
<CustomButton type="add" icon="el-icon-plus" size="small" @click="showAddDialog">
|
||
{{ $t('common.add') }}
|
||
</CustomButton>
|
||
<CustomButton size="small" type="delete" icon="el-icon-delete" @click="deleteSelectedProviders">
|
||
{{ $t('common.delete') }}
|
||
</CustomButton>
|
||
</div>
|
||
</template>
|
||
</CustomTable>
|
||
</el-card>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 新增/编辑供应器对话框 -->
|
||
<provider-dialog :title="dialogTitle" :visible.sync="dialogVisible" :form="providerForm" :model-types="modelTypes"
|
||
@submit="handleSubmit" @cancel="dialogVisible = false" />
|
||
|
||
<el-footer>
|
||
<version-footer />
|
||
</el-footer>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import Api from "@/apis/api";
|
||
import HeaderBar from "@/components/HeaderBar.vue";
|
||
import ProviderDialog from "@/components/ProviderDialog.vue";
|
||
import VersionFooter from "@/components/VersionFooter.vue";
|
||
import CustomButton from "@/components/CustomButton.vue";
|
||
import CustomTable from "@/components/CustomTable.vue";
|
||
|
||
export default {
|
||
components: { HeaderBar, ProviderDialog, VersionFooter, CustomButton, CustomTable },
|
||
data() {
|
||
return {
|
||
searchName: "",
|
||
searchModelType: "",
|
||
providersList: [],
|
||
modelTypes: [
|
||
{ value: "ASR", labelKey: 'providerManagement.modelType.ASR' },
|
||
{ value: "TTS", labelKey: 'providerManagement.modelType.TTS' },
|
||
{ value: "LLM", labelKey: 'providerManagement.modelType.LLM' },
|
||
{ value: "VLLM", labelKey: 'providerManagement.modelType.VLLM' },
|
||
{ value: "Intent", labelKey: 'providerManagement.modelType.Intent' },
|
||
{ value: "Memory", labelKey: 'providerManagement.modelType.Memory' },
|
||
{ value: "VAD", labelKey: 'providerManagement.modelType.VAD' },
|
||
{ value: "Plugin", labelKey: 'providerManagement.modelType.Plugin' },
|
||
{ value: "RAG", labelKey: 'providerManagement.modelType.RAG' }
|
||
],
|
||
currentPage: 1,
|
||
loading: false,
|
||
pageSize: 10,
|
||
pageSizeOptions: [10, 20, 50, 100],
|
||
total: 0,
|
||
dialogVisible: false,
|
||
dialogTitle: "新增供应器",
|
||
isAllSelected: false,
|
||
DropdownVisible: false,
|
||
sensitive_keys: ["api_key", "personal_access_token", "access_token", "token", "secret", "access_key_secret", "secret_key"],
|
||
providerForm: {
|
||
id: null,
|
||
modelType: "",
|
||
providerCode: "",
|
||
name: "",
|
||
fields: [],
|
||
sort: 0
|
||
},
|
||
tableColumns: []
|
||
};
|
||
},
|
||
created() {
|
||
this.initTableColumns();
|
||
this.fetchProviders();
|
||
},
|
||
computed: {
|
||
translatedModelTypes() {
|
||
return this.modelTypes.map(type => ({
|
||
value: type.value,
|
||
label: this.$t(type.labelKey)
|
||
}));
|
||
},
|
||
selectedModelTypeLabel() {
|
||
if (!this.searchModelType) return `(${this.$t('providerManagement.all')})`;
|
||
const selectedType = this.modelTypes.find(item => item.value === this.searchModelType);
|
||
return selectedType ? `(${this.$t(selectedType.labelKey)})` : "";
|
||
},
|
||
filteredProvidersList() {
|
||
return this.providersList;
|
||
}
|
||
},
|
||
methods: {
|
||
initTableColumns() {
|
||
this.tableColumns = [
|
||
{
|
||
prop: 'modelType',
|
||
label: this.$t('providerManagement.category'),
|
||
align: 'center',
|
||
width: 200
|
||
},
|
||
{
|
||
prop: 'providerCode',
|
||
label: this.$t('providerManagement.providerCode'),
|
||
align: 'center',
|
||
width: 150
|
||
},
|
||
{
|
||
prop: 'name',
|
||
label: this.$t('common.name'),
|
||
align: 'center'
|
||
},
|
||
{
|
||
prop: 'fields',
|
||
label: this.$t('providerManagement.fieldConfig'),
|
||
align: 'center'
|
||
},
|
||
{
|
||
prop: 'sort',
|
||
label: this.$t('common.sort'),
|
||
align: 'center',
|
||
width: 80
|
||
}
|
||
];
|
||
},
|
||
fetchProviders() {
|
||
this.loading = true;
|
||
|
||
Api.model.getModelProvidersPage(
|
||
{
|
||
page: this.currentPage,
|
||
limit: this.pageSize,
|
||
name: this.searchName,
|
||
modelType: this.searchModelType
|
||
},
|
||
({ data }) => {
|
||
this.loading = false;
|
||
if (data.code === 0) {
|
||
this.providersList = data.data.list.map(item => {
|
||
return {
|
||
...item,
|
||
selected: false,
|
||
fields: JSON.parse(item.fields)
|
||
};
|
||
});
|
||
this.total = data.data.total;
|
||
} else {
|
||
this.$message.error({
|
||
message: data.msg || '获取参数列表失败'
|
||
});
|
||
}
|
||
}
|
||
);
|
||
},
|
||
handleSearch() {
|
||
this.currentPage = 1;
|
||
this.fetchProviders();
|
||
},
|
||
handleSelectModelType(value) {
|
||
this.searchModelType = value;
|
||
this.handleSearch();
|
||
},
|
||
handleSelectAll() {
|
||
this.isAllSelected = !this.isAllSelected;
|
||
this.providersList.forEach(row => {
|
||
row.selected = this.isAllSelected;
|
||
});
|
||
},
|
||
showAddDialog() {
|
||
this.dialogTitle = this.$t('common.addProvider');
|
||
this.providerForm = {
|
||
id: null,
|
||
modelType: "",
|
||
providerCode: "",
|
||
name: "",
|
||
fields: [],
|
||
sort: 0
|
||
};
|
||
this.dialogVisible = true;
|
||
},
|
||
editProvider(row) {
|
||
this.dialogTitle = this.$t('common.editProvider');
|
||
this.providerForm = {
|
||
...row,
|
||
fields: JSON.parse(JSON.stringify(row.fields))
|
||
};
|
||
this.dialogVisible = true;
|
||
},
|
||
handleSubmit({ form, done }) {
|
||
if (form.id) {
|
||
Api.model.updateModelProvider(form, ({ data }) => {
|
||
if (data.code === 0) {
|
||
this.fetchProviders();
|
||
this.$message.success({
|
||
message: this.$t('common.updateSuccess'),
|
||
showClose: true
|
||
});
|
||
this.dialogVisible = false;
|
||
} else {
|
||
this.$message.error({
|
||
message: data.msg || this.$t('common.updateFailure'),
|
||
showClose: true
|
||
});
|
||
}
|
||
done && done();
|
||
});
|
||
} else {
|
||
Api.model.addModelProvider(form, ({ data }) => {
|
||
if (data.code === 0) {
|
||
this.fetchProviders();
|
||
this.$message.success({
|
||
message: this.$t('common.addSuccess'),
|
||
showClose: true
|
||
});
|
||
this.total += 1;
|
||
this.dialogVisible = false;
|
||
} else {
|
||
this.$message.error({
|
||
message: data.msg || this.$t('common.addFailure'),
|
||
showClose: true
|
||
});
|
||
}
|
||
done && done();
|
||
});
|
||
}
|
||
},
|
||
deleteSelectedProviders() {
|
||
const selectedRows = this.providersList.filter(row => row.selected);
|
||
if (selectedRows.length === 0) {
|
||
this.$message.warning({
|
||
message: this.$t('providerManagement.selectToDelete'),
|
||
showClose: true
|
||
});
|
||
return;
|
||
}
|
||
this.deleteProvider(selectedRows);
|
||
},
|
||
deleteProvider(row) {
|
||
const providers = Array.isArray(row) ? row : [row];
|
||
const providerCount = providers.length;
|
||
|
||
this.$confirm(this.$t('providerManagement.confirmDelete', { count: providerCount }), this.$t('common.warning'), {
|
||
confirmButtonText: this.$t('common.confirm'),
|
||
cancelButtonText: this.$t('common.cancel'),
|
||
type: 'warning',
|
||
}).then(() => {
|
||
const ids = providers.map(provider => provider.id);
|
||
Api.model.deleteModelProviderByIds(ids, ({ data }) => {
|
||
if (data.code === 0) {
|
||
this.isAllSelected = false;
|
||
this.fetchProviders();
|
||
this.$message.success({
|
||
message: this.$t('common.deleteSuccess'),
|
||
showClose: true
|
||
});
|
||
} else {
|
||
this.$message.error({
|
||
message: data.msg || this.$t('common.deleteFailure'),
|
||
showClose: true
|
||
});
|
||
}
|
||
});
|
||
}).catch(() => {
|
||
this.$message({
|
||
type: 'info',
|
||
message: this.$t('common.deleteCancelled'),
|
||
showClose: true,
|
||
duration: 1000
|
||
});
|
||
});
|
||
},
|
||
getModelTypeTag(type) {
|
||
const typeMap = {
|
||
'ASR': 'success',
|
||
'TTS': 'warning',
|
||
'LLM': 'danger',
|
||
'Intent': 'info',
|
||
'Memory': '',
|
||
'VAD': 'primary',
|
||
'RAG': 'warning'
|
||
};
|
||
return typeMap[type] || '';
|
||
},
|
||
getModelTypeLabel(type) {
|
||
const typeItem = this.modelTypes.find(item => item.value === type);
|
||
return typeItem ? this.$t(typeItem.labelKey) : type;
|
||
},
|
||
isSensitiveField(fieldKey) {
|
||
if (typeof fieldKey !== 'string') return false;
|
||
return this.sensitive_keys.some(key =>
|
||
fieldKey.toLowerCase().includes(key.toLowerCase())
|
||
);
|
||
},
|
||
handlePageSizeChange(val) {
|
||
this.pageSize = val;
|
||
this.currentPage = 1;
|
||
this.fetchProviders();
|
||
},
|
||
goToPage(page) {
|
||
if (page !== this.currentPage) {
|
||
this.currentPage = page;
|
||
this.fetchProviders();
|
||
}
|
||
},
|
||
handleDropdownVisibleChange(visible) {
|
||
this.DropdownVisible = visible;
|
||
}
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.welcome {
|
||
min-width: 900px;
|
||
min-height: 506px;
|
||
height: 100vh;
|
||
display: flex;
|
||
position: relative;
|
||
flex-direction: column;
|
||
background-size: cover;
|
||
background: #eff4ff;
|
||
-webkit-background-size: cover;
|
||
-o-background-size: cover;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.main-wrapper {
|
||
// 顶部 63px 底部 35px
|
||
height: calc(100vh - 63px - 35px);
|
||
padding: 20px 22px 0;
|
||
position: relative;
|
||
display: flex;
|
||
flex-direction: column;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.operation-header {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding: 0 0 16px 0;
|
||
}
|
||
|
||
.page-title {
|
||
font-weight: 500;
|
||
font-size: 24px;
|
||
margin: 0;
|
||
}
|
||
|
||
.right-operations {
|
||
display: flex;
|
||
gap: 10px;
|
||
margin-left: auto;
|
||
align-items: center;
|
||
}
|
||
|
||
.search-input {
|
||
width: 240px;
|
||
}
|
||
|
||
.content-panel {
|
||
display: flex;
|
||
overflow: hidden;
|
||
height: 100%;
|
||
border-radius: 15px;
|
||
background: transparent;
|
||
border: 1px solid #fff;
|
||
}
|
||
|
||
.content-area {
|
||
flex: 1;
|
||
height: 100%;
|
||
min-width: 600px;
|
||
overflow: auto;
|
||
background-color: white;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.provider-card {
|
||
background: white;
|
||
flex: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
border: none;
|
||
box-shadow: none;
|
||
overflow: hidden;
|
||
|
||
::v-deep .el-card__body {
|
||
padding: 14px 20px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
flex: 1;
|
||
overflow: hidden;
|
||
}
|
||
}
|
||
|
||
.ctrl_btn {
|
||
display: flex;
|
||
}
|
||
|
||
.field-item {
|
||
padding: 5px 0;
|
||
border-bottom: 1px solid #eee;
|
||
display: flex;
|
||
align-items: center;
|
||
|
||
.field-label {
|
||
flex: 1;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.field-type {
|
||
width: 80px;
|
||
color: #666;
|
||
}
|
||
|
||
.sensitive-tag {
|
||
margin-left: 10px;
|
||
color: #f56c6c;
|
||
font-size: 12px;
|
||
}
|
||
}
|
||
|
||
.rotate-down {
|
||
transform: rotate(180deg);
|
||
transition: transform 0.3s ease;
|
||
}
|
||
|
||
.el-icon-arrow-down {
|
||
transition: transform 0.3s ease;
|
||
}
|
||
|
||
:deep(.el-table .el-button--text) {
|
||
color: #7079aa;
|
||
}
|
||
|
||
:deep(.el-table .el-button--text:hover) {
|
||
color: #5a64b5;
|
||
}
|
||
</style>
|