App.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <script>
  2. // import WebSocketManager from '@/utils/WebSocketManager.js';
  3. import { watch } from 'vue';
  4. import store from '@/store'
  5. export default {
  6. data:{
  7. userId: uni.getStorageSync('userId') //读取本地存储
  8. },
  9. onLaunch: function () {
  10. console.log('App Launch')
  11. },
  12. onShow: function () {
  13. console.log('App Show')
  14. },
  15. onHide: function () {
  16. console.log('App Hide')
  17. },
  18. watch: {
  19. userId: {
  20. handler() {
  21. // console.log('yong---------------',this.userId);
  22. // const wsManager = new WebSocketManager(this.userId);
  23. // // 设置消息回调
  24. // wsManager.onMessage(data => {
  25. // console.log('app-接收到的消息:', data);
  26. // // 处理消息逻辑
  27. // if(data.type === 'msgUnreadCount'){
  28. // store.dispatch('handleMessageCount',data.data)
  29. // }
  30. // });
  31. // // 建立连接
  32. // wsManager.connect();
  33. },
  34. immediate: true,
  35. deep: true
  36. }
  37. },
  38. onMounted() {
  39. console.log("TCL: onMounted -> onMounted", onMounted)
  40. },
  41. }
  42. </script>
  43. <style lang="scss">
  44. @import "uview-plus/index.scss";
  45. @import '@/static/scss/index.scss';
  46. </style>