From 9b6bd0c014b73456edb095ee53b22324437ae646 Mon Sep 17 00:00:00 2001
From: cuijian <cuijian@xalxzn.com>
Date: 星期三, 09 七月 2025 10:59:45 +0800
Subject: [PATCH] 现场问题修改

---
 src/permission.js |   92 ++++++++++++++++++++++++++++------------------
 1 files changed, 56 insertions(+), 36 deletions(-)

diff --git a/src/permission.js b/src/permission.js
index fe8d825..5aaa878 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -4,12 +4,12 @@
 import NProgress from 'nprogress' // progress bar
 import 'nprogress/nprogress.css' // progress bar style
 import notification from 'ant-design-vue/es/notification'
-import { ACCESS_TOKEN,INDEX_MAIN_PAGE_PATH, OAUTH2_LOGIN_PAGE_PATH } from '@/store/mutation-types'
+import { ACCESS_TOKEN, INDEX_MAIN_PAGE_PATH, OAUTH2_LOGIN_PAGE_PATH } from '@/store/mutation-types'
 import { generateIndexRouter, isOAuth2AppEnv } from '@/utils/util'
 
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
-const whiteList = ['/user/login', '/user/register', '/user/register-result','/user/alteration'] // no redirect whitelist
+const whiteList = ['/user/login', '/user/register', '/user/register-result', '/user/alteration', '/terminal/login'] // no redirect whitelist
 whiteList.push(OAUTH2_LOGIN_PAGE_PATH)
 
 router.beforeEach((to, from, next) => {
@@ -21,8 +21,8 @@
     to.matched.splice(2, to.matched.length - 3)
   }
   //update-end---author:scott ---date::2022-10-13  for锛歔jeecg-boot/issues/4091]澶氱骇璺敱缂撳瓨闂 #4091--------------
-  
-  
+
+
   NProgress.start() // start progress bar
 
   if (Vue.ls.get(ACCESS_TOKEN)) {
@@ -30,57 +30,77 @@
     if (to.path === '/user/login' || to.path === OAUTH2_LOGIN_PAGE_PATH) {
       next({ path: INDEX_MAIN_PAGE_PATH })
       NProgress.done()
-    } else {
+    }
+    else {
       if (store.getters.permissionList.length === 0) {
         store.dispatch('GetPermissionList').then(res => {
-              const menuData = res.result.menu;
-              //console.log(res.message)
-              if (menuData === null || menuData === "" || menuData === undefined) {
-                return;
+          const menuData = res.result.menu
+          //console.log(res.message)
+          if (menuData === null || menuData === '' || menuData === undefined) {
+            return
+          }
+          let constRoutes = []
+          constRoutes = generateIndexRouter(menuData)
+          // 娣诲姞涓荤晫闈㈣矾鐢�
+          store.dispatch('UpdateAppRouter', { constRoutes }).then(() => {
+            // 鏍规嵁roles鏉冮檺鐢熸垚鍙闂殑璺敱琛�
+            // 鍔ㄦ�佹坊鍔犲彲璁块棶璺敱琛�
+            router.addRoutes(store.getters.addRouters)
+            const redirect = decodeURIComponent(from.query.redirect || to.path)
+            if (to.path === redirect) {
+              // hack鏂规硶 纭繚addRoutes宸插畬鎴� ,set the replace: true so the navigation will not leave a history record
+              next({ ...to, replace: true })
+            } else {
+              // 璺宠浆鍒扮洰鐨勮矾鐢�
+              if (to.path !== '/terminal/login' && from.path !== '/terminal/login' && redirect.split('/')[1] === 'terminal') {
+                next({ path: '/terminal/login' })
+              } else {
+                next({ path: redirect })
               }
-              let constRoutes = [];
-              constRoutes = generateIndexRouter(menuData);
-              // 娣诲姞涓荤晫闈㈣矾鐢�
-              store.dispatch('UpdateAppRouter',  { constRoutes }).then(() => {
-                // 鏍规嵁roles鏉冮檺鐢熸垚鍙闂殑璺敱琛�
-                // 鍔ㄦ�佹坊鍔犲彲璁块棶璺敱琛�
-                router.addRoutes(store.getters.addRouters)
-                const redirect = decodeURIComponent(from.query.redirect || to.path)
-                if (to.path === redirect) {
-                  // hack鏂规硶 纭繚addRoutes宸插畬鎴� ,set the replace: true so the navigation will not leave a history record
-                  next({ ...to, replace: true })
-                } else {
-                  // 璺宠浆鍒扮洰鐨勮矾鐢�
-                  next({ path: redirect })
-                }
-              })
-            })
+            }
+          })
+        })
           .catch(() => {
-           /* notification.error({
-              message: '绯荤粺鎻愮ず',
-              description: '璇锋眰鐢ㄦ埛淇℃伅澶辫触锛岃閲嶈瘯锛�'
-            })*/
+            /* notification.error({
+               message: '绯荤粺鎻愮ず',
+               description: '璇锋眰鐢ㄦ埛淇℃伅澶辫触锛岃閲嶈瘯锛�'
+             })*/
             store.dispatch('Logout').then(() => {
               next({ path: '/user/login', query: { redirect: to.fullPath } })
             })
           })
-      } else {
-        next()
+      }
+      else {
+        // 璺宠浆鍒扮洰鐨勮矾鐢�
+        const postCode = store.getters.userInfo.post
+        //  濡傛灉闈炴搷浣滃伐鐢ㄦ埛涓旇璁块棶鎿嶄綔宸ラ〉闈㈠垯蹇呴』鍏堣烦杞嚦缁堢鐧诲綍椤电櫥褰曞矖浣嶄负鎿嶄綔宸ョ敤鎴锋柟鍙闂�
+        if (to.path !== '/terminal/login' && to.path.split('/')[1] === 'terminal' && postCode !== 'PCR0001') {
+          next({ path: '/terminal/login' })
+        } else {
+          next()
+        }
       }
     }
-  } else {
+  }
+  else {
     if (whiteList.indexOf(to.path) !== -1) {
       // 鍦ㄥ厤鐧诲綍鐧藉悕鍗曪紝濡傛灉杩涘叆鐨勯〉闈㈡槸login椤甸潰骞朵笖褰撳墠鏄疧Auth2app鐜锛屽氨杩涘叆OAuth2鐧诲綍椤甸潰
       if (to.path === '/user/login' && isOAuth2AppEnv()) {
-        next({path: OAUTH2_LOGIN_PAGE_PATH})
+        next({ path: OAUTH2_LOGIN_PAGE_PATH })
       } else {
         // 鍦ㄥ厤鐧诲綍鐧藉悕鍗曪紝鐩存帴杩涘叆
         next()
       }
       NProgress.done()
-    } else {
+    }
+    else {
       // 濡傛灉褰撳墠鏄湪OAuth2APP鐜锛屽氨璺宠浆鍒癘Auth2鐧诲綍椤甸潰
-      let path = isOAuth2AppEnv() ? OAUTH2_LOGIN_PAGE_PATH : '/user/login'
+      let path
+      if (isOAuth2AppEnv()) path = OAUTH2_LOGIN_PAGE_PATH
+      else {
+        if (to.path.split('/')[1] !== 'terminal') path = '/user/login'
+        else path = '/terminal/login'
+      }
       next({ path: path, query: { redirect: to.fullPath } })
       NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
     }

--
Gitblit v1.9.3