@skyroc/scripts 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +508 -0
- package/dist/cli.mjs +78 -0
- package/dist/config-BKkdncJS.mjs +987 -0
- package/dist/index.mjs +14 -0
- package/package.json +83 -0
- package/templates/admin/.env +62 -0
- package/templates/admin/.env.prod +7 -0
- package/templates/admin/.env.test +7 -0
- package/templates/admin/.oxlintrc.json +6 -0
- package/templates/admin/README.md +508 -0
- package/templates/admin/index.html +14 -0
- package/templates/admin/package.json +105 -0
- package/templates/admin/public/favicon.svg +3 -0
- package/templates/admin/src/App.tsx +71 -0
- package/templates/admin/src/assets/audio/wechat-style-notification.wav +0 -0
- package/templates/admin/src/assets/imgs/skyroc.jpg +0 -0
- package/templates/admin/src/assets/svg-icon/activity.svg +1 -0
- package/templates/admin/src/assets/svg-icon/at-sign.svg +1 -0
- package/templates/admin/src/assets/svg-icon/avatar.svg +1 -0
- package/templates/admin/src/assets/svg-icon/banner.svg +1 -0
- package/templates/admin/src/assets/svg-icon/cast.svg +1 -0
- package/templates/admin/src/assets/svg-icon/chrome.svg +1 -0
- package/templates/admin/src/assets/svg-icon/copy.svg +1 -0
- package/templates/admin/src/assets/svg-icon/custom-icon.svg +1 -0
- package/templates/admin/src/assets/svg-icon/empty-data.svg +1 -0
- package/templates/admin/src/assets/svg-icon/error.svg +1 -0
- package/templates/admin/src/assets/svg-icon/expectation.svg +1 -0
- package/templates/admin/src/assets/svg-icon/heart.svg +1 -0
- package/templates/admin/src/assets/svg-icon/logo.svg +15 -0
- package/templates/admin/src/assets/svg-icon/network-error.svg +1 -0
- package/templates/admin/src/assets/svg-icon/no-icon.svg +1 -0
- package/templates/admin/src/assets/svg-icon/no-permission.svg +1 -0
- package/templates/admin/src/assets/svg-icon/not-found.svg +1 -0
- package/templates/admin/src/assets/svg-icon/service-error.svg +1 -0
- package/templates/admin/src/bootstrap.tsx +60 -0
- package/templates/admin/src/components/SkyrocAvatar.tsx +13 -0
- package/templates/admin/src/components/SystemLogo.tsx +7 -0
- package/templates/admin/src/config.ts +125 -0
- package/templates/admin/src/features/antd/AntdProvider.tsx +21 -0
- package/templates/admin/src/features/auth/components/UserAvatar.tsx +76 -0
- package/templates/admin/src/features/auth/use-auth-form-rules.ts +83 -0
- package/templates/admin/src/features/auth/use-auth.ts +96 -0
- package/templates/admin/src/features/auth/use-login.ts +72 -0
- package/templates/admin/src/features/effects/GlobalEffect.tsx +15 -0
- package/templates/admin/src/features/menus/dynamic-routes.ts +10 -0
- package/templates/admin/src/features/menus/extras.ts +3 -0
- package/templates/admin/src/features/menus/menu-category.ts +14 -0
- package/templates/admin/src/features/menus/menu-config.ts +5 -0
- package/templates/admin/src/features/router/RouterProvider.tsx +18 -0
- package/templates/admin/src/features/router/guard.ts +97 -0
- package/templates/admin/src/features/router/index.ts +52 -0
- package/templates/admin/src/features/router/routeTree.gen.ts +237 -0
- package/templates/admin/src/features/router/router-ref.ts +24 -0
- package/templates/admin/src/locales/antd.ts +8 -0
- package/templates/admin/src/locales/index.ts +22 -0
- package/templates/admin/src/locales/sync.ts +14 -0
- package/templates/admin/src/main.tsx +9 -0
- package/templates/admin/src/pages/(admin)/home/index.tsx +46 -0
- package/templates/admin/src/pages/(admin)/layout.tsx +44 -0
- package/templates/admin/src/pages/(auth)/login/index.tsx +102 -0
- package/templates/admin/src/pages/(auth)/login/layout.tsx +71 -0
- package/templates/admin/src/pages/(auth)/login-out.tsx +27 -0
- package/templates/admin/src/pages/(errors)/403.tsx +16 -0
- package/templates/admin/src/pages/(errors)/404.tsx +16 -0
- package/templates/admin/src/pages/(errors)/500.tsx +16 -0
- package/templates/admin/src/pages/__root.tsx +54 -0
- package/templates/admin/src/pages/error.tsx +19 -0
- package/templates/admin/src/pages/index.tsx +14 -0
- package/templates/admin/src/pages/loading.tsx +45 -0
- package/templates/admin/src/pages/not-found.tsx +9 -0
- package/templates/admin/src/plugins/app.tsx +47 -0
- package/templates/admin/src/plugins/assets.ts +4 -0
- package/templates/admin/src/plugins/index.ts +32 -0
- package/templates/admin/src/service/adapter.ts +63 -0
- package/templates/admin/src/service/api/auth/api.ts +31 -0
- package/templates/admin/src/service/api/auth/hooks.ts +28 -0
- package/templates/admin/src/service/api/auth/index.ts +10 -0
- package/templates/admin/src/service/api/auth/keys.ts +7 -0
- package/templates/admin/src/service/api/auth/urls.ts +7 -0
- package/templates/admin/src/service/api/index.ts +2 -0
- package/templates/admin/src/service/api/route/api.ts +7 -0
- package/templates/admin/src/service/api/route/hooks.ts +21 -0
- package/templates/admin/src/service/api/route/index.ts +10 -0
- package/templates/admin/src/service/api/route/keys.ts +3 -0
- package/templates/admin/src/service/api/route/urls.ts +5 -0
- package/templates/admin/src/service/queryClient.ts +13 -0
- package/templates/admin/src/service/request/index.ts +62 -0
- package/templates/admin/src/styles/scss/global.scss +1 -0
- package/templates/admin/src/styles/scss/scrollbar.scss +28 -0
- package/templates/admin/src/types/auto-imports.d.ts +186 -0
- package/templates/admin/src/types/global.d.ts +16 -0
- package/templates/admin/src/types/router.d.ts +14 -0
- package/templates/admin/src/types/storage.d.ts +17 -0
- package/templates/admin/src/types/vite-env.d.ts +117 -0
- package/templates/admin/src/utils/common.tsx +38 -0
- package/templates/admin/src/utils/icon.ts +9 -0
- package/templates/admin/src/utils/service.ts +75 -0
- package/templates/admin/src/utils/storage.ts +7 -0
- package/templates/admin/tsconfig.json +22 -0
- package/templates/admin/uno.config.ts +18 -0
- package/templates/admin/vite.config.ts +13 -0
- package/templates/admin-shell/i18n/atoms/lang.ts +20 -0
- package/templates/admin-shell/i18n/config/default.ts +11 -0
- package/templates/admin-shell/i18n/features/lang/LangEffect.tsx +25 -0
- package/templates/admin-shell/i18n/features/lang/LangSwitch.tsx +49 -0
- package/templates/admin-shell/i18n/hooks/use-lang.ts +47 -0
- package/templates/admin-shell/i18n/i18n.ts +116 -0
- package/templates/admin-shell/i18n/index.ts +23 -0
- package/templates/admin-shell/i18n/langs/en-us/common.json +49 -0
- package/templates/admin-shell/i18n/langs/en-us/datatable.json +8 -0
- package/templates/admin-shell/i18n/langs/en-us/dropdown.json +9 -0
- package/templates/admin-shell/i18n/langs/en-us/form.json +27 -0
- package/templates/admin-shell/i18n/langs/en-us/icon.json +13 -0
- package/templates/admin-shell/i18n/langs/en-us/notification.json +20 -0
- package/templates/admin-shell/i18n/langs/en-us/page.json +442 -0
- package/templates/admin-shell/i18n/langs/en-us/request.json +8 -0
- package/templates/admin-shell/i18n/langs/en-us/route.json +84 -0
- package/templates/admin-shell/i18n/langs/en-us/system.json +9 -0
- package/templates/admin-shell/i18n/langs/en-us/theme.json +173 -0
- package/templates/admin-shell/i18n/langs/index.ts +63 -0
- package/templates/admin-shell/i18n/langs/zh-cn/common.json +49 -0
- package/templates/admin-shell/i18n/langs/zh-cn/datatable.json +8 -0
- package/templates/admin-shell/i18n/langs/zh-cn/dropdown.json +9 -0
- package/templates/admin-shell/i18n/langs/zh-cn/form.json +27 -0
- package/templates/admin-shell/i18n/langs/zh-cn/icon.json +13 -0
- package/templates/admin-shell/i18n/langs/zh-cn/notification.json +20 -0
- package/templates/admin-shell/i18n/langs/zh-cn/page.json +442 -0
- package/templates/admin-shell/i18n/langs/zh-cn/request.json +8 -0
- package/templates/admin-shell/i18n/langs/zh-cn/route.json +84 -0
- package/templates/admin-shell/i18n/langs/zh-cn/system.json +9 -0
- package/templates/admin-shell/i18n/langs/zh-cn/theme.json +173 -0
- package/templates/admin-shell/i18n/types/i18n.ts +29 -0
- package/templates/admin-shell/i18n/types.ts +53 -0
- package/templates/admin-shell/i18n/utils/helpers.ts +18 -0
- package/templates/admin-shell/layouts/AdminLayout.tsx +161 -0
- package/templates/admin-shell/layouts/constant.ts +56 -0
- package/templates/admin-shell/layouts/context.tsx +101 -0
- package/templates/admin-shell/layouts/features/menus/MenuBadge.tsx +76 -0
- package/templates/admin-shell/layouts/features/menus/dynamic-routes.ts +146 -0
- package/templates/admin-shell/layouts/features/menus/menu-generator.tsx +444 -0
- package/templates/admin-shell/layouts/features/menus/menu-renderer.tsx +149 -0
- package/templates/admin-shell/layouts/features/menus/permissions.ts +28 -0
- package/templates/admin-shell/layouts/features/menus/use-menus.ts +98 -0
- package/templates/admin-shell/layouts/features/use-route.ts +30 -0
- package/templates/admin-shell/layouts/index.ts +44 -0
- package/templates/admin-shell/layouts/materials/index.ts +6 -0
- package/templates/admin-shell/layouts/materials/libs/admin-layout/index.module.css +63 -0
- package/templates/admin-shell/layouts/materials/libs/admin-layout/index.module.css.d.ts +18 -0
- package/templates/admin-shell/layouts/materials/libs/admin-layout/index.tsx +238 -0
- package/templates/admin-shell/layouts/materials/libs/admin-layout/shared.ts +67 -0
- package/templates/admin-shell/layouts/materials/libs/page-tab/ButtonTab.tsx +44 -0
- package/templates/admin-shell/layouts/materials/libs/page-tab/ChromeTab.tsx +54 -0
- package/templates/admin-shell/layouts/materials/libs/page-tab/ChromeTabBg.tsx +30 -0
- package/templates/admin-shell/layouts/materials/libs/page-tab/SliderTab.tsx +44 -0
- package/templates/admin-shell/layouts/materials/libs/page-tab/SvgClose.tsx +51 -0
- package/templates/admin-shell/layouts/materials/libs/page-tab/hook.ts +34 -0
- package/templates/admin-shell/layouts/materials/libs/page-tab/index.module.css +120 -0
- package/templates/admin-shell/layouts/materials/libs/page-tab/index.module.css.d.ts +18 -0
- package/templates/admin-shell/layouts/materials/libs/page-tab/index.tsx +76 -0
- package/templates/admin-shell/layouts/materials/libs/page-tab/shared.ts +32 -0
- package/templates/admin-shell/layouts/materials/types/index.ts +322 -0
- package/templates/admin-shell/layouts/modules/AdminContent.tsx +285 -0
- package/templates/admin-shell/layouts/modules/AdminFooter.tsx +13 -0
- package/templates/admin-shell/layouts/modules/AdminLogo.tsx +28 -0
- package/templates/admin-shell/layouts/modules/AdminSider.tsx +50 -0
- package/templates/admin-shell/layouts/modules/admin-header/AdminHeader.tsx +132 -0
- package/templates/admin-shell/layouts/modules/admin-header/components/Breadcrumb.tsx +62 -0
- package/templates/admin-shell/layouts/modules/admin-header/components/ThemeButton.tsx +24 -0
- package/templates/admin-shell/layouts/modules/admin-menu/AdminMenu.tsx +37 -0
- package/templates/admin-shell/layouts/modules/admin-menu/components/FirstLevelMenu.tsx +156 -0
- package/templates/admin-shell/layouts/modules/admin-menu/components/HorizontalMenu.tsx +88 -0
- package/templates/admin-shell/layouts/modules/admin-menu/components/MenuPortal.tsx +28 -0
- package/templates/admin-shell/layouts/modules/admin-menu/components/VerticalMenu.tsx +123 -0
- package/templates/admin-shell/layouts/modules/admin-menu/enum.ts +47 -0
- package/templates/admin-shell/layouts/modules/admin-menu/modules/Horizontal.tsx +22 -0
- package/templates/admin-shell/layouts/modules/admin-menu/modules/TopHybridHeaderFirst.tsx +15 -0
- package/templates/admin-shell/layouts/modules/admin-menu/modules/TopHybridSidebarFirst.tsx +18 -0
- package/templates/admin-shell/layouts/modules/admin-menu/modules/Vertical.tsx +14 -0
- package/templates/admin-shell/layouts/modules/admin-menu/modules/VerticalHybridHeaderFirst.tsx +18 -0
- package/templates/admin-shell/layouts/modules/admin-menu/modules/VerticalMix.tsx +132 -0
- package/templates/admin-shell/layouts/modules/admin-search/AdminSearch.tsx +36 -0
- package/templates/admin-shell/layouts/modules/admin-search/components/SearchFooter.tsx +38 -0
- package/templates/admin-shell/layouts/modules/admin-search/components/SearchModal.tsx +171 -0
- package/templates/admin-shell/layouts/modules/admin-search/components/SearchResult.tsx +43 -0
- package/templates/admin-shell/layouts/modules/admin-tab/AdminTab.tsx +125 -0
- package/templates/admin-shell/layouts/modules/admin-tab/components/TabContextMenu.tsx +107 -0
- package/templates/admin-shell/layouts/modules/admin-tab/hooks/useTabScroll.ts +86 -0
- package/templates/admin-shell/layouts/modules/shared/logo.ts +42 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/ThemeDrawer.tsx +68 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/components/AnimatedCollapse.tsx +36 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/components/AnimatedItem.tsx +35 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/components/LayoutModeCard.tsx +110 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/components/SettingItem.tsx +31 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/ConfigOperation.tsx +53 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/CustomPicker.tsx +105 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/ThemeColor.tsx +58 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/ThemeSchema.tsx +42 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/ThemeToken.tsx +44 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/index.tsx +23 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/general/GlobalSettings.tsx +57 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/general/ThemeGeneral.tsx +20 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/general/WatermarkSettings.tsx +103 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/ContentSettings.tsx +100 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/FooterSettings.tsx +71 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/HeaderSettings.tsx +63 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/LayoutMode.tsx +73 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/SiderSettings.tsx +124 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/TabSettings.tsx +95 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/ThemeLayout.tsx +32 -0
- package/templates/admin-shell/layouts/modules/theme-drawer/modules/preset/ThemePreset.tsx +132 -0
- package/templates/admin-shell/layouts/options.tsx +79 -0
- package/templates/admin-shell/layouts/setup.ts +102 -0
- package/templates/admin-shell/layouts/state/AdminEffect.tsx +56 -0
- package/templates/admin-shell/layouts/state/AdminTabEffect.tsx +28 -0
- package/templates/admin-shell/layouts/state/index.ts +3 -0
- package/templates/admin-shell/layouts/state/menus/MenuToggler.tsx +53 -0
- package/templates/admin-shell/layouts/state/menus/use-admin-menu-badges.ts +46 -0
- package/templates/admin-shell/layouts/state/menus/use-admin-menus.tsx +164 -0
- package/templates/admin-shell/layouts/state/tabs/index.ts +1 -0
- package/templates/admin-shell/layouts/state/tabs/shared.tsx +148 -0
- package/templates/admin-shell/layouts/state/tabs/use-admin-tab.ts +377 -0
- package/templates/admin-shell/layouts/state/use-admin-state.ts +118 -0
- package/templates/admin-shell/layouts/types/router.d.ts +10 -0
- package/templates/admin-shell/layouts/types/storage.ts +18 -0
- package/templates/admin-shell/notification/NotificationButton.tsx +91 -0
- package/templates/admin-shell/notification/NotificationContext.ts +8 -0
- package/templates/admin-shell/notification/NotificationPanel.tsx +194 -0
- package/templates/admin-shell/notification/NotificationProvider.tsx +59 -0
- package/templates/admin-shell/notification/index.ts +12 -0
- package/templates/admin-shell/notification/mock.ts +59 -0
- package/templates/admin-shell/notification/notification-store.ts +438 -0
- package/templates/admin-shell/notification/notification.css +60 -0
- package/templates/admin-shell/notification/types.ts +104 -0
- package/templates/admin-shell/notification/use-notification.ts +51 -0
- package/templates/admin-shell/notification/useNotificationContext.ts +14 -0
- package/templates/admin-shell/runtime/app-update.ts +156 -0
- package/templates/admin-shell/runtime/dayjs.ts +20 -0
- package/templates/admin-shell/runtime/iconify.ts +17 -0
- package/templates/admin-shell/runtime/index.ts +10 -0
- package/templates/admin-shell/runtime/nprogress.ts +25 -0
- package/templates/admin-shell/runtime/plugins.ts +62 -0
- package/templates/admin-shell/styles/global.css +54 -0
- package/templates/admin-shell/styles/nprogress.css +85 -0
- package/templates/admin-shell/styles/reset.css +378 -0
- package/templates/admin-shell/theme/antd/AntdProvider.tsx +106 -0
- package/templates/admin-shell/theme/antd/index.ts +23 -0
- package/templates/admin-shell/theme/antd/shared.ts +80 -0
- package/templates/admin-shell/theme/antd/ui.ts +250 -0
- package/templates/admin-shell/theme/antd-algorithm/algorithm/dark/colors.ts +99 -0
- package/templates/admin-shell/theme/antd-algorithm/algorithm/dark/index.ts +87 -0
- package/templates/admin-shell/theme/antd-algorithm/algorithm/default/colors.ts +91 -0
- package/templates/admin-shell/theme/antd-algorithm/algorithm/default/index.ts +77 -0
- package/templates/admin-shell/theme/antd-algorithm/index.ts +80 -0
- package/templates/admin-shell/theme/antd-algorithm/seed/index.ts +41 -0
- package/templates/admin-shell/theme/antd-algorithm/shared/colorAlgorithm.ts +10 -0
- package/templates/admin-shell/theme/antd-algorithm/shared/genColorMapToken.ts +165 -0
- package/templates/admin-shell/theme/antd-algorithm/shared/genCommonMapToken.ts +23 -0
- package/templates/admin-shell/theme/antd-algorithm/shared/genControlHeight.ts +14 -0
- package/templates/admin-shell/theme/antd-algorithm/shared/genFontMapToken.ts +274 -0
- package/templates/admin-shell/theme/antd-algorithm/shared/genRadiusMapToken.ts +139 -0
- package/templates/admin-shell/theme/antd-algorithm/shared/genSizeMapToken.ts +114 -0
- package/templates/admin-shell/theme/antd-algorithm/types/index.ts +20 -0
- package/templates/admin-shell/theme/components/ThemeEffect.tsx +55 -0
- package/templates/admin-shell/theme/components/ThemeSchemaSegmented.tsx +27 -0
- package/templates/admin-shell/theme/components/ThemeSchemaSwitch.tsx +77 -0
- package/templates/admin-shell/theme/components/shared.ts +5 -0
- package/templates/admin-shell/theme/config/default.ts +108 -0
- package/templates/admin-shell/theme/config/index.ts +1 -0
- package/templates/admin-shell/theme/hooks/index.ts +2 -0
- package/templates/admin-shell/theme/hooks/use-theme.ts +244 -0
- package/templates/admin-shell/theme/index.ts +78 -0
- package/templates/admin-shell/theme/presets/azir.json +39 -0
- package/templates/admin-shell/theme/presets/compact.json +38 -0
- package/templates/admin-shell/theme/presets/dark.json +93 -0
- package/templates/admin-shell/theme/presets/default.json +95 -0
- package/templates/admin-shell/theme/presets/index.ts +29 -0
- package/templates/admin-shell/theme/presets/shadcn.json +99 -0
- package/templates/admin-shell/theme/setup.ts +115 -0
- package/templates/admin-shell/theme/types/index.ts +27 -0
- package/templates/admin-shell/theme/types/theme.d.ts +316 -0
- package/templates/admin-shell/theme/utils/dark-mode.ts +46 -0
- package/templates/admin-shell/theme/utils/filters.ts +20 -0
- package/templates/admin-shell/theme/utils/index.ts +3 -0
- package/templates/admin-shell/theme/utils/settings.ts +43 -0
- package/templates/admin-shell/types/api/auth.d.ts +148 -0
- package/templates/admin-shell/types/api/common.d.ts +54 -0
- package/templates/admin-shell/types/api/route.d.ts +104 -0
- package/templates/admin-shell/types/api/service.d.ts +51 -0
- package/templates/admin-shell/types/api/system-manage.d.ts +160 -0
- package/templates/admin-shell/types/app/common.d.ts +31 -0
- package/templates/admin-shell/types/app/global.d.ts +71 -0
- package/templates/admin-shell/types/app/menu.d.ts +57 -0
- package/templates/admin-shell/types/app/router.d.ts +201 -0
- package/templates/admin-shell/types/app/storage.d.ts +10 -0
- package/templates/admin-shell/types/app/union-key.d.ts +156 -0
- package/templates/admin-shell/types/locales/i18n.d.ts +135 -0
- package/templates/admin-shell/ui/antd/components/AppTree.tsx +62 -0
- package/templates/admin-shell/ui/antd/components/BeyondHiding.tsx +42 -0
- package/templates/admin-shell/ui/antd/components/ButtonIcon.tsx +123 -0
- package/templates/admin-shell/ui/antd/components/ButtonLink.tsx +30 -0
- package/templates/admin-shell/ui/antd/components/ErrorBoundary.tsx +45 -0
- package/templates/admin-shell/ui/antd/components/ExceptionBase.tsx +69 -0
- package/templates/admin-shell/ui/antd/components/FullScreen.tsx +33 -0
- package/templates/admin-shell/ui/antd/components/PinToggler.tsx +35 -0
- package/templates/admin-shell/ui/antd/components/ReloadButton.tsx +20 -0
- package/templates/admin-shell/ui/antd/components/index.ts +12 -0
- package/templates/admin-shell/ui/antd/components/styles/button-icon-animations.css +246 -0
- package/templates/admin-shell/ui/antd/index.ts +1 -0
- package/templates/admin-shell/ui/antd/styles.d.ts +1 -0
- package/templates/admin-shell/ui/compose/animate-feature.ts +5 -0
- package/templates/admin-shell/ui/compose/components/BetterScroll.tsx +51 -0
- package/templates/admin-shell/ui/compose/components/DarkModeContainer.tsx +22 -0
- package/templates/admin-shell/ui/compose/components/FlipText.tsx +41 -0
- package/templates/admin-shell/ui/compose/components/I18nLabel.tsx +18 -0
- package/templates/admin-shell/ui/compose/components/LazyAnimate.tsx +10 -0
- package/templates/admin-shell/ui/compose/components/LookForward.tsx +24 -0
- package/templates/admin-shell/ui/compose/components/NumberTicker.tsx +105 -0
- package/templates/admin-shell/ui/compose/components/Portal.tsx +74 -0
- package/templates/admin-shell/ui/compose/components/SvgIcon.tsx +39 -0
- package/templates/admin-shell/ui/compose/components/TypingAnimation.tsx +83 -0
- package/templates/admin-shell/ui/compose/components/WaveBg.tsx +56 -0
- package/templates/admin-shell/ui/compose/components/index.ts +11 -0
- package/templates/admin-shell/ui/compose/index.ts +2 -0
- package/templates/admin-shell/ui/compose/table/DragContent.tsx +239 -0
- package/templates/admin-shell/ui/compose/table/TableHeaderOperation.tsx +210 -0
- package/templates/admin-shell/ui/compose/table/hooks.ts +196 -0
- package/templates/admin-shell/ui/compose/table/index.ts +16 -0
- package/templates/admin-shell/ui/compose/table/types.ts +244 -0
- package/templates/admin-shell/ui/compose/table/use-table-operate.ts +136 -0
- package/templates/admin-shell/ui/compose/table/use-table-scroll.ts +49 -0
- package/templates/admin-shell/ui/compose/table/use-table.ts +303 -0
- package/templates/admin.meta.json +756 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { LangSwitch } from '@shell/i18n';
|
|
2
|
+
import { ThemeSchemaSwitch, useSettingsTheme } from '@shell/theme';
|
|
3
|
+
import { FullScreen } from '@shell/ui/antd';
|
|
4
|
+
import { DarkModeContainer } from '@shell/ui/compose';
|
|
5
|
+
import { useFullscreen } from 'ahooks';
|
|
6
|
+
import { memo } from 'react';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
GLOBAL_HEADER_MENU_ID,
|
|
11
|
+
LAYOUT_MODE_HORIZONTAL,
|
|
12
|
+
LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST,
|
|
13
|
+
LAYOUT_MODE_TOP_HYBRID_SIDEBAR_FIRST,
|
|
14
|
+
LAYOUT_MODE_VERTICAL,
|
|
15
|
+
LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST,
|
|
16
|
+
LAYOUT_MODE_VERTICAL_MIX
|
|
17
|
+
} from '../../constant';
|
|
18
|
+
import { useAdminLayoutContext } from '../../context';
|
|
19
|
+
import MenuToggler from '../../state/menus/MenuToggler';
|
|
20
|
+
import { useAdminMenus } from '../../state/menus/use-admin-menus';
|
|
21
|
+
import { useAdminState } from '../../state/use-admin-state';
|
|
22
|
+
import AdminSearch from '../admin-search/AdminSearch';
|
|
23
|
+
import LayoutLogo from '../shared/logo';
|
|
24
|
+
|
|
25
|
+
import AdminBreadcrumb from './components/Breadcrumb';
|
|
26
|
+
import ThemeButton from './components/ThemeButton';
|
|
27
|
+
|
|
28
|
+
const GlobalHeader = memo(() => {
|
|
29
|
+
const { headerLeftActions, headerMiddleActions, headerRightActions, logo, logoComponent, logoTitle, logoTo } =
|
|
30
|
+
useAdminLayoutContext();
|
|
31
|
+
|
|
32
|
+
const [isFullscreen, { toggleFullscreen }] = useFullscreen(document.body);
|
|
33
|
+
|
|
34
|
+
const { isActiveFirstLevelMenuHasChildren } = useAdminMenus();
|
|
35
|
+
|
|
36
|
+
const { t } = useTranslation();
|
|
37
|
+
|
|
38
|
+
const { header, layout, sider } = useSettingsTheme();
|
|
39
|
+
|
|
40
|
+
const { isMobile } = useAdminState();
|
|
41
|
+
|
|
42
|
+
const siderWidth = sider.width;
|
|
43
|
+
|
|
44
|
+
const mode = layout.mode;
|
|
45
|
+
|
|
46
|
+
const HEADER_PROPS_CONFIG: Record<UnionKey.ThemeLayoutMode, App.Global.AdminLayout.HeaderProps> = {
|
|
47
|
+
[LAYOUT_MODE_VERTICAL]: {
|
|
48
|
+
showLogo: false,
|
|
49
|
+
showMenu: false,
|
|
50
|
+
showMenuToggler: true
|
|
51
|
+
},
|
|
52
|
+
[LAYOUT_MODE_VERTICAL_MIX]: {
|
|
53
|
+
showLogo: false,
|
|
54
|
+
showMenu: false,
|
|
55
|
+
showMenuToggler: false
|
|
56
|
+
},
|
|
57
|
+
[LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST]: {
|
|
58
|
+
showLogo: !isActiveFirstLevelMenuHasChildren,
|
|
59
|
+
showMenu: true,
|
|
60
|
+
showMenuToggler: false
|
|
61
|
+
},
|
|
62
|
+
[LAYOUT_MODE_HORIZONTAL]: {
|
|
63
|
+
showLogo: true,
|
|
64
|
+
showMenu: true,
|
|
65
|
+
showMenuToggler: false
|
|
66
|
+
},
|
|
67
|
+
[LAYOUT_MODE_TOP_HYBRID_SIDEBAR_FIRST]: {
|
|
68
|
+
showLogo: true,
|
|
69
|
+
showMenu: true,
|
|
70
|
+
showMenuToggler: false
|
|
71
|
+
},
|
|
72
|
+
[LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST]: {
|
|
73
|
+
showLogo: true,
|
|
74
|
+
showMenu: true,
|
|
75
|
+
showMenuToggler: isActiveFirstLevelMenuHasChildren
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const { showLogo, showMenu, showMenuToggler } = HEADER_PROPS_CONFIG[mode];
|
|
80
|
+
|
|
81
|
+
const hasLogo = Boolean(logo || logoComponent || logoTitle);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<DarkModeContainer className="h-full flex-y-center px-12px shadow-header">
|
|
85
|
+
{showLogo && hasLogo ? (
|
|
86
|
+
<LayoutLogo
|
|
87
|
+
logo={logo}
|
|
88
|
+
logoComponent={logoComponent}
|
|
89
|
+
style={{ width: `${siderWidth}px` }}
|
|
90
|
+
title={logoTitle}
|
|
91
|
+
to={logoTo}
|
|
92
|
+
/>
|
|
93
|
+
) : null}
|
|
94
|
+
|
|
95
|
+
{showMenuToggler && <MenuToggler />}
|
|
96
|
+
|
|
97
|
+
<div className="h-full flex-y-center flex-1-hidden" id={GLOBAL_HEADER_MENU_ID}>
|
|
98
|
+
{!isMobile && !showMenu && <AdminBreadcrumb />}
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<div className="h-full flex-y-center justify-end">
|
|
102
|
+
|
|
103
|
+
{headerLeftActions}
|
|
104
|
+
|
|
105
|
+
<AdminSearch />
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
{!isMobile && (
|
|
109
|
+
<FullScreen
|
|
110
|
+
className="px-12px"
|
|
111
|
+
enterTooltip={t('icon.fullscreen')}
|
|
112
|
+
exitTooltip={t('icon.fullscreenExit')}
|
|
113
|
+
full={isFullscreen}
|
|
114
|
+
toggleFullscreen={toggleFullscreen}
|
|
115
|
+
/>
|
|
116
|
+
)}
|
|
117
|
+
|
|
118
|
+
<LangSwitch className="px-12px" visible={header.multilingual.visible} />
|
|
119
|
+
|
|
120
|
+
{headerMiddleActions}
|
|
121
|
+
|
|
122
|
+
<ThemeSchemaSwitch className="px-12px" tooltipContent={t('icon.themeSchema')} />
|
|
123
|
+
|
|
124
|
+
<ThemeButton />
|
|
125
|
+
|
|
126
|
+
{headerRightActions}
|
|
127
|
+
</div>
|
|
128
|
+
</DarkModeContainer>
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
export default GlobalHeader;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { I18nLabel, SvgIcon } from '@shell/ui/compose';
|
|
2
|
+
import { Link } from '@tanstack/react-router';
|
|
3
|
+
import { Breadcrumb as ABreadcrumb, type BreadcrumbProps } from 'antd';
|
|
4
|
+
|
|
5
|
+
import { getAdminLayoutsOptions } from '../../../setup';
|
|
6
|
+
import { useAdminMenus } from '../../../state/menus/use-admin-menus';
|
|
7
|
+
|
|
8
|
+
const itemRender: BreadcrumbProps['itemRender'] = (currentRoute, _, items) => {
|
|
9
|
+
const isLast = currentRoute?.path === items[items.length - 1]?.path;
|
|
10
|
+
|
|
11
|
+
return isLast ? (
|
|
12
|
+
<div className="flex-y-center text-base-text">{currentRoute.title}</div>
|
|
13
|
+
) : (
|
|
14
|
+
<Link className="inline-flex! items-center whitespace-nowrap hover:text-base-text!" to={currentRoute.path}>
|
|
15
|
+
{currentRoute.title}
|
|
16
|
+
</Link>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const AdminBreadcrumb = () => {
|
|
21
|
+
const { activeMenu, currentMenu, getMenuInfoByPath, home, openKeys, selectedKey } = useAdminMenus();
|
|
22
|
+
const { defaultIcon } = getAdminLayoutsOptions();
|
|
23
|
+
|
|
24
|
+
const isHome = selectedKey[0] === home;
|
|
25
|
+
|
|
26
|
+
const allBreadcrumb = [
|
|
27
|
+
isHome ? null : home,
|
|
28
|
+
...openKeys,
|
|
29
|
+
...selectedKey,
|
|
30
|
+
activeMenu ? currentMenu?.key : null
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const breadcrumb = allBreadcrumb
|
|
34
|
+
.map(key => {
|
|
35
|
+
if (!key) return null;
|
|
36
|
+
|
|
37
|
+
const menuInfo = getMenuInfoByPath(key as Router.RoutePath);
|
|
38
|
+
|
|
39
|
+
if (!menuInfo) return null;
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
title: (
|
|
43
|
+
<>
|
|
44
|
+
<SvgIcon
|
|
45
|
+
className="text-icon mr-4px"
|
|
46
|
+
icon={menuInfo.menu?.icon || defaultIcon}
|
|
47
|
+
localIcon={menuInfo.menu?.localIcon}
|
|
48
|
+
/>
|
|
49
|
+
<span>
|
|
50
|
+
<I18nLabel fallback={menuInfo.title} i18nKey={menuInfo.i18nKey} />
|
|
51
|
+
</span>
|
|
52
|
+
</>
|
|
53
|
+
),
|
|
54
|
+
path: menuInfo?.path
|
|
55
|
+
};
|
|
56
|
+
})
|
|
57
|
+
.filter(Boolean) as BreadcrumbProps['items'];
|
|
58
|
+
|
|
59
|
+
return <ABreadcrumb className="ml-12px" itemRender={itemRender} items={breadcrumb} />;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default AdminBreadcrumb;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ButtonIcon } from '@shell/ui/antd';
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
|
|
5
|
+
import { useAdminState } from '../../../state/use-admin-state';
|
|
6
|
+
|
|
7
|
+
const ThemeButton = memo(() => {
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
|
|
10
|
+
const { openThemeDrawer } = useAdminState();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<ButtonIcon
|
|
14
|
+
triggerParent
|
|
15
|
+
className="px-12px"
|
|
16
|
+
hoverAnimation="pulse"
|
|
17
|
+
icon="majesticons:color-swatch-line"
|
|
18
|
+
tooltipContent={t('icon.themeConfig')}
|
|
19
|
+
onClick={openThemeDrawer}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export default ThemeButton;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useSettingsTheme } from '@shell/theme';
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
LAYOUT_MODE_HORIZONTAL,
|
|
6
|
+
LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST,
|
|
7
|
+
LAYOUT_MODE_VERTICAL,
|
|
8
|
+
LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST,
|
|
9
|
+
LAYOUT_MODE_VERTICAL_MIX
|
|
10
|
+
} from '../../constant';
|
|
11
|
+
|
|
12
|
+
import HorizontalMenu from './modules/Horizontal';
|
|
13
|
+
import TopHybridHeaderFirst from './modules/TopHybridHeaderFirst';
|
|
14
|
+
import TopHybridSidebarFirst from './modules/TopHybridSidebarFirst';
|
|
15
|
+
import VerticalMenu from './modules/Vertical';
|
|
16
|
+
import VerticalHybridHeaderFirst from './modules/VerticalHybridHeaderFirst';
|
|
17
|
+
import VerticalMix from './modules/VerticalMix';
|
|
18
|
+
|
|
19
|
+
const AdminMenu = memo(() => {
|
|
20
|
+
const {
|
|
21
|
+
layout: { mode }
|
|
22
|
+
} = useSettingsTheme();
|
|
23
|
+
|
|
24
|
+
if (mode === LAYOUT_MODE_HORIZONTAL) return <HorizontalMenu />;
|
|
25
|
+
|
|
26
|
+
if (mode === LAYOUT_MODE_VERTICAL) return <VerticalMenu />;
|
|
27
|
+
|
|
28
|
+
if (mode === LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST) return <TopHybridHeaderFirst />;
|
|
29
|
+
|
|
30
|
+
if (mode === LAYOUT_MODE_VERTICAL_MIX) return <VerticalMix />;
|
|
31
|
+
|
|
32
|
+
if (mode === LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST) return <VerticalHybridHeaderFirst />;
|
|
33
|
+
|
|
34
|
+
return <TopHybridSidebarFirst />;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export default AdminMenu;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { transformColorWithOpacity } from '@skyroc/color';
|
|
2
|
+
import { ScrollArea } from '@skyroc/web-ui';
|
|
3
|
+
import { useSettingsTheme } from '@shell/theme';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { cloneElement, memo } from 'react';
|
|
6
|
+
|
|
7
|
+
import MenuToggler from '../../../state/menus/MenuToggler';
|
|
8
|
+
import { useAdminMenus } from '../../../state/menus/use-admin-menus';
|
|
9
|
+
import { useAdminState } from '../../../state/use-admin-state';
|
|
10
|
+
|
|
11
|
+
import { FirstLevelMenuMode } from '../enum';
|
|
12
|
+
|
|
13
|
+
interface FirstLevelMenuProps {
|
|
14
|
+
/** 首级菜单顶部插槽。 */
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
/** 是否使用反色菜单样式。 */
|
|
17
|
+
inverted?: boolean;
|
|
18
|
+
/** 首级菜单展示模式。 */
|
|
19
|
+
mode?: FirstLevelMenuMode;
|
|
20
|
+
/** 选择带子级菜单时的回调。 */
|
|
21
|
+
onSelect?: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface MixMenuItemProps {
|
|
25
|
+
/** Active menu item */
|
|
26
|
+
active: boolean;
|
|
27
|
+
inverted?: boolean;
|
|
28
|
+
/** Menu item label */
|
|
29
|
+
menu: Menu.CommonMenu;
|
|
30
|
+
/** 菜单模式 */
|
|
31
|
+
mode: FirstLevelMenuMode;
|
|
32
|
+
onClick?: () => void;
|
|
33
|
+
/** 选择菜单回调 */
|
|
34
|
+
onSelectMenu: (key: string) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const MixMenuItem = (props: MixMenuItemProps) => {
|
|
38
|
+
const {
|
|
39
|
+
active,
|
|
40
|
+
inverted,
|
|
41
|
+
menu: { children, extra, icon, key, label },
|
|
42
|
+
onClick,
|
|
43
|
+
onSelectMenu
|
|
44
|
+
} = props;
|
|
45
|
+
|
|
46
|
+
const { darkMode, themeColor } = useSettingsTheme();
|
|
47
|
+
|
|
48
|
+
const { siderCollapse } = useAdminState();
|
|
49
|
+
|
|
50
|
+
const { routerPushByKey } = useAdminMenus();
|
|
51
|
+
|
|
52
|
+
const selectedBgColor = getSelectedBgColor();
|
|
53
|
+
|
|
54
|
+
function getSelectedBgColor() {
|
|
55
|
+
const light = transformColorWithOpacity(themeColor, 0.1, '#ffffff');
|
|
56
|
+
const dark = transformColorWithOpacity(themeColor, 0.3, '#000000');
|
|
57
|
+
|
|
58
|
+
return darkMode ? dark : light;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function handleSelectMixMenu() {
|
|
62
|
+
onSelectMenu(key);
|
|
63
|
+
|
|
64
|
+
if (children?.length) {
|
|
65
|
+
if (onClick) onClick();
|
|
66
|
+
} else {
|
|
67
|
+
routerPushByKey(key);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div
|
|
73
|
+
style={{ backgroundColor: active ? selectedBgColor : '' }}
|
|
74
|
+
className={clsx(
|
|
75
|
+
'mx-4px mb-6px flex-col-center cursor-pointer rounded-8px bg-transparent px-4px py-8px transition-300 hover:bg-[rgb(0,0,0,0.08)]',
|
|
76
|
+
{ 'selected-mix-menu text-primary': active },
|
|
77
|
+
{ 'text-white:65 hover:text-white': inverted },
|
|
78
|
+
{ 'bg-primary! text-white!': active && inverted }
|
|
79
|
+
)}
|
|
80
|
+
onClick={handleSelectMixMenu}
|
|
81
|
+
>
|
|
82
|
+
<div className={clsx('flex-center gap-4px')}>
|
|
83
|
+
{icon && cloneElement(icon, { className: siderCollapse ? 'text-icon-small' : 'text-icon-large' } as any)}
|
|
84
|
+
|
|
85
|
+
{!siderCollapse ? Boolean(extra) && extra : null}
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<p
|
|
89
|
+
className={clsx(
|
|
90
|
+
'w-full ellipsis-text text-center text-12px transition-height-300',
|
|
91
|
+
siderCollapse ? 'h-0 pt-0' : 'h-24px pt-4px'
|
|
92
|
+
)}
|
|
93
|
+
>
|
|
94
|
+
{label}
|
|
95
|
+
</p>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const FirstLevelMenu = memo((props: FirstLevelMenuProps) => {
|
|
101
|
+
const { children, inverted, mode = FirstLevelMenuMode.All, onSelect } = props;
|
|
102
|
+
|
|
103
|
+
const {
|
|
104
|
+
sider: { mixCollapsedWidth, mixWidth }
|
|
105
|
+
} = useSettingsTheme();
|
|
106
|
+
|
|
107
|
+
const { siderCollapse } = useAdminState();
|
|
108
|
+
|
|
109
|
+
const {
|
|
110
|
+
activeFirstLevelMenuKey,
|
|
111
|
+
activeSecondLevelMenuKey,
|
|
112
|
+
changeActiveFirstLevelMenuKey,
|
|
113
|
+
changeActiveSecondLevelMenuKey,
|
|
114
|
+
menus: allMenus,
|
|
115
|
+
secondLevelMenus
|
|
116
|
+
} = useAdminMenus();
|
|
117
|
+
|
|
118
|
+
const isFirst = mode === FirstLevelMenuMode.All;
|
|
119
|
+
|
|
120
|
+
const menus = isFirst ? allMenus : secondLevelMenus;
|
|
121
|
+
|
|
122
|
+
const activeKey = isFirst ? activeFirstLevelMenuKey : activeSecondLevelMenuKey;
|
|
123
|
+
|
|
124
|
+
// 根据模式选择对应的激活菜单函数
|
|
125
|
+
const handleSelectMenu = isFirst ? changeActiveFirstLevelMenuKey : changeActiveSecondLevelMenuKey;
|
|
126
|
+
|
|
127
|
+
const firstLevelMenuStyle = {
|
|
128
|
+
width: `${siderCollapse ? mixCollapsedWidth : mixWidth}px`
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<div className="h-full flex-col-stretch flex-1-hidden">
|
|
133
|
+
{children}
|
|
134
|
+
<ScrollArea className="flex-1">
|
|
135
|
+
<div className="h-full" style={firstLevelMenuStyle}>
|
|
136
|
+
{menus
|
|
137
|
+
.filter(item => item.type !== 'divider')
|
|
138
|
+
.map(item => (
|
|
139
|
+
<MixMenuItem
|
|
140
|
+
active={item.key === activeKey}
|
|
141
|
+
inverted={inverted}
|
|
142
|
+
key={item.key}
|
|
143
|
+
menu={item}
|
|
144
|
+
mode={mode}
|
|
145
|
+
onClick={onSelect}
|
|
146
|
+
onSelectMenu={handleSelectMenu}
|
|
147
|
+
/>
|
|
148
|
+
))}
|
|
149
|
+
</div>
|
|
150
|
+
</ScrollArea>
|
|
151
|
+
<MenuToggler arrowIcon className={clsx({ 'text-white:88 !hover:text-white': inverted })} />
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
export default FirstLevelMenu;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useSettingsTheme } from '@shell/theme';
|
|
2
|
+
import { Menu as AMenu, type MenuProps } from 'antd';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
|
|
5
|
+
import { renderAntdMenuItems } from '../../../features/menus/menu-renderer';
|
|
6
|
+
import { useAdminMenus } from '../../../state/menus/use-admin-menus';
|
|
7
|
+
|
|
8
|
+
import { HorizontalMenuMode } from '../enum';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
/** 水平菜单显示模式 */
|
|
12
|
+
mode: HorizontalMenuMode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function stripRootType(menus: Menu.CommonMenu[]): Menu.CommonMenu[] {
|
|
16
|
+
return menus.filter(({ type: _ }) => _ !== 'divider').map(({ type: _, ...rest }) => rest);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function findChildren(menus: Menu.CommonMenu[], key: string) {
|
|
20
|
+
return menus.find(item => item.key === key)?.children || [];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const HorizontalMenu = memo((props: Props) => {
|
|
24
|
+
const { mode } = props;
|
|
25
|
+
|
|
26
|
+
const { header } = useSettingsTheme();
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
activeFirstLevelMenuKey,
|
|
30
|
+
changeActiveFirstLevelMenuKey,
|
|
31
|
+
changeActiveSecondLevelMenuKey,
|
|
32
|
+
firstLevelMenus,
|
|
33
|
+
menus,
|
|
34
|
+
routerPushByKey,
|
|
35
|
+
secondLevelMenus,
|
|
36
|
+
selectedKey,
|
|
37
|
+
setDrawerVisible
|
|
38
|
+
} = useAdminMenus();
|
|
39
|
+
|
|
40
|
+
function getMenus() {
|
|
41
|
+
if (mode === HorizontalMenuMode.All) {
|
|
42
|
+
return menus;
|
|
43
|
+
} else if (mode === HorizontalMenuMode.Child) {
|
|
44
|
+
return secondLevelMenus;
|
|
45
|
+
}
|
|
46
|
+
return firstLevelMenus;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const allMenus = getMenus();
|
|
50
|
+
|
|
51
|
+
const menuItems = renderAntdMenuItems(stripRootType(allMenus), { mode: 'horizontal' });
|
|
52
|
+
|
|
53
|
+
/** 处理菜单点击 - FirstLevel 模式:选择一级菜单,如果有子菜单且 autoSelectFirstMenu 开启,自动选择最深层级菜单 - 其他模式:直接跳转 */
|
|
54
|
+
function handleClickMenu(menuInfo: Parameters<NonNullable<MenuProps['onSelect']>>[0]) {
|
|
55
|
+
if (mode === HorizontalMenuMode.FirstLevel) {
|
|
56
|
+
changeActiveFirstLevelMenuKey(menuInfo.key);
|
|
57
|
+
|
|
58
|
+
const children = findChildren(menus, menuInfo.key);
|
|
59
|
+
|
|
60
|
+
if (!children.length) {
|
|
61
|
+
routerPushByKey(menuInfo.key);
|
|
62
|
+
} else {
|
|
63
|
+
const child = children[0].children || [];
|
|
64
|
+
|
|
65
|
+
if (child.length) {
|
|
66
|
+
changeActiveSecondLevelMenuKey(children[0].key);
|
|
67
|
+
setDrawerVisible(true);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
routerPushByKey(menuInfo.key);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<AMenu
|
|
77
|
+
className="size-full transition-400 border-0!"
|
|
78
|
+
inlineIndent={18}
|
|
79
|
+
items={menuItems}
|
|
80
|
+
mode="horizontal"
|
|
81
|
+
selectedKeys={mode === HorizontalMenuMode.FirstLevel ? [activeFirstLevelMenuKey] : selectedKey}
|
|
82
|
+
style={{ lineHeight: `${header.height}px` }}
|
|
83
|
+
onSelect={handleClickMenu}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export default HorizontalMenu;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { Portal } from '@shell/ui/compose';
|
|
3
|
+
|
|
4
|
+
import { useAdminState } from '../../../state/use-admin-state';
|
|
5
|
+
|
|
6
|
+
interface MenuPortalProps {
|
|
7
|
+
/** 跟随布局容器重新挂载的菜单内容。 */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** 菜单内容需要挂载到的布局容器。 */
|
|
10
|
+
container: string | HTMLElement;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const MenuPortal = (props: MenuPortalProps) => {
|
|
14
|
+
const { children, container } = props;
|
|
15
|
+
|
|
16
|
+
const { isMobile } = useAdminState();
|
|
17
|
+
|
|
18
|
+
const containerKey = typeof container === 'string' ? container : container.id || 'element';
|
|
19
|
+
const deviceKey = isMobile ? 'mobile' : 'desktop';
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Portal container={container} key={`${deviceKey}:${containerKey}`}>
|
|
23
|
+
{children}
|
|
24
|
+
</Portal>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default MenuPortal;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import { useSettingsTheme } from '@shell/theme';
|
|
3
|
+
import { ScrollArea } from '@skyroc/web-ui';
|
|
4
|
+
import { useUpdateEffect } from 'ahooks';
|
|
5
|
+
import { Menu as AMenu, type MenuProps } from 'antd';
|
|
6
|
+
import { clsx } from 'clsx';
|
|
7
|
+
import { memo, useEffect, useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
FIRST_LEVEL_LAYOUT_MODES,
|
|
11
|
+
LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST,
|
|
12
|
+
LAYOUT_MODE_VERTICAL,
|
|
13
|
+
LAYOUT_MODE_VERTICAL_MIX
|
|
14
|
+
} from '../../../constant';
|
|
15
|
+
import { renderAntdMenuItems } from '../../../features/menus/menu-renderer';
|
|
16
|
+
import { useAdminMenus } from '../../../state/menus/use-admin-menus';
|
|
17
|
+
import { useAdminState } from '../../../state/use-admin-state';
|
|
18
|
+
|
|
19
|
+
const VerticalMenu = memo(() => {
|
|
20
|
+
const {
|
|
21
|
+
childLevelMenus,
|
|
22
|
+
menus: allMenus,
|
|
23
|
+
openKeys,
|
|
24
|
+
route,
|
|
25
|
+
routerPushByKey,
|
|
26
|
+
secondLevelMenus,
|
|
27
|
+
selectedKey
|
|
28
|
+
} = useAdminMenus();
|
|
29
|
+
|
|
30
|
+
const { siderCollapse, verticalMenuWidth } = useAdminState();
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
darkMode,
|
|
34
|
+
layout: { mode },
|
|
35
|
+
sider
|
|
36
|
+
} = useSettingsTheme();
|
|
37
|
+
|
|
38
|
+
const isTopHybridHeaderFirst = mode === LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST;
|
|
39
|
+
|
|
40
|
+
const isVertical = mode === LAYOUT_MODE_VERTICAL;
|
|
41
|
+
|
|
42
|
+
const inlineCollapsed = isVertical || isTopHybridHeaderFirst ? siderCollapse : false;
|
|
43
|
+
|
|
44
|
+
const isVerticalMix = mode === LAYOUT_MODE_VERTICAL_MIX;
|
|
45
|
+
|
|
46
|
+
const isMix = FIRST_LEVEL_LAYOUT_MODES.includes(mode);
|
|
47
|
+
|
|
48
|
+
const [stateOpenKeys, setStateOpenKeys] = useState<string[]>(inlineCollapsed ? [] : openKeys);
|
|
49
|
+
|
|
50
|
+
const darkTheme = !darkMode && sider.inverted;
|
|
51
|
+
|
|
52
|
+
const menuTheme = darkTheme ? 'dark' : 'light';
|
|
53
|
+
|
|
54
|
+
const scrollbarClass = 'z-10 w-7px bg-transparent p-0';
|
|
55
|
+
|
|
56
|
+
const scrollbarThumbClass = 'rounded-10px bg-[rgba(144,147,153,0.3)] hover:bg-[rgba(144,147,153,0.3)]';
|
|
57
|
+
|
|
58
|
+
let menus = allMenus;
|
|
59
|
+
|
|
60
|
+
if (isVerticalMix) {
|
|
61
|
+
menus = secondLevelMenus;
|
|
62
|
+
} else if (isMix) {
|
|
63
|
+
menus = isTopHybridHeaderFirst ? secondLevelMenus : childLevelMenus;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const menuItems = renderAntdMenuItems(menus);
|
|
67
|
+
|
|
68
|
+
function handleClickMenu(menuInfo: Parameters<NonNullable<MenuProps['onSelect']>>[0]) {
|
|
69
|
+
routerPushByKey(menuInfo.key);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function handleOpenChange(keys: string[]) {
|
|
73
|
+
if (keys.includes('rc-menu-more')) {
|
|
74
|
+
setStateOpenKeys(keys);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// close
|
|
79
|
+
setStateOpenKeys(keys);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (inlineCollapsed) return;
|
|
84
|
+
setStateOpenKeys(openKeys);
|
|
85
|
+
}, [route.pathname, inlineCollapsed]);
|
|
86
|
+
|
|
87
|
+
useUpdateEffect(() => {
|
|
88
|
+
if (inlineCollapsed) {
|
|
89
|
+
setStateOpenKeys([]);
|
|
90
|
+
} else {
|
|
91
|
+
setStateOpenKeys(openKeys);
|
|
92
|
+
}
|
|
93
|
+
}, [inlineCollapsed]);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<ScrollArea
|
|
97
|
+
className="h-full"
|
|
98
|
+
classNames={{
|
|
99
|
+
scrollbar: scrollbarClass,
|
|
100
|
+
thumb: scrollbarThumbClass
|
|
101
|
+
}}
|
|
102
|
+
orientation="vertical"
|
|
103
|
+
size="xs"
|
|
104
|
+
type="scroll"
|
|
105
|
+
>
|
|
106
|
+
<AMenu
|
|
107
|
+
className={clsx('h-full transition-300 border-0!', { 'bg-container!': !darkTheme })}
|
|
108
|
+
inlineCollapsed={inlineCollapsed}
|
|
109
|
+
inlineIndent={18}
|
|
110
|
+
items={menuItems}
|
|
111
|
+
mode="inline"
|
|
112
|
+
openKeys={stateOpenKeys}
|
|
113
|
+
selectedKeys={selectedKey}
|
|
114
|
+
style={{ width: verticalMenuWidth }}
|
|
115
|
+
theme={menuTheme}
|
|
116
|
+
onOpenChange={handleOpenChange}
|
|
117
|
+
onSelect={handleClickMenu}
|
|
118
|
+
/>
|
|
119
|
+
</ScrollArea>
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
export default VerticalMenu;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 水平菜单模式枚举
|
|
3
|
+
*
|
|
4
|
+
* 用于控制水平菜单的显示内容
|
|
5
|
+
*/
|
|
6
|
+
export enum HorizontalMenuMode {
|
|
7
|
+
/**
|
|
8
|
+
* 全部菜单模式
|
|
9
|
+
*
|
|
10
|
+
* 显示所有层级的菜单项
|
|
11
|
+
*/
|
|
12
|
+
All = 'all',
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 子级菜单模式
|
|
16
|
+
*
|
|
17
|
+
* 仅显示当前激活一级菜单下的子菜单
|
|
18
|
+
*/
|
|
19
|
+
Child = 'child',
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 一级菜单模式
|
|
23
|
+
*
|
|
24
|
+
* 仅显示一级菜单项
|
|
25
|
+
*/
|
|
26
|
+
FirstLevel = 'first-level'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export enum FirstLevelMenuMode {
|
|
30
|
+
/**
|
|
31
|
+
* 一级菜单模式
|
|
32
|
+
*
|
|
33
|
+
* 仅显示一级菜单项
|
|
34
|
+
*/
|
|
35
|
+
All = 'all',
|
|
36
|
+
/**
|
|
37
|
+
* 一级菜单模式
|
|
38
|
+
*
|
|
39
|
+
* 仅显示一级菜单项
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* 子级菜单模式
|
|
43
|
+
*
|
|
44
|
+
* 仅显示当前激活一级菜单下的子菜单
|
|
45
|
+
*/
|
|
46
|
+
SecondLevel = 'second-level'
|
|
47
|
+
}
|