1
lkk
2 天以前 4b6eabfb56d2b736c5f16796614318770c606fd6
src/main.js
@@ -17,7 +17,7 @@
import "./assets/icons";
import "./permission";
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey, yidu } from "@/api/system/config";
import { getConfigKey } from "@/api/system/config";
import {
  parseTime,
  resetForm,
@@ -36,7 +36,7 @@
import DictData from "@/components/DictData";
import * as echarts from "echarts";
import VueBarcode from "vue-barcode";
import { initWebSocket, closeWebSocket } from "@/utils/websocket";
// import { initWebSocket, closeWebSocket } from "@/utils/websocket";
import RightToolbar from "@/components/RightToolbar"
// 注册全局组件
@@ -63,7 +63,7 @@
Vue.prototype.$echarts = echarts;
// 通知管理:跟踪当前通知和偏移量
const notificationManager = {
/* const notificationManager = {
  notifications: [], // 存储当前显示的通知实例
  baseOffset: 50, // 基础偏移量
  notificationHeight: 80, // 每个通知的估计高度(包括间距)
@@ -94,10 +94,10 @@
      notification.customClass = notification.customClass.replace(/notification-\d+/, `notification-${index + 1}`);
    });
  }
};
}; */
// 全局通知方法,添加“已读”按钮
Vue.prototype.$showNotification = function (type, title, message, onClick, noticeId) {
/* Vue.prototype.$showNotification = function (type, title, message, onClick, noticeId) {
  console.log('触发通知:', { type, title, message, noticeId, noticeIdType: typeof noticeId }); // 调试:记录 noticeId 和类型
  const h = this.$createElement;
  const notification = this.$notify({
@@ -134,7 +134,7 @@
    appendTo: document.body
  });
  notificationManager.addNotification(notification); // 添加到通知管理
};
}; */
// 监听路由变化
router.afterEach(() => {
@@ -142,14 +142,14 @@
});
// 定义 WebSocket 初始化标志,防止重复连接
let isWebSocketInitialized = false;
// let isWebSocketInitialized = false;
const app = new Vue({
  el: "#app",
  router,
  store,
  render: (h) => h(App),
  mounted() {
  /* mounted() {
    const token = store.state.user.token || Cookies.get('token') || '';
    if (token && !isWebSocketInitialized) {
      console.log('初始化 WebSocket,Token:', token);
@@ -207,7 +207,7 @@
      isWebSocketInitialized = false;
      console.log('Vue 实例销毁,WebSocket 已清理');
    }
  }
  } */
});
// 注册插件