From bdedc48aca39d4c1ced0941a5310904bc38efb86 Mon Sep 17 00:00:00 2001 From: Ran_Chen <1908198662@qq.com> Date: Wed, 2 Apr 2025 15:38:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90device=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=8C=E8=B0=83=E6=95=B4=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=EF=BC=8C=E4=BC=98=E5=8C=96Headerbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-web/src/apis/module/device.js | 54 +++++++++++++++++++ main/manager-web/src/apis/module/user.js | 52 ------------------ .../src/components/AddDeviceDialog.vue | 4 +- .../src/components/ChangePasswordDialog.vue | 9 ++-- main/manager-web/src/components/HeaderBar.vue | 5 -- main/manager-web/src/components/TtsModel.vue | 9 +++- main/manager-web/src/main.js | 1 + main/manager-web/src/utils/index.js | 9 ++-- .../src/views/DeviceManagement.vue | 45 ++++++++-------- 9 files changed, 99 insertions(+), 89 deletions(-) create mode 100644 main/manager-web/src/apis/module/device.js diff --git a/main/manager-web/src/apis/module/device.js b/main/manager-web/src/apis/module/device.js new file mode 100644 index 00000000..e8dc2c71 --- /dev/null +++ b/main/manager-web/src/apis/module/device.js @@ -0,0 +1,54 @@ +import RequestService from '../httpRequest' +import {getServiceUrl} from '../api' + +export default { + // 已绑设备 + getAgentBindDevices(agentId, callback) { + RequestService.sendRequest() + .url(`${getServiceUrl()}/api/v1/device/bind/${agentId}`) + .method('GET') + .success((res) => { + RequestService.clearRequestTime(); + callback(res); + }) + .fail((err) => { + console.error('获取设备列表失败:', err); + RequestService.reAjaxFun(() => { + this.getAgentBindDevices(agentId, callback); + }); + }).send(); + }, + // 解绑设备 + unbindDevice(device_id, callback) { + RequestService.sendRequest() + .url(`${getServiceUrl()}/api/v1/device/unbind`) + .method('POST') + .data({ deviceId: device_id }) + .success((res) => { + RequestService.clearRequestTime(); + callback(res); + }) + .fail((err) => { + console.error('解绑设备失败:', err); + RequestService.reAjaxFun(() => { + this.unbindDevice(device_id, callback); + }); + }).send(); + }, + // 绑定设备 + bindDevice(agentId, deviceCode, callback) { + RequestService.sendRequest() + .url(`${getServiceUrl()}/api/v1/device/bind/${agentId}/${deviceCode}`) + .method('POST') + .success((res) => { + RequestService.clearRequestTime(); + callback(res); + }) + .fail((err) => { + console.error('绑定设备失败:', err); + RequestService.reAjaxFun(() => { + this.bindDevice(agentId, deviceCode, callback); + }); + }).send(); + }, +} \ No newline at end of file diff --git a/main/manager-web/src/apis/module/user.js b/main/manager-web/src/apis/module/user.js index 8e7513fe..8464794c 100755 --- a/main/manager-web/src/apis/module/user.js +++ b/main/manager-web/src/apis/module/user.js @@ -21,7 +21,6 @@ export default { }, // 获取验证码 getCaptcha(uuid, callback) { - RequestService.sendRequest() .url(`${getServiceUrl()}/api/v1/user/captcha?uuid=${uuid}`) .method('GET') @@ -52,7 +51,6 @@ export default { .fail(() => { }).send() }, - // 保存设备配置 saveDeviceConfig(device_id, configData, callback) { RequestService.sendRequest() @@ -106,54 +104,4 @@ export default { }) .send(); }, - - // 已绑设备 - getAgentBindDevices(agentId, callback) { - RequestService.sendRequest() - .url(`${getServiceUrl()}/api/v1/user/agent/device/bind/${agentId}`) - .method('GET') - .success((res) => { - RequestService.clearRequestTime(); - callback(res); - }) - .fail((err) => { - console.error('获取设备列表失败:', err); - RequestService.reAjaxFun(() => { - this.getAgentBindDevices(agentId, callback); - }); - }).send(); - }, - // 解绑设备 - unbindDevice(device_id, callback) { - RequestService.sendRequest() - .url(`${getServiceUrl()}/api/v1/user/device/unbind/${device_id}`) - .method('PUT') - .success((res) => { - RequestService.clearRequestTime(); - callback(res); - }) - .fail((err) => { - console.error('解绑设备失败:', err); - RequestService.reAjaxFun(() => { - this.unbindDevice(device_id, callback); - }); - }).send(); - }, - // 绑定设备 - bindDevice(agentId, code, callback) { - RequestService.sendRequest() - .url(`${getServiceUrl()}/api/v1/user/agent/device/bind/${agentId}`) - .method('POST') - .data({ code }) - .success((res) => { - RequestService.clearRequestTime(); - callback(res); - }) - .fail((err) => { - console.error('绑定设备失败:', err); - RequestService.reAjaxFun(() => { - this.bindDevice(agentId, code, callback); - }); - }).send(); - }, } diff --git a/main/manager-web/src/components/AddDeviceDialog.vue b/main/manager-web/src/components/AddDeviceDialog.vue index 129ed156..a1ba5540 100644 --- a/main/manager-web/src/components/AddDeviceDialog.vue +++ b/main/manager-web/src/components/AddDeviceDialog.vue @@ -49,8 +49,8 @@ export default { return; } this.loading = true; - import('@/apis/module/user').then(({ default: userApi }) => { - userApi.bindDevice( + import('@/apis/module/device').then(({ default: deviceApi }) => { + deviceApi.bindDevice( this.agentId, this.deviceCode, ({data}) => { this.loading = false; diff --git a/main/manager-web/src/components/ChangePasswordDialog.vue b/main/manager-web/src/components/ChangePasswordDialog.vue index 5d1217ef..a0bb1f7d 100644 --- a/main/manager-web/src/components/ChangePasswordDialog.vue +++ b/main/manager-web/src/components/ChangePasswordDialog.vue @@ -1,9 +1,11 @@