mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-25 08:33:53 +08:00
uptate:增加功能管理菜单
This commit is contained in:
@@ -0,0 +1,592 @@
|
||||
<template>
|
||||
<div class="welcome">
|
||||
<HeaderBar />
|
||||
|
||||
<div class="operation-bar">
|
||||
<h2 class="page-title">{{ $t('header.featureManagement') }}</h2>
|
||||
</div>
|
||||
|
||||
<div class="main-wrapper">
|
||||
<div class="content-panel">
|
||||
<div class="content-area">
|
||||
<el-card class="feature-card" shadow="never">
|
||||
<div class="config-header">
|
||||
<div class="header-icon">
|
||||
<img loading="lazy" src="@/assets/home/equipment.png" alt="" />
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<el-button @click="!isSaving && toggleSelectAll()" class="btn-select-all" :disabled="isSaving">
|
||||
{{ isAllSelected ? $t('featureManagement.deselectAll') : $t('featureManagement.selectAll') }}
|
||||
</el-button>
|
||||
<el-button type="primary" class="save-btn" @click="handleSave" :disabled="isSaving">
|
||||
{{ isSaving ? $t('featureManagement.saving') : $t('featureManagement.save') }}
|
||||
</el-button>
|
||||
<el-button class="reset-btn" @click="handleReset" :disabled="isSaving">
|
||||
{{ $t('featureManagement.reset') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="divider"></div>
|
||||
|
||||
<!-- 功能分组容器 - 左右布局 -->
|
||||
<div class="feature-groups-container">
|
||||
<!-- 功能管理分组 -->
|
||||
<div v-if="featureManagementFeatures.length > 0" class="feature-group">
|
||||
<h3 class="group-title">{{ $t('featureManagement.group.featureManagement') }}</h3>
|
||||
<div class="features-grid">
|
||||
<div
|
||||
v-for="feature in featureManagementFeatures"
|
||||
:key="feature.id"
|
||||
class="feature-card-item"
|
||||
:class="{ 'feature-enabled': feature.enabled, 'feature-disabled': isSaving }"
|
||||
@click="!isSaving && toggleFeature(feature)"
|
||||
>
|
||||
<div class="feature-header">
|
||||
<h3 class="feature-name">{{ $t(`feature.${feature.id}.name`) }}</h3>
|
||||
<el-checkbox
|
||||
v-model="feature.enabled"
|
||||
@change="!isSaving && toggleFeature(feature)"
|
||||
class="feature-checkbox"
|
||||
:disabled="isSaving"
|
||||
/>
|
||||
</div>
|
||||
<p class="feature-description">{{ $t(`feature.${feature.id}.description`) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 语音管理分组 -->
|
||||
<div v-if="voiceManagementFeatures.length > 0" class="feature-group">
|
||||
<h3 class="group-title">{{ $t('featureManagement.group.voiceManagement') }}</h3>
|
||||
<div class="features-grid">
|
||||
<div
|
||||
v-for="feature in voiceManagementFeatures"
|
||||
:key="feature.id"
|
||||
class="feature-card-item"
|
||||
:class="{ 'feature-enabled': feature.enabled, 'feature-disabled': isSaving }"
|
||||
@click="!isSaving && toggleFeature(feature)"
|
||||
>
|
||||
<div class="feature-header">
|
||||
<h3 class="feature-name">{{ $t(`feature.${feature.id}.name`) }}</h3>
|
||||
<el-checkbox
|
||||
v-model="feature.enabled"
|
||||
@change="!isSaving && toggleFeature(feature)"
|
||||
class="feature-checkbox"
|
||||
:disabled="isSaving"
|
||||
/>
|
||||
</div>
|
||||
<p class="feature-description">{{ $t(`feature.${feature.id}.description`) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="filteredFeatures.length === 0" class="empty-state">
|
||||
<el-empty :description="$t('featureManagement.noFeatures')">
|
||||
<p class="empty-tip">{{ $t('featureManagement.contactAdmin') }}</p>
|
||||
</el-empty>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-footer>
|
||||
<VersionFooter />
|
||||
</el-footer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import HeaderBar from "@/components/HeaderBar.vue";
|
||||
import VersionFooter from "@/components/VersionFooter.vue";
|
||||
import featureManager from "@/utils/featureManager.js";
|
||||
|
||||
export default {
|
||||
name: "FeatureManagement",
|
||||
components: {
|
||||
HeaderBar,
|
||||
VersionFooter
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
pendingChanges: false,
|
||||
featureManagementFeatures: [],
|
||||
voiceManagementFeatures: [],
|
||||
isSaving: false // 添加保存状态锁定
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 所有功能列表
|
||||
filteredFeatures() {
|
||||
return [...this.featureManagementFeatures, ...this.voiceManagementFeatures]
|
||||
},
|
||||
|
||||
// 判断是否所有功能都已选中
|
||||
isAllSelected() {
|
||||
const allFeatures = [...this.featureManagementFeatures, ...this.voiceManagementFeatures]
|
||||
return allFeatures.length > 0 && allFeatures.every(feature => feature.enabled)
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
// 等待功能配置管理器初始化完成
|
||||
try {
|
||||
console.log('等待功能配置管理器初始化...')
|
||||
await featureManager.waitForInitialization()
|
||||
console.log('功能配置管理器初始化完成,开始加载功能配置')
|
||||
await this.loadFeatures()
|
||||
this.setupConfigChangeListener()
|
||||
} catch (error) {
|
||||
console.error('功能配置管理器初始化等待失败:', error)
|
||||
await this.loadFeatures()
|
||||
this.setupConfigChangeListener()
|
||||
}
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.removeConfigChangeListener()
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 根据ID列表获取功能
|
||||
async getFeaturesByIds(featureIds) {
|
||||
try {
|
||||
const featureConfig = await featureManager.getAllFeatures()
|
||||
console.log('获取到的功能配置:', JSON.stringify(featureConfig, null, 2))
|
||||
console.log('请求的功能ID列表:', featureIds)
|
||||
|
||||
const result = featureIds.map(id => {
|
||||
const feature = featureConfig[id]
|
||||
console.log(`功能 ${id} 的配置:`, feature)
|
||||
console.log(`功能 ${id} 的启用状态:`, feature?.enabled)
|
||||
|
||||
return {
|
||||
id: id,
|
||||
name: this.$t(`feature.${id}.name`),
|
||||
description: this.$t(`feature.${id}.description`),
|
||||
enabled: feature?.enabled || false
|
||||
}
|
||||
})
|
||||
|
||||
console.log('最终返回的功能列表:', JSON.stringify(result, null, 2))
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('获取功能配置失败:', error)
|
||||
// 如果获取失败,返回默认配置
|
||||
return featureIds.map(id => ({
|
||||
id: id,
|
||||
name: this.$t(`feature.${id}.name`),
|
||||
description: this.$t(`feature.${id}.description`),
|
||||
enabled: false
|
||||
}))
|
||||
}
|
||||
},
|
||||
|
||||
// 加载功能配置
|
||||
async loadFeatures() {
|
||||
// 保存当前用户的选择状态
|
||||
const currentFeatureStates = {}
|
||||
const allCurrentFeatures = [...this.featureManagementFeatures, ...this.voiceManagementFeatures]
|
||||
allCurrentFeatures.forEach(feature => {
|
||||
currentFeatureStates[feature.id] = feature.enabled
|
||||
})
|
||||
|
||||
// 重新加载配置
|
||||
this.featureManagementFeatures = await this.getFeaturesByIds(['voiceprintRecognition', 'voiceClone', 'knowledgeBase', 'mcpAccessPoint'])
|
||||
this.voiceManagementFeatures = await this.getFeaturesByIds(['vad', 'asr'])
|
||||
|
||||
// 恢复用户的选择状态(如果存在)
|
||||
const allFeatures = [...this.featureManagementFeatures, ...this.voiceManagementFeatures]
|
||||
allFeatures.forEach(feature => {
|
||||
if (currentFeatureStates.hasOwnProperty(feature.id)) {
|
||||
feature.enabled = currentFeatureStates[feature.id]
|
||||
}
|
||||
})
|
||||
},
|
||||
// 切换功能状态
|
||||
async toggleFeature(feature) {
|
||||
// 如果正在保存,阻止操作
|
||||
if (this.isSaving) {
|
||||
return
|
||||
}
|
||||
|
||||
feature.enabled = !feature.enabled
|
||||
this.pendingChanges = true
|
||||
|
||||
// 不再立即更新到配置管理器,只在保存时统一更新
|
||||
},
|
||||
// 保存配置
|
||||
async handleSave() {
|
||||
if (!this.pendingChanges) {
|
||||
this.$message.info({
|
||||
message: this.$t('featureManagement.noChanges'),
|
||||
showClose: true
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 设置保存状态,锁定界面
|
||||
this.isSaving = true
|
||||
|
||||
try {
|
||||
// 获取当前所有功能的状态并保存
|
||||
const featureUpdates = {}
|
||||
const allFeatures = [...this.featureManagementFeatures, ...this.voiceManagementFeatures]
|
||||
allFeatures.forEach(feature => {
|
||||
featureUpdates[feature.id] = feature.enabled
|
||||
})
|
||||
await featureManager.updateFeatures(featureUpdates)
|
||||
|
||||
this.pendingChanges = false
|
||||
this.$message.success({
|
||||
message: this.$t('featureManagement.saveSuccess'),
|
||||
showClose: true
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
this.loadFeatures()
|
||||
this.$router.go(0)
|
||||
}, 1000)
|
||||
} catch (error) {
|
||||
console.error('保存配置失败:', error)
|
||||
this.$message.error({
|
||||
message: this.$t('featureManagement.saveError'),
|
||||
showClose: true
|
||||
})
|
||||
} finally {
|
||||
// 无论成功与否,都解除保存状态锁定
|
||||
this.isSaving = false
|
||||
}
|
||||
},
|
||||
// 设置配置变化监听器
|
||||
setupConfigChangeListener() {
|
||||
this.configChangeHandler = () => {
|
||||
console.log('检测到配置变化,重新加载功能列表')
|
||||
this.loadFeatures()
|
||||
}
|
||||
window.addEventListener('featureConfigReloaded', this.configChangeHandler)
|
||||
},
|
||||
|
||||
// 移除配置变化监听器
|
||||
removeConfigChangeListener() {
|
||||
if (this.configChangeHandler) {
|
||||
window.removeEventListener('featureConfigReloaded', this.configChangeHandler)
|
||||
}
|
||||
},
|
||||
|
||||
// 重置配置
|
||||
async handleReset() {
|
||||
try {
|
||||
await this.$confirm(
|
||||
this.$t('featureManagement.resetConfirm'),
|
||||
this.$t('featureManagement.reset'),
|
||||
{
|
||||
confirmButtonText: this.$t('featureManagement.confirm'),
|
||||
cancelButtonText: this.$t('featureManagement.cancel'),
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
|
||||
featureManager.resetToDefault()
|
||||
this.loadFeatures()
|
||||
this.pendingChanges = false
|
||||
|
||||
this.$message.success({
|
||||
message: this.$t('featureManagement.resetSuccess'),
|
||||
showClose: true
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
this.loadFeatures()
|
||||
this.$router.go(0)
|
||||
}, 1000)
|
||||
} catch (error) {
|
||||
// 用户取消操作
|
||||
}
|
||||
},
|
||||
// 搜索功能(预留接口)
|
||||
handleSearch() {
|
||||
// 搜索功能待实现
|
||||
},
|
||||
// 全选/取消全选
|
||||
toggleSelectAll() {
|
||||
// 如果正在保存,阻止操作
|
||||
if (this.isSaving) {
|
||||
return
|
||||
}
|
||||
|
||||
const allFeatures = [...this.featureManagementFeatures, ...this.voiceManagementFeatures]
|
||||
const newStatus = !this.isAllSelected
|
||||
|
||||
allFeatures.forEach(feature => {
|
||||
feature.enabled = newStatus
|
||||
})
|
||||
|
||||
this.pendingChanges = true
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.welcome {
|
||||
min-width: 900px;
|
||||
min-height: 506px;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
position: relative;
|
||||
flex-direction: column;
|
||||
background-size: cover;
|
||||
background: linear-gradient(to bottom right, #dce8ff, #e4eeff, #e6cbfd) center;
|
||||
-webkit-background-size: cover;
|
||||
-o-background-size: cover;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.operation-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px 24px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 24px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.config-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 0 16px 0;
|
||||
}
|
||||
|
||||
.header-icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #5778ff;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.header-icon img {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.divider {
|
||||
height: 1px;
|
||||
background: #e0e0e0;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.btn-select-all {
|
||||
background: #e6ebff;
|
||||
color: #5778ff;
|
||||
border: 1px solid #adbdff;
|
||||
border-radius: 18px;
|
||||
padding: 8px 16px;
|
||||
height: 32px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.btn-select-all:hover {
|
||||
background: #d0d8ff;
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
background: #5778ff;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 18px;
|
||||
padding: 8px 16px;
|
||||
height: 32px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.save-btn:hover {
|
||||
background: #4a6ae8;
|
||||
}
|
||||
|
||||
.reset-btn {
|
||||
background: #e6ebff;
|
||||
color: #5778ff;
|
||||
border: 1px solid #adbdff;
|
||||
border-radius: 18px;
|
||||
padding: 8px 16px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.reset-btn:hover {
|
||||
background: #d0d8ff;
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
margin: 0 22px 5px 22px;
|
||||
border-radius: 15px;
|
||||
min-height: calc(100vh - 24vh);
|
||||
height: auto;
|
||||
max-height: 80vh;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||
position: relative;
|
||||
background: rgba(237, 242, 255, 0.5);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.content-panel {
|
||||
flex: 1;
|
||||
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;
|
||||
}
|
||||
|
||||
.feature-card {
|
||||
background: white;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.feature-card ::v-deep .el-card__body {
|
||||
padding: 24px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.features-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.feature-card-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 20px;
|
||||
border-radius: 12px;
|
||||
border: 2px solid #e0e0e0;
|
||||
background-color: white;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
user-select: none;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.feature-card-item:hover {
|
||||
border-color: #9cc6ef;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.feature-card-item.feature-enabled {
|
||||
border-color: #409eff;
|
||||
box-shadow: 0 4px 16px rgba(95, 112, 243, 0.2);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.feature-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.feature-checkbox ::v-deep .el-checkbox__input {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
|
||||
|
||||
.feature-name {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
|
||||
|
||||
.feature-description {
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
color: #666;
|
||||
margin: 0 0 12px 0;
|
||||
transition: color 0.3s ease;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
||||
/* 功能分组容器 - 左右布局 */
|
||||
.feature-groups-container {
|
||||
display: flex;
|
||||
gap: 32px;
|
||||
align-items: flex-start;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* 分组之间的分隔线 */
|
||||
.feature-groups-container::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 1px;
|
||||
height: 550px;
|
||||
background: #e0e0e0;
|
||||
opacity: 0.5;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
/* 分组样式 */
|
||||
.feature-group {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.group-title {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
margin-bottom: 12px;
|
||||
padding-left: 12px;
|
||||
border-left: 4px solid #5f70f3;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.features-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
</style>
|
||||
@@ -39,8 +39,9 @@
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<DeviceItem v-for="(item, index) in devices" :key="index" :device="item" @configure="goToRoleConfig"
|
||||
@deviceManage="handleDeviceManage" @delete="handleDeleteAgent" @chat-history="handleShowChatHistory" />
|
||||
<DeviceItem v-for="(item, index) in devices" :key="index" :device="item" :feature-status="featureStatus"
|
||||
@configure="goToRoleConfig" @deviceManage="handleDeviceManage" @delete="handleDeleteAgent"
|
||||
@chat-history="handleShowChatHistory" />
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
@@ -61,6 +62,7 @@ import ChatHistoryDialog from '@/components/ChatHistoryDialog.vue';
|
||||
import DeviceItem from '@/components/DeviceItem.vue';
|
||||
import HeaderBar from '@/components/HeaderBar.vue';
|
||||
import VersionFooter from '@/components/VersionFooter.vue';
|
||||
import featureManager from '@/utils/featureManager';
|
||||
|
||||
export default {
|
||||
name: 'HomePage',
|
||||
@@ -76,15 +78,33 @@ export default {
|
||||
skeletonCount: localStorage.getItem('skeletonCount') || 8,
|
||||
showChatHistory: false,
|
||||
currentAgentId: '',
|
||||
currentAgentName: ''
|
||||
currentAgentName: '',
|
||||
// 功能状态
|
||||
featureStatus: {
|
||||
voiceprintRecognition: false,
|
||||
voiceClone: false,
|
||||
knowledgeBase: false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
async mounted() {
|
||||
this.fetchAgentList();
|
||||
await this.loadFeatureStatus();
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 加载功能状态
|
||||
async loadFeatureStatus() {
|
||||
await featureManager.waitForInitialization();
|
||||
const config = featureManager.getConfig();
|
||||
this.featureStatus = {
|
||||
voiceprintRecognition: config.voiceprintRecognition,
|
||||
voiceClone: config.voiceClone,
|
||||
knowledgeBase: config.knowledgeBase
|
||||
};
|
||||
},
|
||||
|
||||
showAddDialog() {
|
||||
this.addDeviceDialogVisible = true
|
||||
},
|
||||
|
||||
@@ -156,6 +156,7 @@ import VersionFooter from "@/components/VersionFooter.vue";
|
||||
import i18n, { changeLanguage } from "@/i18n";
|
||||
import { getUUID, goToPage, showDanger, showSuccess, sm2Encrypt, validateMobile } from "@/utils";
|
||||
import { mapState } from "vuex";
|
||||
import featureManager from "@/utils/featureManager";
|
||||
|
||||
export default {
|
||||
name: "login",
|
||||
@@ -214,6 +215,13 @@ export default {
|
||||
this.$store.dispatch("fetchPubConfig").then(() => {
|
||||
// 根据配置决定默认登录方式
|
||||
this.isMobileLogin = this.enableMobileRegister;
|
||||
|
||||
// pub-config接口调用完成后,重新初始化featureManager以确保使用最新的配置
|
||||
featureManager.waitForInitialization().then(() => {
|
||||
console.log('featureManager重新初始化完成,使用pub-config配置');
|
||||
}).catch(error => {
|
||||
console.warn('featureManager重新初始化失败:', error);
|
||||
});
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -107,7 +107,11 @@
|
||||
</div>
|
||||
<div class="form-column">
|
||||
<div class="model-row">
|
||||
<el-form-item :label="$t('roleConfig.vad')" class="model-item">
|
||||
<el-form-item
|
||||
v-if="featureStatus.vad"
|
||||
:label="$t('roleConfig.vad')"
|
||||
class="model-item"
|
||||
>
|
||||
<div class="model-select-wrapper">
|
||||
<el-select
|
||||
v-model="form.model.vadModelId"
|
||||
@@ -125,7 +129,11 @@
|
||||
</el-select>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('roleConfig.asr')" class="model-item">
|
||||
<el-form-item
|
||||
v-if="featureStatus.asr"
|
||||
:label="$t('roleConfig.asr')"
|
||||
class="model-item"
|
||||
>
|
||||
<div class="model-select-wrapper">
|
||||
<el-select
|
||||
v-model="form.model.asrModelId"
|
||||
@@ -277,6 +285,7 @@ import RequestService from "@/apis/httpRequest";
|
||||
import FunctionDialog from "@/components/FunctionDialog.vue";
|
||||
import HeaderBar from "@/components/HeaderBar.vue";
|
||||
import i18n from "@/i18n";
|
||||
import featureManager from "@/utils/featureManager";
|
||||
|
||||
export default {
|
||||
name: "RoleConfigPage",
|
||||
@@ -326,6 +335,11 @@ export default {
|
||||
isPaused: false,
|
||||
currentAudio: null,
|
||||
currentPlayingVoiceId: null,
|
||||
// 功能状态
|
||||
featureStatus: {
|
||||
vad: false, // 语言检测活动功能状态
|
||||
asr: false, // 语音识别功能状态
|
||||
},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
@@ -980,6 +994,19 @@ export default {
|
||||
this.form.chatHistoryConf = 0;
|
||||
}
|
||||
},
|
||||
// 加载功能状态
|
||||
async loadFeatureStatus() {
|
||||
try {
|
||||
// 确保featureManager已初始化完成
|
||||
await featureManager.waitForInitialization();
|
||||
const config = featureManager.getConfig();
|
||||
this.featureStatus.voiceprintRecognition = config.voiceprintRecognition || false;
|
||||
this.featureStatus.vad = config.vad || false;
|
||||
this.featureStatus.asr = config.asr || false;
|
||||
} catch (error) {
|
||||
console.error("加载功能状态失败:", error);
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
"form.model.ttsModelId": {
|
||||
@@ -1002,7 +1029,7 @@ export default {
|
||||
immediate: true,
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
async mounted() {
|
||||
const agentId = this.$route.query.agentId;
|
||||
if (agentId) {
|
||||
this.fetchAgentConfig(agentId);
|
||||
@@ -1010,6 +1037,8 @@ export default {
|
||||
}
|
||||
this.fetchModelOptions();
|
||||
this.fetchTemplates();
|
||||
// 加载功能状态,确保featureManager已初始化
|
||||
await this.loadFeatureStatus();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user