修改websocket

master
夜笙歌 2 years ago
parent ecc536bc74
commit 95f6511f33

@ -29,11 +29,14 @@
"mockjs": "^1.1.0", "mockjs": "^1.1.0",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"pinia": "2.0.22", "pinia": "2.0.22",
"socket.io-client": "^4.6.1",
"vue": "3.2.45", "vue": "3.2.45",
"vue-3-socket.io": "^1.0.5",
"vue-count-to": "^1.0.13", "vue-count-to": "^1.0.13",
"vue-cropper": "1.0.3", "vue-cropper": "1.0.3",
"vue-i18n": "^9.2.2", "vue-i18n": "^9.2.2",
"vue-router": "4.1.4", "vue-router": "4.1.4",
"vue-socket.io": "^3.0.10",
"vue3-count-to": "^1.1.2" "vue3-count-to": "^1.1.2"
}, },
"devDependencies": { "devDependencies": {

@ -45,6 +45,7 @@ import TreeSelect from '@/components/TreeSelect'
import DictTag from '@/components/DictTag' import DictTag from '@/components/DictTag'
import {useI18n} from "vue-i18n"; import {useI18n} from "vue-i18n";
const app = createApp(App) const app = createApp(App)
// 全局方法挂载 // 全局方法挂载

@ -110,7 +110,8 @@
</div> </div>
</el-footer> </el-footer>
</el-container> </el-container>
<el-aside style="background-color: rgba(0,0,0,0.3);overflow: auto;margin-bottom: 0;height: calc(100vh - 84px)" width="350px"> <el-aside style="background-color: rgba(0,0,0,0.3);overflow: auto;margin-bottom: 0;height: calc(100vh - 84px)"
width="350px">
<div v-for="i in 60" style="position:relative;color:#fff;height: 120px;"> <div v-for="i in 60" style="position:relative;color:#fff;height: 120px;">
<img src="../assets/icons/highTemperature.png" <img src="../assets/icons/highTemperature.png"
style="width: 40px;height: 40px;position: absolute;top: 10px;left: 0px"> style="width: 40px;height: 40px;position: absolute;top: 10px;left: 0px">
@ -132,6 +133,7 @@ import * as echarts from 'echarts';
// import resize from './mixins/resize' // import resize from './mixins/resize'
import chinaMap from './china.json' import chinaMap from './china.json'
const animationDuration = 6000 const animationDuration = 6000
export default { export default {
@ -324,6 +326,7 @@ export default {
this.initChart() this.initChart()
this.initCarChart() this.initCarChart()
this.initTyreChart() this.initTyreChart()
this.getErrInfo()
}) })
}, },
beforeDestroy() { beforeDestroy() {
@ -404,7 +407,6 @@ export default {
label: { label: {
normal: { normal: {
formatter: (e) => { formatter: (e) => {
console.log(e)
return e.data.name return e.data.name
}, },
position: 'right', position: 'right',
@ -644,6 +646,19 @@ export default {
alert("您的浏览器不支持Websocket通信协议") alert("您的浏览器不支持Websocket通信协议")
return 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)
}
} }
} }

@ -13,7 +13,8 @@ export default defineConfig(({mode, command}) => {
// 默认情况下vite 会假设你的应用是被部署在一个域名的根路径上 // 默认情况下vite 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
base: VITE_APP_ENV === 'production' ? '/' : '/', base: VITE_APP_ENV === 'production' ? '/' : '/',
plugins: [createVitePlugins(env, command === 'build'),basicSsl()], plugins: createVitePlugins(env, command === 'build'),
// plugins: [createVitePlugins(env, command === 'build'),basicSsl()],
resolve: { resolve: {
// https://cn.vitejs.dev/config/#resolve-alias // https://cn.vitejs.dev/config/#resolve-alias
alias: { alias: {
@ -29,7 +30,7 @@ export default defineConfig(({mode, command}) => {
server: { server: {
port: 80, port: 80,
host: true, host: true,
https:true, // https:true,
open: true, open: true,
proxy: { proxy: {
'/dev-api': { '/dev-api': {

Loading…
Cancel
Save