|
@ -16,16 +16,18 @@ const Cross = ({ dispatch, actions }) => { |
|
|
const { data } = e |
|
|
const { data } = e |
|
|
if (data && data.action) { |
|
|
if (data && data.action) { |
|
|
if (data.action == 'logout') { |
|
|
if (data.action == 'logout') { |
|
|
|
|
|
// 子系统退出,清除本地缓存的登录信息 |
|
|
preLogout() |
|
|
preLogout() |
|
|
} else if (data.action = 'login') { |
|
|
} else if (data.action = 'login') { |
|
|
|
|
|
// 子系统登录,将登录信息记录到本地缓存 |
|
|
localStorage.setItem('fs_iot_cross_user', JSON.stringify(data.user)) |
|
|
localStorage.setItem('fs_iot_cross_user', JSON.stringify(data.user)) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
function storageListen (e) { |
|
|
function storageListen (e) { |
|
|
console.log(e); |
|
|
|
|
|
if (e.key == 'fs_iot_cross_user') { |
|
|
if (e.key == 'fs_iot_cross_user') { |
|
|
if (!e.newValue) { |
|
|
if (!e.newValue) { |
|
|
|
|
|
// 鉴权系统本身退出 退出其他子系统 |
|
|
// IOT AUTH 退出 |
|
|
// IOT AUTH 退出 |
|
|
window.parent.postMessage({ action: 'logout' }, '*'); |
|
|
window.parent.postMessage({ action: 'logout' }, '*'); |
|
|
} |
|
|
} |
|
@ -40,12 +42,15 @@ const Cross = ({ dispatch, actions }) => { |
|
|
user = JSON.parse(user) |
|
|
user = JSON.parse(user) |
|
|
const crossRslt = await dispatch(authAction.crossCheck({ token: user.token })) |
|
|
const crossRslt = await dispatch(authAction.crossCheck({ token: user.token })) |
|
|
if (crossRslt.success && crossRslt.payload.data.cross) { |
|
|
if (crossRslt.success && crossRslt.payload.data.cross) { |
|
|
|
|
|
// 查询到登录信息且没有过期,则将登录信息发送到子系统 |
|
|
window.parent.postMessage({ action: 'initUser', user: user }, '*'); |
|
|
window.parent.postMessage({ action: 'initUser', user: user }, '*'); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
// 查询到的登录信息不符合条件,发送信息让子系统退出 |
|
|
window.parent.postMessage({ action: 'logout' }, '*'); |
|
|
window.parent.postMessage({ action: 'logout' }, '*'); |
|
|
preLogout() |
|
|
preLogout() |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
// 没有登录信息,发送信息通知子系统进行其他处理 |
|
|
window.parent.postMessage({ action: 'initNotice' }, '*'); |
|
|
window.parent.postMessage({ action: 'initNotice' }, '*'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|