修改websocet

master
wuzuowei 4 months ago
parent 8a45485a93
commit fe3ca7bfbb

@ -72,7 +72,7 @@ const checkMethod = async () => {
let pathname = history.location.pathname; let pathname = history.location.pathname;
pathname = !pathname || pathname.length == 0 ? "" : (pathname[0] == "/" ? pathname.substring(1, pathname.length) : pathname) pathname = !pathname || pathname.length == 0 ? "" : (pathname[0] == "/" ? pathname.substring(1, pathname.length) : pathname)
if (docker.has(pathname) && docker.get(pathname)) return true; if (docker.has(pathname) && docker.get(pathname)) return true;
createAclsMap(); createAclsMap();
if (!acls || acls.length == 0) return false; if (!acls || acls.length == 0) return false;
@ -221,7 +221,7 @@ const interceptor = async (url: string, options: RequestOptionsInit) => {
else{ else{
//throw "webapi url error." //throw "webapi url error."
} }
// console.log("check", check) // console.log("check", check)
// console.log("request:", url) // console.log("request:", url)

@ -15,6 +15,7 @@ import { SystemData } from '@/microhost/models/system'
import { string } from 'prop-types'; import { string } from 'prop-types';
import { FrameMessage as message1 } from '@/library/union'; import { FrameMessage as message1 } from '@/library/union';
import { WebSocketOption as SocketOption, WebSocketLoader as Socket } from "./ws" import { WebSocketOption as SocketOption, WebSocketLoader as Socket } from "./ws"
import { getLoginId } from '@/utils';
/** /**
@ -63,8 +64,14 @@ const RightInfo = () => {
} }
option.onMessage = (msgdata: any) => { option.onMessage = (msgdata: any) => {
setsocketData(JSON.parse(msgdata))
console.log("on message", msgdata) if (getLoginId() == JSON.parse(msgdata).UserNo) {
setsocketData(JSON.parse(msgdata))
} else {
setsocketData({})
}
// console.log("on message", msgdata, getLoginId())
} }
ws.current = new Socket(option) ws.current = new Socket(option)

@ -1,4 +1,4 @@
import {history as umiHistory} from 'umi' import { history as umiHistory } from 'umi'
import localStorageUtil from './localStorageUtil'; import localStorageUtil from './localStorageUtil';
import request from './request'; import request from './request';
import dataUtil from './dataUtil'; import dataUtil from './dataUtil';
@ -7,8 +7,14 @@ import timeUtil from './timeUtil';
const DataUtil = new dataUtil(); const DataUtil = new dataUtil();
const DateUtil = new timeUtil(); const DateUtil = new timeUtil();
const LocalStorageUtil = new localStorageUtil(); const LocalStorageUtil = new localStorageUtil();
export { LocalStorageUtil, request, DataUtil, DateUtil }; const getLoginId = () => {
let userInfo: any = LocalStorageUtil.get("user_info")
return userInfo && userInfo.loginId ? userInfo.loginId : null
export const qiankunJump = (url:string,name='页面名称',params = null) =>{
window.__POWERED_BY_QIANKUN__ ? history.pushState(params,name,url): umiHistory.push(url) }
} export { LocalStorageUtil, request, DataUtil, DateUtil, getLoginId };
export const qiankunJump = (url: string, name = '页面名称', params = null) => {
window.__POWERED_BY_QIANKUN__ ? history.pushState(params, name, url) : umiHistory.push(url)
}

Loading…
Cancel
Save