diff --git a/main/manager-web/src/apis/module/user.js b/main/manager-web/src/apis/module/user.js index 94de7b3fe..444d5d76d 100755 --- a/main/manager-web/src/apis/module/user.js +++ b/main/manager-web/src/apis/module/user.js @@ -5,7 +5,8 @@ import {getServiceUrl} from '../api' export default { // 登录 login(loginForm, callback) { - RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/login`).method('POST') + RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/login`) + .method('POST') .data(loginForm) .success((res) => { RequestService.clearRequestTime() @@ -19,7 +20,8 @@ export default { }, // 获取用户信息 getUserInfo(callback) { - RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/info`).method('GET') + RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/info`) + .method('GET') .success((res) => { RequestService.clearRequestTime() callback(res) @@ -32,7 +34,8 @@ export default { }, // 获取设备信息 getHomeList(callback) { - RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/device/bind`).method('GET') + RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/device/bind`) + .method('GET') .success((res) => { RequestService.clearRequestTime() callback(res) @@ -76,14 +79,14 @@ export default { }, // 获取验证码 getCaptcha(uuid, callback) { - + RequestService.sendRequest() .url(`${getServiceUrl()}/api/v1/user/captcha?uuid=${uuid}`) .method('GET') .type('blob') .header({ 'Content-Type': 'image/gif', - 'Pragma': 'No-cache', + 'Pragma': 'No-cache', 'Cache-Control': 'no-cache' }) .success((res) => { @@ -91,7 +94,7 @@ export default { callback(res); }) .fail((err) => { // 添加错误参数 - + }).send() }, // 注册账号 @@ -105,4 +108,70 @@ export default { .fail(() => { }).send() }, + + // 保存设备配置 + saveDeviceConfig(device_id, configData, callback) { + RequestService.sendRequest() + .url(`${getServiceUrl()}/api/v1/user/configDevice/${device_id}`) + .method('PUT') + .data(configData) + .success((res) => { + RequestService.clearRequestTime(); + callback(res); + }) + .fail((err) => { + console.error('保存配置失败:', err); + RequestService.reAjaxFun(() => { + this.saveDeviceConfig(device_id, configData, callback); + }); + }).send(); + }, + // 获取设备配置 + getDeviceConfig(device_id, callback) { + RequestService.sendRequest() + .url(`${getServiceUrl()}/api/v1/user/configDevice/${device_id}`) + .method('GET') + .success((res) => { + RequestService.clearRequestTime(); + callback(res); + }) + .fail((err) => { + console.error('获取配置失败:', err); + RequestService.reAjaxFun(() => { + this.getDeviceConfig(device_id, callback); + }); + }).send(); + }, + // 获取所有模型名称 + getModelNames(callback) { + RequestService.sendRequest() + .url(`${getServiceUrl()}/api/v1/models/names`) + .method('GET') + .success((res) => { + RequestService.clearRequestTime(); + callback(res); + }) + .fail(() => { + RequestService.reAjaxFun(() => { + this.getModelNames(callback); + }); + }).send(); + }, + + // 获取模型音色 + getModelVoices(modelName, callback) { + RequestService.sendRequest() + .url(`${getServiceUrl()}/api/v1/models/${modelName}/voices`) + .method('GET') + .success((res) => { + RequestService.clearRequestTime(); + callback(res); + }) + .fail(() => { + RequestService.reAjaxFun(() => { + this.getModelVoices(modelName, callback); + }); + }).send(); + }, + } diff --git a/main/manager-web/src/views/home.vue b/main/manager-web/src/views/home.vue index 4d0181f51..3580ced8b 100644 --- a/main/manager-web/src/views/home.vue +++ b/main/manager-web/src/views/home.vue @@ -26,9 +26,14 @@ style="width: 12px;height: 12px;margin-right: 11px;cursor: pointer;" @click="handleSearch" /> +
{{ userInfo.mobile }}
+ + 退出登录 + +
@@ -60,7 +65,6 @@
- {{item.list[0]?.mac_address}}
@@ -73,7 +77,7 @@ 设备型号:{{item.list[0]?.device_type}}
-
+
配置角色
声纹识别
@@ -96,14 +100,14 @@ style="width: 41px;height: 41px;background: #5778ff;border-radius: 50%;display: flex;align-items: center;justify-content: center;">
- CC:ba:97:11:a6:ac + {{ currentDevice?.list?.[0]?.id || '加载中...' }}
- +
@@ -123,8 +127,8 @@
- - + @@ -138,36 +142,91 @@
+ v-model="form.voice" maxlength="2000" show-word-limit />
+ v-model="form.roleDescription" maxlength="1000" />
当前记忆(每次对话后重新生成)
-
+
清除
-
{{form.prompt.length}}/1000
+
{{ form.roleDescription.length }}/1000
- +
-
- - - - -
+
+ + + + +
+ + +
+
+ + + + +
+
+
+ + +
+
+ + + + +
+
+
+ + +
+
+ + + + +
+
+
+ + +
+
+ + + + +
+
+
+ + +
+
+ + + + +
+
+
+
除了“Qwen 实时”,其他模型通常会增加约1秒的延迟。改变模型后,建议清空记忆体,以免影响体验。
@@ -175,9 +234,10 @@
-
- 保存配置
-
+
+ 保存配置 +
+
重制
@@ -235,21 +295,32 @@ export default { switchValue: false, addDeviceDialogVisible: false, deviceCode: "", // 设备验证码 + currentDevice: null, // 存储当前设备 settingDevice: false, form: { - name: "", - timbre: "", - introduction: "", - prompt: "", - model: "" + nickname: "", + templateId: "", + voice: "", + roleDescription: "", + selectedModules: { + tts: "", + vad: "", + asr: "", + llm: "", + memory:"", + intent:"" + } }, - options: [{ - value: '选项1', - label: '黄金糕' - }, { - value: '选项2', - label: '双皮奶' - }], + voiceOptions: [], // 角色音色 + modelOptions: { // 语言模型 + llm: [], + asr: [], + vad: [], + tts: [], + memory: [], + intent: [] + }, + userInfo: { mobile: '' // 初始化用户信息 } @@ -259,8 +330,45 @@ export default { showAddDialog() { this.addDeviceDialogVisible = true; }, - clickSettingDevice() { - this.settingDevice = true + clickSettingDevice(item) { + this.settingDevice = true; + this.currentDevice = item; + // 加载设备配置 + Api.user.getDeviceConfig(item.list[0]?.id, ({ data }) => { + if (data.code === 0) { + this.form = { + nickname: data.data.nickname || "", + templateId: data.data.templateId || "", + voice: data.data.voice || "", + roleDescription: data.data.roleDescription || "", + selectedModules: { + tts: data.data.selectedModules?.tts || "", + vad: data.data.selectedModules?.vad || "", + asr: data.data.selectedModules?.asr || "", + llm: data.data.selectedModules?.llm || "", + memory:data.data.selectedModules?.memory || "", + intent:data.data.selectedModules?.intent || "", + } + }; + // 获取模型音色 + Api.user.getModelVoices(item.list[0]?.device_type, ({ data }) => { + if (data.code === 0) { + this.voiceOptions = data.data.map(voice => ({ + value: voice, + label: voice + })); + } else { + this.$message.error(data.msg || '获取音色失败'); + } + }); + } else if (data.code === 401) { + this.$message.error('未授权,请重新登录'); + this.$router.push('/login'); + } else { + this.$message.error(data.msg || '加载配置失败'); + } + }); + }, // 获取用户信息 fetchUserInfo() { @@ -328,11 +436,107 @@ export default { this.$message.error(data.msg || '设备绑定失败'); } }); + }, + // 清空记忆体输入框内容 + clearroleDescription() { + this.form.roleDescription = ""; + }, + // 保存配置 + saveConfig() { + const configData = { + nickname: this.form.nickname, + templateId: this.form.templateId, + voice: this.form.voice, + roleDescription: this.form.roleDescription, + selectedModules: { + tts: this.form.selectedModules.tts, + vad: this.form.selectedModules.vad, + asr: this.form.selectedModules.asr, + llm: this.form.selectedModules.llm, + its: this.form.selectedModules.its, + memory: this.form.selectedModules.memory, + intent: this.form.selectedModules.intent, + } + }; + + Api.user.saveDeviceConfig(this.currentDevice.list[0]?.id, configData, ({ data }) => { + if (data.code === 0) { + this.$message.success('配置保存成功'); + this.settingDevice = false; + this.getList(); + } else if (data.code === 401) { + this.$message.error('未授权,请重新登录'); + this.$router.push('/login'); + } else { + this.$message.error(data.msg || '配置保存失败'); + } + }); + }, + + // 重置配置 + resetConfig() { + this.form = { + nickname: "", + templateId: "", + voice: "", + roleDescription: "", + selectedModules: { + tts: "", + vad: "", + asr: "", + llm: "" + } + }; + this.$message.info('配置已重置'); + }, + + // 获取模型名称 + fetchModelNames() { + Api.user.getModelNames(({ data }) => { + if (data.code === 0) { + const allModels = data.data; + + // 根据模型后缀名称分类 + this.modelOptions.llm = allModels.filter(model => model.includes("LLM")); + this.modelOptions.asr = allModels.filter(model => model.includes("ASR")); + this.modelOptions.its = allModels.filter(model => model.includes("TTS")); + this.modelOptions.vad = allModels.filter(model => model.includes("VAD")); + this.modelOptions.memory = allModels.filter(model => model.includes("Memory")); + this.modelOptions.intent = allModels.filter(model => model.includes("Intent")); + } else { + this.$message.error(data.msg || '获取模型名称失败'); + } + }); } + }, + // 处理下拉菜单命令 + handleCommand(command) { + if (command === 'logout') { + this.$confirm('确定要退出登录吗?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + // 调用退出登录的接口 + Api.user.logout(({ data }) => { + if (data.code === 0) { + this.$message.success('退出成功'); + this.$router.push('/login'); // 跳转到登录页面 + } else { + this.$message.error(data.msg || '退出失败'); + } + }); + }).catch(() => { + // 用户取消操作 + this.$message.info('已取消退出'); + }); + } + }, mounted() { this.fetchUserInfo(); // 组件加载时获取用户信息 this.getList(); // 初始化设备列表 + this.fetchModelNames(); } } @@ -404,6 +608,7 @@ export default { height: 35px; border-radius: 8px; border: 1px solid #e4e6ef; + padding: 5px; } .add-device-bg { width: 100%; @@ -453,6 +658,7 @@ export default { letter-spacing: -0.02px; text-align: left; color: #3d4566; + cursor: pointer; } .clear-btn { width: 45px; @@ -606,12 +812,16 @@ audio::-webkit-media-controls-panel { border-radius: 8px; background: #f6f8fb; } +.textarea-box:focus-within { + border-color: #5778ff; +} ::v-deep { .textarea-box .el-textarea__inner { background-color: transparent !important; border: none !important; padding: 15px; } + // 搜索输入框的样式调整 .serach-box .el-input__inner { border: none; @@ -620,27 +830,32 @@ audio::-webkit-media-controls-panel { font-size: 12px; color: #3d4566; } + .el-textarea .el-input__count { color: #979db1; font-size: 11px; right: 15px; background-color: transparent; } + .el-input__inner { //border: none; //background-color: transparent; padding: 0 5px 0 15px; border-radius: 8px; } + .input-46 .el-input__inner { padding: 0 15px; height: 38px; } + .lh-form-item { .el-form-item__label { line-height: 17px; } } + .el-form-item__label { line-height: 34px; font-weight: 400; @@ -648,35 +863,44 @@ audio::-webkit-media-controls-panel { text-align: left; color: #3d4566; } + .el-switch__core { height: 21px; border-radius: 10px; } + .el-switch { line-height: 28px; } + .el-switch.is-checked .el-switch__core::after { left: calc(100% - 4px); } + .el-switch__label { color: #3d4566; } + .el-switch__core:after { left: 4px; width: 15px; height: 15px; top: 2px; } + .el-dialog__headerbtn .el-dialog__close { display: none; } + .el-dialog__header, .el-dialog__footer { padding: 0; } + .el-dialog--center .el-dialog__body { padding: 24px 0; } + .el-dialog { display: flex !important; flex-direction: column !important; @@ -685,10 +909,28 @@ audio::-webkit-media-controls-panel { top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) !important; - overflow-y: scroll !important; + overflow-y: auto !important; max-height: 100vh !important; border-radius: 15px; } + + .el-dropdown-menu { + background: #fff; + border: 1px solid #e4e6ef; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + } + + .el-dropdown-menu__item { + font-size: 12px; + color: #3d4566; + padding: 8px 16px; + } + + .el-dropdown-menu__item:hover { + background: #f6f8fb; + color: #5778ff; + } }