@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,52 @@
|
|
|
1
|
+
import { parseQuery, stringifyQuery } from '@skyroc/utils';
|
|
2
|
+
import { createRouter } from '@tanstack/react-router';
|
|
3
|
+
|
|
4
|
+
import { globalConfig } from '@/config';
|
|
5
|
+
import { queryClient } from '@/service/queryClient';
|
|
6
|
+
|
|
7
|
+
import { setRouter } from './router-ref';
|
|
8
|
+
import { routeTree } from './routeTree.gen';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* - 路由配置
|
|
12
|
+
* - 使用的是 TanStack Router 的 约定式路由配置方法 无需手动配置路由
|
|
13
|
+
* - 路由配置文件为 src/features/router/routeTree.gen.ts
|
|
14
|
+
* - 路由约定式 [详情见](https://tanstack.com/router/latest/docs/framework/react/routing/routing-concepts)
|
|
15
|
+
* - https://tanstack.com/router/latest/docs/framework/react/routing/file-based-routing
|
|
16
|
+
* - https://tanstack.com/router/latest/docs/framework/react/routing/file-naming-conventions
|
|
17
|
+
*/
|
|
18
|
+
export const router = createRouter({
|
|
19
|
+
context: {
|
|
20
|
+
initAuth: () => Promise.resolve(null),
|
|
21
|
+
logout: () => Promise.resolve(),
|
|
22
|
+
getHomeRoute: () => globalConfig.defaultHome,
|
|
23
|
+
homeRoute: globalConfig.defaultHome,
|
|
24
|
+
isAuthInitialized: false,
|
|
25
|
+
isLoggedIn: false,
|
|
26
|
+
queryClient,
|
|
27
|
+
userInfo: undefined
|
|
28
|
+
},
|
|
29
|
+
defaultPreload: 'intent',
|
|
30
|
+
stringifySearch: stringifyQuery,
|
|
31
|
+
parseSearch: parseQuery,
|
|
32
|
+
defaultPreloadStaleTime: 0,
|
|
33
|
+
defaultPendingMs: 10,
|
|
34
|
+
defaultPendingMinMs: 1000,
|
|
35
|
+
defaultStructuralSharing: true,
|
|
36
|
+
notFoundMode: 'root',
|
|
37
|
+
routeTree,
|
|
38
|
+
scrollRestoration: true
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export type RouterConfig = typeof router;
|
|
42
|
+
|
|
43
|
+
setRouter(router);
|
|
44
|
+
|
|
45
|
+
declare module '@tanstack/react-router' {
|
|
46
|
+
interface Register {
|
|
47
|
+
router: RouterConfig;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
51
|
+
interface StaticDataRouteOption extends Router.Meta {}
|
|
52
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
|
|
5
|
+
// noinspection JSUnusedGlobalSymbols
|
|
6
|
+
|
|
7
|
+
// This file was automatically generated by TanStack Router.
|
|
8
|
+
// You should NOT make any changes in this file as it will be overwritten.
|
|
9
|
+
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
10
|
+
|
|
11
|
+
import { Route as rootRouteImport } from './../../pages/__root'
|
|
12
|
+
import { Route as adminLayoutRouteImport } from './../../pages/(admin)/layout'
|
|
13
|
+
import { Route as IndexRouteImport } from './../../pages/index'
|
|
14
|
+
import { Route as errors500RouteImport } from './../../pages/(errors)/500'
|
|
15
|
+
import { Route as errors404RouteImport } from './../../pages/(errors)/404'
|
|
16
|
+
import { Route as errors403RouteImport } from './../../pages/(errors)/403'
|
|
17
|
+
import { Route as authLoginOutRouteImport } from './../../pages/(auth)/login-out'
|
|
18
|
+
import { Route as authLoginLayoutRouteImport } from './../../pages/(auth)/login/layout'
|
|
19
|
+
import { Route as authLoginIndexRouteImport } from './../../pages/(auth)/login/index'
|
|
20
|
+
import { Route as adminHomeIndexRouteImport } from './../../pages/(admin)/home/index'
|
|
21
|
+
|
|
22
|
+
const adminLayoutRoute = adminLayoutRouteImport.update({
|
|
23
|
+
id: '/(admin)',
|
|
24
|
+
getParentRoute: () => rootRouteImport,
|
|
25
|
+
} as any)
|
|
26
|
+
const IndexRoute = IndexRouteImport.update({
|
|
27
|
+
id: '/',
|
|
28
|
+
path: '/',
|
|
29
|
+
getParentRoute: () => rootRouteImport,
|
|
30
|
+
} as any)
|
|
31
|
+
const errors500Route = errors500RouteImport.update({
|
|
32
|
+
id: '/(errors)/500',
|
|
33
|
+
path: '/500',
|
|
34
|
+
getParentRoute: () => rootRouteImport,
|
|
35
|
+
} as any)
|
|
36
|
+
const errors404Route = errors404RouteImport.update({
|
|
37
|
+
id: '/(errors)/404',
|
|
38
|
+
path: '/404',
|
|
39
|
+
getParentRoute: () => rootRouteImport,
|
|
40
|
+
} as any)
|
|
41
|
+
const errors403Route = errors403RouteImport.update({
|
|
42
|
+
id: '/(errors)/403',
|
|
43
|
+
path: '/403',
|
|
44
|
+
getParentRoute: () => rootRouteImport,
|
|
45
|
+
} as any)
|
|
46
|
+
const authLoginOutRoute = authLoginOutRouteImport.update({
|
|
47
|
+
id: '/(auth)/login-out',
|
|
48
|
+
path: '/login-out',
|
|
49
|
+
getParentRoute: () => rootRouteImport,
|
|
50
|
+
} as any)
|
|
51
|
+
const authLoginLayoutRoute = authLoginLayoutRouteImport.update({
|
|
52
|
+
id: '/(auth)/login',
|
|
53
|
+
path: '/login',
|
|
54
|
+
getParentRoute: () => rootRouteImport,
|
|
55
|
+
} as any)
|
|
56
|
+
const authLoginIndexRoute = authLoginIndexRouteImport.update({
|
|
57
|
+
id: '/',
|
|
58
|
+
path: '/',
|
|
59
|
+
getParentRoute: () => authLoginLayoutRoute,
|
|
60
|
+
} as any)
|
|
61
|
+
const adminHomeIndexRoute = adminHomeIndexRouteImport.update({
|
|
62
|
+
id: '/home/',
|
|
63
|
+
path: '/home/',
|
|
64
|
+
getParentRoute: () => adminLayoutRoute,
|
|
65
|
+
} as any)
|
|
66
|
+
|
|
67
|
+
export interface FileRoutesByFullPath {
|
|
68
|
+
'/': typeof IndexRoute
|
|
69
|
+
'/login': typeof authLoginLayoutRouteWithChildren
|
|
70
|
+
'/login-out': typeof authLoginOutRoute
|
|
71
|
+
'/403': typeof errors403Route
|
|
72
|
+
'/404': typeof errors404Route
|
|
73
|
+
'/500': typeof errors500Route
|
|
74
|
+
'/home/': typeof adminHomeIndexRoute
|
|
75
|
+
'/login/': typeof authLoginIndexRoute
|
|
76
|
+
}
|
|
77
|
+
export interface FileRoutesByTo {
|
|
78
|
+
'/': typeof IndexRoute
|
|
79
|
+
'/login-out': typeof authLoginOutRoute
|
|
80
|
+
'/403': typeof errors403Route
|
|
81
|
+
'/404': typeof errors404Route
|
|
82
|
+
'/500': typeof errors500Route
|
|
83
|
+
'/home': typeof adminHomeIndexRoute
|
|
84
|
+
'/login': typeof authLoginIndexRoute
|
|
85
|
+
}
|
|
86
|
+
export interface FileRoutesById {
|
|
87
|
+
__root__: typeof rootRouteImport
|
|
88
|
+
'/': typeof IndexRoute
|
|
89
|
+
'/(admin)': typeof adminLayoutRouteWithChildren
|
|
90
|
+
'/(auth)/login': typeof authLoginLayoutRouteWithChildren
|
|
91
|
+
'/(auth)/login-out': typeof authLoginOutRoute
|
|
92
|
+
'/(errors)/403': typeof errors403Route
|
|
93
|
+
'/(errors)/404': typeof errors404Route
|
|
94
|
+
'/(errors)/500': typeof errors500Route
|
|
95
|
+
'/(admin)/home/': typeof adminHomeIndexRoute
|
|
96
|
+
'/(auth)/login/': typeof authLoginIndexRoute
|
|
97
|
+
}
|
|
98
|
+
export interface FileRouteTypes {
|
|
99
|
+
fileRoutesByFullPath: FileRoutesByFullPath
|
|
100
|
+
fullPaths:
|
|
101
|
+
| '/'
|
|
102
|
+
| '/login'
|
|
103
|
+
| '/login-out'
|
|
104
|
+
| '/403'
|
|
105
|
+
| '/404'
|
|
106
|
+
| '/500'
|
|
107
|
+
| '/home/'
|
|
108
|
+
| '/login/'
|
|
109
|
+
fileRoutesByTo: FileRoutesByTo
|
|
110
|
+
to: '/' | '/login-out' | '/403' | '/404' | '/500' | '/home' | '/login'
|
|
111
|
+
id:
|
|
112
|
+
| '__root__'
|
|
113
|
+
| '/'
|
|
114
|
+
| '/(admin)'
|
|
115
|
+
| '/(auth)/login'
|
|
116
|
+
| '/(auth)/login-out'
|
|
117
|
+
| '/(errors)/403'
|
|
118
|
+
| '/(errors)/404'
|
|
119
|
+
| '/(errors)/500'
|
|
120
|
+
| '/(admin)/home/'
|
|
121
|
+
| '/(auth)/login/'
|
|
122
|
+
fileRoutesById: FileRoutesById
|
|
123
|
+
}
|
|
124
|
+
export interface RootRouteChildren {
|
|
125
|
+
IndexRoute: typeof IndexRoute
|
|
126
|
+
adminLayoutRoute: typeof adminLayoutRouteWithChildren
|
|
127
|
+
authLoginLayoutRoute: typeof authLoginLayoutRouteWithChildren
|
|
128
|
+
authLoginOutRoute: typeof authLoginOutRoute
|
|
129
|
+
errors403Route: typeof errors403Route
|
|
130
|
+
errors404Route: typeof errors404Route
|
|
131
|
+
errors500Route: typeof errors500Route
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
declare module '@tanstack/react-router' {
|
|
135
|
+
interface FileRoutesByPath {
|
|
136
|
+
'/(admin)': {
|
|
137
|
+
id: '/(admin)'
|
|
138
|
+
path: ''
|
|
139
|
+
fullPath: ''
|
|
140
|
+
preLoaderRoute: typeof adminLayoutRouteImport
|
|
141
|
+
parentRoute: typeof rootRouteImport
|
|
142
|
+
}
|
|
143
|
+
'/': {
|
|
144
|
+
id: '/'
|
|
145
|
+
path: '/'
|
|
146
|
+
fullPath: '/'
|
|
147
|
+
preLoaderRoute: typeof IndexRouteImport
|
|
148
|
+
parentRoute: typeof rootRouteImport
|
|
149
|
+
}
|
|
150
|
+
'/(errors)/500': {
|
|
151
|
+
id: '/(errors)/500'
|
|
152
|
+
path: '/500'
|
|
153
|
+
fullPath: '/500'
|
|
154
|
+
preLoaderRoute: typeof errors500RouteImport
|
|
155
|
+
parentRoute: typeof rootRouteImport
|
|
156
|
+
}
|
|
157
|
+
'/(errors)/404': {
|
|
158
|
+
id: '/(errors)/404'
|
|
159
|
+
path: '/404'
|
|
160
|
+
fullPath: '/404'
|
|
161
|
+
preLoaderRoute: typeof errors404RouteImport
|
|
162
|
+
parentRoute: typeof rootRouteImport
|
|
163
|
+
}
|
|
164
|
+
'/(errors)/403': {
|
|
165
|
+
id: '/(errors)/403'
|
|
166
|
+
path: '/403'
|
|
167
|
+
fullPath: '/403'
|
|
168
|
+
preLoaderRoute: typeof errors403RouteImport
|
|
169
|
+
parentRoute: typeof rootRouteImport
|
|
170
|
+
}
|
|
171
|
+
'/(auth)/login-out': {
|
|
172
|
+
id: '/(auth)/login-out'
|
|
173
|
+
path: '/login-out'
|
|
174
|
+
fullPath: '/login-out'
|
|
175
|
+
preLoaderRoute: typeof authLoginOutRouteImport
|
|
176
|
+
parentRoute: typeof rootRouteImport
|
|
177
|
+
}
|
|
178
|
+
'/(auth)/login': {
|
|
179
|
+
id: '/(auth)/login'
|
|
180
|
+
path: '/login'
|
|
181
|
+
fullPath: '/login'
|
|
182
|
+
preLoaderRoute: typeof authLoginLayoutRouteImport
|
|
183
|
+
parentRoute: typeof rootRouteImport
|
|
184
|
+
}
|
|
185
|
+
'/(auth)/login/': {
|
|
186
|
+
id: '/(auth)/login/'
|
|
187
|
+
path: '/'
|
|
188
|
+
fullPath: '/login/'
|
|
189
|
+
preLoaderRoute: typeof authLoginIndexRouteImport
|
|
190
|
+
parentRoute: typeof authLoginLayoutRoute
|
|
191
|
+
}
|
|
192
|
+
'/(admin)/home/': {
|
|
193
|
+
id: '/(admin)/home/'
|
|
194
|
+
path: '/home'
|
|
195
|
+
fullPath: '/home/'
|
|
196
|
+
preLoaderRoute: typeof adminHomeIndexRouteImport
|
|
197
|
+
parentRoute: typeof adminLayoutRoute
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
interface adminLayoutRouteChildren {
|
|
203
|
+
adminHomeIndexRoute: typeof adminHomeIndexRoute
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const adminLayoutRouteChildren: adminLayoutRouteChildren = {
|
|
207
|
+
adminHomeIndexRoute: adminHomeIndexRoute,
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const adminLayoutRouteWithChildren = adminLayoutRoute._addFileChildren(
|
|
211
|
+
adminLayoutRouteChildren,
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
interface authLoginLayoutRouteChildren {
|
|
215
|
+
authLoginIndexRoute: typeof authLoginIndexRoute
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const authLoginLayoutRouteChildren: authLoginLayoutRouteChildren = {
|
|
219
|
+
authLoginIndexRoute: authLoginIndexRoute,
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const authLoginLayoutRouteWithChildren = authLoginLayoutRoute._addFileChildren(
|
|
223
|
+
authLoginLayoutRouteChildren,
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
const rootRouteChildren: RootRouteChildren = {
|
|
227
|
+
IndexRoute: IndexRoute,
|
|
228
|
+
adminLayoutRoute: adminLayoutRouteWithChildren,
|
|
229
|
+
authLoginLayoutRoute: authLoginLayoutRouteWithChildren,
|
|
230
|
+
authLoginOutRoute: authLoginOutRoute,
|
|
231
|
+
errors403Route: errors403Route,
|
|
232
|
+
errors404Route: errors404Route,
|
|
233
|
+
errors500Route: errors500Route,
|
|
234
|
+
}
|
|
235
|
+
export const routeTree = rootRouteImport
|
|
236
|
+
._addFileChildren(rootRouteChildren)
|
|
237
|
+
._addFileTypes<FileRouteTypes>()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RouterConfig } from './index';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* - 路由实例引用
|
|
5
|
+
* - 用于在非组件模块(如请求适配器 adapter.ts)中惰性访问 router
|
|
6
|
+
* - 目的:避免这些模块静态 import `./index`,从而切断
|
|
7
|
+
* `request → adapter → router → routeTree.gen → 路由模块` 的加载期循环依赖
|
|
8
|
+
* - 仅做运行时引用存取,本模块无任何运行时依赖
|
|
9
|
+
*/
|
|
10
|
+
let routerRef: RouterConfig | null = null;
|
|
11
|
+
|
|
12
|
+
/** 在 router 创建完成后注册实例(由 ./index 调用)。 */
|
|
13
|
+
export function setRouter(router: RouterConfig) {
|
|
14
|
+
routerRef = router;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** 运行时获取 router 实例,未初始化时抛错以便尽早发现问题。 */
|
|
18
|
+
export function getRouter(): RouterConfig {
|
|
19
|
+
if (!routerRef) {
|
|
20
|
+
throw new Error('[router-ref] router 尚未初始化,请确认在使用前已加载 @/features/router');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return routerRef;
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { setupI18n as setupCoreI18n } from '@shell/i18n';
|
|
2
|
+
import type { LocaleSetupOptions } from '@shell/i18n';
|
|
3
|
+
|
|
4
|
+
import { globalConfig } from '@/config';
|
|
5
|
+
import { localStg } from '@/utils/storage';
|
|
6
|
+
|
|
7
|
+
export { $t } from '@shell/i18n';
|
|
8
|
+
|
|
9
|
+
/** Setup plugin i18n */
|
|
10
|
+
export async function setupI18n(options: LocaleSetupOptions<I18n.LangType> = {}) {
|
|
11
|
+
await setupCoreI18n({
|
|
12
|
+
defaultLocale: globalConfig.defaultLang,
|
|
13
|
+
fallbackLocale: 'en-US',
|
|
14
|
+
localeOptions: globalConfig.defaultLangOptions,
|
|
15
|
+
missingWarn: import.meta.env.DEV,
|
|
16
|
+
storage: {
|
|
17
|
+
getLocale: () => localStg.get('lang'),
|
|
18
|
+
setLocale: lang => localStg.set('lang', lang)
|
|
19
|
+
},
|
|
20
|
+
...options
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// oxlint-disable import/no-unassigned-import
|
|
2
|
+
import { locale } from 'dayjs';
|
|
3
|
+
|
|
4
|
+
import 'dayjs/locale/zh-cn';
|
|
5
|
+
import 'dayjs/locale/en';
|
|
6
|
+
|
|
7
|
+
const localeMap: Record<I18n.LangType, string> = {
|
|
8
|
+
'zh-CN': 'zh-cn',
|
|
9
|
+
'en-US': 'en'
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function syncLocales(lang: I18n.LangType) {
|
|
13
|
+
locale(localeMap[lang]);
|
|
14
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
+
|
|
3
|
+
const quickStartItems = [
|
|
4
|
+
'Edit src/pages/(admin)/home/index.tsx',
|
|
5
|
+
'Add routes under src/pages/(admin)',
|
|
6
|
+
'Configure runtime API adapters in src/service'
|
|
7
|
+
] as const;
|
|
8
|
+
|
|
9
|
+
const Home = () => {
|
|
10
|
+
const { t } = useTranslation();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<ASpace className="w-full" orientation="vertical" size={16}>
|
|
14
|
+
<ACard variant="borderless">
|
|
15
|
+
<ASpace className="w-full" orientation="vertical" size={16}>
|
|
16
|
+
<div>
|
|
17
|
+
<h1 className="m-0 text-28px font-600 text-primary">{t('system.title')}</h1>
|
|
18
|
+
<p className="m-0 mt-8px text-14px text-text-2">A minimal admin starter is ready.</p>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<ARow gutter={[16, 16]}>
|
|
22
|
+
{quickStartItems.map(item => {
|
|
23
|
+
return (
|
|
24
|
+
<ACol key={item} lg={8} span={24}>
|
|
25
|
+
<div className="rounded-8px bg-layout p-16px text-14px text-text-1">{item}</div>
|
|
26
|
+
</ACol>
|
|
27
|
+
);
|
|
28
|
+
})}
|
|
29
|
+
</ARow>
|
|
30
|
+
</ASpace>
|
|
31
|
+
</ACard>
|
|
32
|
+
</ASpace>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Route = createFileRoute('/(admin)/home/')({
|
|
37
|
+
component: Home,
|
|
38
|
+
staticData: {
|
|
39
|
+
i18nKey: 'route.home',
|
|
40
|
+
title: 'home',
|
|
41
|
+
menu: {
|
|
42
|
+
icon: 'mdi:monitor-dashboard',
|
|
43
|
+
order: 1
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AdminLayout as WebAdminLayout } from '@shell/layouts';
|
|
2
|
+
import { NotificationButton } from '@shell/notification';
|
|
3
|
+
import { DarkModeContainer } from '@shell/ui/compose';
|
|
4
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
import SystemLogo from '@/components/SystemLogo';
|
|
8
|
+
import UserAvatar from '@/features/auth/components/UserAvatar';
|
|
9
|
+
import { guardAdminRoute } from '@/features/router/guard';
|
|
10
|
+
|
|
11
|
+
const AdminFooter = () => {
|
|
12
|
+
return (
|
|
13
|
+
<DarkModeContainer className="h-full flex-center">
|
|
14
|
+
<a
|
|
15
|
+
href="https://github.com/Ohh-889/skyroc-admin/blob/main/LICENSE"
|
|
16
|
+
rel="noopener noreferrer"
|
|
17
|
+
target="_blank"
|
|
18
|
+
>
|
|
19
|
+
Copyright MIT © 2021 Skyroc
|
|
20
|
+
</a>
|
|
21
|
+
</DarkModeContainer>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const AdminLayout = () => {
|
|
26
|
+
const { t } = useTranslation();
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<WebAdminLayout
|
|
30
|
+
footer={<AdminFooter />}
|
|
31
|
+
headerMiddleActions={<NotificationButton className="px-12px" />}
|
|
32
|
+
headerRightActions={<UserAvatar />}
|
|
33
|
+
logo={<SystemLogo className="text-32px text-primary" />}
|
|
34
|
+
logoTitle={t('system.title')}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Route = createFileRoute('/(admin)')({
|
|
40
|
+
component: AdminLayout,
|
|
41
|
+
beforeLoad: async options => {
|
|
42
|
+
await guardAdminRoute(options);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
+
|
|
3
|
+
import { useAuthFormRules } from '@/features/auth/use-auth-form-rules';
|
|
4
|
+
import { useInitLogin } from '@/features/auth/use-login';
|
|
5
|
+
|
|
6
|
+
type AccountKey = 'admin' | 'super' | 'user';
|
|
7
|
+
|
|
8
|
+
interface Account {
|
|
9
|
+
key: AccountKey;
|
|
10
|
+
label: string;
|
|
11
|
+
password: string;
|
|
12
|
+
userName: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type LoginParams = Pick<Account, 'password' | 'userName'>;
|
|
16
|
+
|
|
17
|
+
const INITIAL_VALUES = {
|
|
18
|
+
password: '123456',
|
|
19
|
+
userName: 'Soybean'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const Login = () => {
|
|
23
|
+
const { t } = useTranslation();
|
|
24
|
+
|
|
25
|
+
const [form] = AForm.useForm<LoginParams>();
|
|
26
|
+
|
|
27
|
+
const { loading, login } = useInitLogin();
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
formRules: { pwd, userName: userNameRules }
|
|
31
|
+
} = useAuthFormRules();
|
|
32
|
+
|
|
33
|
+
const accounts: Account[] = [
|
|
34
|
+
{
|
|
35
|
+
key: 'super',
|
|
36
|
+
label: t('page.login.pwdLogin.superAdmin'),
|
|
37
|
+
password: '123456',
|
|
38
|
+
userName: 'Super'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
key: 'admin',
|
|
42
|
+
label: t('page.login.pwdLogin.admin'),
|
|
43
|
+
password: '123456',
|
|
44
|
+
userName: 'Admin'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
key: 'user',
|
|
48
|
+
label: t('page.login.pwdLogin.user'),
|
|
49
|
+
password: '123456',
|
|
50
|
+
userName: 'User'
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
function handleAccountLogin(account: Account) {
|
|
55
|
+
login({
|
|
56
|
+
password: account.password,
|
|
57
|
+
userName: account.userName
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
useKeyPress('enter', () => {
|
|
62
|
+
form.submit();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
<h3 className="text-18px text-primary font-medium">{t('page.login.pwdLogin.title')}</h3>
|
|
68
|
+
<AForm className="pt-24px" form={form} initialValues={INITIAL_VALUES} onFinish={login}>
|
|
69
|
+
<AForm.Item name="userName" rules={userNameRules}>
|
|
70
|
+
<AInput size="large" />
|
|
71
|
+
</AForm.Item>
|
|
72
|
+
|
|
73
|
+
<AForm.Item name="password" rules={pwd}>
|
|
74
|
+
<AInput.Password autoComplete="password" size="large" />
|
|
75
|
+
</AForm.Item>
|
|
76
|
+
<ASpace className="w-full" orientation="vertical" size={24}>
|
|
77
|
+
<AButton block color="primary" htmlType="submit" loading={loading} shape="round" size="large" type="primary">
|
|
78
|
+
{t('common.confirm')}
|
|
79
|
+
</AButton>
|
|
80
|
+
<ADivider className="!m-0 !text-14px !text-#666">{t('page.login.pwdLogin.otherAccountLogin')}</ADivider>
|
|
81
|
+
<div className="flex-center gap-12px">
|
|
82
|
+
{accounts.map(item => {
|
|
83
|
+
return (
|
|
84
|
+
<AButton key={item.key} type="primary" onClick={() => handleAccountLogin(item)}>
|
|
85
|
+
{item.label}
|
|
86
|
+
</AButton>
|
|
87
|
+
);
|
|
88
|
+
})}
|
|
89
|
+
</div>
|
|
90
|
+
</ASpace>
|
|
91
|
+
</AForm>
|
|
92
|
+
</>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const Route = createFileRoute('/(auth)/login/')({
|
|
97
|
+
component: Login,
|
|
98
|
+
staticData: {
|
|
99
|
+
title: 'login',
|
|
100
|
+
i18nKey: 'route.login'
|
|
101
|
+
}
|
|
102
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { mixColor } from '@skyroc/color';
|
|
2
|
+
import { useSettingsTheme } from '@shell/theme';
|
|
3
|
+
import { Outlet, createFileRoute, redirect, useLocation } from '@tanstack/react-router';
|
|
4
|
+
import { AnimatePresence, motion } from 'motion/react';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
const COLOR_WHITE = '#ffffff';
|
|
8
|
+
|
|
9
|
+
const LoginSearchSchema = z.object({
|
|
10
|
+
redirect: z.string().startsWith('/').optional()
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const LoginLayout = () => {
|
|
14
|
+
const { t } = useTranslation();
|
|
15
|
+
|
|
16
|
+
const { darkMode, themeColor } = useSettingsTheme();
|
|
17
|
+
|
|
18
|
+
const ratio = darkMode ? 0.5 : 0.2;
|
|
19
|
+
|
|
20
|
+
const location = useLocation();
|
|
21
|
+
|
|
22
|
+
const bgColor = mixColor(COLOR_WHITE, themeColor, ratio);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="relative size-full flex-center overflow-hidden bg-layout" style={{ backgroundColor: bgColor }}>
|
|
26
|
+
<ACard className="relative z-4 w-auto rd-8px" variant="borderless">
|
|
27
|
+
<div className="w-400px lt-sm:w-300px">
|
|
28
|
+
<div className="text-center">
|
|
29
|
+
<h1 className="m-0 text-28px font-600 text-primary">{t('system.title')}</h1>
|
|
30
|
+
<p className="m-0 mt-8px text-14px text-text-2">{t('page.login.common.loginOrRegister')}</p>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<AnimatePresence initial={false} mode="wait">
|
|
34
|
+
<motion.main
|
|
35
|
+
layout
|
|
36
|
+
animate={{ opacity: 1, x: 0, filter: 'blur(0px)' }}
|
|
37
|
+
className="pt-24px"
|
|
38
|
+
exit={{ opacity: 0, x: 28, filter: 'blur(6px)' }}
|
|
39
|
+
initial={{ opacity: 0, x: -28, filter: 'blur(6px)' }}
|
|
40
|
+
key={location.pathname}
|
|
41
|
+
style={{
|
|
42
|
+
willChange: 'transform, opacity, filter'
|
|
43
|
+
}}
|
|
44
|
+
transition={{
|
|
45
|
+
x: { duration: 0.28, ease: [0.22, 1, 0.36, 1] },
|
|
46
|
+
opacity: { duration: 0.18, ease: 'easeOut' },
|
|
47
|
+
filter: { duration: 0.18, ease: 'easeOut' }
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<Outlet />
|
|
51
|
+
</motion.main>
|
|
52
|
+
</AnimatePresence>
|
|
53
|
+
</div>
|
|
54
|
+
</ACard>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const Route = createFileRoute('/(auth)/login')({
|
|
60
|
+
component: LoginLayout,
|
|
61
|
+
validateSearch: LoginSearchSchema,
|
|
62
|
+
beforeLoad: async ({ context, search }) => {
|
|
63
|
+
if (context.isLoggedIn) {
|
|
64
|
+
throw redirect({ to: search.redirect || context.getHomeRoute() });
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
staticData: {
|
|
68
|
+
title: 'login',
|
|
69
|
+
i18nKey: 'route.login'
|
|
70
|
+
}
|
|
71
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createFileRoute, redirect } from '@tanstack/react-router';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
const LoginOut = () => {
|
|
5
|
+
return null;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const LoginSearchSchema = z.object({
|
|
9
|
+
redirect: z.string().startsWith('/').optional()
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const Route = createFileRoute('/(auth)/login-out')({
|
|
13
|
+
component: LoginOut,
|
|
14
|
+
validateSearch: LoginSearchSchema,
|
|
15
|
+
staticData: {
|
|
16
|
+
title: 'login-out',
|
|
17
|
+
i18nKey: 'route.login-out'
|
|
18
|
+
},
|
|
19
|
+
beforeLoad: async ({ context, search }) => {
|
|
20
|
+
const redirectPath = search.redirect;
|
|
21
|
+
|
|
22
|
+
// 等它走完再跳,否则跳到 /login 时本地令牌可能还没清掉
|
|
23
|
+
await context.logout();
|
|
24
|
+
|
|
25
|
+
throw redirect({ to: '/login', search: redirectPath ? { redirect: redirectPath } : undefined });
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ExceptionBase } from '@shell/ui/antd';
|
|
2
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
3
|
+
|
|
4
|
+
const NotAuth = () => {
|
|
5
|
+
const { t } = useTranslation();
|
|
6
|
+
|
|
7
|
+
return <ExceptionBase buttonText={t('common.backToHome')} type="403" />;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const Route = createFileRoute('/(errors)/403')({
|
|
11
|
+
component: NotAuth,
|
|
12
|
+
staticData: {
|
|
13
|
+
title: '403',
|
|
14
|
+
i18nKey: 'route.403'
|
|
15
|
+
}
|
|
16
|
+
});
|