| | |
| | | <component :is="Component" :key="$route.name" |
| | | v-if="!$route.meta || ($route.meta && !$route.meta.hasOwnProperty('keepAlive'))" /> |
| | | </keep-alive> |
| | | <component :is="Component" :key="$route.name" v-if="$route.meta && $route.meta.hasOwnProperty('keepAlive')" /> |
| | | <component :is="Component" :key="$route.name" |
| | | v-if="$route.meta && $route.meta.hasOwnProperty('keepAlive')" /> |
| | | </router-view> |
| | | </el-scrollbar> |
| | | </div> |
| | |
| | | }); |
| | | }; |
| | | |
| | | const s = ref(null); |
| | | const handleMessage = e => { |
| | | if (e) { |
| | | s.value = e.data; |
| | | console.log("WebSocket 鏀跺埌娑堟伅: ", e.data); |
| | | store.dispatch("sethomedata", s.value); |
| | | let data = JSON.parse(e.data); |
| | | messageList.push(data); |
| | | ElNotification({ |
| | | title: data.title, |
| | | message: h("i", { style: "color: teal" }, data.message), |
| | | position: "bottom-right" |
| | | }); |
| | | } |
| | | }; |
| | | const createSocket = url => { |
| | | //console.log(url); |
| | | |
| | | //鍒涘缓WebSocket杩炴帴 |
| | | //"ws://127.0.0.1:9295/admin" |
| | | //client = new WebSocket("ws://192.168.0.250:9260/"); |
| | | client = new WebSocket("ws:localhost:9260/"); |
| | | client.onopen = function () { |
| | | //client.onmessage = handleMessage; |
| | | // store.commit("setWebsocket", client); |
| | | console.log("WebSocket 杩炴帴鎴愬姛"); |
| | | }; |
| | | |
| | | client.onmessage = function (event) { |
| | | // console.log("WebSocket 鏀跺埌娑堟伅: ", event); |
| | | |
| | | if (event != undefined) { |
| | | store.dispatch("sethomedata", JSON.parse(event.data)); |
| | | } |
| | | // handleMessage(event); |
| | | }; |
| | | |
| | | client.onclose = function () { |
| | | console.log("WebSocket 杩炴帴鍏抽棴"); |
| | | setTimeout(createSocket, 10000); |
| | | }; |
| | | |
| | | client.onerror = function (err) { |
| | | console.log("WebSocket 杩炴帴閿欒: ", err); |
| | | }; |
| | | client.onmessage(); |
| | | }; |
| | | |
| | | const getSelectMenuName = (id) => { |
| | | return menuOptions.value.find(function (x) { |
| | | return x.id == id; |