// 同一项目,不同窗口切换时,也要执行进入方法 document.addEventListener('visibilitychange',function(){ if(document.visibilityState=='hidden') { // if(ws){ // ws.close(); //关闭websocket // } }else { handleEntry(location.pathname) } }); function handleEntry(toPath){ let newTarget = menuList.find(v => v.label_id == toPath) // 新进入的页面信息 if(newTarget){ let params = {} params = { menuId: newTarget.id, menuName: newTarget.label, route: newTarget.label_id, userMd5: localStorage.token, userName: localStorage.uname } getEntry(params).then(res => { console.log("getEntryres", res) window.localStorage.setItem("journalId", res.data) }) } }