From 15bc0f69a8367a57fa1bf263e615285349ad4ab9 Mon Sep 17 00:00:00 2001 From: Haishan Date: Sun, 13 Sep 2020 16:34:18 +0800 Subject: feat: multi backends management --- src/components/Root.js | 58 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 20 deletions(-) (limited to 'src/components/Root.js') diff --git a/src/components/Root.js b/src/components/Root.js index 6c13163..8c06100 100644 --- a/src/components/Root.js +++ b/src/components/Root.js @@ -1,11 +1,12 @@ import './Root.css'; import React, { lazy, Suspense } from 'react'; -import { HashRouter as Router, Route, Routes } from 'react-router-dom'; +import { HashRouter as Router, useRoutes } from 'react-router-dom'; import { RecoilRoot } from 'recoil'; import { About } from 'src/components/about/About'; import { actions, initialState } from '../store'; +import APIConfig from './APIConfig'; import APIDiscovery from './APIDiscovery'; import ErrorBoundary from './ErrorBoundary'; import Home from './Home'; @@ -52,33 +53,50 @@ const Rules = lazy(() => ); const routes = [ - ['home', '/', ], - ['connections', '/connections', ], - ['configs', '/configs', ], - ['logs', '/logs', ], - ['proxies', '/proxies', ], - ['rules', '/rules', ], - ['about', '/about', ], - __DEV__ ? ['style', '/style', ] : false, + { path: '/', element: }, + { path: '/connections', element: }, + { path: '/configs', element: }, + { path: '/logs', element: }, + { path: '/proxies', element: }, + { path: '/rules', element: }, + { path: '/about', element: }, + __DEV__ ? { path: '/style', element: } : false, ].filter(Boolean); +function RouteInnerApp() { + return useRoutes(routes); +} + +function SideBarApp() { + return ( + <> + + +
+ }> + + +
+ + ); +} + +function App() { + return useRoutes([ + { path: '/backend', element: }, + { path: '*', element: }, + ]); +} + const Root = () => (
- - -
- }> - - {routes.map(([key, path, element]) => ( - - ))} - - -
+ }> + +
-- cgit v1.3.1