From fd0985868ccd5183b69486ff2fb01ddfbf9c0faa Mon Sep 17 00:00:00 2001 From: g7hoo Date: Sat, 9 Sep 2023 16:49:43 +0800 Subject: [PATCH] add websocket --- package-lock.json | 109 +- package.json | 12 +- src/components/yx-dark/containers/chart.vue | 50 +- .../containers/components/LineChart.vue | 364 +++++++ src/components/yx-dark/containers/table.vue | 2 +- .../yx-dark/socket-server/demo.json | 952 ++++++++++++++++++ src/components/yx-dark/socket-server/index.ts | 67 ++ .../yx-dark/socket-server/tsconfig.json | 109 ++ src/utils/wsClass.js | 3 +- src/views/HomeView.vue | 6 + yarn.lock | 26 +- 11 files changed, 1623 insertions(+), 77 deletions(-) create mode 100644 src/components/yx-dark/containers/components/LineChart.vue create mode 100644 src/components/yx-dark/socket-server/demo.json create mode 100644 src/components/yx-dark/socket-server/index.ts create mode 100644 src/components/yx-dark/socket-server/tsconfig.json diff --git a/package-lock.json b/package-lock.json index a00998a..dc94b2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,13 +17,16 @@ "vuex": "^3.6.2" }, "devDependencies": { + "@types/node": "^20.6.0", + "@types/ws": "^8.5.5", "@vue/cli-plugin-babel": "~5.0.0", "@vue/cli-plugin-router": "~5.0.0", "@vue/cli-plugin-vuex": "~5.0.0", "@vue/cli-service": "~5.0.0", "sass": "^1.32.7", "sass-loader": "^12.0.0", - "vue-template-compiler": "^2.6.14" + "vue-template-compiler": "^2.6.14", + "ws": "^8.14.1" } }, "node_modules/@achrinza/node-ipc": { @@ -2344,11 +2347,10 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.1.0", - "resolved": "https://registry.npmmirror.com/@types/node/-/node-20.1.0.tgz", - "integrity": "sha512-O+z53uwx64xY7D6roOi4+jApDGFg0qn6WHcxe5QeqjMaTezBO/mxdfFXIVAVVyNWKx84OmPB3L8kbVYOTeN34A==", - "dev": true, - "license": "MIT" + "version": "20.6.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.0.tgz", + "integrity": "sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg==", + "dev": true }, "node_modules/@types/normalize-package-data": { "version": "2.4.1", @@ -2435,11 +2437,10 @@ } }, "node_modules/@types/ws": { - "version": "8.5.4", - "resolved": "https://registry.npmmirror.com/@types/ws/-/ws-8.5.4.tgz", - "integrity": "sha512-zdQDHKUgcX/zBc4GrwsE/7dVdAD8JR4EuiAXiiUhhfyIJXXb2+PrGshFyeXWQPMmmZ2XxgaqclgpIC7eTXc1mg==", + "version": "8.5.5", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.5.tgz", + "integrity": "sha512-lwhs8hktwxSjf9UaZ9tG5M03PGogvFaH8gUgLNbN9HKIg0dvv6q+gkSuJ8HN4/VbyxkuLzCjlN7GquQ0gUJfIg==", "dev": true, - "license": "MIT", "dependencies": { "@types/node": "*" } @@ -10108,6 +10109,27 @@ "node": ">= 10.13.0" } }, + "node_modules/webpack-bundle-analyzer/node_modules/ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "dev": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/webpack-chain": { "version": "6.5.1", "resolved": "https://registry.npmmirror.com/webpack-chain/-/webpack-chain-6.5.1.tgz", @@ -10356,28 +10378,6 @@ "url": "https://opencollective.com/webpack" } }, - "node_modules/webpack-dev-server/node_modules/ws": { - "version": "8.13.0", - "resolved": "https://registry.npmmirror.com/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, "node_modules/webpack-merge": { "version": "5.8.0", "resolved": "https://registry.npmmirror.com/webpack-merge/-/webpack-merge-5.8.0.tgz", @@ -10498,17 +10498,16 @@ "license": "ISC" }, "node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmmirror.com/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "8.14.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.1.tgz", + "integrity": "sha512-4OOseMUq8AzRBI/7SLMUwO+FEDnguetSk7KMb1sHwvF2w2Wv5Hoj0nlifx8vtGsftE/jWHojPy8sMMzYLJ2G/A==", "dev": true, - "license": "MIT", "engines": { - "node": ">=8.3.0" + "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" + "utf-8-validate": ">=5.0.2" }, "peerDependenciesMeta": { "bufferutil": { @@ -12177,9 +12176,9 @@ "dev": true }, "@types/node": { - "version": "20.1.0", - "resolved": "https://registry.npmmirror.com/@types/node/-/node-20.1.0.tgz", - "integrity": "sha512-O+z53uwx64xY7D6roOi4+jApDGFg0qn6WHcxe5QeqjMaTezBO/mxdfFXIVAVVyNWKx84OmPB3L8kbVYOTeN34A==", + "version": "20.6.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.0.tgz", + "integrity": "sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg==", "dev": true }, "@types/normalize-package-data": { @@ -12259,9 +12258,9 @@ } }, "@types/ws": { - "version": "8.5.4", - "resolved": "https://registry.npmmirror.com/@types/ws/-/ws-8.5.4.tgz", - "integrity": "sha512-zdQDHKUgcX/zBc4GrwsE/7dVdAD8JR4EuiAXiiUhhfyIJXXb2+PrGshFyeXWQPMmmZ2XxgaqclgpIC7eTXc1mg==", + "version": "8.5.5", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.5.tgz", + "integrity": "sha512-lwhs8hktwxSjf9UaZ9tG5M03PGogvFaH8gUgLNbN9HKIg0dvv6q+gkSuJ8HN4/VbyxkuLzCjlN7GquQ0gUJfIg==", "dev": true, "requires": { "@types/node": "*" @@ -17479,6 +17478,15 @@ "opener": "^1.5.2", "sirv": "^1.0.7", "ws": "^7.3.1" + }, + "dependencies": { + "ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "dev": true, + "requires": {} + } } }, "webpack-chain": { @@ -17639,13 +17647,6 @@ "ajv-formats": "^2.1.1", "ajv-keywords": "^5.1.0" } - }, - "ws": { - "version": "8.13.0", - "resolved": "https://registry.npmmirror.com/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", - "dev": true, - "requires": {} } } }, @@ -17737,9 +17738,9 @@ "dev": true }, "ws": { - "version": "7.5.9", - "resolved": "https://registry.npmmirror.com/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "8.14.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.1.tgz", + "integrity": "sha512-4OOseMUq8AzRBI/7SLMUwO+FEDnguetSk7KMb1sHwvF2w2Wv5Hoj0nlifx8vtGsftE/jWHojPy8sMMzYLJ2G/A==", "dev": true, "requires": {} }, diff --git a/package.json b/package.json index 0609330..ed5605a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "private": true, "scripts": { "serve": "vue-cli-service serve", - "build": "vue-cli-service build" + "build": "vue-cli-service build", + "server": "ts-node ./src/components/yx-dark/socket-server/index.ts" }, "dependencies": { "core-js": "^3.8.3", @@ -16,12 +17,17 @@ "vuex": "^3.6.2" }, "devDependencies": { + "@types/node": "^20.6.0", + "@types/ws": "^8.5.5", "@vue/cli-plugin-babel": "~5.0.0", "@vue/cli-plugin-router": "~5.0.0", "@vue/cli-plugin-vuex": "~5.0.0", "@vue/cli-service": "~5.0.0", "sass": "^1.32.7", "sass-loader": "^12.0.0", - "vue-template-compiler": "^2.6.14" + "ts-node": "^10.9.1", + "typescript": "^5.2.2", + "vue-template-compiler": "^2.6.14", + "ws": "^8.14.1" } -} +} \ No newline at end of file diff --git a/src/components/yx-dark/containers/chart.vue b/src/components/yx-dark/containers/chart.vue index de5155b..75f4c2d 100644 --- a/src/components/yx-dark/containers/chart.vue +++ b/src/components/yx-dark/containers/chart.vue @@ -6,18 +6,41 @@ --> @@ -25,6 +48,23 @@ export default { diff --git a/src/components/yx-dark/containers/components/LineChart.vue b/src/components/yx-dark/containers/components/LineChart.vue new file mode 100644 index 0000000..b44e7dc --- /dev/null +++ b/src/components/yx-dark/containers/components/LineChart.vue @@ -0,0 +1,364 @@ + + + + + diff --git a/src/components/yx-dark/containers/table.vue b/src/components/yx-dark/containers/table.vue index 1c0b556..c9c89d4 100644 --- a/src/components/yx-dark/containers/table.vue +++ b/src/components/yx-dark/containers/table.vue @@ -133,7 +133,7 @@ export default {