shenwu 7 ヶ月 前
コミット
a1a4479bd6
1 ファイル変更4 行追加1 行削除
  1. 4 1
      src/app.tsx

+ 4 - 1
src/app.tsx

@@ -64,7 +64,9 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
         let menu = await getMenu(['book']); //线上获取路由
         let flatMenu = flattenRoutes(menu);
         setInitialState({ ...initialState, menu: flatMenu });
-        history.push(flatMenu[flatMenu['/'].redirect].redirect); //获取到本地路由后跳转到有权限的页面
+        if (!history.location.pathname) {
+          history.push(flatMenu[flatMenu['/'].redirect].redirect); //获取到本地路由后跳转到有权限的页面
+        }
         return menu;
       },
     },
@@ -84,6 +86,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
     },
     // footerRender: () => <Footer />,//页脚
     onPageChange: (location: any) => {
+      sessionStorage.setItem("oldPath", location.pathname)
       //页面发生变化触发
       hasHandledCode300 = false;
       let obj = initialState?.menu || {};