<script lang="ts">
|
import { userInfoStore } from '@/stores/userInfo'
|
import Stomp from 'stompjs'
|
import { ipcRenderer } from 'electron'
|
|
export default {
|
setup() {
|
const user = userInfoStore()
|
var stompClient: Stomp.Client | null=null
|
console.log(user.userInfo)
|
const callback = function(message:any) {
|
if (message.body) {
|
console.log(message.body,'接收到的数据')
|
} else {
|
alert("接收数据异常");
|
}
|
};
|
const connectCallback=function(){
|
console.log("链接成功")
|
if(stompClient!==null){
|
stompClient.subscribe('/queue/12345/67890/keepalive',callback)
|
stompClient.send("/app/device/keepalive/12345/67890", {}, JSON.stringify({"deviceNumber":"testfsfd"}));
|
}
|
}
|
const error_callback=function(error:any){
|
console.log('链接错误',error);
|
setTimeout(()=>{
|
console.log('10秒之后重连')
|
ubtCilert()
|
|
},10000)
|
}
|
|
const ubtCilert=()=>{
|
console.log('ss')
|
ipcRenderer.send('msg_renderer_to_main', { 'param1': "hello" });
|
// const socket = new WebSocket('ws://hemobs.icoldchain.cn/broadcast')
|
// stompClient = Stomp.over(socket)
|
// stompClient.connect({}, connectCallback,error_callback)
|
}
|
return{
|
ubtCilert
|
}
|
},
|
|
|
}
|
|
</script>
|
<template>
|
<div class="home">
|
<el-button @click="ubtCilert">
|
test
|
</el-button>
|
</div>
|
</template>
|
<style>
|
body {
|
background: #f3f7fb;
|
}
|
.coldev {
|
height: 200px;
|
background: #ffff;
|
}
|
.grid-container {
|
display: grid;
|
grid-template-columns: 33% 33% 33%;
|
grid-gap: 20px;
|
background: #f3f7fb;
|
padding: 10px;
|
}
|
.grid-container > div {
|
background: #ffffff;
|
height: 150px;
|
text-align: center;
|
border-radius: 10px;
|
padding: 10px;
|
}
|
.lableText {
|
text-align: left;
|
/* height: 50px; */
|
/* line-height: 50px; */
|
padding-top: 30px;
|
font-size: 13pt;
|
}
|
.conText {
|
height: 50px;
|
line-height: 50px;
|
padding-top: 30px;
|
color: #769aff;
|
font-size: 20pt;
|
}
|
.imgss {
|
height: 30px;
|
}
|
.tale {
|
height: 30px;
|
line-height: 50px;
|
/* text-align: center; */
|
}
|
.zsf {
|
font-size: 18pt;
|
margin-top: 15pt;
|
color: #769aff;
|
}
|
</style>
|