From 090730ca33bf276f647a1b517eeaf60ffe9f4d0b Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期四, 23 一月 2025 15:57:40 +0800 Subject: [PATCH] 新书 --- src/main.ts | 82 ++++++++++++++++------------------------ 1 files changed, 33 insertions(+), 49 deletions(-) diff --git a/src/main.ts b/src/main.ts index 440b309..78dfb1f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,65 +8,47 @@ import router from './router' import * as ElementPlusIconsVue from '@element-plus/icons-vue' import toolClass from '@/assets/js/toolClass' -import MG from "@/assets/js/middleGround/WebMiddleGroundApi.js" +import MG from '@/assets/js/middleGround/WebMiddleGroundApi.js' import './child.ts' +import { loginCtx } from '@/assets/js/config.ts' + +// 鍏紡杈撳叆 +import { MathfieldElement } from "mathlive" +// 鍏紡瑙f瀽 +import VueLatex from 'vatex' + const handleGetToken = () => { return localStorage.getItem('token') } -const getUrlParam =(paraName)=>{ - var url = window.location.toString(); - var arrObj = url.split("?"); - if (arrObj.length > 1) { - var arrPara = arrObj[1].split("&"); - var arr; - for (var i = 0; i < arrPara.length; i++) { - arr = arrPara[i].split("="); - if (arr != null && arr[0] == paraName) { - return arr[1]; - } - } - return ""; - } else { - return ""; - } -} - // 璺敱鎵ц涔嬪墠鐨勪竴浜涙搷浣� router.beforeEach((to, from, next) => { - let token = getUrlParam('token'); - let bookId = getUrlParam('bookId'); - if(bookId){ - localStorage.setItem('bookId', bookId) - } - - if (token) { - localStorage.setItem('token', token) - - if (to.path === '/login') { - next({ path: '/home' }) - } else { - // 濡傛灉涓嶆槸鐧诲綍椤甸潰锛岃烦杞埌鐩爣鐨勯〉闈� - next() - } - }else if (handleGetToken()) { - // 鏄惁鏄櫥褰曢〉闈紝鐩存帴鍒伴椤� - if (to.path === '/login') { - next({ path: '/home' }) - } else { - // 濡傛灉涓嶆槸鐧诲綍椤甸潰锛岃烦杞埌鐩爣鐨勯〉闈� - next() - } + const isInternalLink = from.fullPath.includes('/testBookReader') + if (isInternalLink) { + sessionStorage.removeItem('loginCtx') } else { - // 娌℃湁token - if (!to.meta || !to.meta.auth) { - // 鍦ㄥ厤鐧诲綍鐧藉悕鍗曪紝鐩存帴杩涘叆 - next() - } else { - next(`/login?redirect=${to.fullPath}`) // 鍚﹀垯鍏ㄩ儴閲嶅畾鍚戝埌鐧诲綍椤� - } + 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涓诲簲鐢ㄤ笌寰簲鐢ㄩ�氳 @@ -98,8 +80,10 @@ const app = createApp(App) + app.provide('toolClass', toolClass) app.provide('MG', MG) +app.use(VueLatex) app.use(router) app.use(ElementPlus) app.use(pinia) -- Gitblit v1.9.1