Browse Source

fix: 修复路由白屏的问题

zhupei 1 năm trước cách đây
mục cha
commit
033add2317
3 tập tin đã thay đổi với 11 bổ sung4 xóa
  1. 2 2
      public/i18n/lang-zh.json
  2. 9 0
      src/router/index.js
  3. 0 2
      src/views/Xiaoshu.vue

+ 2 - 2
public/i18n/lang-zh.json

@@ -5,7 +5,7 @@
   "theme": {
     "light": "亮色模式",
     "dark": "暗色模式",
-    "party": "Party Mode"
+    "party": "党建模式"
   },
   "message": {
     "hello": "欢迎光临"
@@ -488,4 +488,4 @@
     "btn_submit": "保存",
     "warning_not_match": "新密码两次输入不一致,请确认"
   }
-}
+}

+ 9 - 0
src/router/index.js

@@ -51,6 +51,7 @@ router.beforeEach(async (to, from, next) => {
     // 用户已登录
     // 判断动态路由表是否已经生成,若未生成,则生成动态路由表
     if (!hasRouteFlag) {
+      // 路由表未生成,开始生成路由表,并进入目标路由
       const { accessRoutes, accessFlatRoutes, firstAccessibleRoute } = await initializeRoutes();
 
       accessRoutes.forEach((route) => {
@@ -63,6 +64,14 @@ router.beforeEach(async (to, from, next) => {
       hasRouteFlag = true;
       // 路由表已经生成
       // next({ path: firstAccessibleRoute.path, replace: true });
+
+      next({
+        path: to.path,
+        replace: true
+      });
+      return;
+    } else {
+      // 动态路由表已经生成,根据情况判断是否进入目标路由
     }
 
     /**

+ 0 - 2
src/views/Xiaoshu.vue

@@ -1,5 +1,4 @@
 <template>
-  <!-- <LayoutExperience> -->
   <ContentContainer :containerStyle="containerStyle">
     <template v-if="!is_mounted"> </template>
 
@@ -14,7 +13,6 @@
       :plugins="plugins"
     ></WujieVue>
   </ContentContainer>
-  <!-- </LayoutExperience> -->
 </template>
 
 <script setup>