@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,22 @@
|
|
|
1
|
+
import { GLOBAL_HEADER_MENU_SELECTOR } from '../../../constant';
|
|
2
|
+
|
|
3
|
+
import HorizontalMenu from '../components/HorizontalMenu';
|
|
4
|
+
import MenuPortal from '../components/MenuPortal';
|
|
5
|
+
import { HorizontalMenuMode } from '../enum';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
/** 水平菜单显示模式 */
|
|
9
|
+
readonly mode?: HorizontalMenuMode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Horizontal = (props: Props) => {
|
|
13
|
+
const { mode = HorizontalMenuMode.All } = props;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<MenuPortal container={GLOBAL_HEADER_MENU_SELECTOR}>
|
|
17
|
+
<HorizontalMenu mode={mode} />
|
|
18
|
+
</MenuPortal>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default Horizontal;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST, LAYOUT_MODE_VERTICAL } from '../../../constant';
|
|
2
|
+
import { HorizontalMenuMode } from '../enum';
|
|
3
|
+
|
|
4
|
+
import Horizontal from './Horizontal';
|
|
5
|
+
import Vertical from './Vertical';
|
|
6
|
+
|
|
7
|
+
const ReversedHorizontalMix = () => {
|
|
8
|
+
return [
|
|
9
|
+
<Vertical key={LAYOUT_MODE_VERTICAL} />,
|
|
10
|
+
|
|
11
|
+
<Horizontal key={`${LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST}-horizontal`} mode={HorizontalMenuMode.FirstLevel} />
|
|
12
|
+
];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default ReversedHorizontalMix;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GLOBAL_SIDER_MENU_SELECTOR, LAYOUT_MODE_HORIZONTAL } from '../../../constant';
|
|
2
|
+
|
|
3
|
+
import FirstLevelMenu from '../components/FirstLevelMenu';
|
|
4
|
+
import { HorizontalMenuMode } from '../enum';
|
|
5
|
+
import MenuPortal from '../components/MenuPortal';
|
|
6
|
+
|
|
7
|
+
import Horizontal from './Horizontal';
|
|
8
|
+
|
|
9
|
+
const HorizontalMix = () => {
|
|
10
|
+
return [
|
|
11
|
+
<Horizontal key={LAYOUT_MODE_HORIZONTAL} mode={HorizontalMenuMode.Child} />,
|
|
12
|
+
<MenuPortal container={GLOBAL_SIDER_MENU_SELECTOR} key="first-level-menu">
|
|
13
|
+
<FirstLevelMenu key="first-level-menu" />
|
|
14
|
+
</MenuPortal>
|
|
15
|
+
];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default HorizontalMix;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GLOBAL_SIDER_MENU_SELECTOR } from '../../../constant';
|
|
2
|
+
|
|
3
|
+
import MenuPortal from '../components/MenuPortal';
|
|
4
|
+
import VerticalMenu from '../components/VerticalMenu';
|
|
5
|
+
|
|
6
|
+
const Vertical = () => {
|
|
7
|
+
return (
|
|
8
|
+
<MenuPortal container={GLOBAL_SIDER_MENU_SELECTOR}>
|
|
9
|
+
<VerticalMenu />
|
|
10
|
+
</MenuPortal>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default Vertical;
|
package/templates/admin-shell/layouts/modules/admin-menu/modules/VerticalHybridHeaderFirst.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST, LAYOUT_MODE_VERTICAL_MIX } from '../../../constant';
|
|
2
|
+
import { FirstLevelMenuMode, HorizontalMenuMode } from '../enum';
|
|
3
|
+
|
|
4
|
+
import Horizontal from './Horizontal';
|
|
5
|
+
import VerticalMixMenu from './VerticalMix';
|
|
6
|
+
|
|
7
|
+
const VerticalHybridHeaderFirst = () => {
|
|
8
|
+
return [
|
|
9
|
+
<Horizontal key={`${LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST}-horizontal`} mode={HorizontalMenuMode.FirstLevel} />,
|
|
10
|
+
|
|
11
|
+
<VerticalMixMenu
|
|
12
|
+
key={`${LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST}-${LAYOUT_MODE_VERTICAL_MIX}`}
|
|
13
|
+
mode={FirstLevelMenuMode.SecondLevel}
|
|
14
|
+
/>
|
|
15
|
+
];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default VerticalHybridHeaderFirst;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { useSettingsTheme } from '@shell/theme';
|
|
2
|
+
import { PinToggler } from '@shell/ui/antd';
|
|
3
|
+
import { DarkModeContainer } from '@shell/ui/compose';
|
|
4
|
+
import classNames from 'clsx';
|
|
5
|
+
import { memo } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
|
|
8
|
+
import { GLOBAL_SIDER_MENU_SELECTOR } from '../../../constant';
|
|
9
|
+
import { useAdminLayoutContext } from '../../../context';
|
|
10
|
+
import { useAdminMenus } from '../../../state/menus/use-admin-menus';
|
|
11
|
+
import { useAdminState } from '../../../state/use-admin-state';
|
|
12
|
+
import LayoutLogo from '../../shared/logo';
|
|
13
|
+
import FirstLevelMenu from '../components/FirstLevelMenu';
|
|
14
|
+
import MenuPortal from '../components/MenuPortal';
|
|
15
|
+
import VerticalMenu from '../components/VerticalMenu';
|
|
16
|
+
import { FirstLevelMenuMode } from '../enum';
|
|
17
|
+
|
|
18
|
+
interface VerticalMixProps {
|
|
19
|
+
/** 混合菜单层级模式。 */
|
|
20
|
+
mode?: FirstLevelMenuMode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const VerticalMix = memo((props: VerticalMixProps) => {
|
|
24
|
+
const { mode = FirstLevelMenuMode.All } = props;
|
|
25
|
+
|
|
26
|
+
const { t } = useTranslation();
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
activeFirstLevelMenuKey,
|
|
30
|
+
activeSecondLevelMenuKey,
|
|
31
|
+
changeActiveFirstLevelMenuKey,
|
|
32
|
+
childLevelMenus,
|
|
33
|
+
drawerVisible,
|
|
34
|
+
menus,
|
|
35
|
+
secondLevelMenus,
|
|
36
|
+
setDrawerVisible
|
|
37
|
+
} = useAdminMenus();
|
|
38
|
+
|
|
39
|
+
const { darkMode, header, sider } = useSettingsTheme();
|
|
40
|
+
|
|
41
|
+
const { mixSiderFixed, siderCollapse, toggleMixSiderFixed } = useAdminState();
|
|
42
|
+
|
|
43
|
+
const { logo, logoComponent, logoTitle, logoTo } = useAdminLayoutContext();
|
|
44
|
+
|
|
45
|
+
const siderInverted = !darkMode && sider.inverted;
|
|
46
|
+
|
|
47
|
+
const isFirst = mode === FirstLevelMenuMode.All;
|
|
48
|
+
|
|
49
|
+
const titleSource = isFirst ? menus : secondLevelMenus;
|
|
50
|
+
|
|
51
|
+
const titleKey = isFirst ? activeFirstLevelMenuKey : activeSecondLevelMenuKey;
|
|
52
|
+
|
|
53
|
+
const activeMenuLabel = titleSource.find(item => item.key === titleKey)?.label;
|
|
54
|
+
|
|
55
|
+
const hasMenus = isFirst
|
|
56
|
+
? secondLevelMenus && secondLevelMenus.length > 0
|
|
57
|
+
: childLevelMenus && childLevelMenus.length > 0;
|
|
58
|
+
|
|
59
|
+
const showDrawer = hasMenus && (drawerVisible || mixSiderFixed);
|
|
60
|
+
|
|
61
|
+
const logoStyle = {
|
|
62
|
+
width: `${siderCollapse ? sider.mixCollapsedWidth : sider.mixWidth}px`
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const hasLogo = Boolean(logo || logoComponent || logoTitle);
|
|
66
|
+
|
|
67
|
+
function handleSelectMixMenu() {
|
|
68
|
+
setDrawerVisible(true);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function handleResetActiveMenu() {
|
|
72
|
+
setDrawerVisible(false);
|
|
73
|
+
|
|
74
|
+
if (isFirst) {
|
|
75
|
+
changeActiveFirstLevelMenuKey();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className="h-full flex" onMouseLeave={handleResetActiveMenu}>
|
|
82
|
+
<FirstLevelMenu inverted={siderInverted} mode={mode} onSelect={handleSelectMixMenu}>
|
|
83
|
+
{hasLogo ? (
|
|
84
|
+
<div className="flex-center px-12px" style={{ height: `${header.height}px` }}>
|
|
85
|
+
<LayoutLogo
|
|
86
|
+
logo={logo}
|
|
87
|
+
logoComponent={logoComponent}
|
|
88
|
+
showTitle={false}
|
|
89
|
+
style={logoStyle}
|
|
90
|
+
title={logoTitle}
|
|
91
|
+
to={logoTo}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
) : null}
|
|
95
|
+
</FirstLevelMenu>
|
|
96
|
+
<div
|
|
97
|
+
className="relative h-full transition-width-300"
|
|
98
|
+
style={{ width: mixSiderFixed && hasMenus ? `${sider.mixChildMenuWidth}px` : '0px' }}
|
|
99
|
+
>
|
|
100
|
+
<DarkModeContainer
|
|
101
|
+
className="absolute-lt h-full flex-col-stretch nowrap-hidden shadow-sm transition-all-300"
|
|
102
|
+
inverted={siderInverted}
|
|
103
|
+
style={{ width: showDrawer ? `${sider.mixChildMenuWidth}px` : '0px' }}
|
|
104
|
+
>
|
|
105
|
+
<header className="flex-y-center justify-between px-12px" style={{ height: `${header.height}px` }}>
|
|
106
|
+
<h2 className="ellipsis-text text-16px text-primary font-bold">{activeMenuLabel}</h2>
|
|
107
|
+
<PinToggler
|
|
108
|
+
className={classNames({ 'text-white:88 !hover:text-white': siderInverted })}
|
|
109
|
+
pin={mixSiderFixed}
|
|
110
|
+
pinnedTooltip={t('icon.unpin')}
|
|
111
|
+
unpinnedTooltip={t('icon.pin')}
|
|
112
|
+
onClick={toggleMixSiderFixed}
|
|
113
|
+
/>
|
|
114
|
+
</header>
|
|
115
|
+
<VerticalMenu />
|
|
116
|
+
</DarkModeContainer>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const VerticalMixMenu = (props: VerticalMixProps) => {
|
|
123
|
+
const { mode } = props;
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<MenuPortal container={GLOBAL_SIDER_MENU_SELECTOR}>
|
|
127
|
+
<VerticalMix mode={mode} />
|
|
128
|
+
</MenuPortal>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export default VerticalMixMenu;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ButtonIcon } from '@shell/ui/antd';
|
|
2
|
+
import { useSettingsTheme } from '@shell/theme';
|
|
3
|
+
import { SvgIcon } from '@shell/ui/compose';
|
|
4
|
+
import { useBoolean } from 'ahooks';
|
|
5
|
+
import { Suspense, lazy, memo } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
|
|
8
|
+
const SearchModal = lazy(() => import('./components/SearchModal'));
|
|
9
|
+
|
|
10
|
+
const GlobalSearch = memo(() => {
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
|
|
13
|
+
const [show, { setFalse, toggle }] = useBoolean();
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
header: {
|
|
17
|
+
globalSearch: { visible }
|
|
18
|
+
}
|
|
19
|
+
} = useSettingsTheme();
|
|
20
|
+
|
|
21
|
+
if (!visible) return null;
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<ButtonIcon className="px-12px" hoverAnimation="scale" tooltipContent={t('common.search')} onClick={toggle}>
|
|
26
|
+
<SvgIcon icon="uil:search" />
|
|
27
|
+
</ButtonIcon>
|
|
28
|
+
|
|
29
|
+
<Suspense>
|
|
30
|
+
<SearchModal show={show} onClose={setFalse} />
|
|
31
|
+
</Suspense>
|
|
32
|
+
</>
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export default GlobalSearch;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SvgIcon } from '@shell/ui/compose';
|
|
2
|
+
import { Divider as ADivider } from 'antd';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { memo } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
const operateIconClass = 'mr-6px p-2px text-20px';
|
|
8
|
+
|
|
9
|
+
const operateIconStyle = {
|
|
10
|
+
boxShadow: 'inset 0 -2px #cdcde6, inset 0 0 1px 1px #fff, 0 1px 2px 1px #1e235a66'
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const SearchFooter = () => {
|
|
14
|
+
const { t } = useTranslation();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<ADivider className="my-2px" />
|
|
19
|
+
<div className="h-44px flex-center gap-14px">
|
|
20
|
+
<span className="flex-y-center">
|
|
21
|
+
<SvgIcon className={clsx(operateIconClass)} icon="mdi:keyboard-return" style={operateIconStyle} />
|
|
22
|
+
<span>{t('common.confirm')}</span>
|
|
23
|
+
</span>
|
|
24
|
+
<span className="flex-y-center">
|
|
25
|
+
<SvgIcon className={clsx(operateIconClass)} icon="mdi:arrow-up-thin" style={operateIconStyle} />
|
|
26
|
+
<SvgIcon className={clsx(operateIconClass)} icon="mdi:arrow-down-thin" style={operateIconStyle} />
|
|
27
|
+
<span>{t('common.switch')}</span>
|
|
28
|
+
</span>
|
|
29
|
+
<span className="flex-y-center">
|
|
30
|
+
<SvgIcon className={clsx(operateIconClass)} icon="mdi:keyboard-esc" style={operateIconStyle} />
|
|
31
|
+
<span>{t('common.close')}</span>
|
|
32
|
+
</span>
|
|
33
|
+
</div>
|
|
34
|
+
</>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default memo(SearchFooter);
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { SvgIcon } from '@shell/ui/compose';
|
|
2
|
+
import { useDebounceFn, useKeyPress } from 'ahooks';
|
|
3
|
+
import { Button as AButton, Empty as AEmpty, Input as AInput, type InputRef, Modal as AModal, Space as ASpace } from 'antd';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
|
|
8
|
+
import { useAdminMenus } from '../../../state/menus/use-admin-menus';
|
|
9
|
+
import { useAdminState } from '../../../state/use-admin-state';
|
|
10
|
+
|
|
11
|
+
import SearchFooter from './SearchFooter';
|
|
12
|
+
import SearchResult from './SearchResult';
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
/** 关闭搜索弹窗 */
|
|
16
|
+
onClose: () => void;
|
|
17
|
+
/** 是否显示搜索弹窗 */
|
|
18
|
+
show: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Transform menu to searchMenus
|
|
23
|
+
*
|
|
24
|
+
* @param menus - Menus
|
|
25
|
+
* @param treeMap
|
|
26
|
+
*/
|
|
27
|
+
function transformMenuToSearchMenus(menus: Menu.CommonMenu[], treeMap: Menu.CommonMenu[] = []) {
|
|
28
|
+
if (menus && menus.length === 0) return [];
|
|
29
|
+
return menus.reduce((acc, cur) => {
|
|
30
|
+
acc.push(cur);
|
|
31
|
+
|
|
32
|
+
if (cur.children && cur.children.length > 0) {
|
|
33
|
+
transformMenuToSearchMenus(cur.children, treeMap);
|
|
34
|
+
}
|
|
35
|
+
return acc;
|
|
36
|
+
}, treeMap);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const SearchModal = (props: Props) => {
|
|
40
|
+
const { onClose, show } = props;
|
|
41
|
+
|
|
42
|
+
const [resultOptions, setResultOptions] = useState<Menu.CommonMenu[]>([]);
|
|
43
|
+
|
|
44
|
+
const [activeRoute, setActiveRoute] = useState<string>('');
|
|
45
|
+
|
|
46
|
+
const { isMobile } = useAdminState();
|
|
47
|
+
|
|
48
|
+
const { t } = useTranslation();
|
|
49
|
+
|
|
50
|
+
const keyword = useRef<InputRef>(null);
|
|
51
|
+
|
|
52
|
+
const { menus, routerPushByKey } = useAdminMenus();
|
|
53
|
+
|
|
54
|
+
const searchMenus = useMemo(() => transformMenuToSearchMenus(menus), [menus]);
|
|
55
|
+
|
|
56
|
+
function getSearchText(menu: Menu.CommonMenu) {
|
|
57
|
+
const i18nTitle = menu.i18nKey ? t(menu.i18nKey) : '';
|
|
58
|
+
return `${menu.title ?? ''} ${i18nTitle}`.toLocaleLowerCase();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function handleClose() {
|
|
62
|
+
// handle with setTimeout to prevent user from seeing some operations
|
|
63
|
+
setTimeout(() => {
|
|
64
|
+
onClose();
|
|
65
|
+
setResultOptions([]);
|
|
66
|
+
}, 200);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function search() {
|
|
70
|
+
const trimKeyword = keyword.current?.input?.value?.toLocaleLowerCase().trim();
|
|
71
|
+
const result = trimKeyword
|
|
72
|
+
? searchMenus.filter(menu => menu.type !== 'divider' && getSearchText(menu).includes(trimKeyword))
|
|
73
|
+
: [];
|
|
74
|
+
|
|
75
|
+
const activeName = result[0]?.key || '';
|
|
76
|
+
|
|
77
|
+
setResultOptions(result);
|
|
78
|
+
|
|
79
|
+
setActiveRoute(activeName as unknown as string);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const handleSearch = useDebounceFn(search, { wait: 300 });
|
|
83
|
+
|
|
84
|
+
/** Key up */
|
|
85
|
+
function handleUp() {
|
|
86
|
+
handleKeyPress(-1); // 方向 -1 表示向上
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Key down */
|
|
90
|
+
function handleDown() {
|
|
91
|
+
handleKeyPress(1); // 方向 1 表示向下
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function getActivePathIndex() {
|
|
95
|
+
return resultOptions.findIndex(item => item.key === activeRoute);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function handleKeyPress(direction: 1 | -1) {
|
|
99
|
+
const { length } = resultOptions;
|
|
100
|
+
if (length === 0) return;
|
|
101
|
+
|
|
102
|
+
const index = getActivePathIndex();
|
|
103
|
+
if (index === -1) return;
|
|
104
|
+
|
|
105
|
+
const activeIndex = (index + direction + length) % length; // 确保 index 在范围内循环
|
|
106
|
+
|
|
107
|
+
const activeKey = resultOptions[activeIndex].key;
|
|
108
|
+
|
|
109
|
+
setActiveRoute(activeKey);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Key enter */
|
|
113
|
+
function handleEnter() {
|
|
114
|
+
if (resultOptions.length === 0 || activeRoute === '') return;
|
|
115
|
+
handleClose();
|
|
116
|
+
routerPushByKey(activeRoute);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
useKeyPress('Escape', handleClose);
|
|
120
|
+
useKeyPress('Enter', handleEnter);
|
|
121
|
+
useKeyPress('uparrow', handleUp);
|
|
122
|
+
useKeyPress('downarrow', handleDown);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<AModal
|
|
126
|
+
destroyOnHidden
|
|
127
|
+
className={clsx({ 'top-0px rounded-0': isMobile })}
|
|
128
|
+
closable={false}
|
|
129
|
+
footer={isMobile ? null : <SearchFooter />}
|
|
130
|
+
height={isMobile ? '100%' : 400}
|
|
131
|
+
open={show}
|
|
132
|
+
style={isMobile ? { margin: 0, maxWidth: '100%', padding: 0 } : undefined}
|
|
133
|
+
styles={{ body: { height: isMobile ? '100vh' : '100%', paddingBottom: 0 } }}
|
|
134
|
+
width={isMobile ? '100%' : 630}
|
|
135
|
+
onCancel={handleClose}
|
|
136
|
+
>
|
|
137
|
+
<ASpace.Compact className="w-full">
|
|
138
|
+
<AInput
|
|
139
|
+
allowClear
|
|
140
|
+
placeholder={t('common.keywordSearch')}
|
|
141
|
+
prefix={<SvgIcon className="text-15px text-#c2c2c2" icon="uil:search" />}
|
|
142
|
+
ref={keyword}
|
|
143
|
+
onInput={handleSearch.run}
|
|
144
|
+
/>
|
|
145
|
+
{isMobile && (
|
|
146
|
+
<AButton ghost type="primary" onClick={handleClose}>
|
|
147
|
+
{t('common.cancel')}
|
|
148
|
+
</AButton>
|
|
149
|
+
)}
|
|
150
|
+
</ASpace.Compact>
|
|
151
|
+
|
|
152
|
+
<div className="mt-20px">
|
|
153
|
+
{resultOptions.length === 0 ? (
|
|
154
|
+
<AEmpty />
|
|
155
|
+
) : (
|
|
156
|
+
resultOptions.map(item => (
|
|
157
|
+
<SearchResult
|
|
158
|
+
active={item.key === activeRoute}
|
|
159
|
+
enter={handleEnter}
|
|
160
|
+
key={item.key}
|
|
161
|
+
menu={item}
|
|
162
|
+
setActiveRouteName={setActiveRoute}
|
|
163
|
+
/>
|
|
164
|
+
))
|
|
165
|
+
)}
|
|
166
|
+
</div>
|
|
167
|
+
</AModal>
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export default SearchModal;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SvgIcon } from '@shell/ui/compose';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
/** 当前结果是否处于键盘或鼠标选中状态 */
|
|
7
|
+
active: boolean;
|
|
8
|
+
/** 确认进入当前选中菜单 */
|
|
9
|
+
enter: () => void;
|
|
10
|
+
/** 当前搜索命中的菜单 */
|
|
11
|
+
menu: Menu.CommonMenu;
|
|
12
|
+
/** 设置当前激活的菜单路径 */
|
|
13
|
+
setActiveRouteName: (name: string) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const SearchResult = memo((props: Props) => {
|
|
17
|
+
const { active, enter, menu, setActiveRouteName } = props;
|
|
18
|
+
|
|
19
|
+
function handleMouseEnter() {
|
|
20
|
+
setActiveRouteName(menu.key);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div
|
|
25
|
+
className={clsx(
|
|
26
|
+
'mt-8px h-56px flex-y-center cursor-pointer justify-between rounded-4px bg-#e5e7eb px-14px dark:bg-dark',
|
|
27
|
+
{ 'bg-primary': active },
|
|
28
|
+
{ 'text-#fff': active }
|
|
29
|
+
)}
|
|
30
|
+
onClick={enter}
|
|
31
|
+
onMouseEnter={handleMouseEnter}
|
|
32
|
+
>
|
|
33
|
+
<span className="ml-5px flex-1">
|
|
34
|
+
{menu.icon}
|
|
35
|
+
{menu.label}
|
|
36
|
+
</span>
|
|
37
|
+
|
|
38
|
+
<SvgIcon icon="ant-design:enter-outlined" />
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export default SearchResult;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import { PageTab } from '../../materials';
|
|
3
|
+
import { FullScreen, ReloadButton } from '@shell/ui/antd';
|
|
4
|
+
import { BetterScroll, DarkModeContainer, SvgIcon } from '@shell/ui/compose';
|
|
5
|
+
import { useSettingsTheme } from '@shell/theme';
|
|
6
|
+
import { useUpdateEffect } from 'ahooks';
|
|
7
|
+
import { clsx } from 'clsx';
|
|
8
|
+
import { useEffect } from 'react';
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
|
|
11
|
+
import { isPC } from '@skyroc/utils/web';
|
|
12
|
+
|
|
13
|
+
import { useAdminTab } from '../../state/tabs/use-admin-tab';
|
|
14
|
+
import { useAdminState } from '../../state/use-admin-state';
|
|
15
|
+
|
|
16
|
+
import { TabContextMenu } from './components/TabContextMenu';
|
|
17
|
+
import { useTabScroll } from './hooks/useTabScroll';
|
|
18
|
+
|
|
19
|
+
function removeFocus() {
|
|
20
|
+
(document.activeElement as HTMLElement)?.blur();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const AdminTab = () => {
|
|
24
|
+
const { t } = useTranslation();
|
|
25
|
+
|
|
26
|
+
const { fullContent, reloadFlag: isReload, reloadPage, toggleFullContent } = useAdminState();
|
|
27
|
+
|
|
28
|
+
const { activeTabId, addTab, initTabStore, isTabRetain, removeTab, route, switchRouteByTab, tabs } = useAdminTab();
|
|
29
|
+
|
|
30
|
+
const { darkMode, tab: tabSettings, themeColor } = useSettingsTheme();
|
|
31
|
+
|
|
32
|
+
const { bsScrollRef, bsWrapper, tabRef } = useTabScroll(activeTabId);
|
|
33
|
+
|
|
34
|
+
const isPCFlag = isPC();
|
|
35
|
+
|
|
36
|
+
function handleReloadPage() {
|
|
37
|
+
reloadPage();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function getContextMenuDisabledKeys(tabId: string, index: number) {
|
|
41
|
+
const disabledKeys: App.Global.DropdownKey[] = [];
|
|
42
|
+
const isRetain = isTabRetain(tabId);
|
|
43
|
+
|
|
44
|
+
if (isRetain) {
|
|
45
|
+
const homeDisable: App.Global.DropdownKey[] = ['closeCurrent', 'closeLeft'];
|
|
46
|
+
disabledKeys.push(...homeDisable);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (index === 0) disabledKeys.push('closeLeft');
|
|
50
|
+
if (index === tabs.length - 1) disabledKeys.push('closeRight');
|
|
51
|
+
|
|
52
|
+
return disabledKeys;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function handleCloseTab(tab: App.Global.Tab) {
|
|
56
|
+
removeTab(tab.id);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function switchTab(tab: App.Global.Tab) {
|
|
60
|
+
switchRouteByTab(tab);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const tabWrapperClass =
|
|
64
|
+
tabSettings.mode === 'chrome' || tabSettings.mode === 'slider' ? 'items-end' : 'items-center gap-12px';
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
initTabStore();
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
// Watch route and add tab
|
|
71
|
+
useUpdateEffect(() => {
|
|
72
|
+
addTab(route.fullPath, route.originPath);
|
|
73
|
+
}, [route.fullPath]);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<DarkModeContainer className="size-full flex-y-center px-16px shadow-tab">
|
|
77
|
+
<div className="h-full flex-1-hidden" ref={bsWrapper}>
|
|
78
|
+
<BetterScroll
|
|
79
|
+
options={{ click: !isPCFlag, scrollX: true, scrollY: false }}
|
|
80
|
+
ref={bsScrollRef}
|
|
81
|
+
onClick={removeFocus}
|
|
82
|
+
>
|
|
83
|
+
<div className={clsx('h-full flex pr-18px', tabWrapperClass)} ref={tabRef}>
|
|
84
|
+
{tabs.map((tab, index) => (
|
|
85
|
+
<TabContextMenu disabledKeys={getContextMenuDisabledKeys(tab.id, index)} key={tab.id} tab={tab}>
|
|
86
|
+
<div className={tabSettings.mode === 'slider' ? 'h-full' : undefined} id={tab.id}>
|
|
87
|
+
<PageTab
|
|
88
|
+
active={tab.id === activeTabId}
|
|
89
|
+
activeColor={themeColor}
|
|
90
|
+
closable={!isTabRetain(tab.id)}
|
|
91
|
+
darkMode={darkMode}
|
|
92
|
+
datatype={tab.id}
|
|
93
|
+
handleClose={() => handleCloseTab(tab)}
|
|
94
|
+
mode={tabSettings.mode}
|
|
95
|
+
prefix={
|
|
96
|
+
<SvgIcon
|
|
97
|
+
className="inline-block align-text-bottom text-16px"
|
|
98
|
+
icon={tab.icon}
|
|
99
|
+
localIcon={tab.localIcon}
|
|
100
|
+
/>
|
|
101
|
+
}
|
|
102
|
+
onClick={() => switchTab(tab)}
|
|
103
|
+
>
|
|
104
|
+
<div className="max-w-240px ellipsis-text">{tab.i18nKey ? t(tab.i18nKey) : tab.label}</div>
|
|
105
|
+
</PageTab>
|
|
106
|
+
</div>
|
|
107
|
+
</TabContextMenu>
|
|
108
|
+
))}
|
|
109
|
+
</div>
|
|
110
|
+
</BetterScroll>
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<ReloadButton isReload={isReload} tooltipContent={t('icon.reload')} onClick={handleReloadPage} />
|
|
114
|
+
|
|
115
|
+
<FullScreen
|
|
116
|
+
enterTooltip={t('icon.fullscreen')}
|
|
117
|
+
exitTooltip={t('icon.fullscreenExit')}
|
|
118
|
+
full={fullContent}
|
|
119
|
+
toggleFullscreen={toggleFullContent}
|
|
120
|
+
/>
|
|
121
|
+
</DarkModeContainer>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default AdminTab;
|