From 745e046bf39c34c2e54ec3082c228c14f65598e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A5=A5=E7=91=9E?= <1131549607@qq.com> Date: Fri, 18 Jul 2025 17:26:18 +0800 Subject: [PATCH] 7.18zxr --- package.json | 4 + pnpm-lock.yaml | 242 ++++-- src/api/devicecontrol/officedevice.ts | 128 +++ src/api/devicecontrol/webSocketService.ts | 210 +++++ .../device-control/office/ALLleader.vue | 814 ++++++++++++++++++ .../device-control/office/Personaldevices.vue | 618 ++++++++++++- .../device-control/office/index.vue | 82 +- .../office/officehomedevice.vue | 569 ++++++++++++ src/pages-humanResource/absence/add.vue | 2 + src/pages.json | 10 +- src/types/uni-pages.d.ts | 2 + src/utils/socket.ts | 101 +++ 12 files changed, 2678 insertions(+), 104 deletions(-) create mode 100644 src/api/devicecontrol/officedevice.ts create mode 100644 src/api/devicecontrol/webSocketService.ts create mode 100644 src/pages-home/device-control/office/ALLleader.vue create mode 100644 src/pages-home/device-control/office/officehomedevice.vue create mode 100644 src/utils/socket.ts diff --git a/package.json b/package.json index 7d4d70a..fdcd29e 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ "@dcloudio/uni-mp-weixin": "3.0.0-4030620241128001", "@dcloudio/uni-mp-xhs": "3.0.0-4030620241128001", "@dcloudio/uni-quickapp-webview": "3.0.0-4030620241128001", + "@stomp/stompjs": "^7.1.1", "@tanstack/match-sorter-utils": "^8.19.4", "@tanstack/query-core": "^5.76.0", "@tanstack/vue-query": "^5.62.16", @@ -101,6 +102,9 @@ "pinia": "2.0.36", "pinia-plugin-persistedstate": "3.2.1", "qs": "6.5.3", + "sockjs": "^0.3.24", + "sockjs-client": "^1.6.1", + "stompjs": "^2.3.3", "tanstack": "^1.0.0", "tslib": "^2.8.1", "uni-parse-pages": "^0.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa6df3b..93d7dc2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,13 +31,13 @@ importers: version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-baidu': specifier: 3.0.0-4030620241128001 - version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) + version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(bufferutil@4.0.9)(postcss@8.4.49)(rollup@4.28.0)(utf-8-validate@5.0.10)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-jd': specifier: 3.0.0-4030620241128001 version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-kuaishou': specifier: 3.0.0-4030620241128001 - version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) + version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(bufferutil@4.0.9)(postcss@8.4.49)(rollup@4.28.0)(utf-8-validate@5.0.10)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-lark': specifier: 3.0.0-4030620241128001 version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) @@ -49,13 +49,16 @@ importers: version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-weixin': specifier: 3.0.0-4030620241128001 - version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) + version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(bufferutil@4.0.9)(postcss@8.4.49)(rollup@4.28.0)(utf-8-validate@5.0.10)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-xhs': specifier: 3.0.0-4030620241128001 version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-quickapp-webview': specifier: 3.0.0-4030620241128001 version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) + '@stomp/stompjs': + specifier: ^7.1.1 + version: 7.1.1 '@tanstack/match-sorter-utils': specifier: ^8.19.4 version: 8.19.4 @@ -131,6 +134,15 @@ importers: qs: specifier: 6.5.3 version: 6.5.3 + sockjs: + specifier: ^0.3.24 + version: 0.3.24 + sockjs-client: + specifier: ^1.6.1 + version: 1.6.1 + stompjs: + specifier: ^2.3.3 + version: 2.3.3 tanstack: specifier: ^1.0.0 version: 1.0.0 @@ -170,7 +182,7 @@ importers: version: 3.4.14 '@dcloudio/uni-automator': specifier: 3.0.0-4030620241128001 - version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(jest-environment-node@27.5.1)(jest@27.0.4)(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) + version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(bufferutil@4.0.9)(jest-environment-node@27.5.1)(jest@27.0.4(bufferutil@4.0.9)(utf-8-validate@5.0.10))(postcss@8.4.49)(rollup@4.28.0)(utf-8-validate@5.0.10)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-cli-shared': specifier: 3.0.0-4030620241128001 version: 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) @@ -225,15 +237,6 @@ importers: '@unocss/preset-legacy-compat': specifier: ^0.59.4 version: 0.59.4 - '@vue/devtools-api': - specifier: ^7.7.6 - version: 7.7.6 - '@vue/devtools-kit': - specifier: ^7.7.6 - version: 7.7.6 - '@vue/devtools-shared': - specifier: ^7.7.6 - version: 7.7.6 '@vue/runtime-core': specifier: ^3.4.21 version: 3.5.13 @@ -243,9 +246,6 @@ importers: autoprefixer: specifier: ^10.4.20 version: 10.4.20(postcss@8.4.49) - birpc: - specifier: ^2.3.0 - version: 2.3.0 commitlint: specifier: ^18.6.1 version: 18.6.1(@types/node@20.17.9)(typescript@5.7.2) @@ -273,18 +273,12 @@ importers: eslint-plugin-vue: specifier: ^9.32.0 version: 9.32.0(eslint@8.57.1) - hookable: - specifier: ^5.5.3 - version: 5.5.3 mockjs: specifier: ^1.1.0 version: 1.1.0 openapi-ts-request: specifier: ^1.1.2 version: 1.1.2(@types/node@20.17.9)(@vue/compiler-sfc@3.5.13)(chokidar@3.6.0)(typescript@5.7.2) - perfect-debounce: - specifier: ^1.0.0 - version: 1.0.0 postcss: specifier: ^8.4.49 version: 8.4.49 @@ -1252,12 +1246,14 @@ packages: engines: {node: '>=10'} cpu: [x64] os: [linux] + libc: [gnu] '@dcloudio/uts-linux-x64-musl@3.0.0-4030620241128001': resolution: {integrity: sha512-HbuOIYCe0KTzW42oqACQDmSuLWmiEG9zUE3rGpp5QP3MKpcB4wJ5BAOusCt3V02akyVv4/IGToktN8dc9N7+Eg==} engines: {node: '>=10'} cpu: [x64] os: [linux] + libc: [musl] '@dcloudio/uts-win32-ia32-msvc@3.0.0-4030620241128001': resolution: {integrity: sha512-pgITm85ya64iJ19mixTUOiYVAyCJQ+V66L5Ue/cmME6CA2dU9DjTtPEP6DdSnoyq9JWcdbQLyVEQkxxtBSOyGA==} @@ -1984,46 +1980,55 @@ packages: resolution: {integrity: sha512-WXveUPKtfqtaNvpf0iOb0M6xC64GzUX/OowbqfiCSXTdi/jLlOmH0Ba94/OkiY2yTGTwteo4/dsHRfh5bDCZ+w==} cpu: [arm] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.28.0': resolution: {integrity: sha512-yLc3O2NtOQR67lI79zsSc7lk31xjwcaocvdD1twL64PK1yNaIqCeWI9L5B4MFPAVGEVjH5k1oWSGuYX1Wutxpg==} cpu: [arm] os: [linux] + libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.28.0': resolution: {integrity: sha512-+P9G9hjEpHucHRXqesY+3X9hD2wh0iNnJXX/QhS/J5vTdG6VhNYMxJ2rJkQOxRUd17u5mbMLHM7yWGZdAASfcg==} cpu: [arm64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.28.0': resolution: {integrity: sha512-1xsm2rCKSTpKzi5/ypT5wfc+4bOGa/9yI/eaOLW0oMs7qpC542APWhl4A37AENGZ6St6GBMWhCCMM6tXgTIplw==} cpu: [arm64] os: [linux] + libc: [musl] '@rollup/rollup-linux-powerpc64le-gnu@4.28.0': resolution: {integrity: sha512-zgWxMq8neVQeXL+ouSf6S7DoNeo6EPgi1eeqHXVKQxqPy1B2NvTbaOUWPn/7CfMKL7xvhV0/+fq/Z/J69g1WAQ==} cpu: [ppc64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.28.0': resolution: {integrity: sha512-VEdVYacLniRxbRJLNtzwGt5vwS0ycYshofI7cWAfj7Vg5asqj+pt+Q6x4n+AONSZW/kVm+5nklde0qs2EUwU2g==} cpu: [riscv64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-s390x-gnu@4.28.0': resolution: {integrity: sha512-LQlP5t2hcDJh8HV8RELD9/xlYtEzJkm/aWGsauvdO2ulfl3QYRjqrKW+mGAIWP5kdNCBheqqqYIGElSRCaXfpw==} cpu: [s390x] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.28.0': resolution: {integrity: sha512-Nl4KIzteVEKE9BdAvYoTkW19pa7LR/RBrT6F1dJCV/3pbjwDcaOq+edkP0LXuJ9kflW/xOK414X78r+K84+msw==} cpu: [x64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-musl@4.28.0': resolution: {integrity: sha512-eKpJr4vBDOi4goT75MvW+0dXcNUqisK4jvibY9vDdlgLx+yekxSm55StsHbxUsRxSTt3JEQvlr3cGDkzcSP8bw==} cpu: [x64] os: [linux] + libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.28.0': resolution: {integrity: sha512-Vi+WR62xWGsE/Oj+mD0FNAPY2MEox3cfyG0zLpotZdehPFXwz6lypkGs5y38Jd/NVSbOD02aVad6q6QYF7i8Bg==} @@ -2095,6 +2100,9 @@ packages: '@sinonjs/fake-timers@8.1.0': resolution: {integrity: sha512-OAPJUAtgeINhh/TAlUID4QTs53Njm7xzddaVlEs/SXwgtiD1tW22zAB/W1wdqfrpmikgaWQ9Fw6Ws+hsiRm5Vg==} + '@stomp/stompjs@7.1.1': + resolution: {integrity: sha512-chcDs6YkAnKp1FqzwhGvh3i7v0+/ytzqWdKYw6XzINEKAzke/iD00dNgFPWSZEqktHOK+C1gSzXhLkLbARIaZw==} + '@szmarczak/http-timer@4.0.6': resolution: {integrity: sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==} engines: {node: '>=10'} @@ -2958,6 +2966,10 @@ packages: buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + bufferutil@4.0.9: + resolution: {integrity: sha512-WDtdLmJvAuNNPzByAYpRo2rF1Mmradw6gvWsQKf63476DDXmomT9zUiGypLcG4ibIM67vhAj8jJRdbmEws2Aqw==} + engines: {node: '>=6.14.2'} + builtin-modules@3.3.0: resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} engines: {node: '>=6'} @@ -3865,6 +3877,10 @@ packages: event-emitter@0.3.5: resolution: {integrity: sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==} + eventsource@2.0.2: + resolution: {integrity: sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==} + engines: {node: '>=12.0.0'} + execa@5.1.1: resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} engines: {node: '>=10'} @@ -3920,6 +3936,10 @@ packages: fastq@1.17.1: resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} + faye-websocket@0.11.4: + resolution: {integrity: sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g==} + engines: {node: '>=0.8.0'} + fb-watchman@2.0.2: resolution: {integrity: sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==} @@ -4280,6 +4300,9 @@ packages: resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==} engines: {node: '>= 0.8'} + http-parser-js@0.5.10: + resolution: {integrity: sha512-Pysuw9XpUq5dVc/2SMHpuTY01RFl8fttgcyunjL7eEMhGM3cI4eOmiCycJDVCo/7O7ClfQD3SaI6ftDzqOXYMA==} + http-proxy-agent@4.0.1: resolution: {integrity: sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==} engines: {node: '>= 6'} @@ -5231,6 +5254,10 @@ packages: encoding: optional: true + node-gyp-build@4.8.4: + resolution: {integrity: sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==} + hasBin: true + node-int64@0.4.0: resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==} @@ -6076,6 +6103,13 @@ packages: resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==} engines: {node: '>=10'} + sockjs-client@1.6.1: + resolution: {integrity: sha512-2g0tjOR+fRs0amxENLi/q5TiJTqY+WXFOzb5UwXndlK6TO3U/mirZznpx6w34HVMoc3g7cY24yC/ZMIYnDlfkw==} + engines: {node: '>=12'} + + sockjs@0.3.24: + resolution: {integrity: sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ==} + source-map-js@1.2.1: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} @@ -6146,6 +6180,9 @@ packages: std-env@3.8.0: resolution: {integrity: sha512-Bc3YwwCB+OzldMxOXJIIvC6cPRWr/LxOp48CdQTOkPyk/t4JWWJbrilwBd7RJzKV8QW7tJkcgAmeuLLJugl5/w==} + stompjs@2.3.3: + resolution: {integrity: sha512-5l/Ogz0DTFW7TrpHF0LAETGqM/so8UxNJvYZjJKqcX31EVprSQgnGkO80tZctPC/lFBDUrSFiTG3xd0R27XAIA==} + string-hash@1.1.3: resolution: {integrity: sha512-kJUvRUFK49aub+a7T1nNE66EJbZBMnBgoC1UbCZ5n6bsZKBRga4KgBRTMn/pFkeCZSYtNeSyMxPDM0AXWELk2A==} @@ -6631,6 +6668,10 @@ packages: url-parse@1.5.10: resolution: {integrity: sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==} + utf-8-validate@5.0.10: + resolution: {integrity: sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==} + engines: {node: '>=6.14.2'} + utif@2.0.1: resolution: {integrity: sha512-Z/S1fNKCicQTf375lIP9G8Sa1H/phcysstNrrSdZKj1f9g58J4NMgb5IgiEZN9/nLMPDwF0W7hdOe9Qq2IYoLg==} @@ -6641,6 +6682,10 @@ packages: resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==} engines: {node: '>= 0.4.0'} + uuid@8.3.2: + resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} + hasBin: true + v8-to-istanbul@8.1.1: resolution: {integrity: sha512-FGtKtv3xIpR6BYhvgH8MI/y78oT7d8Au3ww4QIxymrCtZEh5b8gCw2siywE+puhEmuWKDtmfrvF5UlB298ut3w==} engines: {node: '>=10.12.0'} @@ -6820,6 +6865,18 @@ packages: webpack-virtual-modules@0.6.2: resolution: {integrity: sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==} + websocket-driver@0.7.4: + resolution: {integrity: sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg==} + engines: {node: '>=0.8.0'} + + websocket-extensions@0.1.4: + resolution: {integrity: sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==} + engines: {node: '>=0.8.0'} + + websocket@1.0.35: + resolution: {integrity: sha512-/REy6amwPZl44DDzvRCkaI1q1bIiQB0mEFQLUrhz3z2EK91cp3n72rAjUlrTP0zV22HJIUOVHQGPxhFRjxjt+Q==} + engines: {node: '>=4.0.0'} + whatwg-encoding@1.0.5: resolution: {integrity: sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==} @@ -6952,6 +7009,11 @@ packages: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} + yaeti@0.0.6: + resolution: {integrity: sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug==} + engines: {node: '>=0.10.32'} + deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. + yallist@3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} @@ -8122,7 +8184,7 @@ snapshots: - ts-node - vue - '@dcloudio/uni-automator@3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(jest-environment-node@27.5.1)(jest@27.0.4)(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2))': + '@dcloudio/uni-automator@3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(bufferutil@4.0.9)(jest-environment-node@27.5.1)(jest@27.0.4(bufferutil@4.0.9)(utf-8-validate@5.0.10))(postcss@8.4.49)(rollup@4.28.0)(utf-8-validate@5.0.10)(vue@3.4.21(typescript@5.7.2))': dependencies: '@dcloudio/uni-cli-shared': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) address: 1.2.2 @@ -8130,14 +8192,14 @@ snapshots: debug: 4.3.7 default-gateway: 6.0.3 fs-extra: 10.1.0 - jest: 27.0.4 + jest: 27.0.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) jest-environment-node: 27.5.1 jsonc-parser: 3.3.1 licia: 1.46.0 merge: 2.1.1 qrcode-reader: 1.0.4 qrcode-terminal: 0.12.0 - ws: 8.18.0 + ws: 8.18.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) transitivePeerDependencies: - '@nuxt/kit' - '@vueuse/core' @@ -8308,13 +8370,13 @@ snapshots: - ts-node - vue - '@dcloudio/uni-mp-baidu@3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2))': + '@dcloudio/uni-mp-baidu@3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(bufferutil@4.0.9)(postcss@8.4.49)(rollup@4.28.0)(utf-8-validate@5.0.10)(vue@3.4.21(typescript@5.7.2))': dependencies: '@dcloudio/uni-cli-shared': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-compiler': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-vite': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-vue': 3.0.0-4030620241128001 - '@dcloudio/uni-mp-weixin': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) + '@dcloudio/uni-mp-weixin': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(bufferutil@4.0.9)(postcss@8.4.49)(rollup@4.28.0)(utf-8-validate@5.0.10)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-shared': 3.0.0-4030620241128001 '@vue/compiler-core': 3.4.21 '@vue/shared': 3.4.21 @@ -8322,7 +8384,7 @@ snapshots: licia: 1.46.0 qrcode-reader: 1.0.4 qrcode-terminal: 0.12.0 - ws: 8.18.0 + ws: 8.18.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) transitivePeerDependencies: - '@nuxt/kit' - '@vueuse/core' @@ -8372,13 +8434,13 @@ snapshots: - ts-node - vue - '@dcloudio/uni-mp-kuaishou@3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2))': + '@dcloudio/uni-mp-kuaishou@3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(bufferutil@4.0.9)(postcss@8.4.49)(rollup@4.28.0)(utf-8-validate@5.0.10)(vue@3.4.21(typescript@5.7.2))': dependencies: '@dcloudio/uni-cli-shared': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-compiler': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-vite': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-vue': 3.0.0-4030620241128001 - '@dcloudio/uni-mp-weixin': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) + '@dcloudio/uni-mp-weixin': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(bufferutil@4.0.9)(postcss@8.4.49)(rollup@4.28.0)(utf-8-validate@5.0.10)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-shared': 3.0.0-4030620241128001 '@vue/compiler-core': 3.4.21 '@vue/shared': 3.4.21 @@ -8473,7 +8535,7 @@ snapshots: '@dcloudio/uni-shared': 3.0.0-4030620241128001 '@vue/shared': 3.4.21 - '@dcloudio/uni-mp-weixin@3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2))': + '@dcloudio/uni-mp-weixin@3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(bufferutil@4.0.9)(postcss@8.4.49)(rollup@4.28.0)(utf-8-validate@5.0.10)(vue@3.4.21(typescript@5.7.2))': dependencies: '@dcloudio/uni-cli-shared': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) '@dcloudio/uni-mp-vite': 3.0.0-4030620241128001(@vueuse/core@11.3.0(vue@3.4.21(typescript@5.7.2)))(postcss@8.4.49)(rollup@4.28.0)(vue@3.4.21(typescript@5.7.2)) @@ -8484,7 +8546,7 @@ snapshots: licia: 1.46.0 qrcode-reader: 1.0.4 qrcode-terminal: 0.12.0 - ws: 8.18.0 + ws: 8.18.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) transitivePeerDependencies: - '@nuxt/kit' - '@vueuse/core' @@ -8943,7 +9005,7 @@ snapshots: jest-util: 27.5.1 slash: 3.0.0 - '@jest/core@27.5.1': + '@jest/core@27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10)': dependencies: '@jest/console': 27.5.1 '@jest/reporters': 27.5.1 @@ -8957,13 +9019,13 @@ snapshots: exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 27.5.1 - jest-config: 27.5.1 + jest-config: 27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) jest-haste-map: 27.5.1 jest-message-util: 27.5.1 jest-regex-util: 27.5.1 jest-resolve: 27.5.1 jest-resolve-dependencies: 27.5.1 - jest-runner: 27.5.1 + jest-runner: 27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) jest-runtime: 27.5.1 jest-snapshot: 27.5.1 jest-util: 27.5.1 @@ -9551,6 +9613,8 @@ snapshots: dependencies: '@sinonjs/commons': 1.8.6 + '@stomp/stompjs@7.1.1': {} + '@szmarczak/http-timer@4.0.6': dependencies: defer-to-connect: 2.0.1 @@ -10696,6 +10760,11 @@ snapshots: base64-js: 1.5.1 ieee754: 1.2.1 + bufferutil@4.0.9: + dependencies: + node-gyp-build: 4.8.4 + optional: true + builtin-modules@3.3.0: {} builtins@5.1.0: @@ -11733,6 +11802,8 @@ snapshots: d: 1.0.2 es5-ext: 0.10.64 + eventsource@2.0.2: {} + execa@5.1.1: dependencies: cross-spawn: 7.0.6 @@ -11834,6 +11905,10 @@ snapshots: dependencies: reusify: 1.0.4 + faye-websocket@0.11.4: + dependencies: + websocket-driver: 0.7.4 + fb-watchman@2.0.2: dependencies: bser: 2.1.1 @@ -12251,6 +12326,8 @@ snapshots: statuses: 2.0.1 toidentifier: 1.0.1 + http-parser-js@0.5.10: {} + http-proxy-agent@4.0.1: dependencies: '@tootallnate/once': 1.1.2 @@ -12557,16 +12634,16 @@ snapshots: transitivePeerDependencies: - supports-color - jest-cli@27.5.1: + jest-cli@27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10): dependencies: - '@jest/core': 27.5.1 + '@jest/core': 27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 import-local: 3.2.0 - jest-config: 27.5.1 + jest-config: 27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) jest-util: 27.5.1 jest-validate: 27.5.1 prompts: 2.4.2 @@ -12578,7 +12655,7 @@ snapshots: - ts-node - utf-8-validate - jest-config@27.5.1: + jest-config@27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10): dependencies: '@babel/core': 7.26.0 '@jest/test-sequencer': 27.5.1 @@ -12590,13 +12667,13 @@ snapshots: glob: 7.2.3 graceful-fs: 4.2.11 jest-circus: 27.5.1 - jest-environment-jsdom: 27.5.1 + jest-environment-jsdom: 27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) jest-environment-node: 27.5.1 jest-get-type: 27.5.1 jest-jasmine2: 27.5.1 jest-regex-util: 27.5.1 jest-resolve: 27.5.1 - jest-runner: 27.5.1 + jest-runner: 27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) jest-util: 27.5.1 jest-validate: 27.5.1 micromatch: 4.0.8 @@ -12629,7 +12706,7 @@ snapshots: jest-util: 27.5.1 pretty-format: 27.5.1 - jest-environment-jsdom@27.5.1: + jest-environment-jsdom@27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10): dependencies: '@jest/environment': 27.5.1 '@jest/fake-timers': 27.5.1 @@ -12637,7 +12714,7 @@ snapshots: '@types/node': 20.17.9 jest-mock: 27.5.1 jest-util: 27.5.1 - jsdom: 16.7.0 + jsdom: 16.7.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) transitivePeerDependencies: - bufferutil - canvas @@ -12750,7 +12827,7 @@ snapshots: resolve.exports: 1.1.1 slash: 3.0.0 - jest-runner@27.5.1: + jest-runner@27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10): dependencies: '@jest/console': 27.5.1 '@jest/environment': 27.5.1 @@ -12762,7 +12839,7 @@ snapshots: emittery: 0.8.1 graceful-fs: 4.2.11 jest-docblock: 27.5.1 - jest-environment-jsdom: 27.5.1 + jest-environment-jsdom: 27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) jest-environment-node: 27.5.1 jest-haste-map: 27.5.1 jest-leak-detector: 27.5.1 @@ -12872,11 +12949,11 @@ snapshots: merge-stream: 2.0.0 supports-color: 8.1.1 - jest@27.0.4: + jest@27.0.4(bufferutil@4.0.9)(utf-8-validate@5.0.10): dependencies: - '@jest/core': 27.5.1 + '@jest/core': 27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) import-local: 3.2.0 - jest-cli: 27.5.1 + jest-cli: 27.5.1(bufferutil@4.0.9)(utf-8-validate@5.0.10) transitivePeerDependencies: - bufferutil - canvas @@ -12916,7 +12993,7 @@ snapshots: dependencies: argparse: 2.0.1 - jsdom@16.7.0: + jsdom@16.7.0(bufferutil@4.0.9)(utf-8-validate@5.0.10): dependencies: abab: 2.0.6 acorn: 8.14.0 @@ -12943,7 +13020,7 @@ snapshots: whatwg-encoding: 1.0.5 whatwg-mimetype: 2.3.0 whatwg-url: 8.7.0 - ws: 7.5.10 + ws: 7.5.10(bufferutil@4.0.9)(utf-8-validate@5.0.10) xml-name-validator: 3.0.0 transitivePeerDependencies: - bufferutil @@ -13343,6 +13420,9 @@ snapshots: dependencies: whatwg-url: 5.0.0 + node-gyp-build@4.8.4: + optional: true + node-int64@0.4.0: {} node-readfiles@0.2.0: @@ -14264,6 +14344,22 @@ snapshots: astral-regex: 2.0.0 is-fullwidth-code-point: 3.0.0 + sockjs-client@1.6.1: + dependencies: + debug: 3.2.7 + eventsource: 2.0.2 + faye-websocket: 0.11.4 + inherits: 2.0.4 + url-parse: 1.5.10 + transitivePeerDependencies: + - supports-color + + sockjs@0.3.24: + dependencies: + faye-websocket: 0.11.4 + uuid: 8.3.2 + websocket-driver: 0.7.4 + source-map-js@1.2.1: {} source-map-support@0.5.21: @@ -14334,6 +14430,12 @@ snapshots: std-env@3.8.0: {} + stompjs@2.3.3: + optionalDependencies: + websocket: 1.0.35 + transitivePeerDependencies: + - supports-color + string-hash@1.1.3: {} string-length@4.0.2: @@ -14921,6 +15023,11 @@ snapshots: querystringify: 2.2.0 requires-port: 1.0.0 + utf-8-validate@5.0.10: + dependencies: + node-gyp-build: 4.8.4 + optional: true + utif@2.0.1: dependencies: pako: 1.0.11 @@ -14929,6 +15036,8 @@ snapshots: utils-merge@1.0.1: {} + uuid@8.3.2: {} + v8-to-istanbul@8.1.1: dependencies: '@types/istanbul-lib-coverage': 2.0.6 @@ -15130,6 +15239,26 @@ snapshots: webpack-virtual-modules@0.6.2: {} + websocket-driver@0.7.4: + dependencies: + http-parser-js: 0.5.10 + safe-buffer: 5.2.1 + websocket-extensions: 0.1.4 + + websocket-extensions@0.1.4: {} + + websocket@1.0.35: + dependencies: + bufferutil: 4.0.9 + debug: 2.6.9 + es5-ext: 0.10.64 + typedarray-to-buffer: 3.1.5 + utf-8-validate: 5.0.10 + yaeti: 0.0.6 + transitivePeerDependencies: + - supports-color + optional: true + whatwg-encoding@1.0.5: dependencies: iconv-lite: 0.4.24 @@ -15228,9 +15357,15 @@ snapshots: imurmurhash: 0.1.4 signal-exit: 4.1.0 - ws@7.5.10: {} + ws@7.5.10(bufferutil@4.0.9)(utf-8-validate@5.0.10): + optionalDependencies: + bufferutil: 4.0.9 + utf-8-validate: 5.0.10 - ws@8.18.0: {} + ws@8.18.0(bufferutil@4.0.9)(utf-8-validate@5.0.10): + optionalDependencies: + bufferutil: 4.0.9 + utf-8-validate: 5.0.10 xhr@2.6.0: dependencies: @@ -15262,6 +15397,9 @@ snapshots: y18n@5.0.8: {} + yaeti@0.0.6: + optional: true + yallist@3.1.1: {} yallist@4.0.0: {} diff --git a/src/api/devicecontrol/officedevice.ts b/src/api/devicecontrol/officedevice.ts new file mode 100644 index 0000000..bdddc25 --- /dev/null +++ b/src/api/devicecontrol/officedevice.ts @@ -0,0 +1,128 @@ +import { http } from '@/utils/http'; +// const mqtturl='https://szcx.zyyt.sinopec.com/mqttprod';//发布发布!!!!!,张祥瑞 +const mqtturl = 'http://10.75.15.246:8899/mqttprod';//测试使用,张祥瑞 + +export function gethomelist(config : object) { // 获取房间信息 + return http({ + url: '/RoomOperation/RoomOperation/gethomelist', + method: 'GET', + data: config + }) +} + +export function testcontiont(config : object) { // 获取房间信息 + return http({ + url: mqtturl + '/mqttSubclient/mqttSubclient/testgetcontint', + method: 'GET', + data: config + }) +} + +export function contiontmqtt(config : object) { // 链接mqtt + return http({ + url: mqtturl + '/mqtt/mqtttest/getMqttPushClient', + method: 'GET', + data: config + }) +} + + +export function treeRootList(config : object) { // 查询部门树节点 + return http({ + url: '/sysdepartwlwcode/sysDepartWlwCode/rootList', + method: 'GET', + data: config + }) +} + + +export function selectfjkzbmforfjid(config : object) { // 查询部门树节点 + return http({ + url: '/RoomOperation/RoomOperation/selectfjkzbmforfjid', + method: 'GET', + data: config + }) +} + +export function createdSwitch(config : object) { // 查询开关状态 + return http({ + url: mqtturl + + "/mqttSubclientCreateSwitch/mqttSubclientCreateSwitch/createdSwitch", + method: 'GET', + data: config + }) +} + +export function getMqttPushClient(config : object) { // 查询开关状态 + return http({ + url: mqtturl + '/mqtt/mqtttest/getMqttPushClient', + method: 'GET', + data: config + }) +} + +export function treeChildList(config : object) { // 查询开关状态 + return http({ + url: '/sysdepartwlwcode/sysDepartWlwCode/childList', + method: 'GET', + data: config + }) +} + + +export function listAllRegions(config : object) { // 查询开关状态 + return http({ + url: '/sysdepartwlwcode/sysDepartWlwCode/getWlwTree', + method: 'GET', + data: config + }) +} + +export function Selecthomelist(config : object) { // 查询开关状态 + return http({ + url: '/RoomOperation/RoomOperation/Selecthomelist', + method: 'GET', + data: config + }) +} + +export function getsblb(config : object) { // 查询开关状态 + return http({ + url: '/RoomOperation/RoomOperation/getsblb', + method: 'GET', + data: config + }) +} + +export function subscribeByOneTopic(config : object) { // 查询开关状态 + return http({ + url: mqtturl +'/mqttSubclient/mqttSubclient/subscribeByOneTopic', + method: 'GET', + data: config + }) +} + +export function pushMqttsubscribeForYKQ(config : object) { // 查询开关状态 + return http({ + url: mqtturl +'/mqttpush/mqtttestpush/pushMqttsubscribeForYKQ', + method: 'GET', + data: config + }) +} +export function pushMqttsubscribeforSendInfo(config : object) { // 查询开关状态 + return http({ + url: mqtturl +'/mqttpush/mqtttestpush/pushMqttsubscribeforSendInfo', + method: 'GET', + data: config + }) +} +export function pushMqttsubscribe(config : object) { // 查询开关状态 + return http({ + url: mqtturl +'/mqttpush/mqtttestpush/pushMqttsubscribe', + method: 'GET', + data: config + }) +} +//--------------------------------------个人查询页面 end----------------------------------------------------------- + +//**---------------------------------所有部门查询----------------------------------------------------/ \ No newline at end of file diff --git a/src/api/devicecontrol/webSocketService.ts b/src/api/devicecontrol/webSocketService.ts new file mode 100644 index 0000000..d66092e --- /dev/null +++ b/src/api/devicecontrol/webSocketService.ts @@ -0,0 +1,210 @@ +// utils/webSocketService.ts +import { ref, Ref, onUnmounted } from 'vue' +import { Uni } from '@dcloudio/uni-app' + +// 消息订阅回调函数类型 +type MessageCallback = (message: string) => void + +// WebSocket服务接口 +interface WebSocketService { + connected: Ref + connectionStatus: Ref + messages: Ref + connectWebSocket: (url: string, destination: string) => void + disconnectWebSocket: () => void + subscribe: (callback: MessageCallback) => () => void + sendMessage: (destination: string, content: string) => void +} + +// 存储单例WebSocket服务 +let webSocketServiceInstance: WebSocketService | null = null + +/** + * 创建或获取全局WebSocket服务实例 + */ +export default function useWebSocketService(): WebSocketService { + // 如果实例已存在,直接返回 + if (webSocketServiceInstance) { + return webSocketServiceInstance + } + + // WebSocket状态 + const connected = ref(false) + const connectionStatus = ref('未连接') + const messages = ref([]) + let socketTask: UniApp.SocketTask | null = null + let subscribers: MessageCallback[] = [] // 存储消息订阅者 + + // STOMP帧构建器 + const buildStompFrame = (command: string, headers: Record = {}, body: string = '') => { + let frame = `${command}\n` + for (const [key, value] of Object.entries(headers)) { + frame += `${key}:${value}\n` + } + frame += `\n${body}` + return frame + '\x00' + } + + // 连接WebSocket + const connectWebSocket = (url: string, destination: string) => { + if (connected.value) return + + connectionStatus.value = '连接中...' + + if (socketTask) { + socketTask.close({}) + socketTask = null + } + + socketTask = uni.connectSocket({ + url: url, + protocols: ['v12.stomp', 'v11.stomp'], + success: () => { + console.log('开始连接WebSocket') + }, + fail: (err) => { + console.error('连接失败:', err) + connectionStatus.value = '连接失败' + } + }) + + // 只注册一次全局事件监听器 + socketTask.onOpen((res) => { + console.log('WebSocket连接已打开', res) + connected.value = true + connectionStatus.value = '连接中...' + + // 发送STOMP CONNECT帧 + const connectFrame = buildStompFrame('CONNECT', { + 'accept-version': '1.2', + 'heart-beat': '10000,10000' + }) + + socketTask?.send({ + data: connectFrame + }) + }) + + // 监听消息 + socketTask.onMessage((res) => { + const data = res.data as string + const [commandLine, ...headerLines] = data.split('\n') + const emptyLineIndex = headerLines.findIndex(line => line === '') + const headers: Record = {} + + for (let i = 0; i < emptyLineIndex; i++) { + const [key, value] = headerLines[i].split(':') + headers[key] = value + } + + const body = headerLines.slice(emptyLineIndex + 1).join('\n').replace(/\x00$/, '') + + switch (commandLine) { + case 'CONNECTED': + connectionStatus.value = 'STOMP已连接' + // 订阅主题 + const subscribeFrame = buildStompFrame('SUBSCRIBE', { + id: 'sub-0', + destination: destination + }) + + socketTask?.send({ + data: subscribeFrame + }) + break + + case 'MESSAGE': + // 通知所有订阅者 + subscribers.forEach(subscriber => { + subscriber(body) + }) + break + + case 'ERROR': + console.error('服务器错误:', body) + break + } + }) + + // 监听错误 + socketTask.onError((err) => { + console.error('WebSocket错误:', err) + connectionStatus.value = '连接错误' + connected.value = false + }) + + // 监听关闭 + socketTask.onClose((closeRes) => { + console.log('WebSocket连接已关闭', closeRes) + connectionStatus.value = '已断开' + connected.value = false + }) + } + + // 断开WebSocket + const disconnectWebSocket = () => { + if (socketTask) { + // 发送STOMP DISCONNECT帧 + const disconnectFrame = buildStompFrame('DISCONNECT', { + receipt: 'disconnect-receipt' + }) + + socketTask.send({ + data: disconnectFrame, + success: () => { + socketTask?.close({ + code: 1000, + reason: '用户手动关闭', + success: () => { + connected.value = false + connectionStatus.value = '已断开' + } + }) + } + }) + } + } + + // 订阅消息 + const subscribe = (callback: MessageCallback) => { + subscribers.push(callback) + // 返回取消订阅函数 + return () => { + subscribers = subscribers.filter(sub => sub !== callback) + } + } + + // 发送消息 + const sendMessage = (destination: string, content: string) => { + if (!socketTask || !connected.value) { + console.error('WebSocket未连接') + return + } + + // 构建STOMP SEND帧 + const sendFrame = buildStompFrame('SEND', { + destination: destination, + 'content-type': 'text/plain' + }, content) + + socketTask.send({ + data: sendFrame + }) + } + + // 创建服务实例 + const service: WebSocketService = { + connected, + connectionStatus, + messages, + connectWebSocket, + disconnectWebSocket, + subscribe, + sendMessage + } + + // 存储单例 + webSocketServiceInstance = service + + return service +} \ No newline at end of file diff --git a/src/pages-home/device-control/office/ALLleader.vue b/src/pages-home/device-control/office/ALLleader.vue new file mode 100644 index 0000000..d60bd2f --- /dev/null +++ b/src/pages-home/device-control/office/ALLleader.vue @@ -0,0 +1,814 @@ + + { + layout: 'default', + style: { + navigationBarTitleText: '办公室设备列表', + + }, + } + + + + + + + \ No newline at end of file diff --git a/src/pages-home/device-control/office/Personaldevices.vue b/src/pages-home/device-control/office/Personaldevices.vue index 263a5ee..3c079cf 100644 --- a/src/pages-home/device-control/office/Personaldevices.vue +++ b/src/pages-home/device-control/office/Personaldevices.vue @@ -1,44 +1,590 @@ \ No newline at end of file diff --git a/src/pages-home/device-control/office/index.vue b/src/pages-home/device-control/office/index.vue index f9187cc..c5896e5 100644 --- a/src/pages-home/device-control/office/index.vue +++ b/src/pages-home/device-control/office/index.vue @@ -1,35 +1,87 @@ - - { - layout: 'default', - style: { - navigationBarTitleText: '办公室设备列表', - }, - } - - \ No newline at end of file diff --git a/src/pages-humanResource/absence/add.vue b/src/pages-humanResource/absence/add.vue index 47d59ee..dadb295 100644 --- a/src/pages-humanResource/absence/add.vue +++ b/src/pages-humanResource/absence/add.vue @@ -226,8 +226,10 @@ /*获取请假类型*/ const getTypeList = () => { getCategoryItemsApi('1838487445813645313').then((res) => { + console.log("res-------",res.result) if (res.success) { data.value = res.result + console.log("res-------",data.value) typeData.value = [data.value.map(item => { return { value: item.name, diff --git a/src/pages.json b/src/pages.json index 7fa1038..eaa5d09 100644 --- a/src/pages.json +++ b/src/pages.json @@ -222,13 +222,21 @@ "root": "pages-home", "pages": [ { - "path": "device-control/office/index", + "path": "device-control/office/ALLleader", "type": "page", "layout": "default", "style": { "navigationBarTitleText": "办公室设备列表" } }, + { + "path": "device-control/office/index", + "type": "page" + }, + { + "path": "device-control/office/officehomedevice", + "type": "page" + }, { "path": "device-control/office/Personaldevices", "type": "page" diff --git a/src/types/uni-pages.d.ts b/src/types/uni-pages.d.ts index 9ab397e..195aaa2 100644 --- a/src/types/uni-pages.d.ts +++ b/src/types/uni-pages.d.ts @@ -27,7 +27,9 @@ interface NavigateToOptions { "/pages/production/shishishuju/nyxhSssj" | "/pages/production/shishishuju/trqSssj" | "/pages/production/shishishuju/ysjSssj" | + "/pages-home/device-control/office/ALLleader" | "/pages-home/device-control/office/index" | + "/pages-home/device-control/office/officehomedevice" | "/pages-home/device-control/office/Personaldevices" | "/pages-message/chat/chat" | "/pages-message/contacts/contacts" | diff --git a/src/utils/socket.ts b/src/utils/socket.ts new file mode 100644 index 0000000..cfabc45 --- /dev/null +++ b/src/utils/socket.ts @@ -0,0 +1,101 @@ +// utils/socket.js +import { ref, onUnmounted } from 'vue'; + +export default function useWebSocket() { + const continturl='http://10.75.15.246:8899/mqttprod/ws'; + console.log("传进来的url----useWebSocket----11111--",continturl) + // 连接状态 + const isConnected = ref(false); + // 接收的消息 + const receivedMessages = ref([]); + // WebSocket实例 + let socket = null; + console.log("连接WebSocket---22222---",continturl) + // 连接WebSocket + const connect = () => { + // 使用uni-app的WebSocket API + socket = uni.connectSocket({ + url: continturl, + success: () => { + console.log('WebSocket连接成功'); + }, + fail: (err) => { + console.error('WebSocket连接失败:', err); + } + }); + console.log("连接WebSocket---333333---",continturl) + // 监听连接打开 + socket.onOpen(() => { + isConnected.value = true; + console.log('WebSocket已连接'); + }); + + // 监听消息接收 + socket.onMessage((res) => { + try { + // 尝试解析JSON消息 + const message = JSON.parse(res.data); + receivedMessages.value.push(message); + } catch (e) { + // 普通文本消息 + receivedMessages.value.push(res.data); + } + }); + + // 监听错误 + socket.onError((err) => { + console.error('WebSocket错误:', err); + }); + }; + // 监听连接关闭 + socket.onClose(() => { + isConnected.value = false; + console.log('WebSocket已关闭'); + }); + + // 发送消息 + const sendMessage = (data) => { + if (isConnected.value) { + socket.send({ + data: typeof data === 'string' ? data : JSON.stringify(data), + success: () => { + console.log('消息发送成功'); + }, + fail: (err) => { + console.error('消息发送失败:', err); + } + }); + } else { + console.error('WebSocket未连接,无法发送消息'); + } + }; + + // 关闭连接 + const disconnect = () => { + console.log("关闭连接------",socket) + if (socket) { + socket.close({ + success: () => { + console.log('WebSocket关闭成功'); + }, + fail: (err) => { + console.error('WebSocket关闭失败:', err); + } + }); + socket = null; + } + }; + + // 组件卸载时关闭连接 + onUnmounted(() => { + disconnect(); + }); + + return { + isConnected, + receivedMessages, + connect, + sendMessage, + disconnect + }; +} \ No newline at end of file