@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,149 @@
|
|
|
1
|
+
import { BeyondHiding } from '@shell/ui/antd';
|
|
2
|
+
import { I18nLabel, SvgIcon } from '@shell/ui/compose';
|
|
3
|
+
import type { MenuProps } from 'antd';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
import { createElement } from 'react';
|
|
6
|
+
|
|
7
|
+
import { getAdminLayoutsOptions } from '../../setup';
|
|
8
|
+
import type { GeneratedMenu } from './menu-generator';
|
|
9
|
+
import MenuBadge from './MenuBadge';
|
|
10
|
+
|
|
11
|
+
type AntdMenuItems = NonNullable<MenuProps['items']>;
|
|
12
|
+
|
|
13
|
+
interface RenderAntdMenuItemsOptions {
|
|
14
|
+
/** Ant Design 菜单模式,用于区分横向菜单和侧边菜单的 extra 布局。 */
|
|
15
|
+
mode?: MenuProps['mode'];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function createMenuTitle(menu: GeneratedMenu) {
|
|
19
|
+
return <I18nLabel fallback={menu.title} i18nKey={menu.i18nKey} />;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function createMenuExtra(menu: GeneratedMenu) {
|
|
23
|
+
const badge = menu.badge ? <MenuBadge badge={menu.badge} /> : null;
|
|
24
|
+
const extra = createCustomMenuExtra(menu);
|
|
25
|
+
|
|
26
|
+
if (badge && extra) {
|
|
27
|
+
return (
|
|
28
|
+
<span className="inline-flex items-center gap-6px">
|
|
29
|
+
{badge}
|
|
30
|
+
{extra}
|
|
31
|
+
</span>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return badge ?? extra;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function createCustomMenuExtra(menu: GeneratedMenu) {
|
|
39
|
+
if (!menu.extra) return undefined;
|
|
40
|
+
|
|
41
|
+
const { extras } = getAdminLayoutsOptions();
|
|
42
|
+
const Extra = extras?.[menu.extra];
|
|
43
|
+
|
|
44
|
+
if (!Extra) return undefined;
|
|
45
|
+
|
|
46
|
+
return createElement(Extra, menu);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function renderMenu(menu: GeneratedMenu): Menu.CommonMenu {
|
|
50
|
+
if (menu.type === 'divider') {
|
|
51
|
+
return {
|
|
52
|
+
key: menu.key,
|
|
53
|
+
label: null,
|
|
54
|
+
order: menu.order,
|
|
55
|
+
title: menu.title,
|
|
56
|
+
type: 'divider'
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const title = createMenuTitle(menu);
|
|
61
|
+
const { defaultIcon } = getAdminLayoutsOptions();
|
|
62
|
+
const commonMenu: Menu.CommonMenu = {
|
|
63
|
+
extra: createMenuExtra(menu),
|
|
64
|
+
i18nKey: menu.i18nKey,
|
|
65
|
+
icon: <SvgIcon icon={menu.icon || defaultIcon} localIcon={menu.localIcon} style={{ fontSize: '20px' }} />,
|
|
66
|
+
key: menu.key,
|
|
67
|
+
label: <BeyondHiding title={title} />,
|
|
68
|
+
order: menu.order,
|
|
69
|
+
title: menu.title,
|
|
70
|
+
type: menu.type
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (menu.children?.length) {
|
|
74
|
+
commonMenu.children = renderCommonMenus(menu.children);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return commonMenu;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function createSubMenuLabel(label: ReactNode, extra: ReactNode) {
|
|
81
|
+
return (
|
|
82
|
+
<span
|
|
83
|
+
className="box-border flex-y-center min-w-0 w-full justify-between gap-8px pr-28px"
|
|
84
|
+
data-menu-submenu-label="with-extra"
|
|
85
|
+
>
|
|
86
|
+
<span className="min-w-0 flex-1 overflow-hidden">{label}</span>
|
|
87
|
+
<span className="inline-flex shrink-0 items-center">{extra}</span>
|
|
88
|
+
</span>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function createHorizontalMenuLabel(label: ReactNode, extra: ReactNode) {
|
|
93
|
+
return (
|
|
94
|
+
<span className="inline-flex max-w-full min-w-0 items-center gap-6px" data-menu-horizontal-label="with-extra">
|
|
95
|
+
<span className="min-w-0 overflow-hidden">{label}</span>
|
|
96
|
+
<span className="inline-flex shrink-0 items-center">{extra}</span>
|
|
97
|
+
</span>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function createMenuItemLabel(label: ReactNode, extra: ReactNode | undefined, isHorizontalRootMenu: boolean) {
|
|
102
|
+
if (!extra) {
|
|
103
|
+
return label;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (isHorizontalRootMenu) {
|
|
107
|
+
return createHorizontalMenuLabel(label, extra);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return createSubMenuLabel(label, extra);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function createAntdMenuItem(
|
|
114
|
+
menu: Menu.CommonMenu,
|
|
115
|
+
options: RenderAntdMenuItemsOptions = {},
|
|
116
|
+
level = 0
|
|
117
|
+
): AntdMenuItems[number] {
|
|
118
|
+
const { children, extra, i18nKey: _, label, ...rest } = menu;
|
|
119
|
+
const isHorizontalRootMenu = options.mode === 'horizontal' && level === 0;
|
|
120
|
+
|
|
121
|
+
if (children?.length) {
|
|
122
|
+
return {
|
|
123
|
+
...rest,
|
|
124
|
+
children: children.map(child => createAntdMenuItem(child, options, level + 1)),
|
|
125
|
+
label: createMenuItemLabel(label, extra, isHorizontalRootMenu)
|
|
126
|
+
} as AntdMenuItems[number];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (extra && isHorizontalRootMenu) {
|
|
130
|
+
return {
|
|
131
|
+
...rest,
|
|
132
|
+
label: createHorizontalMenuLabel(label, extra)
|
|
133
|
+
} as AntdMenuItems[number];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
...rest,
|
|
138
|
+
extra,
|
|
139
|
+
label
|
|
140
|
+
} as AntdMenuItems[number];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function renderCommonMenus(menus: GeneratedMenu[]) {
|
|
144
|
+
return menus.map(renderMenu);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function renderAntdMenuItems(menus: Menu.CommonMenu[], options: RenderAntdMenuItemsOptions = {}): AntdMenuItems {
|
|
148
|
+
return menus.map(menu => createAntdMenuItem(menu, options));
|
|
149
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getAdminLayoutsOptions } from '../../setup';
|
|
2
|
+
|
|
3
|
+
interface PermissionRouteMatch {
|
|
4
|
+
staticData?: Router.Meta;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function hasAnyRoutePermission(permissions: string[] | null | undefined, userInfo?: Api.Auth.UserInfo | null) {
|
|
8
|
+
if (!permissions?.length) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const roles = userInfo?.roles ?? [];
|
|
13
|
+
const { permissionSuperRole } = getAdminLayoutsOptions();
|
|
14
|
+
|
|
15
|
+
if (permissionSuperRole && roles.includes(permissionSuperRole)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return permissions.some(permission => roles.includes(permission));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function hasRoutePermission(routeMeta: Router.Meta | undefined, userInfo?: Api.Auth.UserInfo | null) {
|
|
23
|
+
return hasAnyRoutePermission(routeMeta?.permissions, userInfo);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function hasMatchedRoutePermission(matches: PermissionRouteMatch[], userInfo?: Api.Auth.UserInfo | null) {
|
|
27
|
+
return matches.every(match => hasRoutePermission(match.staticData, userInfo));
|
|
28
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { atomWithPartial, getAtomValue } from '@skyroc/core-state';
|
|
2
|
+
import { useAtom } from 'jotai';
|
|
3
|
+
|
|
4
|
+
import { getAdminLayoutsOptions } from '../../setup';
|
|
5
|
+
import type { GeneratedMenus } from './menu-generator';
|
|
6
|
+
import { menuGenerator, normalizePath } from './menu-generator';
|
|
7
|
+
import { hasRoutePermission } from './permissions';
|
|
8
|
+
|
|
9
|
+
interface MenusAtom {
|
|
10
|
+
/** 当前用户首页路由 */
|
|
11
|
+
home: Router.RoutePath;
|
|
12
|
+
/** 原始菜单数据:RouteId(layoutId) -> 菜单列表 */
|
|
13
|
+
menus: GeneratedMenus;
|
|
14
|
+
quickReferenceMenus: Menu.QuickReferenceMenus;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function createInitialState(): MenusAtom {
|
|
18
|
+
return {
|
|
19
|
+
home: getAdminLayoutsOptions().defaultHome,
|
|
20
|
+
menus: new Map(),
|
|
21
|
+
quickReferenceMenus: new Map()
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const menusAtom = atomWithPartial<MenusAtom>({
|
|
26
|
+
home: '' as Router.RoutePath,
|
|
27
|
+
menus: new Map(),
|
|
28
|
+
quickReferenceMenus: new Map()
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const useMenus = () => {
|
|
32
|
+
const [menusState, setMenusState] = useAtom(menusAtom);
|
|
33
|
+
|
|
34
|
+
async function initMenus(userInfo?: Api.Auth.UserInfo | null) {
|
|
35
|
+
const { loadDynamicRoutes, routeMode } = getAdminLayoutsOptions();
|
|
36
|
+
|
|
37
|
+
if (routeMode === 'dynamic') {
|
|
38
|
+
if (!loadDynamicRoutes) {
|
|
39
|
+
throw new Error('Admin layouts routeMode is dynamic, but loadDynamicRoutes is not configured.');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const routeData = await loadDynamicRoutes();
|
|
43
|
+
const { allMenus, home, quickReferenceMenus } = menuGenerator.generate({
|
|
44
|
+
backendRoutes: routeData.routes,
|
|
45
|
+
home: routeData.home,
|
|
46
|
+
userInfo
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
setMenusState({ home, menus: allMenus, quickReferenceMenus });
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { allMenus, home, quickReferenceMenus } = menuGenerator.generate({ userInfo });
|
|
54
|
+
setMenusState({ home, menus: allMenus, quickReferenceMenus });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function clearMenus() {
|
|
58
|
+
setMenusState(createInitialState());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getHomeRoute() {
|
|
62
|
+
return getAtomValue(menusAtom).home;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
...menusState,
|
|
67
|
+
initMenus,
|
|
68
|
+
clearMenus,
|
|
69
|
+
getHomeRoute
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export function getQuickReferenceMenuByPath(path: string) {
|
|
74
|
+
const normalizedPath = normalizePath(path) as Router.RoutePath;
|
|
75
|
+
const { quickReferenceMenus } = getAtomValue(menusAtom);
|
|
76
|
+
|
|
77
|
+
for (const quickReferenceMenuMap of quickReferenceMenus.values()) {
|
|
78
|
+
const menu = quickReferenceMenuMap.get(normalizedPath);
|
|
79
|
+
|
|
80
|
+
if (menu) {
|
|
81
|
+
return menu;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function hasAuthorizedRoutePath(path: string, userInfo?: Api.Auth.UserInfo | null) {
|
|
89
|
+
const { routeMode } = getAdminLayoutsOptions();
|
|
90
|
+
|
|
91
|
+
if (routeMode !== 'dynamic') {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const menu = getQuickReferenceMenuByPath(path);
|
|
96
|
+
|
|
97
|
+
return Boolean(menu && hasRoutePermission(menu, userInfo));
|
|
98
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { stringifyQuery } from '@skyroc/utils';
|
|
2
|
+
import { useMatches } from '@tanstack/react-router';
|
|
3
|
+
|
|
4
|
+
import { normalizePath } from './menus/menu-generator';
|
|
5
|
+
|
|
6
|
+
export function useRoute() {
|
|
7
|
+
const route = useMatches({
|
|
8
|
+
select: matches => {
|
|
9
|
+
const m = matches[matches.length - 1];
|
|
10
|
+
|
|
11
|
+
const qs = stringifyQuery(m.search);
|
|
12
|
+
|
|
13
|
+
const fullPath = qs ? `${m.pathname}${qs}` : m.pathname;
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
routeId: m.routeId,
|
|
17
|
+
params: m.params,
|
|
18
|
+
pathname: m.pathname,
|
|
19
|
+
fullPath,
|
|
20
|
+
staticData: m.staticData,
|
|
21
|
+
searchStr: qs,
|
|
22
|
+
originPath: normalizePath(m.fullPath) as Router.RoutePath,
|
|
23
|
+
search: m.search
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
structuralSharing: false
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return route;
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export { default as AdminLayout } from './AdminLayout';
|
|
2
|
+
export type { AdminLayoutProps } from './AdminLayout';
|
|
3
|
+
export type { AdminLayoutLogoComponent, AdminLayoutLogoProps, AdminLayoutSlots } from './context';
|
|
4
|
+
export type {
|
|
5
|
+
CreateAdminDynamicRouteLoaderOptions,
|
|
6
|
+
NormalizeBackendRouteResponseOptions
|
|
7
|
+
} from './features/menus/dynamic-routes';
|
|
8
|
+
export {
|
|
9
|
+
collectAvailableRoutePaths,
|
|
10
|
+
createAdminDynamicRouteLoader,
|
|
11
|
+
createBackendRouteNormalizer,
|
|
12
|
+
normalizeBackendRouteResponse
|
|
13
|
+
} from './features/menus/dynamic-routes';
|
|
14
|
+
export { normalizePath } from './features/menus/menu-generator';
|
|
15
|
+
export type {
|
|
16
|
+
GeneratedMenu,
|
|
17
|
+
GeneratedMenus,
|
|
18
|
+
GenerateMenuOptions,
|
|
19
|
+
GenerateMenuResult
|
|
20
|
+
} from './features/menus/menu-generator';
|
|
21
|
+
|
|
22
|
+
export { hasAnyRoutePermission, hasMatchedRoutePermission, hasRoutePermission } from './features/menus/permissions';
|
|
23
|
+
export { getQuickReferenceMenuByPath, hasAuthorizedRoutePath, useMenus } from './features/menus/use-menus';
|
|
24
|
+
export { useRoute } from './features/use-route';
|
|
25
|
+
export type {
|
|
26
|
+
AdminLayoutMenuCategory,
|
|
27
|
+
AdminLayoutsDynamicRoutes,
|
|
28
|
+
AdminLayoutsOptions,
|
|
29
|
+
AdminLayoutsStorage,
|
|
30
|
+
MenuNodeCallback,
|
|
31
|
+
MenuNodeConfig
|
|
32
|
+
} from './setup';
|
|
33
|
+
export { setupAdminLayouts } from './setup';
|
|
34
|
+
export type { MenuBadgeValues } from './state/menus/use-admin-menu-badges';
|
|
35
|
+
export {
|
|
36
|
+
clearMenuBadgeValues,
|
|
37
|
+
setMenuBadgeValue,
|
|
38
|
+
setMenuBadgeValues,
|
|
39
|
+
useAdminMenuBadges
|
|
40
|
+
} from './state/menus/use-admin-menu-badges';
|
|
41
|
+
export { useAdminMenus } from './state/menus/use-admin-menus';
|
|
42
|
+
export { cacheTabs, useAdminTab } from './state/tabs/use-admin-tab';
|
|
43
|
+
export { useAdminState } from './state/use-admin-state';
|
|
44
|
+
export * from './types/storage';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import AdminLayout from './libs/admin-layout';
|
|
2
|
+
import { LAYOUT_MAX_Z_INDEX, LAYOUT_SCROLL_EL_ID } from './libs/admin-layout/shared';
|
|
3
|
+
import PageTab from './libs/page-tab';
|
|
4
|
+
|
|
5
|
+
export * from './types';
|
|
6
|
+
export { AdminLayout, LAYOUT_MAX_Z_INDEX, LAYOUT_SCROLL_EL_ID, PageTab };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* @type */
|
|
2
|
+
|
|
3
|
+
.layout-header,
|
|
4
|
+
.layout-header-placement {
|
|
5
|
+
height: var(--soy-header-height);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.layout-header {
|
|
9
|
+
z-index: var(--soy-header-z-index);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.layout-tab {
|
|
13
|
+
top: var(--soy-header-height);
|
|
14
|
+
height: var(--soy-tab-height);
|
|
15
|
+
z-index: var(--soy-tab-z-index);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.layout-tab-placement {
|
|
19
|
+
height: var(--soy-tab-height);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.layout-sider {
|
|
23
|
+
width: var(--soy-sider-width) !important;
|
|
24
|
+
z-index: var(--soy-sider-z-index);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.layout-mobile-sider {
|
|
28
|
+
z-index: var(--soy-sider-z-index);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.layout-mobile-sider-mask {
|
|
32
|
+
z-index: var(--soy-mobile-sider-z-index);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.layout-sider_collapsed {
|
|
36
|
+
width: var(--soy-sider-collapsed-width);
|
|
37
|
+
z-index: var(--soy-sider-z-index);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.layout-footer,
|
|
41
|
+
.layout-footer-placement {
|
|
42
|
+
height: var(--soy-footer-height);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.layout-footer {
|
|
46
|
+
z-index: var(--soy-footer-z-index);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.left-gap {
|
|
50
|
+
padding-left: var(--soy-sider-width);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.left-gap_collapsed {
|
|
54
|
+
padding-left: var(--soy-sider-collapsed-width);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sider-padding-top {
|
|
58
|
+
padding-top: var(--soy-header-height);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.sider-padding-bottom {
|
|
62
|
+
padding-bottom: var(--soy-footer-height);
|
|
63
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare const styles: {
|
|
2
|
+
readonly 'layout-footer': string;
|
|
3
|
+
readonly 'layout-footer-placement': string;
|
|
4
|
+
readonly 'layout-header': string;
|
|
5
|
+
readonly 'layout-header-placement': string;
|
|
6
|
+
readonly 'layout-mobile-sider': string;
|
|
7
|
+
readonly 'layout-mobile-sider-mask': string;
|
|
8
|
+
readonly 'layout-sider': string;
|
|
9
|
+
readonly 'layout-sider_collapsed': string;
|
|
10
|
+
readonly 'layout-tab': string;
|
|
11
|
+
readonly 'layout-tab-placement': string;
|
|
12
|
+
readonly 'left-gap': string;
|
|
13
|
+
readonly 'left-gap_collapsed': string;
|
|
14
|
+
readonly 'sider-padding-bottom': string;
|
|
15
|
+
readonly 'sider-padding-top': string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default styles;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import classNames from 'clsx';
|
|
2
|
+
import { type FC } from 'react';
|
|
3
|
+
import type { AdminLayoutProps } from '../../types';
|
|
4
|
+
import { LAYOUT_MAX_Z_INDEX, LAYOUT_SCROLL_EL_ID, createLayoutCssVars } from './shared';
|
|
5
|
+
import style from './index.module.css';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line complexity
|
|
8
|
+
const AdminLayout: FC<AdminLayoutProps> = ({
|
|
9
|
+
children,
|
|
10
|
+
commonClass = 'transition-all-300',
|
|
11
|
+
contentClass,
|
|
12
|
+
fixedFooter,
|
|
13
|
+
fixedTop = true,
|
|
14
|
+
Footer,
|
|
15
|
+
footerClass,
|
|
16
|
+
footerHeight = 48,
|
|
17
|
+
footerVisible = true,
|
|
18
|
+
fullContent,
|
|
19
|
+
Header,
|
|
20
|
+
headerClass,
|
|
21
|
+
headerHeight = 56,
|
|
22
|
+
headerVisible = true,
|
|
23
|
+
isMobile,
|
|
24
|
+
maxZIndex = LAYOUT_MAX_Z_INDEX,
|
|
25
|
+
mobileSiderClass,
|
|
26
|
+
mode = 'vertical',
|
|
27
|
+
rightFooter = false,
|
|
28
|
+
scrollElId = LAYOUT_SCROLL_EL_ID,
|
|
29
|
+
scrollMode = 'content',
|
|
30
|
+
scrollWrapperClass,
|
|
31
|
+
Sider,
|
|
32
|
+
siderClass,
|
|
33
|
+
siderCollapse = false,
|
|
34
|
+
siderCollapsedWidth = 64,
|
|
35
|
+
siderVisible = true,
|
|
36
|
+
siderWidth = 220,
|
|
37
|
+
Tab,
|
|
38
|
+
tabClass,
|
|
39
|
+
tabHeight = 44,
|
|
40
|
+
tabVisible = true,
|
|
41
|
+
updateSiderCollapse
|
|
42
|
+
// eslint-disable-next-line complexity
|
|
43
|
+
}) => {
|
|
44
|
+
const cssVar = createLayoutCssVars({
|
|
45
|
+
footerHeight,
|
|
46
|
+
headerHeight,
|
|
47
|
+
isMobile,
|
|
48
|
+
maxZIndex,
|
|
49
|
+
mode,
|
|
50
|
+
siderCollapsedWidth,
|
|
51
|
+
siderWidth,
|
|
52
|
+
tabHeight
|
|
53
|
+
}) as React.CSSProperties;
|
|
54
|
+
// config visible
|
|
55
|
+
const showHeader = Boolean(Header) && headerVisible;
|
|
56
|
+
const showSider = !isMobile && Boolean(Sider) && siderVisible;
|
|
57
|
+
const showMobileSider = isMobile && Boolean(Sider) && siderVisible;
|
|
58
|
+
const showTab = Boolean(Tab) && tabVisible;
|
|
59
|
+
const showFooter = Boolean(Footer) && footerVisible;
|
|
60
|
+
|
|
61
|
+
// scroll mode
|
|
62
|
+
const isWrapperScroll = scrollMode === 'wrapper';
|
|
63
|
+
const isContentScroll = scrollMode === 'content';
|
|
64
|
+
// layout direction
|
|
65
|
+
const isVertical = mode === 'vertical';
|
|
66
|
+
const isHorizontal = mode === 'horizontal';
|
|
67
|
+
const fixedHeaderAndTab = fixedTop || (isHorizontal && isWrapperScroll);
|
|
68
|
+
|
|
69
|
+
// css
|
|
70
|
+
const leftGapClass = () => {
|
|
71
|
+
if (!fullContent && showSider) {
|
|
72
|
+
return siderCollapse ? style['left-gap_collapsed'] : style['left-gap'];
|
|
73
|
+
}
|
|
74
|
+
return '';
|
|
75
|
+
};
|
|
76
|
+
const headerLeftGapClass = isVertical ? leftGapClass() : '';
|
|
77
|
+
|
|
78
|
+
const footerLeftGapClass = () => {
|
|
79
|
+
const condition1 = isVertical;
|
|
80
|
+
const condition2 = isHorizontal && isWrapperScroll && !fixedFooter;
|
|
81
|
+
const condition3 = Boolean(isHorizontal && rightFooter);
|
|
82
|
+
|
|
83
|
+
if (condition1 || condition2 || condition3) {
|
|
84
|
+
return leftGapClass();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return '';
|
|
88
|
+
};
|
|
89
|
+
const siderPaddingClass = () => {
|
|
90
|
+
let cls = '';
|
|
91
|
+
|
|
92
|
+
if (showHeader && !headerLeftGapClass) {
|
|
93
|
+
cls += style['sider-padding-top'];
|
|
94
|
+
}
|
|
95
|
+
if (showFooter && !footerLeftGapClass()) {
|
|
96
|
+
cls += ` ${style['sider-padding-bottom']}`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return cls;
|
|
100
|
+
};
|
|
101
|
+
// display
|
|
102
|
+
const headerDisplay = !fullContent && fixedHeaderAndTab ? 'block' : 'none';
|
|
103
|
+
const siderDisplay = fullContent ? 'none' : 'block';
|
|
104
|
+
const mobileSider = siderCollapse ? 'none' : 'block';
|
|
105
|
+
const footerDisplay = !fullContent && fixedFooter ? 'block' : 'none';
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<section className={classNames('relative h-full', commonClass)} style={cssVar}>
|
|
109
|
+
<section
|
|
110
|
+
id={isWrapperScroll ? scrollElId : ''}
|
|
111
|
+
className={classNames('h-full flex flex-col', scrollWrapperClass, commonClass, {
|
|
112
|
+
'overflow-y-auto': isWrapperScroll
|
|
113
|
+
})}
|
|
114
|
+
>
|
|
115
|
+
{/* Header */}
|
|
116
|
+
{showHeader && (
|
|
117
|
+
<>
|
|
118
|
+
<header
|
|
119
|
+
style={{ display: fullContent ? 'none' : 'block' }}
|
|
120
|
+
className={classNames(
|
|
121
|
+
'flex-shrink-0',
|
|
122
|
+
style['layout-header'],
|
|
123
|
+
commonClass,
|
|
124
|
+
headerClass,
|
|
125
|
+
headerLeftGapClass,
|
|
126
|
+
{ 'absolute left-0 top-0 w-full': fixedHeaderAndTab }
|
|
127
|
+
)}
|
|
128
|
+
>
|
|
129
|
+
{Header}
|
|
130
|
+
</header>
|
|
131
|
+
<div
|
|
132
|
+
className={classNames('flex-shrink-0 overflow-hidden', style['layout-header-placement'])}
|
|
133
|
+
style={{ display: headerDisplay }}
|
|
134
|
+
/>
|
|
135
|
+
</>
|
|
136
|
+
)}
|
|
137
|
+
|
|
138
|
+
{/* Tab */}
|
|
139
|
+
{showTab && (
|
|
140
|
+
<>
|
|
141
|
+
<div
|
|
142
|
+
className={classNames(
|
|
143
|
+
'flex-shrink-0',
|
|
144
|
+
style['layout-tab'],
|
|
145
|
+
commonClass,
|
|
146
|
+
tabClass,
|
|
147
|
+
{ 'top-0!': fullContent || !showHeader },
|
|
148
|
+
leftGapClass(),
|
|
149
|
+
{ 'absolute left-0 w-full': fixedHeaderAndTab }
|
|
150
|
+
)}
|
|
151
|
+
>
|
|
152
|
+
{Tab}
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<div
|
|
156
|
+
className={classNames('flex-shrink-0 overflow-hidden', [style['layout-tab-placement']])}
|
|
157
|
+
style={{ display: fixedHeaderAndTab || fullContent ? 'block' : 'none' }}
|
|
158
|
+
/>
|
|
159
|
+
</>
|
|
160
|
+
)}
|
|
161
|
+
|
|
162
|
+
{/* Sider */}
|
|
163
|
+
{showSider && (
|
|
164
|
+
<aside
|
|
165
|
+
style={{ display: siderDisplay }}
|
|
166
|
+
className={classNames(
|
|
167
|
+
'absolute left-0 top-0 h-full',
|
|
168
|
+
commonClass,
|
|
169
|
+
siderClass,
|
|
170
|
+
siderPaddingClass(),
|
|
171
|
+
siderCollapse ? style['layout-sider_collapsed'] : style['layout-sider']
|
|
172
|
+
)}
|
|
173
|
+
>
|
|
174
|
+
{Sider}
|
|
175
|
+
</aside>
|
|
176
|
+
)}
|
|
177
|
+
|
|
178
|
+
{/* Mobile Sider */}
|
|
179
|
+
{showMobileSider && (
|
|
180
|
+
<>
|
|
181
|
+
<aside
|
|
182
|
+
className={classNames('absolute left-0 top-0 h-full w-0 bg-white', [
|
|
183
|
+
commonClass,
|
|
184
|
+
siderClass,
|
|
185
|
+
mobileSiderClass,
|
|
186
|
+
style['layout-mobile-sider'],
|
|
187
|
+
siderCollapse ? 'overflow-hidden' : style['layout-sider']
|
|
188
|
+
])}
|
|
189
|
+
>
|
|
190
|
+
{Sider}
|
|
191
|
+
</aside>
|
|
192
|
+
<div
|
|
193
|
+
style={{ display: mobileSider }}
|
|
194
|
+
className={classNames('absolute left-0 top-0 h-full w-full bg-[rgba(0,0,0,0.2)]', [
|
|
195
|
+
style['layout-mobile-sider-mask']
|
|
196
|
+
])}
|
|
197
|
+
onClick={() => updateSiderCollapse()}
|
|
198
|
+
/>
|
|
199
|
+
</>
|
|
200
|
+
)}
|
|
201
|
+
|
|
202
|
+
{/* Main Content */}
|
|
203
|
+
<main
|
|
204
|
+
id={isContentScroll ? scrollElId : ''}
|
|
205
|
+
className={classNames('flex flex-col flex-grow bg-layout', commonClass, contentClass, leftGapClass(), {
|
|
206
|
+
'overflow-y-auto': isContentScroll
|
|
207
|
+
})}
|
|
208
|
+
>
|
|
209
|
+
{children}
|
|
210
|
+
</main>
|
|
211
|
+
|
|
212
|
+
{/* Footer */}
|
|
213
|
+
{showFooter && (
|
|
214
|
+
<>
|
|
215
|
+
<footer
|
|
216
|
+
style={{ display: siderDisplay }}
|
|
217
|
+
className={classNames(
|
|
218
|
+
'flex-shrink-0',
|
|
219
|
+
style['layout-footer'],
|
|
220
|
+
commonClass,
|
|
221
|
+
footerClass,
|
|
222
|
+
footerLeftGapClass(),
|
|
223
|
+
{ 'absolute bottom-0 left-0 w-full': fixedFooter }
|
|
224
|
+
)}
|
|
225
|
+
>
|
|
226
|
+
{Footer}
|
|
227
|
+
</footer>
|
|
228
|
+
<div
|
|
229
|
+
className={classNames('flex-shrink-0 overflow-hidden', style['layout-footer-placement'])}
|
|
230
|
+
style={{ display: footerDisplay }}
|
|
231
|
+
/>
|
|
232
|
+
</>
|
|
233
|
+
)}
|
|
234
|
+
</section>
|
|
235
|
+
</section>
|
|
236
|
+
);
|
|
237
|
+
};
|
|
238
|
+
export default AdminLayout;
|