diff --git a/src/common/globalRouter.js b/src/common/globalRouter.js index 5f582bd..4db15c5 100644 --- a/src/common/globalRouter.js +++ b/src/common/globalRouter.js @@ -21,11 +21,42 @@ let routes = [ routes = $globalRouterModules(routes); // 加载模块路由 +// vite base 保持 './',一份包可挂不同目录;这里只决定 Router 前缀 +const getRouterBase = () => { + const pathname = window.location.pathname; + if (pathname === "/enforce" || pathname.startsWith("/enforce/")) { + return "/enforce/"; + } + if (pathname === "/enterprise" || pathname.startsWith("/enterprise/")) { + return "/enterprise/"; + } + return "/"; +}; + +// 业务约定不可改:企业端 Hash(第三方),执法端 History(第三方) +// 与上面 redirect 切换保持一致:/enforceHome=执法端,/home=企业端 +const createAppHistory = () => { + const base = getRouterBase(); + const pathname = window.location.pathname; + // 按 nginx 挂载路径区分 + if (pathname === "/enterprise" || pathname.startsWith("/enterprise/")) { + return createWebHashHistory(base); // 企业端 + } + if (pathname === "/enforce" || pathname.startsWith("/enforce/")) { + return createWebHistory(base); // 执法端 + } + // 根路径部署:与当前 redirect 一致(现在是执法端) + // 打企业端包时改 redirect 为 /home,并把下面改成 createWebHashHistory(base) + return createWebHistory(base); +}; + const $globalRouter = createRouter({ // 企业端 // history: createWebHashHistory(), // 执法端 - history: createWebHistory(), + // history: createWebHistory(), + + history: createAppHistory(), routes, }); diff --git a/src/views/enforceHome.vue b/src/views/enforceHome.vue index a77b846..9b7d254 100644 --- a/src/views/enforceHome.vue +++ b/src/views/enforceHome.vue @@ -281,13 +281,11 @@ const onLoad = () => { }; onMounted(() => { - // new Vconsolefrom(); let fullUrl = window.location.href; let code = fullUrl.substring( fullUrl.indexOf("code=") + 5, fullUrl.indexOf("&state="), ); - console.log("=======================================================",useCommon.firstLoad); isLoading.value = useCommon.firstLoad; // getSzyptLoginAuth(route?.query?.code,success =>{ getSzyptLoginAuth( diff --git a/vite-config/index.js b/vite-config/index.js index 6226ff0..d1322c2 100644 --- a/vite-config/index.js +++ b/vite-config/index.js @@ -48,7 +48,8 @@ const baseCfg = (viteEnv = {}) => { minify: "terser", // esbuild 打包更快,但是不能去除 console.log,去除 console 使用 terser 模式 terserOptions: { compress: { - drop_console: true, // 移除 console + // 排查问题时先关掉;上线稳定后可改回 true + drop_console: false, drop_debugger: true, // 移除 debugger }, },