From 98f0335e581fa19075091bf34ab485c0025817a3 Mon Sep 17 00:00:00 2001 From: yanfeiyong <2060201549@qq.com> Date: Tue, 27 May 2025 14:34:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/permission.js | 58 +-- src/router/index.js | 5 + src/views/{tongjifenxi => Home}/index.vue | 0 src/views/compilation/handbook/index.vue | 105 +++++- src/views/compilation/handbook/yulan.vue | 60 --- .../{onecailiao => monolithic}/index.vue | 0 .../components/ProjectDetails/Months.vue | 4 +- src/views/entLogin.vue | 357 ++++++++++++++++++ src/views/index.vue | 2 +- src/views/login_v1.vue | 4 +- src/views/manage-add/index.vue | 4 +- src/views/manage-info/index.vue | 4 +- src/views/manage/index.vue | 1 + src/views/models/badlist/index.vue | 1 + 14 files changed, 495 insertions(+), 110 deletions(-) rename src/views/{tongjifenxi => Home}/index.vue (100%) delete mode 100644 src/views/compilation/handbook/yulan.vue rename src/views/compilation/{onecailiao => monolithic}/index.vue (100%) create mode 100644 src/views/entLogin.vue diff --git a/src/permission.js b/src/permission.js index 029dc5a..5d7ede3 100644 --- a/src/permission.js +++ b/src/permission.js @@ -13,7 +13,7 @@ import { governmentGetInfo } from "@/api/login/index"; NProgress.configure({ showSpinner: false }); -const whiteList = ["/login", "/entLogin", "/register"]; // 白名单路径 +const whiteList = ["/login", "/entLogin", "/register"]; const isWhiteList = (path) => { return whiteList.some((pattern) => isPathMatch(pattern, path)); @@ -25,14 +25,15 @@ router.beforeEach((to, from, next) => { } NProgress.start(); - const search = window.location.search || window.location.hash.split("?")[1] || ""; + const search = + window.location.search || window.location.hash.split("?")[1] || ""; const params = new URLSearchParams(search); const userToken = params.get("userToken"); const signature = params.get("signature"); const timespan = params.get("timespan"); // ============================= - // 🔑 新增:处理 clienttoken 登录逻辑 + // 🔑 新增:处理 clienttoken 登录企业单点登录逻辑 // ============================= if (window.location.href.includes("clienttoken=")) { const reg = /[?&]clienttoken=([^&#]+)/; @@ -41,21 +42,25 @@ router.beforeEach((to, from, next) => { if (clienttoken) { // 清除 clienttoken 避免死循环 - let modifiedUrl = window.location.href.replace(/[?&]clienttoken=[^&#]+/, ''); - if (modifiedUrl.endsWith('?') || modifiedUrl.endsWith('&')) { - modifiedUrl = modifiedUrl.slice(0, -1); // 去掉末尾多余的符号 + let modifiedUrl = window.location.href.replace( + /[?&]clienttoken=[^&#]+/, + "" + ); + if (modifiedUrl.endsWith("?") || modifiedUrl.endsWith("&")) { + modifiedUrl = modifiedUrl.slice(0, -1); } // 如果 roles 还未加载,则拉取用户信息 if (store.getters.roles.length === 0) { isRelogin.show = true; - store.dispatch("SingleSignOnGetInfo", { clientToken: clienttoken }) + store + .dispatch("SingleSignOnGetInfo", { clientToken: clienttoken }) .then(() => { isRelogin.show = false; // 清除 URL 中的 clienttoken 并刷新页面 - window.history.replaceState({}, '', modifiedUrl); + window.history.replaceState({}, "", modifiedUrl); // 获取用户权限并生成路由 return store.dispatch("GenerateRoutes"); @@ -68,11 +73,12 @@ router.beforeEach((to, from, next) => { // console.error("单点登录失败:", err); store.dispatch("LogOut").then(() => { // Message.error("单点登录失败,请重试"); - window.location.href = "https://qytt.sipac.gov.cn/ecobrainportal/index.html"; + window.location.href = + "https://qytt.sipac.gov.cn/ecobrainportal/index.html"; }); }); - return; + return; } } } @@ -85,7 +91,7 @@ router.beforeEach((to, from, next) => { return; } - if (userToken && signature && timespan && to.path !== "/login") { + if (userToken && signature && timespan && !isPathMatch("/login", to.path)) { next({ path: "/login", query: { userToken, signature, timespan }, @@ -150,30 +156,34 @@ router.beforeEach((to, from, next) => { // ============================= // 🔐 原始本地登录逻辑 // ============================= - const token = getToken(); - if (token) { + if (getToken()) { to.meta.title && store.dispatch("settings/setTitle", to.meta.title); - if (to.path === "/login") { + /* has token*/ + if (to.path === "/entLogin") { next({ path: "/" }); NProgress.done(); - } else if (isWhiteList(to.path)) { - next(); + } else if (whiteList.indexOf(to.path) !== -1) { + next({ path: "/" }); + NProgress.done(); + // next(); } else { if (store.getters.roles.length === 0) { isRelogin.show = true; + // 判断当前用户是否已拉取完user_info信息 store .dispatch("GetInfo") .then(() => { isRelogin.show = false; store.dispatch("GenerateRoutes").then((accessRoutes) => { - router.addRoutes(accessRoutes); - next({ ...to, replace: true }); + // 根据roles权限生成可访问的路由表 + router.addRoutes(accessRoutes); + next({ ...to, replace: true }); }); }) .catch((err) => { store.dispatch("LogOut").then(() => { Message.error(err); - next("/"); + next({ path: "/" }); }); }); } else { @@ -181,14 +191,16 @@ router.beforeEach((to, from, next) => { } } } else { - if (isWhiteList(to.path)) { + // 没有token + if (whiteList.indexOf(to.path) !== -1) { + // 在免登录白名单,直接进入 next(); } else { - next(`/login?redirect=${encodeURIComponent(to.fullPath)}`); + next(`/entLogin?redirect=${encodeURIComponent(to.fullPath)}`); + NProgress.done(); } } }); - router.afterEach(() => { NProgress.done(); -}); \ No newline at end of file +}); diff --git a/src/router/index.js b/src/router/index.js index 0777c10..92ffe87 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -48,6 +48,11 @@ export const constantRoutes = [ // 测试 component: () => import("@/views/login_v1"), hidden: true, + }, + { + path: "/entLogin", + component: () => import("@/views/entLogin"), + hidden: true, }, { path: "/login_v2", diff --git a/src/views/tongjifenxi/index.vue b/src/views/Home/index.vue similarity index 100% rename from src/views/tongjifenxi/index.vue rename to src/views/Home/index.vue diff --git a/src/views/compilation/handbook/index.vue b/src/views/compilation/handbook/index.vue index 3234361..9cc8b6e 100644 --- a/src/views/compilation/handbook/index.vue +++ b/src/views/compilation/handbook/index.vue @@ -50,7 +50,6 @@
-
+
- +
+
+ + +
+ +
+
@@ -337,7 +352,7 @@
-
+ +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
- +
+
+
@@ -430,7 +479,8 @@ export default { activeStep: 1, coverForm: { title: "", - subtitle: "", + subtitle1: "", + subtitle2: "", imageUrl: "", }, // 项目选择相关 @@ -445,7 +495,11 @@ export default { // 封尾设计 endForm: { imageUrl: "", - subtitle: "", + dwname: "", + name: "", + phone: "", + lxname: "", + address: "", }, // 导出相关 selectedRows: [], @@ -577,13 +631,18 @@ export default { resetAddForm() { this.coverForm = { title: "", - subtitle: "", + subtitle1: "", + subtitle2: "", imageUrl: "", }; this.projectSearch = ""; this.endForm = { imageUrl: "", - subtitle: "", + dwname: "", + date: "", + phone: "", + lxname: "", + address: "", }; }, nextStep() { @@ -694,9 +753,14 @@ export default { if (this.coverForm.imageUrl) data.coverImg = this.coverForm.imageUrl; if (this.coverForm.title) data.name = this.coverForm.title; - if (this.coverForm.subtitle) data.subtitle = this.coverForm.subtitle; + if (this.coverForm.subtitle1) data.subtitle1 = this.coverForm.subtitle1; + if (this.coverForm.subtitle2) data.subtitle2 = this.coverForm.subtitle2; if (this.endForm.imageUrl) data.tailingImg = this.endForm.imageUrl; - if (this.endForm.subtitle) data.tail = this.endForm.subtitle; + if (this.endForm.dwname) data.dwname = this.endForm.dwname; + if (this.endForm.date) data.date = this.endForm.date; + if (this.endForm.phone) data.phone = this.endForm.phone; + if (this.endForm.lxname) data.lxname = this.endForm.lxname; + if (this.endForm.address) data.address = this.endForm.address; if (this.selectedProjects && this.selectedProjects.length > 0) { data.xmId = this.selectedProjects .map((project) => project.id) @@ -795,12 +859,17 @@ export default { const detail = res.data; this.coverForm = { title: detail.name, - subtitle: detail.subtitle, + subtitle1: detail.subtitle1, + subtitle2: detail.subtitle2, imageUrl: detail.coverImg, }; this.endForm = { - imageUrl: detail.tailingImg, - subtitle: detail.tail, + imageUrl: detail.tailingImg || "", + dwname: detail.dwname || "", + lxname: detail.lxname || "", + phone: detail.phone || "", + address: detail.address || "", + date: detail.date || "", }; // 先清空选中状态 diff --git a/src/views/compilation/handbook/yulan.vue b/src/views/compilation/handbook/yulan.vue deleted file mode 100644 index b12e719..0000000 --- a/src/views/compilation/handbook/yulan.vue +++ /dev/null @@ -1,60 +0,0 @@ - - - \ No newline at end of file diff --git a/src/views/compilation/onecailiao/index.vue b/src/views/compilation/monolithic/index.vue similarity index 100% rename from src/views/compilation/onecailiao/index.vue rename to src/views/compilation/monolithic/index.vue diff --git a/src/views/components/ProjectDetails/Months.vue b/src/views/components/ProjectDetails/Months.vue index 02a52ae..f22401e 100644 --- a/src/views/components/ProjectDetails/Months.vue +++ b/src/views/components/ProjectDetails/Months.vue @@ -155,9 +155,9 @@ - +
diff --git a/src/views/entLogin.vue b/src/views/entLogin.vue new file mode 100644 index 0000000..02e2c6f --- /dev/null +++ b/src/views/entLogin.vue @@ -0,0 +1,357 @@ + + + + + \ No newline at end of file diff --git a/src/views/index.vue b/src/views/index.vue index 6a9bc69..3294d2a 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -18,7 +18,7 @@ export default { this.$router.push({path:"/statistics"}) }else{ //企业人员 - this.$router.push({path:"/tongjifenxi"}) + this.$router.push({path:"/Home"}) } } }; diff --git a/src/views/login_v1.vue b/src/views/login_v1.vue index 7a5cc13..2b3d235 100644 --- a/src/views/login_v1.vue +++ b/src/views/login_v1.vue @@ -93,7 +93,7 @@ > 政务统一身份认证登录 --> - 企业统一身份认证登录 - + -->
主办单位:苏州工业园区经济发展委员会 diff --git a/src/views/manage-add/index.vue b/src/views/manage-add/index.vue index d847776..631f324 100644 --- a/src/views/manage-add/index.vue +++ b/src/views/manage-add/index.vue @@ -112,9 +112,9 @@
-
+
diff --git a/src/views/manage-info/index.vue b/src/views/manage-info/index.vue index a15e66a..b868a64 100644 --- a/src/views/manage-info/index.vue +++ b/src/views/manage-info/index.vue @@ -106,9 +106,9 @@
-
+
diff --git a/src/views/manage/index.vue b/src/views/manage/index.vue index 5dcc14d..3e0b6ed 100644 --- a/src/views/manage/index.vue +++ b/src/views/manage/index.vue @@ -669,6 +669,7 @@ export default { return deleteBasicInformation(ids); }) .then(() => { + this.queryParams.current = 1; // 重置页码 this.getList(); this.$modal.msgSuccess("删除成功"); }) diff --git a/src/views/models/badlist/index.vue b/src/views/models/badlist/index.vue index fb13433..d59637a 100644 --- a/src/views/models/badlist/index.vue +++ b/src/views/models/badlist/index.vue @@ -299,6 +299,7 @@ export default { return deleteBasicInformation(ids); }) .then(() => { + this.queryParams.current = 1; // 重置页码 this.getList(); this.$modal.msgSuccess("删除成功"); })