From e4c7bca105e64c047fbcd6bbb53ff5d32b0c5fd6 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Tue, 10 Jun 2025 14:19:29 +0800
Subject: [PATCH] feat:日历去掉今日

---
 src/permission.js |   64 +++++++++++++++++++++++++++++++-
 1 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/src/permission.js b/src/permission.js
index cb2ef3b..c244bec 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -7,6 +7,8 @@
  * @Description:
  * Copyright (c) 2024 by GuLiMmo, All Rights Reserved.
  */
+
+import { getStore } from '@/utils/store'
 import router from './router/'
 import store from './store'
 import { getToken } from '@/utils/auth'
@@ -17,10 +19,70 @@
 const lockPage = '/lock' //锁屏页
 const urlParams = getUrlParams(window.location.href)
 
+function findRouteByPath (routes, targetPath) {
+  // 遍历数组中的每个路由对象
+  for (const route of routes) {
+    // 如果当前路由的path匹配目标路径,直接返回
+    if (route.path === targetPath) {
+      return route
+    }
+
+    // 如果有子路由,递归查找
+    if (route.children && route.children.length > 0) {
+      const foundInChildren = findRouteByPath(route.children, targetPath)
+      if (foundInChildren) {
+        return foundInChildren
+      }
+    }
+  }
+
+  // 遍历完所有路由都没找到,返回null
+  return null
+}
+
 router.beforeEach((to, from, next) => {
   const meta = to.meta || {}
   const isMenu = meta.menu === undefined ? to.query.menu : meta.menu
   store.commit('SET_IS_MENU', isMenu === undefined)
+
+  const menuAll = getStore({ name: 'menuAll' })
+
+  if (!menuAll) {
+    store.dispatch('GetMenu').then(data => {
+      if (data.length !== 0) {
+        router.$avueRouter.formatRoutes(data, true)
+
+        let newMenu = getStore({ name: 'menuAll' })
+
+        let firstMenu = newMenu[0]
+
+        let toMenu = findRouteByPath(newMenu, to.path)
+
+        store.commit('ADD_TAG', {
+          name: firstMenu.name,
+          path: firstMenu.path,
+          fullPath: firstMenu.path,
+          params: firstMenu.params || {},
+          query: firstMenu.query || {},
+          meta: firstMenu.meta || {},
+        })
+
+        store.commit('ADD_TAG', {
+          name: toMenu.name,
+          path: toMenu.path,
+          fullPath: toMenu.path,
+          params: toMenu.params || {},
+          query: toMenu.query || {},
+          meta: toMenu.meta || {},
+        })
+
+        next(to.fullPath)
+      }
+    })
+
+    return
+  }
+
   if (getToken()) {
     if (store.getters.isLock && to.path !== lockPage) {
       //如果系统激活锁屏,全部跳转到锁屏页
@@ -41,8 +103,6 @@
           window.open(query.url.replace(/#/g, '&'))
           return
         } else if (meta.isTab !== false) {
-          console.log(meta, 111111)
-
           store.commit('ADD_TAG', {
             name: query.name || to.name,
             path: to.path,

--
Gitblit v1.9.3