From 03b51f73e7c446ff56a25c9d3a3b0e763ef56579 Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Tue, 16 Sep 2025 00:06:57 +0800 Subject: [PATCH 1/8] =?UTF-8?q?update:=E8=BF=9C=E7=A8=8B=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/McpToolCallDialog.vue | 884 ++++++++++++++++++ main/manager-web/src/i18n/en.js | 23 + main/manager-web/src/i18n/zh_CN.js | 23 + main/manager-web/src/i18n/zh_TW.js | 23 + .../src/views/DeviceManagement.vue | 177 ++-- main/manager-web/src/views/UserManagement.vue | 23 +- 6 files changed, 1059 insertions(+), 94 deletions(-) create mode 100644 main/manager-web/src/components/McpToolCallDialog.vue diff --git a/main/manager-web/src/components/McpToolCallDialog.vue b/main/manager-web/src/components/McpToolCallDialog.vue new file mode 100644 index 00000000..6c7b9a24 --- /dev/null +++ b/main/manager-web/src/components/McpToolCallDialog.vue @@ -0,0 +1,884 @@ + + + + + \ No newline at end of file diff --git a/main/manager-web/src/i18n/en.js b/main/manager-web/src/i18n/en.js index c030cc33..1e560dc3 100644 --- a/main/manager-web/src/i18n/en.js +++ b/main/manager-web/src/i18n/en.js @@ -8,6 +8,28 @@ export default { 'header.paramManagement': 'Params Management', 'header.dictManagement': 'Dict Management', + // McpToolCallDialog component text + 'mcpToolCall.title': 'Tool Call', + 'mcpToolCall.execute': 'Execute', + 'mcpToolCall.chooseFunction': '1、Choose Function', + 'mcpToolCall.searchFunction': 'Search Function', + 'mcpToolCall.noResults': 'No matching functions found', + 'mcpToolCall.settings': '2、Parameter Settings', + 'mcpToolCall.inputPlaceholder': 'Please enter {label}', + 'mcpToolCall.valueRange': 'Value range: {min} - {max}', + 'mcpToolCall.selectPlaceholder': 'Please select {label}', + 'mcpToolCall.lightTheme': 'Light Theme', + 'mcpToolCall.darkTheme': 'Dark Theme', + 'mcpToolCall.pleaseSelect': 'Please select a function', + 'mcpToolCall.cancel': 'Cancel', + 'mcpToolCall.requiredField': 'Please enter {field}', + 'mcpToolCall.minValue': 'Minimum value is {value}', + 'mcpToolCall.maxValue': 'Maximum value is {value}', + 'mcpToolCall.selectTool': 'Please select a tool to execute', + 'mcpToolCall.executionResult': '3、Execution Result', + 'mcpToolCall.copyResult': 'Copy Result', + 'mcpToolCall.noResultYet': 'No result yet', + // Dictionary data dialog related 'dictDataDialog.addDictData': 'Add Dictionary Data', 'dictDataDialog.dictLabel': 'Dictionary Label', @@ -288,6 +310,7 @@ export default { 'device.bindWithCode': 'Bind with Verification Code', 'device.manualAdd': 'Manual Add', 'device.unbind': 'Unbind', + 'device.toolCall': 'Tool Call', 'device.selectAtLeastOne': 'Please select at least one record', 'device.confirmBatchUnbind': 'Are you sure you want to unbind {count} selected devices?', 'device.batchUnbindSuccess': 'Successfully unbound {count} devices', diff --git a/main/manager-web/src/i18n/zh_CN.js b/main/manager-web/src/i18n/zh_CN.js index 946e977f..c8c267f4 100644 --- a/main/manager-web/src/i18n/zh_CN.js +++ b/main/manager-web/src/i18n/zh_CN.js @@ -8,6 +8,28 @@ export default { 'header.paramManagement': '参数管理', 'header.dictManagement': '字典管理', + // McpToolCallDialog组件文本 + 'mcpToolCall.title': '工具调用', + 'mcpToolCall.execute': '执行', + 'mcpToolCall.chooseFunction': '1、选择功能', + 'mcpToolCall.searchFunction': '搜索功能', + 'mcpToolCall.noResults': '未找到匹配的功能', + 'mcpToolCall.settings': '2、参数设置', + 'mcpToolCall.inputPlaceholder': '请输入{label}', + 'mcpToolCall.valueRange': '取值范围:{min} - {max}', + 'mcpToolCall.selectPlaceholder': '请选择{label}', + 'mcpToolCall.lightTheme': '浅色主题', + 'mcpToolCall.darkTheme': '深色主题', + 'mcpToolCall.pleaseSelect': '请选择一个功能', + 'mcpToolCall.cancel': '取消', + 'mcpToolCall.requiredField': '请输入{field}', + 'mcpToolCall.minValue': '最小值为{value}', + 'mcpToolCall.maxValue': '最大值为{value}', + 'mcpToolCall.selectTool': '请选择要执行的工具', + 'mcpToolCall.executionResult': '3、执行结果', + 'mcpToolCall.copyResult': '复制结果', + 'mcpToolCall.noResultYet': '暂无执行结果', + // 字典数据对话框相关 'dictDataDialog.addDictData': '新增字典数据', 'dictDataDialog.dictLabel': '字典标签', @@ -289,6 +311,7 @@ export default { 'device.bindWithCode': '扫码绑定', 'device.manualAdd': '手动添加', 'device.unbind': '解绑', + 'device.toolCall': '工具调用', 'device.selectAtLeastOne': '请至少选择一条记录', 'device.confirmBatchUnbind': '确认要解绑选中的 {count} 台设备吗?', 'device.batchUnbindSuccess': '成功解绑 {count} 台设备', diff --git a/main/manager-web/src/i18n/zh_TW.js b/main/manager-web/src/i18n/zh_TW.js index 51143d26..8f2c51a7 100644 --- a/main/manager-web/src/i18n/zh_TW.js +++ b/main/manager-web/src/i18n/zh_TW.js @@ -8,6 +8,28 @@ export default { 'header.paramManagement': '參數管理', 'header.dictManagement': '字典管理', + // McpToolCallDialog组件文本 + 'mcpToolCall.title': '工具調用', + 'mcpToolCall.execute': '執行', + 'mcpToolCall.chooseFunction': '1、選擇功能', + 'mcpToolCall.searchFunction': '搜索功能', + 'mcpToolCall.noResults': '未找到匹配的功能', + 'mcpToolCall.settings': '2、參數設置', + 'mcpToolCall.inputPlaceholder': '請輸入{label}', + 'mcpToolCall.valueRange': '取值範圍:{min} - {max}', + 'mcpToolCall.selectPlaceholder': '請選擇{label}', + 'mcpToolCall.lightTheme': '淺色主題', + 'mcpToolCall.darkTheme': '深色主題', + 'mcpToolCall.pleaseSelect': '請選擇一個功能', + 'mcpToolCall.cancel': '取消', + 'mcpToolCall.requiredField': '請輸入{field}', + 'mcpToolCall.minValue': '最小值為{value}', + 'mcpToolCall.maxValue': '最大值為{value}', + 'mcpToolCall.selectTool': '請選擇要執行的工具', + 'mcpToolCall.executionResult': '3、執行結果', + 'mcpToolCall.copyResult': '複製結果', + 'mcpToolCall.noResultYet': '暫無執行結果', + // 字典數據對話框相關 'dictDataDialog.addDictData': '新增字典數據', 'dictDataDialog.dictLabel': '字典標籤', @@ -288,6 +310,7 @@ export default { 'device.bindWithCode': '驗證碼綁定', 'device.manualAdd': '手動添加', 'device.unbind': '解綁', + 'device.toolCall': '工具調用', 'device.selectAtLeastOne': '請至少選擇一條記錄', 'device.confirmBatchUnbind': '確認要解綁選中的 {count} 台設備嗎?', 'device.batchUnbindSuccess': '成功解綁 {count} 台設備', diff --git a/main/manager-web/src/views/DeviceManagement.vue b/main/manager-web/src/views/DeviceManagement.vue index 65945eb8..c504e5ca 100644 --- a/main/manager-web/src/views/DeviceManagement.vue +++ b/main/manager-web/src/views/DeviceManagement.vue @@ -1,12 +1,12 @@ @@ -115,19 +119,23 @@ \ No newline at end of file + From 387398a069017efb22de664f313efd5550e7bd4b Mon Sep 17 00:00:00 2001 From: 3030332422 <3030332422@qq.com> Date: Thu, 18 Sep 2025 14:42:03 +0800 Subject: [PATCH 7/8] =?UTF-8?q?update:=E6=B7=BB=E5=8A=A0=E5=A4=9A=E8=AF=AD?= =?UTF-8?q?=E8=A8=80=E6=94=AF=E6=8C=81=E5=B9=B6=E5=A2=9E=E5=BC=BA=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/McpToolCallDialog.vue | 323 ++++++++++-------- main/manager-web/src/i18n/en.js | 109 ++++++ main/manager-web/src/i18n/zh_CN.js | 109 ++++++ main/manager-web/src/i18n/zh_TW.js | 109 ++++++ 4 files changed, 513 insertions(+), 137 deletions(-) diff --git a/main/manager-web/src/components/McpToolCallDialog.vue b/main/manager-web/src/components/McpToolCallDialog.vue index eb7ef85f..d271c3ff 100644 --- a/main/manager-web/src/components/McpToolCallDialog.vue +++ b/main/manager-web/src/components/McpToolCallDialog.vue @@ -30,7 +30,7 @@
-
正在获取工具列表...
+
{{ $t("mcpToolCall.loadingToolList") }}
@@ -160,15 +160,18 @@ - +
@@ -226,11 +229,20 @@ export default { }; }, created() { - // 在created钩子中初始化themeOptions,此时this.$t已经可用 - this.themeOptions = [ - { label: this.$t("mcpToolCall.lightTheme"), value: "light" }, - { label: this.$t("mcpToolCall.darkTheme"), value: "dark" }, - ]; + // 初始化主题选项 + this.initializeThemeOptions(); + + // 添加对语言变化的监听 + if (this.$eventBus) { + this.$eventBus.$on("languageChanged", this.initializeThemeOptions); + } + }, + + beforeDestroy() { + // 移除事件监听,避免内存泄漏 + if (this.$eventBus) { + this.$eventBus.$off("languageChanged", this.initializeThemeOptions); + } }, computed: { selectedTool() { @@ -242,7 +254,8 @@ export default { return this.toolList.filter( (tool) => tool.name.toLowerCase().includes(keyword) || - tool.description.toLowerCase().includes(keyword) + tool.description.toLowerCase().includes(keyword) || + this.getToolDisplayName(tool.name).toLowerCase().includes(keyword) ); }, formattedExecutionResult() { @@ -275,6 +288,17 @@ export default { }, }, methods: { + // 初始化主题选项 + initializeThemeOptions() { + this.themeOptions = [ + { label: this.$t("mcpToolCall.lightTheme"), value: "light" }, + { label: this.$t("mcpToolCall.darkTheme"), value: "dark" }, + ]; + this.$nextTick(() => { + this.$forceUpdate(); + }); + }, + // 添加handleThemeChange方法强制更新视图 handleThemeChange() { this.$nextTick(() => { @@ -305,8 +329,8 @@ export default { if (deviceData.audio_speaker) { if (deviceData.audio_speaker.volume !== undefined) { tableData.push({ - category: "音频扬声器", - property: "音量", + category: this.$t("mcpToolCall.table.audioSpeaker"), + property: this.$t("mcpToolCall.prop.volume"), value: deviceData.audio_speaker.volume + "%", }); } @@ -315,16 +339,19 @@ export default { if (deviceData.screen) { if (deviceData.screen.brightness !== undefined) { tableData.push({ - category: "屏幕", - property: "亮度", + category: this.$t("mcpToolCall.table.screen"), + property: this.$t("mcpToolCall.prop.brightness"), value: deviceData.screen.brightness + "%", }); } if (deviceData.screen.theme !== undefined) { tableData.push({ - category: "屏幕", - property: "主题", - value: deviceData.screen.theme === "dark" ? "深色" : "浅色", + category: this.$t("mcpToolCall.table.screen"), + property: this.$t("mcpToolCall.prop.theme"), + value: + deviceData.screen.theme === "dark" + ? this.$t("mcpToolCall.darkTheme") + : this.$t("mcpToolCall.lightTheme"), }); } } @@ -332,27 +359,27 @@ export default { if (deviceData.network) { if (deviceData.network.type !== undefined) { tableData.push({ - category: "网络", - property: "类型", + category: this.$t("mcpToolCall.table.network"), + property: this.$t("mcpToolCall.prop.type"), value: deviceData.network.type.toUpperCase(), }); } if (deviceData.network.ssid !== undefined) { tableData.push({ - category: "网络", - property: "SSID", + category: this.$t("mcpToolCall.table.network"), + property: this.$t("mcpToolCall.prop.ssid"), value: deviceData.network.ssid, }); } if (deviceData.network.signal !== undefined) { const signalMap = { - strong: "强", - medium: "中", - weak: "弱", + strong: this.$t("mcpToolCall.text.strong"), + medium: this.$t("mcpToolCall.text.medium"), + weak: this.$t("mcpToolCall.text.weak"), }; tableData.push({ - category: "网络", - property: "信号强度", + category: this.$t("mcpToolCall.table.network"), + property: this.$t("mcpToolCall.prop.signalStrength"), value: signalMap[deviceData.network.signal] || deviceData.network.signal, }); } @@ -367,27 +394,35 @@ export default { if (toolName === "self.audio_speaker.set_volume") { tableData.push({ - category: "音频控制", - property: "操作结果", - value: result.success ? "设置成功" : "设置失败", + category: this.$t("mcpToolCall.table.audioControl"), + property: this.$t("mcpToolCall.prop.operationResult"), + value: result.success + ? this.$t("mcpToolCall.text.setSuccess") + : this.$t("mcpToolCall.text.setFailed"), }); } else if (toolName === "self.screen.set_brightness") { tableData.push({ - category: "屏幕控制", - property: "操作结果", - value: result.success ? "亮度设置成功" : "亮度设置失败", + category: this.$t("mcpToolCall.table.screenControl"), + property: this.$t("mcpToolCall.prop.operationResult"), + value: result.success + ? this.$t("mcpToolCall.text.brightnessSetSuccess") + : this.$t("mcpToolCall.text.brightnessSetFailed"), }); } else if (toolName === "self.screen.set_theme") { tableData.push({ - category: "屏幕控制", - property: "操作结果", - value: result.success ? "主题设置成功" : "主题设置失败", + category: this.$t("mcpToolCall.table.screenControl"), + property: this.$t("mcpToolCall.prop.operationResult"), + value: result.success + ? this.$t("mcpToolCall.text.themeSetSuccess") + : this.$t("mcpToolCall.text.themeSetFailed"), }); } else if (toolName === "self.reboot") { tableData.push({ - category: "系统控制", - property: "操作结果", - value: result.success ? "重启指令已发送" : "重启失败", + category: this.$t("mcpToolCall.table.systemControl"), + property: this.$t("mcpToolCall.prop.operationResult"), + value: result.success + ? this.$t("mcpToolCall.text.rebootCommandSent") + : this.$t("mcpToolCall.text.rebootFailed"), }); } else if (toolName === "self.screen.get_info") { // 解析屏幕信息 @@ -402,38 +437,44 @@ export default { const screenInfo = JSON.parse(result.data.content[0].text); if (screenInfo.width !== undefined) { tableData.push({ - category: "屏幕信息", - property: "宽度", + category: this.$t("mcpToolCall.table.screenInfo"), + property: this.$t("mcpToolCall.prop.width"), value: screenInfo.width + "像素", }); } if (screenInfo.height !== undefined) { tableData.push({ - category: "屏幕信息", - property: "高度", + category: this.$t("mcpToolCall.table.screenInfo"), + property: this.$t("mcpToolCall.prop.height"), value: screenInfo.height + "像素", }); } if (screenInfo.monochrome !== undefined) { tableData.push({ - category: "屏幕信息", - property: "类型", - value: screenInfo.monochrome ? "单色屏" : "彩色屏", + category: this.$t("mcpToolCall.table.screenInfo"), + property: this.$t("mcpToolCall.prop.screenType"), + value: screenInfo.monochrome + ? this.$t("mcpToolCall.text.monochrome") + : this.$t("mcpToolCall.text.color"), }); } } catch (parseError) { // 解析失败时显示原始信息 tableData.push({ - category: "屏幕信息", - property: "获取结果", - value: result.success ? "获取成功,但解析失败" : "获取失败", + category: this.$t("mcpToolCall.table.screenInfo"), + property: this.$t("mcpToolCall.prop.getResult"), + value: result.success + ? this.$t("mcpToolCall.text.getSuccessParseFailed") + : this.$t("mcpToolCall.text.getFailed"), }); } } else { tableData.push({ - category: "屏幕信息", - property: "获取结果", - value: result.success ? "获取成功,但数据格式异常" : "获取失败", + category: this.$t("mcpToolCall.table.screenInfo"), + property: this.$t("mcpToolCall.prop.getResult"), + value: result.success + ? this.$t("mcpToolCall.text.getSuccessFormatError") + : this.$t("mcpToolCall.text.getFailed"), }); } } else if (toolName === "self.get_system_info") { @@ -451,8 +492,8 @@ export default { // 基本信息 if (systemInfo.chip_model_name) { tableData.push({ - category: "硬件信息", - property: "芯片型号", + category: this.$t("mcpToolCall.table.hardwareInfo"), + property: this.$t("mcpToolCall.prop.chipModel"), value: systemInfo.chip_model_name.toUpperCase(), }); } @@ -460,15 +501,15 @@ export default { if (systemInfo.chip_info) { if (systemInfo.chip_info.cores) { tableData.push({ - category: "硬件信息", - property: "CPU核心数", + category: this.$t("mcpToolCall.table.hardwareInfo"), + property: this.$t("mcpToolCall.prop.cpuCores"), value: systemInfo.chip_info.cores + "核", }); } if (systemInfo.chip_info.revision) { tableData.push({ - category: "硬件信息", - property: "芯片版本", + category: this.$t("mcpToolCall.table.hardwareInfo"), + property: this.$t("mcpToolCall.prop.chipVersion"), value: "Rev " + systemInfo.chip_info.revision, }); } @@ -476,8 +517,8 @@ export default { if (systemInfo.flash_size) { tableData.push({ - category: "硬件信息", - property: "Flash大小", + category: this.$t("mcpToolCall.table.hardwareInfo"), + property: this.$t("mcpToolCall.prop.flashSize"), value: (systemInfo.flash_size / 1024 / 1024).toFixed(0) + " MB", }); } @@ -485,8 +526,8 @@ export default { // 内存信息 if (systemInfo.minimum_free_heap_size) { tableData.push({ - category: "内存信息", - property: "最小可用堆", + category: this.$t("mcpToolCall.table.memoryInfo"), + property: this.$t("mcpToolCall.prop.minFreeHeap"), value: (parseInt(systemInfo.minimum_free_heap_size) / 1024).toFixed(0) + " KB", }); @@ -496,29 +537,29 @@ export default { if (systemInfo.application) { if (systemInfo.application.name) { tableData.push({ - category: "应用信息", - property: "应用名称", + category: this.$t("mcpToolCall.table.applicationInfo"), + property: this.$t("mcpToolCall.prop.applicationName"), value: systemInfo.application.name, }); } if (systemInfo.application.version) { tableData.push({ - category: "应用信息", - property: "应用版本", + category: this.$t("mcpToolCall.table.applicationInfo"), + property: this.$t("mcpToolCall.prop.applicationVersion"), value: systemInfo.application.version, }); } if (systemInfo.application.compile_time) { tableData.push({ - category: "应用信息", - property: "编译时间", + category: this.$t("mcpToolCall.table.applicationInfo"), + property: this.$t("mcpToolCall.prop.compileTime"), value: systemInfo.application.compile_time, }); } if (systemInfo.application.idf_version) { tableData.push({ - category: "应用信息", - property: "IDF版本", + category: this.$t("mcpToolCall.table.applicationInfo"), + property: this.$t("mcpToolCall.prop.idfVersion"), value: systemInfo.application.idf_version, }); } @@ -527,8 +568,8 @@ export default { // 网络信息 if (systemInfo.mac_address) { tableData.push({ - category: "网络信息", - property: "MAC地址", + category: this.$t("mcpToolCall.table.networkInfo"), + property: this.$t("mcpToolCall.prop.macAddress"), value: systemInfo.mac_address, }); } @@ -536,34 +577,36 @@ export default { if (systemInfo.board) { if (systemInfo.board.ip) { tableData.push({ - category: "网络信息", - property: "IP地址", + category: this.$t("mcpToolCall.table.networkInfo"), + property: this.$t("mcpToolCall.prop.ipAddress"), value: systemInfo.board.ip, }); } if (systemInfo.board.ssid) { tableData.push({ - category: "网络信息", - property: "WiFi名称", + category: this.$t("mcpToolCall.table.networkInfo"), + property: this.$t("mcpToolCall.prop.wifiName"), value: systemInfo.board.ssid, }); } if (systemInfo.board.rssi) { const signalStrength = systemInfo.board.rssi; - let signalLevel = "弱"; - if (signalStrength > -50) signalLevel = "强"; - else if (signalStrength > -70) signalLevel = "中"; + let signalLevel = this.$t("mcpToolCall.text.weak"); + if (signalStrength > -50) + signalLevel = this.$t("mcpToolCall.text.strong"); + else if (signalStrength > -70) + signalLevel = this.$t("mcpToolCall.text.medium"); tableData.push({ - category: "网络信息", - property: "信号强度", + category: this.$t("mcpToolCall.table.networkInfo"), + property: this.$t("mcpToolCall.prop.signalStrength"), value: `${signalStrength} dBm (${signalLevel})`, }); } if (systemInfo.board.channel) { tableData.push({ - category: "网络信息", - property: "WiFi信道", + category: this.$t("mcpToolCall.table.networkInfo"), + property: this.$t("mcpToolCall.prop.wifiChannel"), value: systemInfo.board.channel + "频道", }); } @@ -573,16 +616,18 @@ export default { if (systemInfo.display) { if (systemInfo.display.width && systemInfo.display.height) { tableData.push({ - category: "显示信息", - property: "屏幕尺寸", + category: this.$t("mcpToolCall.table.displayInfo"), + property: this.$t("mcpToolCall.prop.screenSize"), value: `${systemInfo.display.width} × ${systemInfo.display.height}`, }); } if (systemInfo.display.monochrome !== undefined) { tableData.push({ - category: "显示信息", - property: "屏幕类型", - value: systemInfo.display.monochrome ? "单色屏" : "彩色屏", + category: this.$t("mcpToolCall.table.displayInfo"), + property: this.$t("mcpToolCall.prop.screenType"), + value: systemInfo.display.monochrome + ? this.$t("mcpToolCall.text.monochrome") + : this.$t("mcpToolCall.text.color"), }); } } @@ -590,40 +635,44 @@ export default { // 其他信息 if (systemInfo.uuid) { tableData.push({ - category: "设备信息", - property: "设备UUID", + category: this.$t("mcpToolCall.table.deviceInfo"), + property: this.$t("mcpToolCall.prop.deviceUuid"), value: systemInfo.uuid, }); } if (systemInfo.language) { tableData.push({ - category: "设备信息", - property: "系统语言", + category: this.$t("mcpToolCall.table.deviceInfo"), + property: this.$t("mcpToolCall.prop.systemLanguage"), value: systemInfo.language, }); } if (systemInfo.ota && systemInfo.ota.label) { tableData.push({ - category: "系统信息", - property: "当前OTA分区", + category: this.$t("mcpToolCall.table.systemInfo"), + property: this.$t("mcpToolCall.prop.currentOtaPartition"), value: systemInfo.ota.label, }); } } catch (parseError) { // 解析失败时显示原始信息 tableData.push({ - category: "系统信息", - property: "获取结果", - value: result.success ? "获取成功,但解析失败" : "获取失败", + category: this.$t("mcpToolCall.table.systemInfo"), + property: this.$t("mcpToolCall.prop.getResult"), + value: result.success + ? this.$t("mcpToolCall.text.getSuccessParseFailed") + : this.$t("mcpToolCall.text.getFailed"), }); } } else { tableData.push({ - category: "系统信息", - property: "获取结果", - value: result.success ? "获取成功,但数据格式异常" : "获取失败", + category: this.$t("mcpToolCall.table.systemInfo"), + property: this.$t("mcpToolCall.prop.getResult"), + value: result.success + ? this.$t("mcpToolCall.text.getSuccessFormatError") + : this.$t("mcpToolCall.text.getFailed"), }); } } @@ -817,14 +866,14 @@ export default { }, formatPropertyLabel(key, property) { - // 将属性名转换为更友好的中文标签 + // 将属性名转换为更友好的标签 const labelMap = { - volume: "音量", - brightness: "亮度", - theme: "主题", - question: "问题", - url: "网址", - quality: "质量", + volume: this.$t("mcpToolCall.prop.volume"), + brightness: this.$t("mcpToolCall.prop.brightness"), + theme: this.$t("mcpToolCall.prop.theme"), + question: this.$t("mcpToolCall.prop.question"), + url: this.$t("mcpToolCall.prop.url"), + quality: this.$t("mcpToolCall.prop.quality"), }; return labelMap[key] || key; }, @@ -832,35 +881,36 @@ export default { // 获取工具的显示名称 getToolDisplayName(toolName) { const nameMap = { - "self.get_device_status": "查看设备状态", - "self.audio_speaker.set_volume": "设置音量", - "self.screen.set_brightness": "设置亮度", - "self.screen.set_theme": "设置主题", - "self.camera.take_photo": "拍照识别", - "self.get_system_info": "系统信息", - "self.reboot": "重启设备", - "self.upgrade_firmware": "升级固件", - "self.screen.get_info": "屏幕信息", - "self.screen.snapshot": "屏幕截图", - "self.screen.preview_image": "预览图片", - "self.assets.set_download_url": "设置下载地址", + "self.get_device_status": this.$t("mcpToolCall.toolName.getDeviceStatus"), + "self.audio_speaker.set_volume": this.$t("mcpToolCall.toolName.setVolume"), + "self.screen.set_brightness": this.$t("mcpToolCall.toolName.setBrightness"), + "self.screen.set_theme": this.$t("mcpToolCall.toolName.setTheme"), + "self.camera.take_photo": this.$t("mcpToolCall.toolName.takePhoto"), + "self.get_system_info": this.$t("mcpToolCall.toolName.getSystemInfo"), + "self.reboot": this.$t("mcpToolCall.toolName.reboot"), + "self.upgrade_firmware": this.$t("mcpToolCall.toolName.upgradeFirmware"), + "self.screen.get_info": this.$t("mcpToolCall.toolName.getScreenInfo"), + "self.screen.snapshot": this.$t("mcpToolCall.toolName.snapshot"), + "self.screen.preview_image": this.$t("mcpToolCall.toolName.previewImage"), + "self.assets.set_download_url": this.$t("mcpToolCall.toolName.setDownloadUrl"), }; return nameMap[toolName] || toolName; }, // 获取工具分类 getToolCategory(toolName) { - if (toolName.includes("audio_speaker")) return "音频"; - if (toolName.includes("screen")) return "显示"; - if (toolName.includes("camera")) return "拍摄"; + if (toolName.includes("audio_speaker")) + return this.$t("mcpToolCall.category.audio"); + if (toolName.includes("screen")) return this.$t("mcpToolCall.category.display"); + if (toolName.includes("camera")) return this.$t("mcpToolCall.category.camera"); if ( toolName.includes("system") || toolName.includes("reboot") || toolName.includes("upgrade") ) - return "系统"; - if (toolName.includes("assets")) return "资源"; - return "设备信息"; + return this.$t("mcpToolCall.category.system"); + if (toolName.includes("assets")) return this.$t("mcpToolCall.category.assets"); + return this.$t("mcpToolCall.category.deviceInfo"); }, // 获取简化的工具描述 @@ -872,19 +922,18 @@ export default { // 获取工具帮助文本 getToolHelpText(toolName) { const helpMap = { - "self.get_device_status": "查看设备的当前运行状态,包括音量、屏幕、电池等信息。", - "self.audio_speaker.set_volume": "调整设备的音量大小,请输入0-100之间的数值。", - "self.screen.set_brightness": "调整设备屏幕的亮度,请输入0-100之间的数值。", - "self.screen.set_theme": "切换设备屏幕的显示主题,可以选择浅色或深色模式。", - "self.camera.take_photo": - "使用设备摄像头拍摄照片并进行识别分析,请输入要询问的问题。", - "self.get_system_info": "获取设备的系统信息,包括硬件规格、软件版本等。", - "self.reboot": "重启设备,执行后设备将重新启动。", - "self.upgrade_firmware": "从指定URL下载并升级设备固件,升级后设备会自动重启。", - "self.screen.get_info": "获取屏幕的详细信息,如分辨率、尺寸等参数。", - "self.screen.snapshot": "对当前屏幕进行截图并上传到指定URL。", - "self.screen.preview_image": "在设备屏幕上预览指定URL的图片。", - "self.assets.set_download_url": "设置设备资源文件的下载地址。", + "self.get_device_status": this.$t("mcpToolCall.help.getDeviceStatus"), + "self.audio_speaker.set_volume": this.$t("mcpToolCall.help.setVolume"), + "self.screen.set_brightness": this.$t("mcpToolCall.help.setBrightness"), + "self.screen.set_theme": this.$t("mcpToolCall.help.setTheme"), + "self.camera.take_photo": this.$t("mcpToolCall.help.takePhoto"), + "self.get_system_info": this.$t("mcpToolCall.help.getSystemInfo"), + "self.reboot": this.$t("mcpToolCall.help.reboot"), + "self.upgrade_firmware": this.$t("mcpToolCall.help.upgradeFirmware"), + "self.screen.get_info": this.$t("mcpToolCall.help.getScreenInfo"), + "self.screen.snapshot": this.$t("mcpToolCall.help.snapshot"), + "self.screen.preview_image": this.$t("mcpToolCall.help.previewImage"), + "self.assets.set_download_url": this.$t("mcpToolCall.help.setDownloadUrl"), }; return helpMap[toolName] || ""; }, diff --git a/main/manager-web/src/i18n/en.js b/main/manager-web/src/i18n/en.js index b5d7b856..462f0ed1 100644 --- a/main/manager-web/src/i18n/en.js +++ b/main/manager-web/src/i18n/en.js @@ -29,6 +29,115 @@ export default { 'mcpToolCall.executionResult': '3、Execution Result', 'mcpToolCall.copyResult': 'Copy Result', 'mcpToolCall.noResultYet': 'No result yet', + 'mcpToolCall.loadingToolList': 'Loading tool list...', + + // Tool names + 'mcpToolCall.toolName.getDeviceStatus': 'View Device Status', + 'mcpToolCall.toolName.setVolume': 'Set Volume', + 'mcpToolCall.toolName.setBrightness': 'Set Brightness', + 'mcpToolCall.toolName.setTheme': 'Set Theme', + 'mcpToolCall.toolName.takePhoto': 'Take Photo & Recognize', + 'mcpToolCall.toolName.getSystemInfo': 'System Info', + 'mcpToolCall.toolName.reboot': 'Reboot Device', + 'mcpToolCall.toolName.upgradeFirmware': 'Upgrade Firmware', + 'mcpToolCall.toolName.getScreenInfo': 'Screen Info', + 'mcpToolCall.toolName.snapshot': 'Screen Snapshot', + 'mcpToolCall.toolName.previewImage': 'Preview Image', + 'mcpToolCall.toolName.setDownloadUrl': 'Set Download URL', + + // Tool categories + 'mcpToolCall.category.audio': 'Audio', + 'mcpToolCall.category.display': 'Display', + 'mcpToolCall.category.camera': 'Camera', + 'mcpToolCall.category.system': 'System', + 'mcpToolCall.category.assets': 'Assets', + 'mcpToolCall.category.deviceInfo': 'Device Info', + + // Table categories and properties + 'mcpToolCall.table.audioSpeaker': 'Audio Speaker', + 'mcpToolCall.table.screen': 'Screen', + 'mcpToolCall.table.network': 'Network', + 'mcpToolCall.table.audioControl': 'Audio Control', + 'mcpToolCall.table.screenControl': 'Screen Control', + 'mcpToolCall.table.systemControl': 'System Control', + 'mcpToolCall.table.screenInfo': 'Screen Info', + 'mcpToolCall.table.hardwareInfo': 'Hardware Info', + 'mcpToolCall.table.memoryInfo': 'Memory Info', + 'mcpToolCall.table.applicationInfo': 'Application Info', + 'mcpToolCall.table.networkInfo': 'Network Info', + 'mcpToolCall.table.displayInfo': 'Display Info', + 'mcpToolCall.table.deviceInfo': 'Device Info', + 'mcpToolCall.table.systemInfo': 'System Info', + // Table column headers + 'mcpToolCall.table.component': 'Component', + 'mcpToolCall.table.property': 'Property', + 'mcpToolCall.table.value': 'Value', + + 'mcpToolCall.prop.volume': 'Volume', + 'mcpToolCall.prop.brightness': 'Brightness', + 'mcpToolCall.prop.theme': 'Theme', + 'mcpToolCall.prop.type': 'Type', + 'mcpToolCall.prop.ssid': 'SSID', + 'mcpToolCall.prop.signalStrength': 'Signal Strength', + 'mcpToolCall.prop.operationResult': 'Operation Result', + 'mcpToolCall.prop.width': 'Width', + 'mcpToolCall.prop.height': 'Height', + 'mcpToolCall.prop.screenType': 'Type', + 'mcpToolCall.prop.chipModel': 'Chip Model', + 'mcpToolCall.prop.cpuCores': 'CPU Cores', + 'mcpToolCall.prop.chipVersion': 'Chip Version', + 'mcpToolCall.prop.flashSize': 'Flash Size', + 'mcpToolCall.prop.minFreeHeap': 'Minimum Free Heap', + 'mcpToolCall.prop.applicationName': 'Application Name', + 'mcpToolCall.prop.applicationVersion': 'Application Version', + 'mcpToolCall.prop.compileTime': 'Compile Time', + 'mcpToolCall.prop.idfVersion': 'IDF Version', + 'mcpToolCall.prop.macAddress': 'MAC Address', + 'mcpToolCall.prop.ipAddress': 'IP Address', + 'mcpToolCall.prop.wifiName': 'WiFi Name', + 'mcpToolCall.prop.wifiChannel': 'WiFi Channel', + 'mcpToolCall.prop.screenSize': 'Screen Size', + 'mcpToolCall.prop.deviceUuid': 'Device UUID', + 'mcpToolCall.prop.systemLanguage': 'System Language', + 'mcpToolCall.prop.currentOtaPartition': 'Current OTA Partition', + 'mcpToolCall.prop.getResult': 'Get Result', + 'mcpToolCall.prop.url': 'URL', + 'mcpToolCall.prop.quality': 'Quality', + 'mcpToolCall.prop.question': 'Question', + + // Tool help texts + 'mcpToolCall.help.getDeviceStatus': 'View the current running status of the device, including volume, screen, battery and other information.', + 'mcpToolCall.help.setVolume': 'Adjust the volume of the device, please enter a value between 0-100.', + 'mcpToolCall.help.setBrightness': 'Adjust the brightness of the device screen, please enter a value between 0-100.', + 'mcpToolCall.help.setTheme': 'Switch the display theme of the device screen, you can choose light or dark mode.', + 'mcpToolCall.help.takePhoto': 'Take photos with the device camera and perform recognition analysis, please enter the question you want to ask.', + 'mcpToolCall.help.getSystemInfo': 'Get the system information of the device, including hardware specifications, software version, etc.', + 'mcpToolCall.help.reboot': 'Reboot the device, the device will restart after execution.', + 'mcpToolCall.help.upgradeFirmware': 'Download and upgrade the device firmware from the specified URL, the device will restart automatically after the upgrade.', + 'mcpToolCall.help.getScreenInfo': 'Get detailed information about the screen, such as resolution, size and other parameters.', + 'mcpToolCall.help.snapshot': 'Take a screenshot of the current screen and upload it to the specified URL.', + 'mcpToolCall.help.previewImage': 'Preview images from the specified URL on the device screen.', + 'mcpToolCall.help.setDownloadUrl': 'Set the download address for device resource files.', + + // Other text + 'mcpToolCall.text.strong': 'Strong', + 'mcpToolCall.text.medium': 'Medium', + 'mcpToolCall.text.weak': 'Weak', + 'mcpToolCall.text.dark': 'Dark', + 'mcpToolCall.text.light': 'Light', + 'mcpToolCall.text.setSuccess': 'Setting successful', + 'mcpToolCall.text.setFailed': 'Setting failed', + 'mcpToolCall.text.brightnessSetSuccess': 'Brightness setting successful', + 'mcpToolCall.text.brightnessSetFailed': 'Brightness setting failed', + 'mcpToolCall.text.themeSetSuccess': 'Theme setting successful', + 'mcpToolCall.text.themeSetFailed': 'Theme setting failed', + 'mcpToolCall.text.rebootCommandSent': 'Reboot command sent', + 'mcpToolCall.text.rebootFailed': 'Reboot failed', + 'mcpToolCall.text.monochrome': 'Monochrome Screen', + 'mcpToolCall.text.color': 'Color Screen', + 'mcpToolCall.text.getSuccessParseFailed': 'Get successful, but parse failed', + 'mcpToolCall.text.getFailed': 'Get failed', + 'mcpToolCall.text.getSuccessFormatError': 'Get successful, but data format is abnormal', // Dictionary data dialog related 'dictDataDialog.addDictData': 'Add Dictionary Data', diff --git a/main/manager-web/src/i18n/zh_CN.js b/main/manager-web/src/i18n/zh_CN.js index 323e936e..332e8d43 100644 --- a/main/manager-web/src/i18n/zh_CN.js +++ b/main/manager-web/src/i18n/zh_CN.js @@ -29,6 +29,115 @@ export default { 'mcpToolCall.executionResult': '3、执行结果', 'mcpToolCall.copyResult': '复制结果', 'mcpToolCall.noResultYet': '暂无执行结果', + 'mcpToolCall.loadingToolList': '正在获取工具列表...', + + // 工具名称 + 'mcpToolCall.toolName.getDeviceStatus': '查看设备状态', + 'mcpToolCall.toolName.setVolume': '设置音量', + 'mcpToolCall.toolName.setBrightness': '设置亮度', + 'mcpToolCall.toolName.setTheme': '设置主题', + 'mcpToolCall.toolName.takePhoto': '拍照识别', + 'mcpToolCall.toolName.getSystemInfo': '系统信息', + 'mcpToolCall.toolName.reboot': '重启设备', + 'mcpToolCall.toolName.upgradeFirmware': '升级固件', + 'mcpToolCall.toolName.getScreenInfo': '屏幕信息', + 'mcpToolCall.toolName.snapshot': '屏幕截图', + 'mcpToolCall.toolName.previewImage': '预览图片', + 'mcpToolCall.toolName.setDownloadUrl': '设置下载地址', + + // 工具分类 + 'mcpToolCall.category.audio': '音频', + 'mcpToolCall.category.display': '显示', + 'mcpToolCall.category.camera': '拍摄', + 'mcpToolCall.category.system': '系统', + 'mcpToolCall.category.assets': '资源', + 'mcpToolCall.category.deviceInfo': '设备信息', + + // 表格分类和属性 + 'mcpToolCall.table.audioSpeaker': '音频扬声器', + 'mcpToolCall.table.screen': '屏幕', + 'mcpToolCall.table.network': '网络', + 'mcpToolCall.table.audioControl': '音频控制', + 'mcpToolCall.table.screenControl': '屏幕控制', + 'mcpToolCall.table.systemControl': '系统控制', + 'mcpToolCall.table.screenInfo': '屏幕信息', + 'mcpToolCall.table.hardwareInfo': '硬件信息', + 'mcpToolCall.table.memoryInfo': '内存信息', + 'mcpToolCall.table.applicationInfo': '应用信息', + 'mcpToolCall.table.networkInfo': '网络信息', + 'mcpToolCall.table.displayInfo': '显示信息', + 'mcpToolCall.table.deviceInfo': '设备信息', + 'mcpToolCall.table.systemInfo': '系统信息', + // 表格列标题 + 'mcpToolCall.table.component': '组件', + 'mcpToolCall.table.property': '属性', + 'mcpToolCall.table.value': '值', + + 'mcpToolCall.prop.volume': '音量', + 'mcpToolCall.prop.brightness': '亮度', + 'mcpToolCall.prop.theme': '主题', + 'mcpToolCall.prop.type': '类型', + 'mcpToolCall.prop.ssid': 'SSID', + 'mcpToolCall.prop.signalStrength': '信号强度', + 'mcpToolCall.prop.operationResult': '操作结果', + 'mcpToolCall.prop.width': '宽度', + 'mcpToolCall.prop.height': '高度', + 'mcpToolCall.prop.screenType': '类型', + 'mcpToolCall.prop.chipModel': '芯片型号', + 'mcpToolCall.prop.cpuCores': 'CPU核心数', + 'mcpToolCall.prop.chipVersion': '芯片版本', + 'mcpToolCall.prop.flashSize': 'Flash大小', + 'mcpToolCall.prop.minFreeHeap': '最小可用堆', + 'mcpToolCall.prop.applicationName': '应用名称', + 'mcpToolCall.prop.applicationVersion': '应用版本', + 'mcpToolCall.prop.compileTime': '编译时间', + 'mcpToolCall.prop.idfVersion': 'IDF版本', + 'mcpToolCall.prop.macAddress': 'MAC地址', + 'mcpToolCall.prop.ipAddress': 'IP地址', + 'mcpToolCall.prop.wifiName': 'WiFi名称', + 'mcpToolCall.prop.wifiChannel': 'WiFi信道', + 'mcpToolCall.prop.screenSize': '屏幕尺寸', + 'mcpToolCall.prop.deviceUuid': '设备UUID', + 'mcpToolCall.prop.systemLanguage': '系统语言', + 'mcpToolCall.prop.currentOtaPartition': '当前OTA分区', + 'mcpToolCall.prop.getResult': '获取结果', + 'mcpToolCall.prop.url': 'URL', + 'mcpToolCall.prop.quality': '质量', + 'mcpToolCall.prop.question': '问题', + + // 工具帮助文本 + 'mcpToolCall.help.getDeviceStatus': '查看设备的当前运行状态,包括音量、屏幕、电池等信息。', + 'mcpToolCall.help.setVolume': '调整设备的音量大小,请输入0-100之间的数值。', + 'mcpToolCall.help.setBrightness': '调整设备屏幕的亮度,请输入0-100之间的数值。', + 'mcpToolCall.help.setTheme': '切换设备屏幕的显示主题,可以选择浅色或深色模式。', + 'mcpToolCall.help.takePhoto': '使用设备摄像头拍摄照片并进行识别分析,请输入要询问的问题。', + 'mcpToolCall.help.getSystemInfo': '获取设备的系统信息,包括硬件规格、软件版本等。', + 'mcpToolCall.help.reboot': '重启设备,执行后设备将重新启动。', + 'mcpToolCall.help.upgradeFirmware': '从指定URL下载并升级设备固件,升级后设备会自动重启。', + 'mcpToolCall.help.getScreenInfo': '获取屏幕的详细信息,如分辨率、尺寸等参数。', + 'mcpToolCall.help.snapshot': '对当前屏幕进行截图并上传到指定URL。', + 'mcpToolCall.help.previewImage': '在设备屏幕上预览指定URL的图片。', + 'mcpToolCall.help.setDownloadUrl': '设置设备资源文件的下载地址。', + + // 其他文本 + 'mcpToolCall.text.strong': '强', + 'mcpToolCall.text.medium': '中', + 'mcpToolCall.text.weak': '弱', + 'mcpToolCall.text.dark': '深色', + 'mcpToolCall.text.light': '浅色', + 'mcpToolCall.text.setSuccess': '设置成功', + 'mcpToolCall.text.setFailed': '设置失败', + 'mcpToolCall.text.brightnessSetSuccess': '亮度设置成功', + 'mcpToolCall.text.brightnessSetFailed': '亮度设置失败', + 'mcpToolCall.text.themeSetSuccess': '主题设置成功', + 'mcpToolCall.text.themeSetFailed': '主题设置失败', + 'mcpToolCall.text.rebootCommandSent': '重启指令已发送', + 'mcpToolCall.text.rebootFailed': '重启失败', + 'mcpToolCall.text.monochrome': '单色屏', + 'mcpToolCall.text.color': '彩色屏', + 'mcpToolCall.text.getSuccessParseFailed': '获取成功,但解析失败', + 'mcpToolCall.text.getFailed': '获取失败', + 'mcpToolCall.text.getSuccessFormatError': '获取成功,但数据格式异常', // 字典数据对话框相关 'dictDataDialog.addDictData': '新增字典数据', diff --git a/main/manager-web/src/i18n/zh_TW.js b/main/manager-web/src/i18n/zh_TW.js index 3f921279..df766c05 100644 --- a/main/manager-web/src/i18n/zh_TW.js +++ b/main/manager-web/src/i18n/zh_TW.js @@ -29,6 +29,115 @@ export default { 'mcpToolCall.executionResult': '3、執行結果', 'mcpToolCall.copyResult': '複製結果', 'mcpToolCall.noResultYet': '暫無執行結果', + 'mcpToolCall.loadingToolList': '正在獲取工具列表...', + + // 工具名稱 + 'mcpToolCall.toolName.getDeviceStatus': '查看設備狀態', + 'mcpToolCall.toolName.setVolume': '設置音量', + 'mcpToolCall.toolName.setBrightness': '設置亮度', + 'mcpToolCall.toolName.setTheme': '設置主題', + 'mcpToolCall.toolName.takePhoto': '拍照識別', + 'mcpToolCall.toolName.getSystemInfo': '系統資訊', + 'mcpToolCall.toolName.reboot': '重啟設備', + 'mcpToolCall.toolName.upgradeFirmware': '升級固件', + 'mcpToolCall.toolName.getScreenInfo': '螢幕資訊', + 'mcpToolCall.toolName.snapshot': '螢幕截圖', + 'mcpToolCall.toolName.previewImage': '預覽圖片', + 'mcpToolCall.toolName.setDownloadUrl': '設置下載地址', + + // 工具分類 + 'mcpToolCall.category.audio': '音頻', + 'mcpToolCall.category.display': '顯示', + 'mcpToolCall.category.camera': '拍攝', + 'mcpToolCall.category.system': '系統', + 'mcpToolCall.category.assets': '資源', + 'mcpToolCall.category.deviceInfo': '設備資訊', + + // 表格分類和屬性 + 'mcpToolCall.table.audioSpeaker': '音頻揚聲器', + 'mcpToolCall.table.screen': '螢幕', + 'mcpToolCall.table.network': '網路', + 'mcpToolCall.table.audioControl': '音頻控制', + 'mcpToolCall.table.screenControl': '螢幕控制', + 'mcpToolCall.table.systemControl': '系統控制', + 'mcpToolCall.table.screenInfo': '螢幕資訊', + 'mcpToolCall.table.hardwareInfo': '硬體資訊', + 'mcpToolCall.table.memoryInfo': '記憶體資訊', + 'mcpToolCall.table.applicationInfo': '應用資訊', + 'mcpToolCall.table.networkInfo': '網路資訊', + 'mcpToolCall.table.displayInfo': '顯示資訊', + 'mcpToolCall.table.deviceInfo': '設備資訊', + 'mcpToolCall.table.systemInfo': '系統資訊', + // 表格列標題 + 'mcpToolCall.table.component': '組件', + 'mcpToolCall.table.property': '屬性', + 'mcpToolCall.table.value': '值', + + 'mcpToolCall.prop.volume': '音量', + 'mcpToolCall.prop.brightness': '亮度', + 'mcpToolCall.prop.theme': '主題', + 'mcpToolCall.prop.type': '類型', + 'mcpToolCall.prop.ssid': 'SSID', + 'mcpToolCall.prop.signalStrength': '信號強度', + 'mcpToolCall.prop.operationResult': '操作結果', + 'mcpToolCall.prop.width': '寬度', + 'mcpToolCall.prop.height': '高度', + 'mcpToolCall.prop.screenType': '類型', + 'mcpToolCall.prop.chipModel': '晶片型號', + 'mcpToolCall.prop.cpuCores': 'CPU核心數', + 'mcpToolCall.prop.chipVersion': '晶片版本', + 'mcpToolCall.prop.flashSize': 'Flash大小', + 'mcpToolCall.prop.minFreeHeap': '最小可用堆', + 'mcpToolCall.prop.applicationName': '應用名稱', + 'mcpToolCall.prop.applicationVersion': '應用版本', + 'mcpToolCall.prop.compileTime': '編譯時間', + 'mcpToolCall.prop.idfVersion': 'IDF版本', + 'mcpToolCall.prop.macAddress': 'MAC地址', + 'mcpToolCall.prop.ipAddress': 'IP地址', + 'mcpToolCall.prop.wifiName': 'WiFi名稱', + 'mcpToolCall.prop.wifiChannel': 'WiFi信道', + 'mcpToolCall.prop.screenSize': '螢幕尺寸', + 'mcpToolCall.prop.deviceUuid': '設備UUID', + 'mcpToolCall.prop.systemLanguage': '系統語言', + 'mcpToolCall.prop.currentOtaPartition': '當前OTA分區', + 'mcpToolCall.prop.getResult': '獲取結果', + 'mcpToolCall.prop.url': 'URL', + 'mcpToolCall.prop.quality': '品質', + 'mcpToolCall.prop.question': '問題', + + // 工具幫助文本 + 'mcpToolCall.help.getDeviceStatus': '查看設備的當前運行狀態,包括音量、螢幕、電池等資訊。', + 'mcpToolCall.help.setVolume': '調整設備的音量大小,請輸入0-100之間的數值。', + 'mcpToolCall.help.setBrightness': '調整設備螢幕的亮度,請輸入0-100之間的數值。', + 'mcpToolCall.help.setTheme': '切換設備螢幕的顯示主題,可以選擇淺色或深色模式。', + 'mcpToolCall.help.takePhoto': '使用設備攝像頭拍攝照片並進行識別分析,請輸入要詢問的問題。', + 'mcpToolCall.help.getSystemInfo': '獲取設備的系統資訊,包括硬體規格、軟體版本等。', + 'mcpToolCall.help.reboot': '重啟設備,執行後設備將重新啟動。', + 'mcpToolCall.help.upgradeFirmware': '從指定URL下載並升級設備固件,升級後設備會自動重啟。', + 'mcpToolCall.help.getScreenInfo': '獲取螢幕的詳細資訊,如解析度、尺寸等參數。', + 'mcpToolCall.help.snapshot': '對當前螢幕進行截圖並上傳到指定URL。', + 'mcpToolCall.help.previewImage': '在設備螢幕上預覽指定URL的圖片。', + 'mcpToolCall.help.setDownloadUrl': '設置設備資源文件的下載地址。', + + // 其他文本 + 'mcpToolCall.text.strong': '強', + 'mcpToolCall.text.medium': '中', + 'mcpToolCall.text.weak': '弱', + 'mcpToolCall.text.dark': '深色', + 'mcpToolCall.text.light': '淺色', + 'mcpToolCall.text.setSuccess': '設置成功', + 'mcpToolCall.text.setFailed': '設置失敗', + 'mcpToolCall.text.brightnessSetSuccess': '亮度設置成功', + 'mcpToolCall.text.brightnessSetFailed': '亮度設置失敗', + 'mcpToolCall.text.themeSetSuccess': '主題設置成功', + 'mcpToolCall.text.themeSetFailed': '主題設置失敗', + 'mcpToolCall.text.rebootCommandSent': '重啟指令已發送', + 'mcpToolCall.text.rebootFailed': '重啟失敗', + 'mcpToolCall.text.monochrome': '單色屏', + 'mcpToolCall.text.color': '彩色屏', + 'mcpToolCall.text.getSuccessParseFailed': '獲取成功,但解析失敗', + 'mcpToolCall.text.getFailed': '獲取失敗', + 'mcpToolCall.text.getSuccessFormatError': '獲取成功,但數據格式異常', // 字典數據對話框相關 'dictDataDialog.addDictData': '新增字典數據', From 58127cdfdc96f27ef39af8c9d71cc4c2c87759e8 Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Thu, 18 Sep 2025 19:08:24 +0800 Subject: [PATCH 8/8] =?UTF-8?q?update:=E4=BC=98=E5=8C=96=E6=9C=AA=E9=85=8D?= =?UTF-8?q?=E7=BD=AEmqtt=E7=BD=91=E5=85=B3=E6=97=B6=E7=9A=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/controller/DeviceController.java | 39 +++++++++++-------- .../{202509161609.sql => 202509161610.sql} | 2 +- .../db/changelog/db.changelog-master.yaml | 4 +- 3 files changed, 26 insertions(+), 19 deletions(-) rename main/manager-api/src/main/resources/db/changelog/{202509161609.sql => 202509161610.sql} (62%) diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java b/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java index cc4eb5a3..e476dc32 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/device/controller/DeviceController.java @@ -5,6 +5,10 @@ import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.BeanUtils; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -12,30 +16,26 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; -import lombok.AllArgsConstructor; import xiaozhi.common.exception.ErrorCode; import xiaozhi.common.redis.RedisKeys; import xiaozhi.common.redis.RedisUtils; import xiaozhi.common.user.UserDetail; import xiaozhi.common.utils.Result; +import xiaozhi.modules.device.dto.DeviceManualAddDTO; import xiaozhi.modules.device.dto.DeviceRegisterDTO; import xiaozhi.modules.device.dto.DeviceUnBindDTO; import xiaozhi.modules.device.dto.DeviceUpdateDTO; -import xiaozhi.modules.device.dto.DeviceManualAddDTO; import xiaozhi.modules.device.entity.DeviceEntity; import xiaozhi.modules.device.service.DeviceService; import xiaozhi.modules.security.user.SecurityUser; import xiaozhi.modules.sys.service.SysParamsService; -import org.springframework.web.client.RestTemplate; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import com.fasterxml.jackson.databind.ObjectMapper; @Tag(name = "设备管理") @RestController @@ -47,7 +47,8 @@ public class DeviceController { private final RestTemplate restTemplate; private final ObjectMapper objectMapper; - public DeviceController(DeviceService deviceService, RedisUtils redisUtils, SysParamsService sysParamsService, RestTemplate restTemplate, ObjectMapper objectMapper) { + public DeviceController(DeviceService deviceService, RedisUtils redisUtils, SysParamsService sysParamsService, + RestTemplate restTemplate, ObjectMapper objectMapper) { this.deviceService = deviceService; this.redisUtils = redisUtils; this.sysParamsService = sysParamsService; @@ -98,8 +99,8 @@ public class DeviceController { try { // 从系统参数中获取MQTT网关地址 String mqttGatewayUrl = sysParamsService.getValue("server.mqtt_manager_api", true); - if (StringUtils.isBlank(mqttGatewayUrl)) { - return new Result().error("MQTT网关地址未配置"); + if (StringUtils.isBlank(mqttGatewayUrl) || "null".equals(mqttGatewayUrl)) { + return new Result<>(); } // 获取当前用户的设备列表 @@ -152,7 +153,8 @@ public class DeviceController { private String generateBearerToken() { try { // 获取当前日期,格式为yyyy-MM-dd - String dateStr = java.time.LocalDate.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")); + String dateStr = java.time.LocalDate.now() + .format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 获取MQTT签名密钥 String signatureKey = sysParamsService.getValue("server.mqtt_signature_key", false); @@ -214,13 +216,17 @@ public class DeviceController { try { // 从系统参数中获取MQTT网关地址 String mqttGatewayUrl = sysParamsService.getValue("server.mqtt_manager_api", true); - if (StringUtils.isBlank(mqttGatewayUrl)) { + if (StringUtils.isBlank(mqttGatewayUrl) || "null".equals(mqttGatewayUrl)) { return new Result().error("MQTT网关地址未配置"); } // 构建完整的URL // 获取设备信息以构建mqttClientId DeviceEntity deviceById = deviceService.selectById(deviceId); + + if (!deviceById.getUserId().equals(SecurityUser.getUser().getId())) { + return new Result().error("设备不存在"); + } String macAddress = deviceById != null ? deviceById.getMacAddress() : "unknown"; String groupId = deviceById != null ? deviceById.getBoard() : null; if (groupId == null) { @@ -228,10 +234,10 @@ public class DeviceController { } groupId = groupId.replace(":", "_"); macAddress = macAddress.replace(":", "_"); - + // 拼接为groupId@@@macAddress@@@deviceId格式 String mqttClientId = groupId + "@@@" + macAddress + "@@@" + macAddress; - + String url = "http://" + mqttGatewayUrl + "/api/commands/" + mqttClientId; // 设置请求头 @@ -239,7 +245,8 @@ public class DeviceController { headers.set("Content-Type", "application/json"); // 生成Bearer令牌 - String dateStr = java.time.LocalDate.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")); + String dateStr = java.time.LocalDate.now() + .format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd")); String signatureKey = sysParamsService.getValue("server.mqtt_signature_key", false); if (StringUtils.isBlank(signatureKey)) { return new Result().error("MQTT签名密钥未配置"); diff --git a/main/manager-api/src/main/resources/db/changelog/202509161609.sql b/main/manager-api/src/main/resources/db/changelog/202509161610.sql similarity index 62% rename from main/manager-api/src/main/resources/db/changelog/202509161609.sql rename to main/manager-api/src/main/resources/db/changelog/202509161610.sql index 61270e26..df4b1fcb 100644 --- a/main/manager-api/src/main/resources/db/changelog/202509161609.sql +++ b/main/manager-api/src/main/resources/db/changelog/202509161610.sql @@ -1,3 +1,3 @@ delete from `sys_params` where param_code = 'server.mqtt_manager_api'; INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) -VALUES (119, 'server.mqtt_manager_api', null, 'string', 1, 'MQTT网关管理API的地址'); +VALUES (119, 'server.mqtt_manager_api', 'null', 'string', 1, 'MQTT网关管理API的地址'); diff --git a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml index 7ecb2f03..934f7314 100755 --- a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml @@ -346,12 +346,12 @@ databaseChangeLog: encoding: utf8 path: classpath:db/changelog/202509080922.sql - changeSet: - id: 202509161609 + id: 202509161610 author: fyb changes: - sqlFile: encoding: utf8 - path: classpath:db/changelog/202509161609.sql + path: classpath:db/changelog/202509161610.sql - changeSet: id: 202509161701 author: RanChen