@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,107 @@
|
|
|
1
|
+
import { SvgIcon } from '@shell/ui/compose';
|
|
2
|
+
import { Dropdown as ADropdown, type MenuProps } from 'antd';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
|
|
6
|
+
import { useAdminTab } from '../../../state/tabs/use-admin-tab';
|
|
7
|
+
|
|
8
|
+
interface TabContextMenuProps {
|
|
9
|
+
/** 右键菜单触发区域。 */
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/** 当前场景禁用的菜单项。 */
|
|
12
|
+
disabledKeys?: App.Global.DropdownKey[];
|
|
13
|
+
/** 当前操作的标签页。 */
|
|
14
|
+
tab: App.Global.Tab;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const TabContextMenu = (props: TabContextMenuProps) => {
|
|
18
|
+
const { children, disabledKeys = [], tab } = props;
|
|
19
|
+
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
|
|
22
|
+
const [open, setOpen] = useState(false);
|
|
23
|
+
|
|
24
|
+
const { clearLeftTabs, clearRightTabs, clearTabs, fixTab, homeTab, removeTab, unfixTab } = useAdminTab();
|
|
25
|
+
|
|
26
|
+
const { id: tabId } = tab;
|
|
27
|
+
|
|
28
|
+
const isHomeTab = tabId === homeTab?.id;
|
|
29
|
+
|
|
30
|
+
const isFixed = tab.fixedIndex !== undefined && tab.fixedIndex !== null;
|
|
31
|
+
|
|
32
|
+
const items: MenuProps['items'] = [
|
|
33
|
+
{
|
|
34
|
+
key: 'closeCurrent',
|
|
35
|
+
label: t('dropdown.closeCurrent'),
|
|
36
|
+
icon: <SvgIcon className="text-icon" icon="ant-design:close-outlined" />,
|
|
37
|
+
disabled: disabledKeys.includes('closeCurrent'),
|
|
38
|
+
onClick: () => {
|
|
39
|
+
removeTab(tabId);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: 'closeOther',
|
|
44
|
+
label: t('dropdown.closeOther'),
|
|
45
|
+
icon: <SvgIcon className="text-icon" icon="ant-design:column-width-outlined" />,
|
|
46
|
+
onClick: () => {
|
|
47
|
+
clearTabs([tabId]);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: 'closeLeft',
|
|
52
|
+
label: t('dropdown.closeLeft'),
|
|
53
|
+
icon: <SvgIcon className="text-icon" icon="mdi:format-horizontal-align-left" />,
|
|
54
|
+
disabled: disabledKeys.includes('closeLeft'),
|
|
55
|
+
onClick: () => {
|
|
56
|
+
clearLeftTabs(tabId);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
key: 'closeRight',
|
|
61
|
+
label: t('dropdown.closeRight'),
|
|
62
|
+
icon: <SvgIcon className="text-icon" icon="mdi:format-horizontal-align-right" />,
|
|
63
|
+
disabled: disabledKeys.includes('closeRight'),
|
|
64
|
+
onClick: () => {
|
|
65
|
+
clearRightTabs(tabId);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: 'closeAll',
|
|
70
|
+
label: t('dropdown.closeAll'),
|
|
71
|
+
icon: <SvgIcon className="text-icon" icon="ant-design:line-outlined" />,
|
|
72
|
+
onClick: () => {
|
|
73
|
+
clearTabs();
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'divider'
|
|
78
|
+
},
|
|
79
|
+
isFixed
|
|
80
|
+
? {
|
|
81
|
+
key: 'unfixTab',
|
|
82
|
+
label: t('dropdown.unpin'),
|
|
83
|
+
icon: <SvgIcon className="text-icon" icon="mdi:pin-off-outline" />,
|
|
84
|
+
onClick: () => {
|
|
85
|
+
unfixTab(tabId);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
: {
|
|
89
|
+
key: 'fixTab',
|
|
90
|
+
label: t('dropdown.pin'),
|
|
91
|
+
icon: <SvgIcon className="text-icon" icon="mdi:pin-outline" />,
|
|
92
|
+
onClick: () => {
|
|
93
|
+
fixTab(tabId);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
if (isHomeTab) {
|
|
99
|
+
items.splice(-2);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<ADropdown menu={{ items }} open={open} trigger={['contextMenu']} onOpenChange={setOpen}>
|
|
104
|
+
{children}
|
|
105
|
+
</ADropdown>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type BScroll from '@better-scroll/core';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
export function useTabScroll(activeTabId: string) {
|
|
5
|
+
const bsWrapper = useRef<HTMLDivElement>(null);
|
|
6
|
+
const tabRef = useRef<HTMLDivElement>(null);
|
|
7
|
+
const bsScrollRef = useRef<BScroll | null>(null);
|
|
8
|
+
const [bsWrapperInfo, setBsWrapperInfo] = useState({ width: 0, left: 0 });
|
|
9
|
+
|
|
10
|
+
// Update wrapper info when window resizes
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const updateWrapperInfo = () => {
|
|
13
|
+
if (bsWrapper.current) {
|
|
14
|
+
const rect = bsWrapper.current.getBoundingClientRect();
|
|
15
|
+
setBsWrapperInfo({ width: rect.width, left: rect.left });
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
updateWrapperInfo();
|
|
20
|
+
window.addEventListener('resize', updateWrapperInfo);
|
|
21
|
+
|
|
22
|
+
return () => {
|
|
23
|
+
window.removeEventListener('resize', updateWrapperInfo);
|
|
24
|
+
};
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
/** Scroll to active tab */
|
|
28
|
+
async function scrollToActiveTab() {
|
|
29
|
+
await new Promise(resolve => {
|
|
30
|
+
setTimeout(resolve, 0);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (!tabRef.current) return;
|
|
34
|
+
|
|
35
|
+
const { children } = tabRef.current;
|
|
36
|
+
|
|
37
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
38
|
+
const child = children[i];
|
|
39
|
+
|
|
40
|
+
const tabId = child.id;
|
|
41
|
+
|
|
42
|
+
if (tabId === activeTabId) {
|
|
43
|
+
const { left, width } = child.getBoundingClientRect();
|
|
44
|
+
const clientX = left + width / 2;
|
|
45
|
+
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
scrollByClientX(clientX);
|
|
48
|
+
}, 50);
|
|
49
|
+
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Scroll by client X
|
|
57
|
+
*
|
|
58
|
+
* @param clientX
|
|
59
|
+
*/
|
|
60
|
+
function scrollByClientX(clientX: number) {
|
|
61
|
+
const currentX = clientX - bsWrapperInfo.left;
|
|
62
|
+
const deltaX = currentX - bsWrapperInfo.width / 2;
|
|
63
|
+
|
|
64
|
+
if (bsScrollRef.current) {
|
|
65
|
+
const { maxScrollX, scrollBy, x: leftX } = bsScrollRef.current;
|
|
66
|
+
|
|
67
|
+
const rightX = maxScrollX - leftX;
|
|
68
|
+
const update = deltaX > 0 ? Math.max(-deltaX, rightX) : Math.min(-deltaX, -leftX);
|
|
69
|
+
|
|
70
|
+
scrollBy(update, 0, 300);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Watch active tab id and scroll to it
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
scrollToActiveTab();
|
|
77
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
|
+
}, [activeTabId]);
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
bsWrapper,
|
|
82
|
+
tabRef,
|
|
83
|
+
bsScrollRef,
|
|
84
|
+
scrollToActiveTab
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { AdminLayoutLogoComponent } from '../../context';
|
|
5
|
+
import AdminLogo from '../AdminLogo';
|
|
6
|
+
|
|
7
|
+
interface LayoutLogoProps {
|
|
8
|
+
/** 品牌图标,由默认 Logo 组件渲染。 */
|
|
9
|
+
logo?: ReactNode;
|
|
10
|
+
/** 自定义完整 Logo 插槽。 */
|
|
11
|
+
logoComponent?: AdminLayoutLogoComponent;
|
|
12
|
+
/** 是否展示默认 Logo 标题。 */
|
|
13
|
+
showTitle?: boolean;
|
|
14
|
+
/** 当前布局位置传入的 Logo 样式。 */
|
|
15
|
+
style?: CSSProperties;
|
|
16
|
+
/** 默认 Logo 标题内容。 */
|
|
17
|
+
title?: ReactNode;
|
|
18
|
+
/** 默认 Logo 点击跳转路径。 */
|
|
19
|
+
to?: Router.RoutePath;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function renderLogoComponent(logoComponent: AdminLayoutLogoComponent, style: CSSProperties): ReactNode {
|
|
23
|
+
if (typeof logoComponent === 'function') {
|
|
24
|
+
return logoComponent(style);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return logoComponent;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const LayoutLogo = (props: LayoutLogoProps) => {
|
|
31
|
+
const { logo, logoComponent, showTitle = true, style = {}, title, to } = props;
|
|
32
|
+
|
|
33
|
+
if (logoComponent) {
|
|
34
|
+
return renderLogoComponent(logoComponent, style);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!logo && !title) return null;
|
|
38
|
+
|
|
39
|
+
return createElement(AdminLogo, { logo, showTitle, style, title, to });
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default LayoutLogo;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ScrollArea } from '@skyroc/web-ui';
|
|
2
|
+
import { ButtonIcon } from '@shell/ui/antd';
|
|
3
|
+
import { Drawer as ADrawer, Segmented as ASegmented } from 'antd';
|
|
4
|
+
import { AnimatePresence, motion } from 'motion/react';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
|
|
8
|
+
import { themeTabsOptions, translateOptions } from '../../options';
|
|
9
|
+
import { useAdminState } from '../../state/use-admin-state';
|
|
10
|
+
|
|
11
|
+
import Appearance from './modules/appearance';
|
|
12
|
+
import ConfigOperation from './modules/ConfigOperation';
|
|
13
|
+
import ThemeGeneral from './modules/general/ThemeGeneral';
|
|
14
|
+
import ThemeLayout from './modules/layout/ThemeLayout';
|
|
15
|
+
import ThemePreset from './modules/preset/ThemePreset';
|
|
16
|
+
|
|
17
|
+
const ThemeDrawer = () => {
|
|
18
|
+
const { closeThemeDrawer, themeDrawerVisible } = useAdminState();
|
|
19
|
+
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
|
|
22
|
+
const options = translateOptions(themeTabsOptions);
|
|
23
|
+
|
|
24
|
+
const [activeTab, setActiveTab] = useState<string>(options[0].value);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<ADrawer
|
|
28
|
+
closeIcon={false}
|
|
29
|
+
footer={<ConfigOperation />}
|
|
30
|
+
open={themeDrawerVisible}
|
|
31
|
+
styles={{ body: { padding: 0 } }}
|
|
32
|
+
title={t('theme.themeDrawerTitle')}
|
|
33
|
+
extra={<ButtonIcon icon="ant-design:close-outlined" onClick={closeThemeDrawer} />}
|
|
34
|
+
onClose={closeThemeDrawer}
|
|
35
|
+
>
|
|
36
|
+
<ScrollArea className="h-full">
|
|
37
|
+
<div className="min-h-400px overflow-x-hidden px-24px pb-24px pt-8px">
|
|
38
|
+
<ASegmented<string>
|
|
39
|
+
classNames={{ root: 'w-full mb-16px', item: 'flex-1 py-2px font-500' }}
|
|
40
|
+
options={options}
|
|
41
|
+
value={activeTab}
|
|
42
|
+
onChange={setActiveTab}
|
|
43
|
+
/>
|
|
44
|
+
|
|
45
|
+
<AnimatePresence initial={false} mode="wait">
|
|
46
|
+
<motion.div
|
|
47
|
+
animate={{ opacity: 1, x: 0 }}
|
|
48
|
+
exit={{ opacity: 0, x: -10 }}
|
|
49
|
+
initial={{ opacity: 0, x: 10 }}
|
|
50
|
+
key={activeTab}
|
|
51
|
+
transition={{
|
|
52
|
+
duration: 0.2,
|
|
53
|
+
ease: [0.22, 1, 0.36, 1]
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
{activeTab === options[0].value && <Appearance />}
|
|
57
|
+
{activeTab === options[1].value && <ThemeLayout />}
|
|
58
|
+
{activeTab === options[2].value && <ThemeGeneral />}
|
|
59
|
+
{activeTab === options[3].value && <ThemePreset />}
|
|
60
|
+
</motion.div>
|
|
61
|
+
</AnimatePresence>
|
|
62
|
+
</div>
|
|
63
|
+
</ScrollArea>
|
|
64
|
+
</ADrawer>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default ThemeDrawer;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Easing } from 'motion/react';
|
|
2
|
+
import { AnimatePresence, motion } from 'motion/react';
|
|
3
|
+
import type { PropsWithChildren } from 'react';
|
|
4
|
+
|
|
5
|
+
type Props = PropsWithChildren<{
|
|
6
|
+
/** Extra class name for the animated wrapper. */
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Duration of the animation in seconds */
|
|
9
|
+
duration?: number;
|
|
10
|
+
/** Easing function */
|
|
11
|
+
ease?: string | number[];
|
|
12
|
+
/** Whether the content is visible */
|
|
13
|
+
visible: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
|
|
16
|
+
const AnimatedCollapse = (props: Props) => {
|
|
17
|
+
const { children, className, duration = 0.2, ease = 'easeInOut', visible } = props;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<AnimatePresence initial={false}>
|
|
21
|
+
{visible && (
|
|
22
|
+
<motion.div
|
|
23
|
+
animate={{ opacity: 1, height: 'auto' }}
|
|
24
|
+
className={className}
|
|
25
|
+
exit={{ opacity: 0, height: 0 }}
|
|
26
|
+
initial={{ opacity: 0, height: 0 }}
|
|
27
|
+
transition={{ duration, ease: ease as Easing }}
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
</motion.div>
|
|
31
|
+
)}
|
|
32
|
+
</AnimatePresence>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default AnimatedCollapse;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { motion } from 'motion/react';
|
|
2
|
+
import type { PropsWithChildren } from 'react';
|
|
3
|
+
|
|
4
|
+
type Props = PropsWithChildren<{
|
|
5
|
+
/** Extra class name for the animated wrapper. */
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Duration of the animation in seconds */
|
|
8
|
+
duration?: number;
|
|
9
|
+
/** Scale value for animation (0-1) */
|
|
10
|
+
scale?: number;
|
|
11
|
+
/** Whether the content is visible */
|
|
12
|
+
visible: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
const AnimatedItem = (props: Props) => {
|
|
16
|
+
const { children, className, duration = 0.15, scale = 0.85, visible } = props;
|
|
17
|
+
|
|
18
|
+
if (!visible) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return (
|
|
22
|
+
<motion.div
|
|
23
|
+
layout
|
|
24
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
25
|
+
className={className}
|
|
26
|
+
exit={{ opacity: 0, scale }}
|
|
27
|
+
initial={{ opacity: 0, scale }}
|
|
28
|
+
transition={{ duration, ease: 'easeOut' }}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</motion.div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default AnimatedItem;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { useSettingsTheme } from '@shell/theme';
|
|
2
|
+
import type { TooltipProps } from 'antd';
|
|
3
|
+
import { Tooltip } from 'antd';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
LAYOUT_MODE_HORIZONTAL,
|
|
9
|
+
LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST,
|
|
10
|
+
LAYOUT_MODE_TOP_HYBRID_SIDEBAR_FIRST,
|
|
11
|
+
LAYOUT_MODE_VERTICAL,
|
|
12
|
+
LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST,
|
|
13
|
+
LAYOUT_MODE_VERTICAL_MIX,
|
|
14
|
+
VERTICAL_LAYOUT_MODES
|
|
15
|
+
} from '../../../constant';
|
|
16
|
+
import { themeLayoutModeRecord } from '../../../options';
|
|
17
|
+
import { useAdminState } from '../../../state/use-admin-state';
|
|
18
|
+
|
|
19
|
+
type LayoutConfig = Record<
|
|
20
|
+
UnionKey.ThemeLayoutMode,
|
|
21
|
+
{
|
|
22
|
+
mainClass: string;
|
|
23
|
+
menuClass: string;
|
|
24
|
+
placement: TooltipProps['placement'];
|
|
25
|
+
}
|
|
26
|
+
>;
|
|
27
|
+
|
|
28
|
+
type Props = Record<UnionKey.ThemeLayoutMode, React.ReactNode>;
|
|
29
|
+
|
|
30
|
+
const LAYOUT_CONFIG: LayoutConfig = {
|
|
31
|
+
[LAYOUT_MODE_VERTICAL]: {
|
|
32
|
+
placement: 'bottom',
|
|
33
|
+
menuClass: 'w-1/3 h-full',
|
|
34
|
+
mainClass: 'w-2/3 h-3/4'
|
|
35
|
+
},
|
|
36
|
+
[LAYOUT_MODE_VERTICAL_MIX]: {
|
|
37
|
+
placement: 'bottom',
|
|
38
|
+
menuClass: 'w-1/4 h-full',
|
|
39
|
+
mainClass: 'w-2/3 h-3/4'
|
|
40
|
+
},
|
|
41
|
+
[LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST]: {
|
|
42
|
+
placement: 'bottom',
|
|
43
|
+
menuClass: 'w-1/4 h-full',
|
|
44
|
+
mainClass: 'w-2/3 h-3/4'
|
|
45
|
+
},
|
|
46
|
+
[LAYOUT_MODE_HORIZONTAL]: {
|
|
47
|
+
placement: 'bottom',
|
|
48
|
+
menuClass: 'w-full h-1/4',
|
|
49
|
+
mainClass: 'w-full h-3/4'
|
|
50
|
+
},
|
|
51
|
+
[LAYOUT_MODE_TOP_HYBRID_SIDEBAR_FIRST]: {
|
|
52
|
+
placement: 'bottom',
|
|
53
|
+
menuClass: 'w-full h-1/4',
|
|
54
|
+
mainClass: 'w-2/3 h-3/4'
|
|
55
|
+
},
|
|
56
|
+
[LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST]: {
|
|
57
|
+
placement: 'bottom',
|
|
58
|
+
menuClass: 'w-full h-1/4',
|
|
59
|
+
mainClass: 'w-2/3 h-3/4'
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const LayoutModeCard = (props: Props) => {
|
|
64
|
+
const { ...rest } = props;
|
|
65
|
+
|
|
66
|
+
const { t } = useTranslation();
|
|
67
|
+
|
|
68
|
+
const { isMobile } = useAdminState();
|
|
69
|
+
|
|
70
|
+
const {
|
|
71
|
+
layout: { mode },
|
|
72
|
+
setThemeLayout
|
|
73
|
+
} = useSettingsTheme();
|
|
74
|
+
|
|
75
|
+
function handleChangeMode(modeType: UnionKey.ThemeLayoutMode) {
|
|
76
|
+
if (isMobile) return;
|
|
77
|
+
|
|
78
|
+
setThemeLayout(modeType);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div className="grid grid-cols-2 gap-x-12px gap-y-12px md:grid-cols-3">
|
|
83
|
+
{Object.entries(LAYOUT_CONFIG).map(([key, item]) => {
|
|
84
|
+
const layoutMode = key as UnionKey.ThemeLayoutMode;
|
|
85
|
+
const isVerticalLayout = VERTICAL_LAYOUT_MODES.includes(layoutMode);
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div className="flex-col-center cursor-pointer" key={key} onClick={() => handleChangeMode(layoutMode)}>
|
|
89
|
+
<Tooltip placement={item.placement} title={t(`theme.layout.layoutMode.${key}_detail`)}>
|
|
90
|
+
<div
|
|
91
|
+
className={clsx(
|
|
92
|
+
'h-64px w-96px gap-6px rd-4px p-6px shadow ring-2 ring-transparent transition-all hover:ring-primary',
|
|
93
|
+
mode === layoutMode && '!ring-primary'
|
|
94
|
+
)}
|
|
95
|
+
>
|
|
96
|
+
<div className={clsx('h-full w-full gap-1', isVerticalLayout ? 'flex' : 'flex-col')}>
|
|
97
|
+
{rest[layoutMode]}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</Tooltip>
|
|
101
|
+
|
|
102
|
+
<p className="mt-8px text-12px">{t(themeLayoutModeRecord[layoutMode])}</p>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
})}
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default LayoutModeCard;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import type { PropsWithChildren } from 'react';
|
|
3
|
+
|
|
4
|
+
type Props = PropsWithChildren<{
|
|
5
|
+
/** Extra class name for the setting row. */
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Label */
|
|
8
|
+
label: React.ReactNode;
|
|
9
|
+
/** Whether the row should be rendered. */
|
|
10
|
+
show?: boolean;
|
|
11
|
+
/** Extra content rendered beside the label. */
|
|
12
|
+
suffix?: React.ReactNode;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
const SettingItem = (props: Props) => {
|
|
16
|
+
const { children, className, label, show = true, suffix } = props;
|
|
17
|
+
|
|
18
|
+
if (!show) return null;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className={clsx('w-full flex-y-center justify-between', className)}>
|
|
22
|
+
<div className="flex-y-center">
|
|
23
|
+
<span className="pr-8px text-base-text">{label}</span>
|
|
24
|
+
{suffix}
|
|
25
|
+
</div>
|
|
26
|
+
{children}
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default SettingItem;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useCopy } from '@skyroc/hooks/web';
|
|
2
|
+
import { showErrorMessage, showSuccessMessage, useSettingsTheme } from '@shell/theme';
|
|
3
|
+
import { Button as AButton } from 'antd';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
|
|
6
|
+
const ConfigOperation = () => {
|
|
7
|
+
const { t } = useTranslation();
|
|
8
|
+
|
|
9
|
+
const { reset, setThemeScheme, settingsJson } = useSettingsTheme();
|
|
10
|
+
|
|
11
|
+
const { copy } = useCopy();
|
|
12
|
+
|
|
13
|
+
function formatConfigText() {
|
|
14
|
+
const reg = /"\w+":/g;
|
|
15
|
+
|
|
16
|
+
return settingsJson.replace(reg, (match: string) => match.replace(/"/g, ''));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function handleCopy() {
|
|
20
|
+
const text = formatConfigText();
|
|
21
|
+
|
|
22
|
+
const success = await copy(text);
|
|
23
|
+
|
|
24
|
+
if (success) {
|
|
25
|
+
showSuccessMessage(t('theme.configOperation.copySuccessMsg'));
|
|
26
|
+
} else {
|
|
27
|
+
showErrorMessage(t('theme.configOperation.copyFailedMsg'));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function handleReset() {
|
|
32
|
+
setThemeScheme('light');
|
|
33
|
+
|
|
34
|
+
reset();
|
|
35
|
+
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
showSuccessMessage(t('theme.configOperation.resetSuccessMsg'));
|
|
38
|
+
}, 50);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div className="flex justify-between">
|
|
43
|
+
<AButton danger onClick={handleReset}>
|
|
44
|
+
{t('theme.configOperation.resetConfig')}
|
|
45
|
+
</AButton>
|
|
46
|
+
<AButton type="primary" onClick={handleCopy}>
|
|
47
|
+
{t('theme.configOperation.copyConfig')}
|
|
48
|
+
</AButton>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default ConfigOperation;
|
package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/CustomPicker.tsx
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { useSettingsTheme } from '@shell/theme';
|
|
2
|
+
import {
|
|
3
|
+
Checkbox as ACheckbox,
|
|
4
|
+
type CheckboxProps,
|
|
5
|
+
ColorPicker as AColorPicker,
|
|
6
|
+
type ColorPickerProps,
|
|
7
|
+
Flex as AFlex,
|
|
8
|
+
Space as ASpace,
|
|
9
|
+
Tooltip as ATooltip
|
|
10
|
+
} from 'antd';
|
|
11
|
+
import { useState } from 'react';
|
|
12
|
+
import { useTranslation } from 'react-i18next';
|
|
13
|
+
|
|
14
|
+
import SettingItem from '../../components/SettingItem';
|
|
15
|
+
|
|
16
|
+
const swatches: { color: string; name: string }[] = [
|
|
17
|
+
{ color: '#3b82f6', name: '海洋蓝' },
|
|
18
|
+
{ color: '#6366f1', name: '紫罗兰' },
|
|
19
|
+
{ color: '#8b5cf6', name: '梦幻紫' },
|
|
20
|
+
{ color: '#a855f7', name: '迷人紫' },
|
|
21
|
+
{ color: '#0ea5e9', name: '清澈海洋' },
|
|
22
|
+
{ color: '#06b6d4', name: '天空蓝' },
|
|
23
|
+
{ color: '#f43f5e', name: '樱桃红' },
|
|
24
|
+
{ color: '#ef4444', name: '火焰红' },
|
|
25
|
+
{ color: '#ec4899', name: '玫瑰粉' },
|
|
26
|
+
{ color: '#d946ef', name: '紫色魅影' },
|
|
27
|
+
{ color: '#f97316', name: '橙色阳光' },
|
|
28
|
+
{ color: '#f59e0b', name: '金色晨曦' },
|
|
29
|
+
{ color: '#eab308', name: '柠檬黄' },
|
|
30
|
+
{ color: '#84cc16', name: '草地绿' },
|
|
31
|
+
{ color: '#22c55e', name: '清新绿' },
|
|
32
|
+
{ color: '#10b981', name: '热带绿' }
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
interface Props {
|
|
36
|
+
index: number;
|
|
37
|
+
isInfoFollowPrimary: boolean;
|
|
38
|
+
label: string;
|
|
39
|
+
theme: string;
|
|
40
|
+
value: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const CustomPicker = (props: Props) => {
|
|
44
|
+
const { isInfoFollowPrimary, label, theme, value } = props;
|
|
45
|
+
|
|
46
|
+
const { t } = useTranslation();
|
|
47
|
+
|
|
48
|
+
const { setSettings, updateThemeColors } = useSettingsTheme();
|
|
49
|
+
|
|
50
|
+
function handleUpdateColor(color: string, name: Theme.ThemeColorKey) {
|
|
51
|
+
updateThemeColors(name, color);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const [selectTheme, setSelectTheme] = useState<string>(theme);
|
|
55
|
+
|
|
56
|
+
const onChange: CheckboxProps['onChange'] = e => {
|
|
57
|
+
setSettings({ isInfoFollowPrimary: e.target.checked });
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const customPanelRender: ColorPickerProps['panelRender'] = (_, { components: { Picker } }) => (
|
|
61
|
+
<ASpace className="w-250px" orientation="vertical">
|
|
62
|
+
<>
|
|
63
|
+
<Picker />
|
|
64
|
+
<AFlex wrap gap="small">
|
|
65
|
+
{swatches.map(item => (
|
|
66
|
+
<ATooltip key={item.name} title={item.name}>
|
|
67
|
+
<span
|
|
68
|
+
onClick={() => {
|
|
69
|
+
handleUpdateColor(item.color, selectTheme as Theme.ThemeColorKey);
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
<AColorPicker defaultValue={item.color} open={false} size="small" />
|
|
73
|
+
</span>
|
|
74
|
+
</ATooltip>
|
|
75
|
+
))}
|
|
76
|
+
</AFlex>
|
|
77
|
+
</>
|
|
78
|
+
</ASpace>
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<SettingItem
|
|
83
|
+
label={t(`theme.appearance.themeColor.${label}`)}
|
|
84
|
+
suffix={
|
|
85
|
+
label === 'info' && (
|
|
86
|
+
<ACheckbox checked={isInfoFollowPrimary} onChange={onChange}>
|
|
87
|
+
{t('theme.appearance.themeColor.followPrimary')}
|
|
88
|
+
</ACheckbox>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
>
|
|
92
|
+
<AColorPicker
|
|
93
|
+
disabled={label === 'info' && isInfoFollowPrimary}
|
|
94
|
+
panelRender={customPanelRender}
|
|
95
|
+
value={value}
|
|
96
|
+
onChangeComplete={hex => handleUpdateColor(hex.toHexString(), label as Theme.ThemeColorKey)}
|
|
97
|
+
onOpenChange={() => {
|
|
98
|
+
setSelectTheme(label);
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
</SettingItem>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export default CustomPicker;
|