From 95f6511f339968e4781036ca157bf93027f7d15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Fri, 7 Apr 2023 10:31:38 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9websocket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/package.json | 3 +++ ruoyi-ui/src/main.js | 1 + ruoyi-ui/src/views/index.vue | 31 +++++++++++++++++++++++-------- ruoyi-ui/vite.config.js | 5 +++-- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index d5c9911..beaa63f 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -29,11 +29,14 @@ "mockjs": "^1.1.0", "nprogress": "0.2.0", "pinia": "2.0.22", + "socket.io-client": "^4.6.1", "vue": "3.2.45", + "vue-3-socket.io": "^1.0.5", "vue-count-to": "^1.0.13", "vue-cropper": "1.0.3", "vue-i18n": "^9.2.2", "vue-router": "4.1.4", + "vue-socket.io": "^3.0.10", "vue3-count-to": "^1.1.2" }, "devDependencies": { diff --git a/ruoyi-ui/src/main.js b/ruoyi-ui/src/main.js index ab2f6ba..8fa6196 100644 --- a/ruoyi-ui/src/main.js +++ b/ruoyi-ui/src/main.js @@ -45,6 +45,7 @@ import TreeSelect from '@/components/TreeSelect' import DictTag from '@/components/DictTag' import {useI18n} from "vue-i18n"; + const app = createApp(App) // 全局方法挂载 diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index 0475433..152b2b8 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -110,7 +110,8 @@ - +
@@ -132,6 +133,7 @@ import * as echarts from 'echarts'; // import resize from './mixins/resize' import chinaMap from './china.json' + const animationDuration = 6000 export default { @@ -324,6 +326,7 @@ export default { this.initChart() this.initCarChart() this.initTyreChart() + this.getErrInfo() }) }, beforeDestroy() { @@ -372,7 +375,7 @@ export default { geo: { show: true, map: this.mapName, - zoom:1.2, + zoom: 1.2, label: { normal: { show: false @@ -404,7 +407,6 @@ export default { label: { normal: { formatter: (e) => { - console.log(e) return e.data.name }, position: 'right', @@ -424,7 +426,7 @@ export default { type: 'map', map: 'china', geoIndex: 0, - zoom:1.6, + zoom: 1.6, aspectScale: 0.75, //长宽比 showLegendSymbol: false, // 存在legend时显示 label: { @@ -639,18 +641,31 @@ export default { ], }) }, - getErrInfo(){ - if( typeof(WebSocket) != "function" ) { + getErrInfo() { + if (typeof (WebSocket) != "function") { alert("您的浏览器不支持Websocket通信协议") return } + let url = "ws://127.0.0.1:8080/websocket/message"; //请求的后端地址 + + let websocket = null;//全局WebSocket对象 + let lockReconnect = false; // 网络断开重连 + let wsCreateHandler = null; // 创建连接 + + websocket = new WebSocket(url) + websocket.onopen = function(event) { + console.log("服务已连接") + }; + websocket.onmessage = function(event){ + console.log(event) + } } } } diff --git a/ruoyi-ui/vite.config.js b/ruoyi-ui/vite.config.js index bee9e1d..c53d6e9 100644 --- a/ruoyi-ui/vite.config.js +++ b/ruoyi-ui/vite.config.js @@ -13,7 +13,8 @@ export default defineConfig(({mode, command}) => { // 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上 // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 base: VITE_APP_ENV === 'production' ? '/' : '/', - plugins: [createVitePlugins(env, command === 'build'),basicSsl()], + plugins: createVitePlugins(env, command === 'build'), + // plugins: [createVitePlugins(env, command === 'build'),basicSsl()], resolve: { // https://cn.vitejs.dev/config/#resolve-alias alias: { @@ -29,7 +30,7 @@ export default defineConfig(({mode, command}) => { server: { port: 80, host: true, - https:true, + // https:true, open: true, proxy: { '/dev-api': { From 6e86463fcdf606fbe90c89a5eb8eea0e19f92d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Fri, 7 Apr 2023 10:32:57 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9websocket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index 152b2b8..6030753 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -646,7 +646,7 @@ export default { alert("您的浏览器不支持Websocket通信协议") return } - let url = "ws://127.0.0.1:8080/websocket/message"; //请求的后端地址 + let url = "ws://10.11.41.249:8080/websocket/message"; //请求的后端地址 let websocket = null;//全局WebSocket对象 let lockReconnect = false; // 网络断开重连 From 9844bc76eab93a398008319178d35912c5e8a3d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Fri, 7 Apr 2023 10:39:31 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=87=8D=E8=BF=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/index.vue | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index 6030753..5d5aca9 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -646,20 +646,20 @@ export default { alert("您的浏览器不支持Websocket通信协议") return } - let url = "ws://10.11.41.249:8080/websocket/message"; //请求的后端地址 - let websocket = null;//全局WebSocket对象 - let lockReconnect = false; // 网络断开重连 - let wsCreateHandler = null; // 创建连接 - - websocket = new WebSocket(url) - websocket.onopen = function(event) { - console.log("服务已连接") - }; - websocket.onmessage = function(event){ - console.log(event) + const getWebsocket = () => { + let websocket = new WebSocket("ws://10.11.41.249:8080/websocket/message") + websocket.onopen = function (event) { + console.log("服务已连接") + }; + websocket.onmessage = function (event) { + console.log(event) + } + websocket.onerror = function (event) { + setTimeout(getWebsocket,1000) + }; } - + getWebsocket() } } } From 780741437d924c41b3e987a5c40dd8534f964207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Fri, 7 Apr 2023 11:35:23 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/index.vue | 48 +++++++++--------------------------- ruoyi-ui/src/views/login.vue | 4 +-- 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index 5d5aca9..553cd8d 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -160,39 +160,15 @@ export default { tyreChart: null, mapName: 'china', geoCoordMap: {}, - chartData: [ - {name: "北京", value: 177}, - {name: "天津", value: 42}, - {name: "河北", value: 102}, - {name: "山西", value: 81}, - {name: "内蒙古", value: 47}, - {name: "辽宁", value: 67}, - {name: "吉林", value: 82}, - {name: "黑龙江", value: 66}, - {name: "上海", value: 24}, - {name: "江苏", value: 92}, - {name: "浙江", value: 114}, - {name: "安徽", value: 109}, - {name: "福建", value: 116}, - {name: "江西", value: 91}, - {name: "山东", value: 119}, - {name: "河南", value: 137}, - {name: "湖北", value: 116}, - {name: "湖南", value: 114}, - {name: "重庆", value: 91}, - {name: "四川", value: 125}, - {name: "贵州", value: 62}, - {name: "云南", value: 83}, - {name: "西藏", value: 9}, - {name: "陕西", value: 80}, - {name: "甘肃", value: 56}, - {name: "青海", value: 10}, - {name: "宁夏", value: 18}, - {name: "新疆", value: 67}, - {name: "广东", value: 123}, - {name: "广西", value: 59}, - {name: "海南", value: 14}, - ], + chartData: [...(chinaMap.features.map(e => { + return { + name: e.properties.name, + value: Math.random() * 200 + } + })), { + name: '南海诸岛', + value: Math.random() * 200 + }], toolTipData: [ { "name": "北京", @@ -326,7 +302,7 @@ export default { this.initChart() this.initCarChart() this.initTyreChart() - this.getErrInfo() + // this.getErrInfo() }) }, beforeDestroy() { @@ -655,8 +631,8 @@ export default { websocket.onmessage = function (event) { console.log(event) } - websocket.onerror = function (event) { - setTimeout(getWebsocket,1000) + websocket.onerror = function () { + setTimeout(getWebsocket, 1000) }; } getWebsocket() diff --git a/ruoyi-ui/src/views/login.vue b/ruoyi-ui/src/views/login.vue index 3595157..325a8ee 100644 --- a/ruoyi-ui/src/views/login.vue +++ b/ruoyi-ui/src/views/login.vue @@ -114,8 +114,8 @@ const userStore = useUserStore() const router = useRouter(); const {proxy} = getCurrentInstance(); const loginForm = ref({ - username: "admin", - password: "admin123", + username: "", + password: "", rememberMe: false, code: "", uuid: "" From 279931d8ba0260816674a766ac2cf57d61309d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Fri, 7 Apr 2023 11:37:55 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index 553cd8d..dffa17e 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -302,7 +302,7 @@ export default { this.initChart() this.initCarChart() this.initTyreChart() - // this.getErrInfo() + this.getErrInfo() }) }, beforeDestroy() {