<script setup>
import { Push } from '@/common/push'
import mitt from "@/utils/mitt";
import {useRoute} from "vue-router";

const route = useRoute();

console.log(route);

var connection = new Push({
  url: 'ws://192.168.1.24:3131', // websocket地址
  app_key: 'aaea61749929eb53a4bd75a1474c1d27',
});
// 假设用户uid为1
var uid = 5;
// 浏览器监听user-2频道的消息，也就是用户uid为1的用户消息
var user_channel = connection.subscribe('user-' + uid);

// 当user-2频道有message事件的消息时
user_channel.on('message', function (data) {
  mitt.emit(data.content.event, data.content.data);

  console.log("收到消息--",data)

});
// 断线事件
user_channel.on('close', function () {

});
</script>

<template>
  <router-view></router-view>
</template>

<style scoped lang="scss">
* {
  margin: 0;
  padding: 0;
}
</style>
