diff --git a/src/ant-design.d.ts b/src/ant-design.d.ts new file mode 100644 index 0000000..5ec575f --- /dev/null +++ b/src/ant-design.d.ts @@ -0,0 +1,8 @@ +import * as React from 'react' +import { CustomIconComponentProps } from '@ant-design/icons/es/components/Icon' + +declare global { + type IconComponent = + | React.ComponentType> + | React.ForwardRefExoticComponent +} diff --git a/src/assets/css/pages/tools-framework.scss b/src/assets/css/pages/tools-framework.scss new file mode 100644 index 0000000..d8b6342 --- /dev/null +++ b/src/assets/css/pages/tools-framework.scss @@ -0,0 +1,43 @@ +@use "@/assets/css/constants" as constants; + +.left-panel { + width: 16%; + background-color: constants.$origin-color; + + .title { + font-size: 2em; + text-align: center; + font-weight: bold; + letter-spacing: 0.6em; + padding: 10px; + color: constants.$main-color; + } + + .content { + ul{ + li { + //background-color: #4E47BB; + margin: 4px 10px; + padding: 4px; + &.item { + background-color: #4E47BB; + } + + .separate { + height: 0; + border: { + width: 1px; + color: constants.$font-secondary-color; + style: solid; + }; + opacity: 0.4; + } + } + } + } +} + +.right-panel { + flex: 1; + background-color: constants.$background-color; +} \ No newline at end of file diff --git a/src/vite-env.d.ts b/src/global.d.ts similarity index 91% rename from src/vite-env.d.ts rename to src/global.d.ts index 1311793..aa1a600 100644 --- a/src/vite-env.d.ts +++ b/src/global.d.ts @@ -1,4 +1,5 @@ /// +/// interface ImportMetaEnv { readonly VITE_API_URL: string @@ -16,6 +17,7 @@ type RouteHandle = { titlePrefix?: string title?: string titlePostfix?: string + icon?: IconComponent } type _Response = { diff --git a/src/pages/ToolsFramework.tsx b/src/pages/ToolsFramework.tsx index 96c04ad..f59a243 100644 --- a/src/pages/ToolsFramework.tsx +++ b/src/pages/ToolsFramework.tsx @@ -1,7 +1,127 @@ import React from 'react' +import FitFullScreen from '@/components/common/FitFullScreen' +import '@/assets/css/pages/tools-framework.scss' +import router from '@/router' +import { NavLink } from 'react-router-dom' +import Icon from '@ant-design/icons' const ToolsFramework: React.FC = () => { - return <> + const frameworkRoute = useMatches()[1] + const routeId = frameworkRoute.id + const routeChildren = router.routes[0].children?.find((value) => value.id === routeId)?.children + + return ( + <> + +
+
氦工具
+
+
    +
  • + + isPending ? ' pending' : isActive ? ' active' : '' + } + > + {routeChildren ? ( + <> + + + {(routeChildren[0].handle as RouteHandle).name} + + + ) : ( + '全部工具' + )} + +
    +
  • +
  • +
    +
  • + {routeChildren?.map((route) => { + return (route.handle as RouteHandle).menu && + route.id !== 'tools' ? ( +
  • + + isPending ? 'pending' : isActive ? 'active' : '' + } + > + + + {(route.handle as RouteHandle).name} + + + {route.children ? ( +
      + {route.children.map((subRoute) => { + return (subRoute.handle as RouteHandle).menu ? ( +
    • + + isPending + ? 'pending' + : isActive + ? 'active' + : '' + } + > + + + { + ( + subRoute.handle as RouteHandle + ).name + } + + +
    • + ) : ( + <> + ) + })} +
    + ) : ( + <> + )} +
  • + ) : ( + <> + ) + })} +
+
+
+
+
+ + ) } export default ToolsFramework diff --git a/src/router/index.tsx b/src/router/index.tsx index fe6967e..6c152d4 100644 --- a/src/router/index.tsx +++ b/src/router/index.tsx @@ -26,6 +26,7 @@ const routes: RouteObject[] = [ Component: React.lazy(() => import('@/pages/tools')), handle: { name: '全部工具', + icon: React.lazy(() => import('~icons/fatweb/logo.jsx')), menu: true, auth: false } @@ -34,11 +35,57 @@ const routes: RouteObject[] = [ path: 'translation', id: 'tools-translation', Component: React.lazy(() => import('@/pages/tools/Translation')), + children: [ + { + path: '1', + id: '1', + handle: { + name: '翻译1', + menu: true + } + }, + { + path: '2', + id: '2', + handle: { + name: '翻译2', + menu: true + } + } + ], handle: { name: '翻译', menu: true, auth: true } + }, + { + path: 'translation-', + id: 'tools-translation-', + Component: React.lazy(() => import('@/pages/tools/Translation')), + children: [ + { + path: '1-', + id: '1-', + handle: { + name: '翻译1-', + menu: true + } + }, + { + path: '2-', + id: '2-', + handle: { + name: '翻译2-', + menu: true + } + } + ], + handle: { + name: '翻译-', + menu: true, + auth: true + } } ], handle: {