Commit 407bb3c3 by Liu

fix:清理toolId

parent af79aca0
...@@ -202,8 +202,14 @@ export const Home: React.FC = () => { ...@@ -202,8 +202,14 @@ export const Home: React.FC = () => {
let res = {} as any let res = {} as any
if (viteOutputObj === 'inner') { if (viteOutputObj === 'inner') {
if (_loginCode) { if (_loginCode) {
// 每次进入页面调用 sso_login 时,先清空 sessionStorage 中的 currentToolId
// 避免关闭标签页后再次打开时使用上次的历史 toolId
safeSessionStorageRemoveItem('currentToolId')
res = await fetchLoginByToken(_loginCode) res = await fetchLoginByToken(_loginCode)
if (res.data) { if (res.data) {
// 登录成功后先打印完整的原始链接(删除之前)
// eslint-disable-next-line no-console
console.log('登录成功,删除前完整链接:', window.location.href)
// 登录成功后先清理旧状态,避免沿用上一次的工具模式 // 登录成功后先清理旧状态,避免沿用上一次的工具模式
dispatch(clearCurrentToolId()) dispatch(clearCurrentToolId())
safeSessionStorageRemoveItem('currentToolId') safeSessionStorageRemoveItem('currentToolId')
...@@ -213,6 +219,9 @@ export const Home: React.FC = () => { ...@@ -213,6 +219,9 @@ export const Home: React.FC = () => {
// 使用 replace 避免产生新的历史记录 // 使用 replace 避免产生新的历史记录
window.history.replaceState({}, '', currentUrl.toString()) window.history.replaceState({}, '', currentUrl.toString())
} }
// 删除后打印链接
// eslint-disable-next-line no-console
console.log('登录成功,删除后完整链接:', window.location.href)
setToken(res.data.token) setToken(res.data.token)
// 主动触发 storage 事件,确保其他组件能监听到变化 // 主动触发 storage 事件,确保其他组件能监听到变化
window.dispatchEvent( window.dispatchEvent(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment