up
chenyc
2022-07-04 5d61d2535302e9d472b650e2607a8cfbbdff1d18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<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>