plantScreen/src/App.vue

60 lines
1.2 KiB
Vue
Raw Normal View History

2023-12-01 18:22:09 +08:00
<script setup lang="ts">
2023-12-19 18:15:24 +08:00
2024-01-09 18:33:44 +08:00
// let Token =localStorage.getItem('TOKEN')
import { globalEventBus } from '@/common/eventBus'
import { Push } from '@/common/push'
2023-12-18 18:49:52 +08:00
import { areaObj } from "@/store/index.js"
const userInfoStore=areaObj()
2023-12-19 18:15:24 +08:00
userInfoStore.changeUserInfoFn(510521)
2023-12-18 18:49:52 +08:00
2024-01-09 18:33:44 +08:00
var connection = new Push({
url: 'ws://192.168.1.10:3131', // websocket地址
app_key: 'aaea61749929eb53a4bd75a1474c1d27',
});
// 假设用户uid为1
var uid = 3;
// 浏览器监听user-2频道的消息也就是用户uid为1的用户消息
var user_channel = connection.subscribe('user-' + uid);
// 当user-2频道有message事件的消息时
user_channel.on('message', function (data) {
globalEventBus.emit(data.content.event, data.content.data)
console.log("收到消息",data)
});
// 断线事件
user_channel.on('close', function () {
});
2023-12-18 18:49:52 +08:00
2023-12-01 18:22:09 +08:00
</script>
<template>
<router-view></router-view>
2023-12-02 18:36:12 +08:00
<div>
2023-12-01 18:22:09 +08:00
</div>
</template>
<style lang="scss">
@import '/static/font/font.css';
* {
margin: 0;
padding: 0;
}
2023-12-14 20:08:53 +08:00
2023-12-01 18:22:09 +08:00
.color-font {
font-family: FZCYJ;
color: #E5EFFF;
background: linear-gradient(to bottom, #DAE8FE 30%, #53A0FF 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
</style>