Parcourir la source

🚑 hotfix: support InspectorWrapper

chenshuai2144 il y a 5 ans
Parent
commit
9862c9430f
2 fichiers modifiés avec 50 ajouts et 39 suppressions
  1. 44 38
      config/routes.ts
  2. 6 1
      src/layouts/BlankLayout.tsx

+ 44 - 38
config/routes.ts

@@ -1,64 +1,70 @@
 export default [
   {
-    path: '/user',
-    component: '../layouts/UserLayout',
+    path: '/',
+    component: '../layouts/BlankLayout',
     routes: [
       {
-        name: 'login',
-        path: '/user/login',
-        component: './user/login',
+        path: '/user',
+        component: '../layouts/UserLayout',
+        routes: [
+          {
+            name: 'login',
+            path: '/user/login',
+            component: './user/login',
+          },
+        ],
       },
-    ],
-  },
-  {
-    path: '/',
-    component: '../layouts/SecurityLayout',
-    routes: [
       {
         path: '/',
-        component: '../layouts/BasicLayout',
-        authority: ['admin', 'user'],
+        component: '../layouts/SecurityLayout',
         routes: [
           {
             path: '/',
-            redirect: '/welcome',
-          },
-          {
-            path: '/welcome',
-            name: 'welcome',
-            icon: 'smile',
-            component: './Welcome',
-          },
-          {
-            path: '/admin',
-            name: 'admin',
-            icon: 'crown',
-            component: './Admin',
-            authority: ['admin'],
+            component: '../layouts/BasicLayout',
+            authority: ['admin', 'user'],
             routes: [
               {
-                path: '/admin/sub-page',
-                name: 'sub-page',
+                path: '/',
+                redirect: '/welcome',
+              },
+              {
+                path: '/welcome',
+                name: 'welcome',
                 icon: 'smile',
                 component: './Welcome',
+              },
+              {
+                path: '/admin',
+                name: 'admin',
+                icon: 'crown',
+                component: './Admin',
                 authority: ['admin'],
+                routes: [
+                  {
+                    path: '/admin/sub-page',
+                    name: 'sub-page',
+                    icon: 'smile',
+                    component: './Welcome',
+                    authority: ['admin'],
+                  },
+                ],
+              },
+              {
+                name: 'list.table-list',
+                icon: 'table',
+                path: '/list',
+                component: './ListTableList',
+              },
+              {
+                component: './404',
               },
             ],
           },
           {
-            name: 'list.table-list',
-            icon: 'table',
-            path: '/list',
-            component: './ListTableList',
-          },
-          {
             component: './404',
           },
         ],
       },
-      {
-        component: './404',
-      },
     ],
   },
   {

+ 6 - 1
src/layouts/BlankLayout.tsx

@@ -1,5 +1,10 @@
 import React from 'react';
+import { Inspector } from 'react-dev-inspector';
 
-const Layout: React.FC = ({ children }) => <>{children}</>;
+const InspectorWrapper = process.env.NODE_ENV === 'development' ? Inspector : React.Fragment;
+
+const Layout: React.FC = ({ children }) => {
+  return <InspectorWrapper>{children}</InspectorWrapper>;
+};
 
 export default Layout;