优化导出、导入数据接收问题
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// eventBus.js
|
||||
export const eventBus = {
|
||||
listeners: {},
|
||||
|
||||
$on(eventName, listener) {
|
||||
if (!this.listeners[eventName]) {
|
||||
this.listeners[eventName] = [];
|
||||
}
|
||||
this.listeners[eventName].push(listener);
|
||||
},
|
||||
|
||||
$emit(eventName, ...args) {
|
||||
const listeners = this.listeners[eventName];
|
||||
if (listeners) {
|
||||
listeners.forEach((listener) => listener(...args));
|
||||
}
|
||||
},
|
||||
|
||||
$off(eventName, listener) {
|
||||
const listeners = this.listeners[eventName];
|
||||
if (listeners) {
|
||||
this.listeners[eventName] = listeners.filter(l => l !== listener);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -5,6 +5,7 @@ import systemConfig from '@/config';
|
||||
import api from '../api';
|
||||
import router from "@/router";
|
||||
import {ElNotification} from 'element-plus';
|
||||
import {eventBus} from "./eventBus"
|
||||
// import store from "../store";
|
||||
|
||||
let websocket = null;
|
||||
@@ -153,6 +154,8 @@ function webSocketOnMessage(msg) {
|
||||
}
|
||||
}
|
||||
|
||||
eventBus.$emit('sockBack',result);
|
||||
|
||||
if(result.type == 'init'){
|
||||
if(showNot && showNot.close){
|
||||
showNot.close();
|
||||
@@ -168,7 +171,7 @@ function handleError() {
|
||||
}
|
||||
|
||||
function getSock(callback) {
|
||||
global_callback = callback
|
||||
global_callback = callback;
|
||||
}
|
||||
|
||||
// 数据发送
|
||||
|
||||
Reference in New Issue
Block a user