From 7efeb8faf02f54053cc925f6d22163441e71fb44 Mon Sep 17 00:00:00 2001 From: yangchunlong <292345300@qq.com> Date: Fri, 17 Oct 2025 09:56:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=9A=80=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routers/index.ts | 24 ++----- src/views/foundation/subscribe/list/add.vue | 2 + src/views/home/index.vue | 80 ++++++++++----------- src/views/login/index.vue | 44 ++++++++++++ 4 files changed, 90 insertions(+), 60 deletions(-) diff --git a/src/routers/index.ts b/src/routers/index.ts index 63dfb8a..c4b6a92 100644 --- a/src/routers/index.ts +++ b/src/routers/index.ts @@ -29,22 +29,6 @@ const router = createRouter({ scrollBehavior: () => ({ left: 0, top: 0 }) }); -// 1. 定义获取URL参数的函数 -function getUrlParam(paramName: any) { - // 获取当前页面URL的查询参数部分(如 "?redirect_path=xxx&t=xxx") - const searchStr = window.location.search.slice(1); - // 将参数按 "&" 分割成数组(如 ["redirect_path=xxx", "t=xxx"]) - const paramArr = searchStr.split("&"); - // 遍历数组匹配目标参数 - for (let item of paramArr) { - const [key, value] = item.split("="); - if (key === paramName) { - return decodeURIComponent(value); // 解码特殊字符,确保内容准确 - } - } - return null; // 未找到参数时返回null -} - /** * @description 路由拦截 beforeEach * */ @@ -54,8 +38,8 @@ router.beforeEach(async (to, from, next) => { // 1.NProgress 开始 NProgress.start(); - let redirect_path = getUrlParam("redirect_path"); - + const currentPath = window.location.pathname; + console.log(currentPath, "=currentPath="); // 2.动态设置标题 const title = import.meta.env.VITE_GLOB_APP_TITLE; document.title = to.meta.title ? `${to.meta.title} - ${title}` : title; @@ -72,11 +56,11 @@ router.beforeEach(async (to, from, next) => { if (ROUTER_WHITE_LIST.includes(to.path)) return next(); // 如果没有token但是有订阅路由就将订阅路由当参数携带 - if (!userStore.newUserToken && redirect_path) { + if (!userStore.newUserToken && currentPath === "/foundation/subscribe/warehousing/index") { return next({ path: LOGIN_URL, replace: true, - query: { redirect_path: redirect_path } // 通过query传递参数 + query: { redirect_path: currentPath } // 通过query传递参数 }); } diff --git a/src/views/foundation/subscribe/list/add.vue b/src/views/foundation/subscribe/list/add.vue index 304f307..60cdfea 100644 --- a/src/views/foundation/subscribe/list/add.vue +++ b/src/views/foundation/subscribe/list/add.vue @@ -77,6 +77,8 @@ const getSubscribeAdd = async (params: any) => { const result = await getSubscribeAddApi(params); if (result?.code === 0) { useMsg("success", "新增成功 !"); + dataStore.ruleForm = cloneDeep(RULE_FORM); + init(); setTimeout(() => { $router.replace({ path: "/foundation/subscribe/list/index" }); }, 300); diff --git a/src/views/home/index.vue b/src/views/home/index.vue index a809619..7496eb8 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -6,51 +6,51 @@