@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,156 @@
|
|
|
1
|
+
/** The union key namespace */
|
|
2
|
+
declare global {
|
|
3
|
+
namespace UnionKey {
|
|
4
|
+
/** Login module */
|
|
5
|
+
type LoginModule = 'bind-wechat' | 'code-login' | 'pwd-login' | 'register' | 'reset-pwd';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The layout mode
|
|
9
|
+
*
|
|
10
|
+
* - Vertical: the vertical menu in left
|
|
11
|
+
* - Horizontal: the horizontal menu in top
|
|
12
|
+
* - Vertical-mix: two vertical mixed menus in left
|
|
13
|
+
* - Top-hybrid-sidebar-first: the vertical first level menus in left and horizontal child level menus in top
|
|
14
|
+
* - Top-hybrid-header-first: the horizontal first level menus in top and vertical child level menus in left
|
|
15
|
+
*/
|
|
16
|
+
type ThemeLayoutMode =
|
|
17
|
+
| 'horizontal'
|
|
18
|
+
| 'top-hybrid-header-first'
|
|
19
|
+
| 'top-hybrid-sidebar-first'
|
|
20
|
+
| 'vertical'
|
|
21
|
+
| 'vertical-hybrid-header-first'
|
|
22
|
+
| 'vertical-mix';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The scroll mode when content overflow
|
|
26
|
+
*
|
|
27
|
+
* - Wrapper: the wrapper component's root element overflow
|
|
28
|
+
* - Content: the content component overflow
|
|
29
|
+
*/
|
|
30
|
+
type ThemeScrollMode = 'content' | 'wrapper';
|
|
31
|
+
|
|
32
|
+
/** Page animate mode */
|
|
33
|
+
type ThemePageAnimateMode =
|
|
34
|
+
| 'fade'
|
|
35
|
+
| 'fade-bottom'
|
|
36
|
+
| 'fade-scale'
|
|
37
|
+
| 'fade-slide'
|
|
38
|
+
| 'none'
|
|
39
|
+
| 'zoom-fade'
|
|
40
|
+
| 'zoom-out';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Tab mode
|
|
44
|
+
*
|
|
45
|
+
* - Chrome: chrome style
|
|
46
|
+
* - Button: button style
|
|
47
|
+
*/
|
|
48
|
+
type ThemeTabMode = 'button' | 'chrome' | 'slider';
|
|
49
|
+
|
|
50
|
+
/** Unocss animate key */
|
|
51
|
+
type UnoCssAnimateKey =
|
|
52
|
+
| 'back-in-down'
|
|
53
|
+
| 'back-in-left'
|
|
54
|
+
| 'back-in-right'
|
|
55
|
+
| 'back-in-up'
|
|
56
|
+
| 'back-out-down'
|
|
57
|
+
| 'back-out-left'
|
|
58
|
+
| 'back-out-right'
|
|
59
|
+
| 'back-out-up'
|
|
60
|
+
| 'bounce'
|
|
61
|
+
| 'bounce-alt'
|
|
62
|
+
| 'bounce-in'
|
|
63
|
+
| 'bounce-in-down'
|
|
64
|
+
| 'bounce-in-left'
|
|
65
|
+
| 'bounce-in-right'
|
|
66
|
+
| 'bounce-in-up'
|
|
67
|
+
| 'bounce-out'
|
|
68
|
+
| 'bounce-out-down'
|
|
69
|
+
| 'bounce-out-left'
|
|
70
|
+
| 'bounce-out-right'
|
|
71
|
+
| 'bounce-out-up'
|
|
72
|
+
| 'fade-in'
|
|
73
|
+
| 'fade-in-bottom-left'
|
|
74
|
+
| 'fade-in-bottom-right'
|
|
75
|
+
| 'fade-in-down'
|
|
76
|
+
| 'fade-in-down-big'
|
|
77
|
+
| 'fade-in-left'
|
|
78
|
+
| 'fade-in-left-big'
|
|
79
|
+
| 'fade-in-right'
|
|
80
|
+
| 'fade-in-right-big'
|
|
81
|
+
| 'fade-in-top-left'
|
|
82
|
+
| 'fade-in-top-right'
|
|
83
|
+
| 'fade-in-up'
|
|
84
|
+
| 'fade-in-up-big'
|
|
85
|
+
| 'fade-out'
|
|
86
|
+
| 'fade-out-bottom-left'
|
|
87
|
+
| 'fade-out-bottom-right'
|
|
88
|
+
| 'fade-out-down'
|
|
89
|
+
| 'fade-out-down-big'
|
|
90
|
+
| 'fade-out-left'
|
|
91
|
+
| 'fade-out-left-big'
|
|
92
|
+
| 'fade-out-right'
|
|
93
|
+
| 'fade-out-right-big'
|
|
94
|
+
| 'fade-out-top-left'
|
|
95
|
+
| 'fade-out-top-right'
|
|
96
|
+
| 'fade-out-up'
|
|
97
|
+
| 'fade-out-up-big'
|
|
98
|
+
| 'flash'
|
|
99
|
+
| 'flip'
|
|
100
|
+
| 'flip-in-x'
|
|
101
|
+
| 'flip-in-y'
|
|
102
|
+
| 'flip-out-x'
|
|
103
|
+
| 'flip-out-y'
|
|
104
|
+
| 'head-shake'
|
|
105
|
+
| 'heart-beat'
|
|
106
|
+
| 'hinge'
|
|
107
|
+
| 'jack-in-the-box'
|
|
108
|
+
| 'jello'
|
|
109
|
+
| 'light-speed-in-left'
|
|
110
|
+
| 'light-speed-in-right'
|
|
111
|
+
| 'light-speed-out-left'
|
|
112
|
+
| 'light-speed-out-right'
|
|
113
|
+
| 'ping'
|
|
114
|
+
| 'pulse'
|
|
115
|
+
| 'pulse-alt'
|
|
116
|
+
| 'roll-in'
|
|
117
|
+
| 'roll-out'
|
|
118
|
+
| 'rotate-in'
|
|
119
|
+
| 'rotate-in-down-left'
|
|
120
|
+
| 'rotate-in-down-right'
|
|
121
|
+
| 'rotate-in-up-left'
|
|
122
|
+
| 'rotate-in-up-right'
|
|
123
|
+
| 'rotate-out'
|
|
124
|
+
| 'rotate-out-down-left'
|
|
125
|
+
| 'rotate-out-down-right'
|
|
126
|
+
| 'rotate-out-up-left'
|
|
127
|
+
| 'rotate-out-up-right'
|
|
128
|
+
| 'rubber-band'
|
|
129
|
+
| 'shake-x'
|
|
130
|
+
| 'shake-y'
|
|
131
|
+
| 'slide-in-down'
|
|
132
|
+
| 'slide-in-left'
|
|
133
|
+
| 'slide-in-right'
|
|
134
|
+
| 'slide-in-up'
|
|
135
|
+
| 'slide-out-down'
|
|
136
|
+
| 'slide-out-left'
|
|
137
|
+
| 'slide-out-right'
|
|
138
|
+
| 'slide-out-up'
|
|
139
|
+
| 'spin'
|
|
140
|
+
| 'swing'
|
|
141
|
+
| 'tada'
|
|
142
|
+
| 'wobble'
|
|
143
|
+
| 'zoom-in'
|
|
144
|
+
| 'zoom-in-down'
|
|
145
|
+
| 'zoom-in-left'
|
|
146
|
+
| 'zoom-in-right'
|
|
147
|
+
| 'zoom-in-up'
|
|
148
|
+
| 'zoom-out'
|
|
149
|
+
| 'zoom-out-down'
|
|
150
|
+
| 'zoom-out-left'
|
|
151
|
+
| 'zoom-out-right'
|
|
152
|
+
| 'zoom-out-up';
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// oxlint-disable unicorn/require-module-specifiers
|
|
2
|
+
/** Shared i18n type primitives and extension points */
|
|
3
|
+
declare global {
|
|
4
|
+
namespace I18n {
|
|
5
|
+
interface LangRegistry {
|
|
6
|
+
'en-US': true;
|
|
7
|
+
'zh-CN': true;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type LangType = keyof LangRegistry extends never ? string : Extract<keyof LangRegistry, string>;
|
|
11
|
+
|
|
12
|
+
type LangOption = {
|
|
13
|
+
key: LangType;
|
|
14
|
+
label: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
interface LocaleMessages {
|
|
18
|
+
common: Common;
|
|
19
|
+
datatable: Datatable;
|
|
20
|
+
dropdown: Record<App.Global.DropdownKey, string>;
|
|
21
|
+
form: Form;
|
|
22
|
+
icon: Icon;
|
|
23
|
+
page: Page;
|
|
24
|
+
request: Request;
|
|
25
|
+
route: Route;
|
|
26
|
+
system: System;
|
|
27
|
+
theme: Theme;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface Schema {
|
|
31
|
+
translation: LocaleMessages;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type GetI18nKey<T extends object, K extends keyof T = keyof T> = K extends string
|
|
35
|
+
? T[K] extends object
|
|
36
|
+
? `${K}.${GetI18nKey<Extract<T[K], object>>}`
|
|
37
|
+
: K
|
|
38
|
+
: never;
|
|
39
|
+
|
|
40
|
+
type I18nKey = GetI18nKey<Schema['translation']>;
|
|
41
|
+
|
|
42
|
+
type TranslateOptions<Locales extends string> = import('react-i18next').TranslationProps<Locales>;
|
|
43
|
+
|
|
44
|
+
interface $T {
|
|
45
|
+
(key: I18nKey): string;
|
|
46
|
+
(key: I18nKey, plural: number, options?: TranslateOptions<LangType>): string;
|
|
47
|
+
(key: I18nKey, defaultMsg: string, options?: TranslateOptions<I18nKey>): string;
|
|
48
|
+
(key: I18nKey, list: unknown[], options?: TranslateOptions<I18nKey>): string;
|
|
49
|
+
(key: I18nKey, list: unknown[], plural: number): string;
|
|
50
|
+
(key: I18nKey, list: unknown[], defaultMsg: string): string;
|
|
51
|
+
(key: I18nKey, named: Record<string, unknown>, options?: TranslateOptions<LangType>): string;
|
|
52
|
+
(key: I18nKey, named: Record<string, unknown>, plural: number): string;
|
|
53
|
+
(key: I18nKey, named: Record<string, unknown>, defaultMsg: string): string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface Common {
|
|
57
|
+
action: string;
|
|
58
|
+
add: string;
|
|
59
|
+
addSuccess: string;
|
|
60
|
+
backToHome: string;
|
|
61
|
+
batchDelete: string;
|
|
62
|
+
cancel: string;
|
|
63
|
+
check: string;
|
|
64
|
+
close: string;
|
|
65
|
+
columnSetting: string;
|
|
66
|
+
config: string;
|
|
67
|
+
confirm: string;
|
|
68
|
+
confirmDelete: string;
|
|
69
|
+
createTime: string;
|
|
70
|
+
delete: string;
|
|
71
|
+
deleteSuccess: string;
|
|
72
|
+
detail: string;
|
|
73
|
+
edit: string;
|
|
74
|
+
error: string;
|
|
75
|
+
errorHint: string;
|
|
76
|
+
expandColumn: string;
|
|
77
|
+
index: string;
|
|
78
|
+
keywordSearch: string;
|
|
79
|
+
logout: string;
|
|
80
|
+
logoutConfirm: string;
|
|
81
|
+
lookForward: string;
|
|
82
|
+
modify: string;
|
|
83
|
+
modifySuccess: string;
|
|
84
|
+
noData: string;
|
|
85
|
+
operate: string;
|
|
86
|
+
pleaseCheckValue: string;
|
|
87
|
+
refresh: string;
|
|
88
|
+
reset: string;
|
|
89
|
+
search: string;
|
|
90
|
+
selectAll: string;
|
|
91
|
+
switch: string;
|
|
92
|
+
tip: string;
|
|
93
|
+
trigger: string;
|
|
94
|
+
tryAlign: string;
|
|
95
|
+
update: string;
|
|
96
|
+
updateTime: string;
|
|
97
|
+
updateSuccess: string;
|
|
98
|
+
userCenter: string;
|
|
99
|
+
warning: string;
|
|
100
|
+
yesOrNo: {
|
|
101
|
+
no: string;
|
|
102
|
+
yes: string;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type RouteKey = Router.RoutePath;
|
|
107
|
+
|
|
108
|
+
type ReplaceSlash<S extends string> = S extends `${infer A}/${infer B}` ? `${A}_${ReplaceSlash<B>}` : S;
|
|
109
|
+
|
|
110
|
+
type TransformPath<P extends string> = P extends '/'
|
|
111
|
+
? 'home'
|
|
112
|
+
: P extends `/${infer Rest}`
|
|
113
|
+
? ReplaceSlash<Rest>
|
|
114
|
+
: never;
|
|
115
|
+
|
|
116
|
+
type I18nRouteKey = string extends RouteKey ? string : TransformPath<RouteKey>;
|
|
117
|
+
|
|
118
|
+
type I18nRouteMap = Record<I18nRouteKey, string>;
|
|
119
|
+
|
|
120
|
+
interface Route extends I18nRouteMap {
|
|
121
|
+
notFound: string;
|
|
122
|
+
root: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface Datatable {}
|
|
126
|
+
interface Form {}
|
|
127
|
+
interface Icon {}
|
|
128
|
+
interface Page {}
|
|
129
|
+
interface Request {}
|
|
130
|
+
interface System {}
|
|
131
|
+
interface Theme extends Record<string, unknown> {}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { SvgIcon } from '@shell/ui/compose';
|
|
2
|
+
import { ConfigProvider, Tree } from 'antd';
|
|
3
|
+
import type { ConfigProviderProps, TreeDataNode, TreeNodeProps, TreeProps } from 'antd';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
|
|
6
|
+
type TreeClassNames = Exclude<NonNullable<TreeProps['classNames']>, (...args: never[]) => unknown>;
|
|
7
|
+
|
|
8
|
+
const APP_TREE_THEME: ConfigProviderProps['theme'] = {
|
|
9
|
+
components: {
|
|
10
|
+
Tree: {
|
|
11
|
+
directoryNodeSelectedBg: 'transparent',
|
|
12
|
+
indentSize: 16,
|
|
13
|
+
nodeHoverBg: 'transparent',
|
|
14
|
+
nodeSelectedBg: 'transparent'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const DEFAULT_CLASS_NAMES: TreeClassNames = {
|
|
20
|
+
item: 'h-38px items-center rounded-md hover:bg-layout [&:has(.ant-tree-node-selected)]:bg-primary-bg!',
|
|
21
|
+
itemSwitcher: 'mt-4px mr-0 block hover:before:bg-transparent!',
|
|
22
|
+
itemTitle: '[.ant-tree-node-selected_&]:(text-primary font-bold)'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export interface AppTreeProps<T extends TreeDataNode = TreeDataNode> extends Omit<TreeProps<T>, 'classNames'> {
|
|
26
|
+
/** 在默认视觉样式之上追加的 Tree 语义类名。 */
|
|
27
|
+
classNames?: TreeClassNames;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function renderDefaultSwitcherIcon(nodeProps: TreeNodeProps) {
|
|
31
|
+
return (
|
|
32
|
+
<SvgIcon
|
|
33
|
+
className="mt-6px size-16px"
|
|
34
|
+
icon="ph:caret-down"
|
|
35
|
+
style={{
|
|
36
|
+
transform: `rotate(${nodeProps.expanded ? 0 : -90}deg)`,
|
|
37
|
+
transition: 'transform 0.3s'
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const AppTree = <T extends TreeDataNode = TreeDataNode>(props: AppTreeProps<T>) => {
|
|
44
|
+
const { classNames, switcherIcon = renderDefaultSwitcherIcon, ...treeProps } = props;
|
|
45
|
+
|
|
46
|
+
function resolveClassNames(): TreeClassNames {
|
|
47
|
+
return {
|
|
48
|
+
...classNames,
|
|
49
|
+
item: clsx(DEFAULT_CLASS_NAMES.item, classNames?.item),
|
|
50
|
+
itemSwitcher: clsx(DEFAULT_CLASS_NAMES.itemSwitcher, classNames?.itemSwitcher),
|
|
51
|
+
itemTitle: clsx(DEFAULT_CLASS_NAMES.itemTitle, classNames?.itemTitle)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<ConfigProvider theme={APP_TREE_THEME}>
|
|
57
|
+
<Tree<T> classNames={resolveClassNames()} switcherIcon={switcherIcon} {...treeProps} />
|
|
58
|
+
</ConfigProvider>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default AppTree;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Tooltip } from 'antd';
|
|
2
|
+
import type { TooltipProps } from 'antd/lib/tooltip';
|
|
3
|
+
import React, { useRef, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
type BeyondHidingProps = Omit<TooltipProps, 'open' | 'trigger'> & {
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
title: React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const BeyondHiding = ({ className, style, title, ...props }: BeyondHidingProps) => {
|
|
12
|
+
const [isShow, setIsShow] = useState(false);
|
|
13
|
+
|
|
14
|
+
const contentRef = useRef<HTMLSpanElement>(null);
|
|
15
|
+
|
|
16
|
+
const isShowTooltip = (): void => {
|
|
17
|
+
// 计算span标签的offsetWidth与盒子元素的offsetWidth,给isShow赋值
|
|
18
|
+
if (contentRef.current && contentRef.current.parentElement) {
|
|
19
|
+
const spanWidth = contentRef.current.offsetWidth;
|
|
20
|
+
const parentWidth = contentRef.current.parentElement.offsetWidth;
|
|
21
|
+
|
|
22
|
+
if (spanWidth > parentWidth) {
|
|
23
|
+
setIsShow(true);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return (
|
|
28
|
+
<Tooltip open={isShow} title={title} {...props}>
|
|
29
|
+
<span
|
|
30
|
+
className={className}
|
|
31
|
+
ref={contentRef}
|
|
32
|
+
style={style}
|
|
33
|
+
onMouseLeave={() => setIsShow(false)}
|
|
34
|
+
onMouseOver={isShowTooltip}
|
|
35
|
+
>
|
|
36
|
+
{title}
|
|
37
|
+
</span>
|
|
38
|
+
</Tooltip>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default BeyondHiding;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// oxlint-disable import/no-unassigned-import
|
|
2
|
+
import { SvgIcon } from '@shell/ui/compose';
|
|
3
|
+
import { Button, Tooltip } from 'antd';
|
|
4
|
+
import type { ButtonProps, TooltipProps } from 'antd';
|
|
5
|
+
import { clsx } from 'clsx';
|
|
6
|
+
import type { CSSProperties } from 'react';
|
|
7
|
+
|
|
8
|
+
import type { ButtonLinkComponentProps } from './ButtonLink';
|
|
9
|
+
import ButtonLink from './ButtonLink';
|
|
10
|
+
import './styles/button-icon-animations.css';
|
|
11
|
+
|
|
12
|
+
/** Icon hover animation types */
|
|
13
|
+
export type IconHoverAnimation =
|
|
14
|
+
| 'bounce' // 弹跳 - 活泼有趣
|
|
15
|
+
| 'flip' // 3D翻转 - 酷炫效果
|
|
16
|
+
| 'pulse' // 脉冲缩放 - 呼吸效果
|
|
17
|
+
| 'rotate' // 旋转 - 适合刷新、设置等图标
|
|
18
|
+
| 'scale' // 缩放放大 - 经典的交互反馈
|
|
19
|
+
| 'shake' // 左右抖动 - 吸引注意力
|
|
20
|
+
| 'spin' // 持续旋转 - 适合加载、刷新
|
|
21
|
+
| 'swing' // 摇摆 - 类似钟摆
|
|
22
|
+
| 'tada' // 惊喜效果 - 多维度组合动画
|
|
23
|
+
| 'wiggle'; // 扭动 - 俏皮可爱
|
|
24
|
+
|
|
25
|
+
type BaseProps = {
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
/** Button class */
|
|
28
|
+
className?: string;
|
|
29
|
+
/** Tooltip class names */
|
|
30
|
+
classNames?: {
|
|
31
|
+
button?: string;
|
|
32
|
+
icon?: string;
|
|
33
|
+
tooltip?: TooltipProps['classNames'];
|
|
34
|
+
};
|
|
35
|
+
/** Icon hover animation effect */
|
|
36
|
+
hoverAnimation?: IconHoverAnimation;
|
|
37
|
+
/** Iconify icon name */
|
|
38
|
+
icon?: string;
|
|
39
|
+
styles?: {
|
|
40
|
+
button?: ButtonProps['styles'];
|
|
41
|
+
icon?: CSSProperties;
|
|
42
|
+
tooltip?: TooltipProps['styles'];
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** Tooltip content */
|
|
46
|
+
tooltipContent?: string;
|
|
47
|
+
/** Tooltip placement */
|
|
48
|
+
tooltipPlacement?: TooltipProps['placement'];
|
|
49
|
+
/** Tooltip props */
|
|
50
|
+
tooltipProps?: Omit<TooltipProps, 'children' | 'classNames' | 'getPopupContainer' | 'placement' | 'title' | 'zIndex'>;
|
|
51
|
+
/** Trigger tooltip on parent */
|
|
52
|
+
triggerParent?: boolean;
|
|
53
|
+
/** Z-index */
|
|
54
|
+
zIndex?: number;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
type WithButtonProps = Omit<ButtonProps, 'icon' | 'iconPosition'> & BaseProps;
|
|
58
|
+
|
|
59
|
+
type WithLinkProps = Partial<Omit<ButtonLinkComponentProps, 'icon' | 'iconPosition'>> & BaseProps;
|
|
60
|
+
|
|
61
|
+
export type ButtonIconProps = WithButtonProps | WithLinkProps;
|
|
62
|
+
|
|
63
|
+
/** - 动态计算class */
|
|
64
|
+
const computeClass = (className: string) => {
|
|
65
|
+
let clsStr = className;
|
|
66
|
+
|
|
67
|
+
if (!clsStr.includes('h-')) {
|
|
68
|
+
clsStr += ' h-2xl';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!clsStr.includes('text-')) {
|
|
72
|
+
clsStr += ' text-lg';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return clsStr;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const ButtonIcon = ({
|
|
79
|
+
children,
|
|
80
|
+
className = 'h-2xl text-lg',
|
|
81
|
+
classNames,
|
|
82
|
+
hoverAnimation,
|
|
83
|
+
icon,
|
|
84
|
+
styles,
|
|
85
|
+
tooltipContent,
|
|
86
|
+
tooltipPlacement = 'bottom',
|
|
87
|
+
tooltipProps,
|
|
88
|
+
triggerParent,
|
|
89
|
+
zIndex = 98,
|
|
90
|
+
...rest
|
|
91
|
+
}: ButtonIconProps) => {
|
|
92
|
+
const cls = computeClass(className);
|
|
93
|
+
|
|
94
|
+
function getPopupContainer(triggerNode: HTMLElement) {
|
|
95
|
+
return triggerParent ? triggerNode.parentElement! : document.body;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const Comp = 'to' in rest ? ButtonLink : Button;
|
|
99
|
+
|
|
100
|
+
const typeProps = 'to' in rest ? { btnType: 'text' as const } : { type: 'text' as const };
|
|
101
|
+
|
|
102
|
+
// 根据动画类型添加对应的动画类名
|
|
103
|
+
const animationClass = hoverAnimation ? `btn-icon-hover-${hoverAnimation}` : '';
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<Tooltip
|
|
107
|
+
classNames={classNames?.tooltip}
|
|
108
|
+
getPopupContainer={getPopupContainer}
|
|
109
|
+
placement={tooltipPlacement}
|
|
110
|
+
styles={styles?.tooltip}
|
|
111
|
+
title={tooltipContent}
|
|
112
|
+
zIndex={zIndex}
|
|
113
|
+
{...tooltipProps}
|
|
114
|
+
>
|
|
115
|
+
<Comp className={clsx(cls, classNames?.button)} {...typeProps} {...rest} styles={styles?.button}>
|
|
116
|
+
<div className={clsx('flex-center gap-8px', animationClass)}>
|
|
117
|
+
{children || <SvgIcon className={classNames?.icon} icon={icon} style={styles?.icon} />}
|
|
118
|
+
</div>
|
|
119
|
+
</Comp>
|
|
120
|
+
</Tooltip>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
123
|
+
export default ButtonIcon;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createLink } from '@tanstack/react-router';
|
|
2
|
+
import type { LinkComponent, LinkComponentProps } from '@tanstack/react-router';
|
|
3
|
+
import { Button } from 'antd';
|
|
4
|
+
import type { ButtonProps } from 'antd';
|
|
5
|
+
import type { Ref } from 'react';
|
|
6
|
+
|
|
7
|
+
interface ButtonLinkProps extends Omit<ButtonProps, 'type'> {
|
|
8
|
+
/**
|
|
9
|
+
* - Button type
|
|
10
|
+
* - 因为link组件也有type属性,并且会吞掉button的type属性,所以需要单独传入
|
|
11
|
+
*/
|
|
12
|
+
btnType?: ButtonProps['type'];
|
|
13
|
+
ref?: Ref<HTMLAnchorElement>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const ButtonLinkComponent = (props: ButtonLinkProps) => {
|
|
17
|
+
const { btnType, ref, ...rest } = props;
|
|
18
|
+
|
|
19
|
+
return <Button type={btnType} {...rest} ref={ref} />;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type ButtonLinkComponentProps = LinkComponentProps<typeof ButtonLinkComponent>;
|
|
23
|
+
|
|
24
|
+
const CreatedButtonLinkComponent = createLink(ButtonLinkComponent);
|
|
25
|
+
|
|
26
|
+
const ButtonLink: LinkComponent<typeof ButtonLinkComponent> = props => {
|
|
27
|
+
return <CreatedButtonLinkComponent preload="intent" {...props} />;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default ButtonLink;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SvgIcon } from '@shell/ui/compose';
|
|
2
|
+
import { Button, Typography } from 'antd';
|
|
3
|
+
import type { FallbackProps } from 'react-error-boundary';
|
|
4
|
+
|
|
5
|
+
const { Text, Title } = Typography;
|
|
6
|
+
|
|
7
|
+
interface ErrorBoundaryProps extends FallbackProps {
|
|
8
|
+
/** Error hint text shown in production (default: 'Something went wrong') */
|
|
9
|
+
errorHint?: string;
|
|
10
|
+
/** Whether in development mode */
|
|
11
|
+
isDev?: boolean;
|
|
12
|
+
/** Retry button text (default: 'Try Again') */
|
|
13
|
+
retryText?: string;
|
|
14
|
+
/** Theme color for the reset button */
|
|
15
|
+
themeColor?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const ErrorPage = (props: ErrorBoundaryProps) => {
|
|
19
|
+
const {
|
|
20
|
+
error,
|
|
21
|
+
errorHint = 'Something went wrong',
|
|
22
|
+
isDev = false,
|
|
23
|
+
resetErrorBoundary,
|
|
24
|
+
retryText = 'Try Again',
|
|
25
|
+
themeColor
|
|
26
|
+
} = props;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className="size-full min-h-520px flex-col-center gap-16px overflow-hidden">
|
|
30
|
+
<div className="flex text-400px text-primary">
|
|
31
|
+
<SvgIcon localIcon="error" />
|
|
32
|
+
</div>
|
|
33
|
+
{isDev ? <Text code>{error.message}</Text> : <Title level={3}>{errorHint}</Title>}
|
|
34
|
+
<Button
|
|
35
|
+
style={themeColor ? { backgroundColor: themeColor } : undefined}
|
|
36
|
+
type="primary"
|
|
37
|
+
onClick={resetErrorBoundary}
|
|
38
|
+
>
|
|
39
|
+
{retryText}
|
|
40
|
+
</Button>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default ErrorPage;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { SvgIcon } from '@shell/ui/compose';
|
|
2
|
+
import { useNavigate, useRouter } from '@tanstack/react-router';
|
|
3
|
+
import { Button } from 'antd';
|
|
4
|
+
import { memo } from 'react';
|
|
5
|
+
|
|
6
|
+
type ExceptionType = '403' | '404' | '500';
|
|
7
|
+
|
|
8
|
+
interface HomeRouteContext {
|
|
9
|
+
getHomeRoute?: () => string;
|
|
10
|
+
homeRoute?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ExceptionBaseProps {
|
|
14
|
+
/** Button text (default: 'Back to Home') */
|
|
15
|
+
buttonText?: string;
|
|
16
|
+
/** Home route used by the action button. Defaults to the router context home route. */
|
|
17
|
+
homePath?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Exception type
|
|
20
|
+
*
|
|
21
|
+
* - 403: no permission
|
|
22
|
+
* - 404: not found
|
|
23
|
+
* - 500: service error
|
|
24
|
+
*/
|
|
25
|
+
type: ExceptionType;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const iconMap: Record<ExceptionType, string> = {
|
|
29
|
+
'403': 'no-permission',
|
|
30
|
+
'404': 'not-found',
|
|
31
|
+
'500': 'service-error'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function getHomePath(context: unknown) {
|
|
35
|
+
if (!context || typeof context !== 'object') {
|
|
36
|
+
return '/';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { getHomeRoute, homeRoute } = context as HomeRouteContext;
|
|
40
|
+
|
|
41
|
+
return homeRoute || getHomeRoute?.() || '/';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const ExceptionBase = memo((props: ExceptionBaseProps) => {
|
|
45
|
+
const { buttonText = 'Back to Home', homePath, type } = props;
|
|
46
|
+
|
|
47
|
+
const nav = useNavigate();
|
|
48
|
+
const router = useRouter();
|
|
49
|
+
const targetHomePath = homePath || getHomePath(router.options.context);
|
|
50
|
+
|
|
51
|
+
function handleClick() {
|
|
52
|
+
nav({ to: targetHomePath });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div className="size-full min-h-520px flex-col-center gap-24px overflow-hidden">
|
|
57
|
+
<div className="flex text-400px text-primary">
|
|
58
|
+
<SvgIcon localIcon={iconMap[type]} />
|
|
59
|
+
</div>
|
|
60
|
+
<Button type="primary" onClick={handleClick}>
|
|
61
|
+
{buttonText}
|
|
62
|
+
</Button>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
ExceptionBase.displayName = 'ExceptionBase';
|
|
68
|
+
|
|
69
|
+
export default ExceptionBase;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Icon } from '@iconify/react';
|
|
2
|
+
|
|
3
|
+
import ButtonIcon from './ButtonIcon';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
/** Button class */
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Tooltip text when entering fullscreen (default: 'Fullscreen') */
|
|
9
|
+
enterTooltip?: string;
|
|
10
|
+
/** Tooltip text when exiting fullscreen (default: 'Exit Fullscreen') */
|
|
11
|
+
exitTooltip?: string;
|
|
12
|
+
/** Whether currently in fullscreen */
|
|
13
|
+
full?: boolean;
|
|
14
|
+
/** Toggle fullscreen callback */
|
|
15
|
+
toggleFullscreen: () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const FullScreen = (props: Props) => {
|
|
19
|
+
const { className, enterTooltip = 'Fullscreen', exitTooltip = 'Exit Fullscreen', full, toggleFullscreen } = props;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<ButtonIcon
|
|
23
|
+
className={className}
|
|
24
|
+
hoverAnimation="scale"
|
|
25
|
+
tooltipContent={full ? exitTooltip : enterTooltip}
|
|
26
|
+
onClick={toggleFullscreen}
|
|
27
|
+
>
|
|
28
|
+
<Icon icon={full ? 'gridicons:fullscreen-exit' : 'gridicons:fullscreen'} />
|
|
29
|
+
</ButtonIcon>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default FullScreen;
|