From 214c5dda8bceda15e9630f0e5c22cd02708fc34b Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期一, 01 七月 2024 18:04:06 +0800 Subject: [PATCH] 资源列表默认图标替换 --- src/main.ts | 42 +++++++++++++++++++++++++++--------------- 1 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/main.ts b/src/main.ts index 6bb3e37..de5d30d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,6 +10,7 @@ import toolClass from '@/assets/js/toolClass' import MG from '@/assets/js/middleGround/WebMiddleGroundApi.js' import './child.ts' +import { loginCtx } from '@/assets/js/config.ts' const handleGetToken = () => { return localStorage.getItem('token') @@ -17,23 +18,34 @@ // 璺敱鎵ц涔嬪墠鐨勪竴浜涙搷浣� router.beforeEach((to, from, next) => { - if (handleGetToken()) { - // 鏄惁鏄櫥褰曢〉闈紝鐩存帴鍒伴椤� - if (to.path === '/login') { - next({ path: '/home', query: { bookId: localStorage.getItem('bookId') } }) - } else { - // 濡傛灉涓嶆槸鐧诲綍椤甸潰锛岃烦杞埌鐩爣鐨勯〉闈� - next() - } + console.log(to, from) + const isInternalLink = from.fullPath.includes('/testBookReader') + if (isInternalLink) { + console.log('閫氳繃鍐呴儴閾炬帴杩涘叆椤圭洰') + sessionStorage.removeItem('loginCtx') } else { - // 娌℃湁token - if (!to.meta || !to.meta.auth) { - // 鍦ㄥ厤鐧诲綍鐧藉悕鍗曪紝鐩存帴杩涘叆 - next() - } else { - next(`/login?redirect=${to.fullPath}`) // 鍚﹀垯鍏ㄩ儴閲嶅畾鍚戝埌鐧诲綍椤� - } + console.log(loginCtx, '閫氳繃澶栭儴閾炬帴杩涘叆椤圭洰') + sessionStorage.setItem('loginCtx', loginCtx) } + + next() + // if (handleGetToken()) { + // // 鏄惁鏄櫥褰曢〉闈紝鐩存帴鍒伴椤� + // if (to.path === '/login') { + // next({ path: '/home', query: { bookId: localStorage.getItem('bookId') } }) + // } else { + // // 濡傛灉涓嶆槸鐧诲綍椤甸潰锛岃烦杞埌鐩爣鐨勯〉闈� + // next() + // } + // } else { + // // 娌℃湁token + // if (!to.meta || !to.meta.auth) { + // // 鍦ㄥ厤鐧诲綍鐧藉悕鍗曪紝鐩存帴杩涘叆 + // next() + // } else { + // next(`/login?redirect=${to.fullPath}`) // 鍚﹀垯鍏ㄩ儴閲嶅畾鍚戝埌鐧诲綍椤� + // } + // } }) // qiankun涓诲簲鐢ㄤ笌寰簲鐢ㄩ�氳 -- Gitblit v1.9.1