@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.
Files changed (333) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +508 -0
  3. package/dist/cli.mjs +78 -0
  4. package/dist/config-BKkdncJS.mjs +987 -0
  5. package/dist/index.mjs +14 -0
  6. package/package.json +83 -0
  7. package/templates/admin/.env +62 -0
  8. package/templates/admin/.env.prod +7 -0
  9. package/templates/admin/.env.test +7 -0
  10. package/templates/admin/.oxlintrc.json +6 -0
  11. package/templates/admin/README.md +508 -0
  12. package/templates/admin/index.html +14 -0
  13. package/templates/admin/package.json +105 -0
  14. package/templates/admin/public/favicon.svg +3 -0
  15. package/templates/admin/src/App.tsx +71 -0
  16. package/templates/admin/src/assets/audio/wechat-style-notification.wav +0 -0
  17. package/templates/admin/src/assets/imgs/skyroc.jpg +0 -0
  18. package/templates/admin/src/assets/svg-icon/activity.svg +1 -0
  19. package/templates/admin/src/assets/svg-icon/at-sign.svg +1 -0
  20. package/templates/admin/src/assets/svg-icon/avatar.svg +1 -0
  21. package/templates/admin/src/assets/svg-icon/banner.svg +1 -0
  22. package/templates/admin/src/assets/svg-icon/cast.svg +1 -0
  23. package/templates/admin/src/assets/svg-icon/chrome.svg +1 -0
  24. package/templates/admin/src/assets/svg-icon/copy.svg +1 -0
  25. package/templates/admin/src/assets/svg-icon/custom-icon.svg +1 -0
  26. package/templates/admin/src/assets/svg-icon/empty-data.svg +1 -0
  27. package/templates/admin/src/assets/svg-icon/error.svg +1 -0
  28. package/templates/admin/src/assets/svg-icon/expectation.svg +1 -0
  29. package/templates/admin/src/assets/svg-icon/heart.svg +1 -0
  30. package/templates/admin/src/assets/svg-icon/logo.svg +15 -0
  31. package/templates/admin/src/assets/svg-icon/network-error.svg +1 -0
  32. package/templates/admin/src/assets/svg-icon/no-icon.svg +1 -0
  33. package/templates/admin/src/assets/svg-icon/no-permission.svg +1 -0
  34. package/templates/admin/src/assets/svg-icon/not-found.svg +1 -0
  35. package/templates/admin/src/assets/svg-icon/service-error.svg +1 -0
  36. package/templates/admin/src/bootstrap.tsx +60 -0
  37. package/templates/admin/src/components/SkyrocAvatar.tsx +13 -0
  38. package/templates/admin/src/components/SystemLogo.tsx +7 -0
  39. package/templates/admin/src/config.ts +125 -0
  40. package/templates/admin/src/features/antd/AntdProvider.tsx +21 -0
  41. package/templates/admin/src/features/auth/components/UserAvatar.tsx +76 -0
  42. package/templates/admin/src/features/auth/use-auth-form-rules.ts +83 -0
  43. package/templates/admin/src/features/auth/use-auth.ts +96 -0
  44. package/templates/admin/src/features/auth/use-login.ts +72 -0
  45. package/templates/admin/src/features/effects/GlobalEffect.tsx +15 -0
  46. package/templates/admin/src/features/menus/dynamic-routes.ts +10 -0
  47. package/templates/admin/src/features/menus/extras.ts +3 -0
  48. package/templates/admin/src/features/menus/menu-category.ts +14 -0
  49. package/templates/admin/src/features/menus/menu-config.ts +5 -0
  50. package/templates/admin/src/features/router/RouterProvider.tsx +18 -0
  51. package/templates/admin/src/features/router/guard.ts +97 -0
  52. package/templates/admin/src/features/router/index.ts +52 -0
  53. package/templates/admin/src/features/router/routeTree.gen.ts +237 -0
  54. package/templates/admin/src/features/router/router-ref.ts +24 -0
  55. package/templates/admin/src/locales/antd.ts +8 -0
  56. package/templates/admin/src/locales/index.ts +22 -0
  57. package/templates/admin/src/locales/sync.ts +14 -0
  58. package/templates/admin/src/main.tsx +9 -0
  59. package/templates/admin/src/pages/(admin)/home/index.tsx +46 -0
  60. package/templates/admin/src/pages/(admin)/layout.tsx +44 -0
  61. package/templates/admin/src/pages/(auth)/login/index.tsx +102 -0
  62. package/templates/admin/src/pages/(auth)/login/layout.tsx +71 -0
  63. package/templates/admin/src/pages/(auth)/login-out.tsx +27 -0
  64. package/templates/admin/src/pages/(errors)/403.tsx +16 -0
  65. package/templates/admin/src/pages/(errors)/404.tsx +16 -0
  66. package/templates/admin/src/pages/(errors)/500.tsx +16 -0
  67. package/templates/admin/src/pages/__root.tsx +54 -0
  68. package/templates/admin/src/pages/error.tsx +19 -0
  69. package/templates/admin/src/pages/index.tsx +14 -0
  70. package/templates/admin/src/pages/loading.tsx +45 -0
  71. package/templates/admin/src/pages/not-found.tsx +9 -0
  72. package/templates/admin/src/plugins/app.tsx +47 -0
  73. package/templates/admin/src/plugins/assets.ts +4 -0
  74. package/templates/admin/src/plugins/index.ts +32 -0
  75. package/templates/admin/src/service/adapter.ts +63 -0
  76. package/templates/admin/src/service/api/auth/api.ts +31 -0
  77. package/templates/admin/src/service/api/auth/hooks.ts +28 -0
  78. package/templates/admin/src/service/api/auth/index.ts +10 -0
  79. package/templates/admin/src/service/api/auth/keys.ts +7 -0
  80. package/templates/admin/src/service/api/auth/urls.ts +7 -0
  81. package/templates/admin/src/service/api/index.ts +2 -0
  82. package/templates/admin/src/service/api/route/api.ts +7 -0
  83. package/templates/admin/src/service/api/route/hooks.ts +21 -0
  84. package/templates/admin/src/service/api/route/index.ts +10 -0
  85. package/templates/admin/src/service/api/route/keys.ts +3 -0
  86. package/templates/admin/src/service/api/route/urls.ts +5 -0
  87. package/templates/admin/src/service/queryClient.ts +13 -0
  88. package/templates/admin/src/service/request/index.ts +62 -0
  89. package/templates/admin/src/styles/scss/global.scss +1 -0
  90. package/templates/admin/src/styles/scss/scrollbar.scss +28 -0
  91. package/templates/admin/src/types/auto-imports.d.ts +186 -0
  92. package/templates/admin/src/types/global.d.ts +16 -0
  93. package/templates/admin/src/types/router.d.ts +14 -0
  94. package/templates/admin/src/types/storage.d.ts +17 -0
  95. package/templates/admin/src/types/vite-env.d.ts +117 -0
  96. package/templates/admin/src/utils/common.tsx +38 -0
  97. package/templates/admin/src/utils/icon.ts +9 -0
  98. package/templates/admin/src/utils/service.ts +75 -0
  99. package/templates/admin/src/utils/storage.ts +7 -0
  100. package/templates/admin/tsconfig.json +22 -0
  101. package/templates/admin/uno.config.ts +18 -0
  102. package/templates/admin/vite.config.ts +13 -0
  103. package/templates/admin-shell/i18n/atoms/lang.ts +20 -0
  104. package/templates/admin-shell/i18n/config/default.ts +11 -0
  105. package/templates/admin-shell/i18n/features/lang/LangEffect.tsx +25 -0
  106. package/templates/admin-shell/i18n/features/lang/LangSwitch.tsx +49 -0
  107. package/templates/admin-shell/i18n/hooks/use-lang.ts +47 -0
  108. package/templates/admin-shell/i18n/i18n.ts +116 -0
  109. package/templates/admin-shell/i18n/index.ts +23 -0
  110. package/templates/admin-shell/i18n/langs/en-us/common.json +49 -0
  111. package/templates/admin-shell/i18n/langs/en-us/datatable.json +8 -0
  112. package/templates/admin-shell/i18n/langs/en-us/dropdown.json +9 -0
  113. package/templates/admin-shell/i18n/langs/en-us/form.json +27 -0
  114. package/templates/admin-shell/i18n/langs/en-us/icon.json +13 -0
  115. package/templates/admin-shell/i18n/langs/en-us/notification.json +20 -0
  116. package/templates/admin-shell/i18n/langs/en-us/page.json +442 -0
  117. package/templates/admin-shell/i18n/langs/en-us/request.json +8 -0
  118. package/templates/admin-shell/i18n/langs/en-us/route.json +84 -0
  119. package/templates/admin-shell/i18n/langs/en-us/system.json +9 -0
  120. package/templates/admin-shell/i18n/langs/en-us/theme.json +173 -0
  121. package/templates/admin-shell/i18n/langs/index.ts +63 -0
  122. package/templates/admin-shell/i18n/langs/zh-cn/common.json +49 -0
  123. package/templates/admin-shell/i18n/langs/zh-cn/datatable.json +8 -0
  124. package/templates/admin-shell/i18n/langs/zh-cn/dropdown.json +9 -0
  125. package/templates/admin-shell/i18n/langs/zh-cn/form.json +27 -0
  126. package/templates/admin-shell/i18n/langs/zh-cn/icon.json +13 -0
  127. package/templates/admin-shell/i18n/langs/zh-cn/notification.json +20 -0
  128. package/templates/admin-shell/i18n/langs/zh-cn/page.json +442 -0
  129. package/templates/admin-shell/i18n/langs/zh-cn/request.json +8 -0
  130. package/templates/admin-shell/i18n/langs/zh-cn/route.json +84 -0
  131. package/templates/admin-shell/i18n/langs/zh-cn/system.json +9 -0
  132. package/templates/admin-shell/i18n/langs/zh-cn/theme.json +173 -0
  133. package/templates/admin-shell/i18n/types/i18n.ts +29 -0
  134. package/templates/admin-shell/i18n/types.ts +53 -0
  135. package/templates/admin-shell/i18n/utils/helpers.ts +18 -0
  136. package/templates/admin-shell/layouts/AdminLayout.tsx +161 -0
  137. package/templates/admin-shell/layouts/constant.ts +56 -0
  138. package/templates/admin-shell/layouts/context.tsx +101 -0
  139. package/templates/admin-shell/layouts/features/menus/MenuBadge.tsx +76 -0
  140. package/templates/admin-shell/layouts/features/menus/dynamic-routes.ts +146 -0
  141. package/templates/admin-shell/layouts/features/menus/menu-generator.tsx +444 -0
  142. package/templates/admin-shell/layouts/features/menus/menu-renderer.tsx +149 -0
  143. package/templates/admin-shell/layouts/features/menus/permissions.ts +28 -0
  144. package/templates/admin-shell/layouts/features/menus/use-menus.ts +98 -0
  145. package/templates/admin-shell/layouts/features/use-route.ts +30 -0
  146. package/templates/admin-shell/layouts/index.ts +44 -0
  147. package/templates/admin-shell/layouts/materials/index.ts +6 -0
  148. package/templates/admin-shell/layouts/materials/libs/admin-layout/index.module.css +63 -0
  149. package/templates/admin-shell/layouts/materials/libs/admin-layout/index.module.css.d.ts +18 -0
  150. package/templates/admin-shell/layouts/materials/libs/admin-layout/index.tsx +238 -0
  151. package/templates/admin-shell/layouts/materials/libs/admin-layout/shared.ts +67 -0
  152. package/templates/admin-shell/layouts/materials/libs/page-tab/ButtonTab.tsx +44 -0
  153. package/templates/admin-shell/layouts/materials/libs/page-tab/ChromeTab.tsx +54 -0
  154. package/templates/admin-shell/layouts/materials/libs/page-tab/ChromeTabBg.tsx +30 -0
  155. package/templates/admin-shell/layouts/materials/libs/page-tab/SliderTab.tsx +44 -0
  156. package/templates/admin-shell/layouts/materials/libs/page-tab/SvgClose.tsx +51 -0
  157. package/templates/admin-shell/layouts/materials/libs/page-tab/hook.ts +34 -0
  158. package/templates/admin-shell/layouts/materials/libs/page-tab/index.module.css +120 -0
  159. package/templates/admin-shell/layouts/materials/libs/page-tab/index.module.css.d.ts +18 -0
  160. package/templates/admin-shell/layouts/materials/libs/page-tab/index.tsx +76 -0
  161. package/templates/admin-shell/layouts/materials/libs/page-tab/shared.ts +32 -0
  162. package/templates/admin-shell/layouts/materials/types/index.ts +322 -0
  163. package/templates/admin-shell/layouts/modules/AdminContent.tsx +285 -0
  164. package/templates/admin-shell/layouts/modules/AdminFooter.tsx +13 -0
  165. package/templates/admin-shell/layouts/modules/AdminLogo.tsx +28 -0
  166. package/templates/admin-shell/layouts/modules/AdminSider.tsx +50 -0
  167. package/templates/admin-shell/layouts/modules/admin-header/AdminHeader.tsx +132 -0
  168. package/templates/admin-shell/layouts/modules/admin-header/components/Breadcrumb.tsx +62 -0
  169. package/templates/admin-shell/layouts/modules/admin-header/components/ThemeButton.tsx +24 -0
  170. package/templates/admin-shell/layouts/modules/admin-menu/AdminMenu.tsx +37 -0
  171. package/templates/admin-shell/layouts/modules/admin-menu/components/FirstLevelMenu.tsx +156 -0
  172. package/templates/admin-shell/layouts/modules/admin-menu/components/HorizontalMenu.tsx +88 -0
  173. package/templates/admin-shell/layouts/modules/admin-menu/components/MenuPortal.tsx +28 -0
  174. package/templates/admin-shell/layouts/modules/admin-menu/components/VerticalMenu.tsx +123 -0
  175. package/templates/admin-shell/layouts/modules/admin-menu/enum.ts +47 -0
  176. package/templates/admin-shell/layouts/modules/admin-menu/modules/Horizontal.tsx +22 -0
  177. package/templates/admin-shell/layouts/modules/admin-menu/modules/TopHybridHeaderFirst.tsx +15 -0
  178. package/templates/admin-shell/layouts/modules/admin-menu/modules/TopHybridSidebarFirst.tsx +18 -0
  179. package/templates/admin-shell/layouts/modules/admin-menu/modules/Vertical.tsx +14 -0
  180. package/templates/admin-shell/layouts/modules/admin-menu/modules/VerticalHybridHeaderFirst.tsx +18 -0
  181. package/templates/admin-shell/layouts/modules/admin-menu/modules/VerticalMix.tsx +132 -0
  182. package/templates/admin-shell/layouts/modules/admin-search/AdminSearch.tsx +36 -0
  183. package/templates/admin-shell/layouts/modules/admin-search/components/SearchFooter.tsx +38 -0
  184. package/templates/admin-shell/layouts/modules/admin-search/components/SearchModal.tsx +171 -0
  185. package/templates/admin-shell/layouts/modules/admin-search/components/SearchResult.tsx +43 -0
  186. package/templates/admin-shell/layouts/modules/admin-tab/AdminTab.tsx +125 -0
  187. package/templates/admin-shell/layouts/modules/admin-tab/components/TabContextMenu.tsx +107 -0
  188. package/templates/admin-shell/layouts/modules/admin-tab/hooks/useTabScroll.ts +86 -0
  189. package/templates/admin-shell/layouts/modules/shared/logo.ts +42 -0
  190. package/templates/admin-shell/layouts/modules/theme-drawer/ThemeDrawer.tsx +68 -0
  191. package/templates/admin-shell/layouts/modules/theme-drawer/components/AnimatedCollapse.tsx +36 -0
  192. package/templates/admin-shell/layouts/modules/theme-drawer/components/AnimatedItem.tsx +35 -0
  193. package/templates/admin-shell/layouts/modules/theme-drawer/components/LayoutModeCard.tsx +110 -0
  194. package/templates/admin-shell/layouts/modules/theme-drawer/components/SettingItem.tsx +31 -0
  195. package/templates/admin-shell/layouts/modules/theme-drawer/modules/ConfigOperation.tsx +53 -0
  196. package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/CustomPicker.tsx +105 -0
  197. package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/ThemeColor.tsx +58 -0
  198. package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/ThemeSchema.tsx +42 -0
  199. package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/ThemeToken.tsx +44 -0
  200. package/templates/admin-shell/layouts/modules/theme-drawer/modules/appearance/index.tsx +23 -0
  201. package/templates/admin-shell/layouts/modules/theme-drawer/modules/general/GlobalSettings.tsx +57 -0
  202. package/templates/admin-shell/layouts/modules/theme-drawer/modules/general/ThemeGeneral.tsx +20 -0
  203. package/templates/admin-shell/layouts/modules/theme-drawer/modules/general/WatermarkSettings.tsx +103 -0
  204. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/ContentSettings.tsx +100 -0
  205. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/FooterSettings.tsx +71 -0
  206. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/HeaderSettings.tsx +63 -0
  207. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/LayoutMode.tsx +73 -0
  208. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/SiderSettings.tsx +124 -0
  209. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/TabSettings.tsx +95 -0
  210. package/templates/admin-shell/layouts/modules/theme-drawer/modules/layout/ThemeLayout.tsx +32 -0
  211. package/templates/admin-shell/layouts/modules/theme-drawer/modules/preset/ThemePreset.tsx +132 -0
  212. package/templates/admin-shell/layouts/options.tsx +79 -0
  213. package/templates/admin-shell/layouts/setup.ts +102 -0
  214. package/templates/admin-shell/layouts/state/AdminEffect.tsx +56 -0
  215. package/templates/admin-shell/layouts/state/AdminTabEffect.tsx +28 -0
  216. package/templates/admin-shell/layouts/state/index.ts +3 -0
  217. package/templates/admin-shell/layouts/state/menus/MenuToggler.tsx +53 -0
  218. package/templates/admin-shell/layouts/state/menus/use-admin-menu-badges.ts +46 -0
  219. package/templates/admin-shell/layouts/state/menus/use-admin-menus.tsx +164 -0
  220. package/templates/admin-shell/layouts/state/tabs/index.ts +1 -0
  221. package/templates/admin-shell/layouts/state/tabs/shared.tsx +148 -0
  222. package/templates/admin-shell/layouts/state/tabs/use-admin-tab.ts +377 -0
  223. package/templates/admin-shell/layouts/state/use-admin-state.ts +118 -0
  224. package/templates/admin-shell/layouts/types/router.d.ts +10 -0
  225. package/templates/admin-shell/layouts/types/storage.ts +18 -0
  226. package/templates/admin-shell/notification/NotificationButton.tsx +91 -0
  227. package/templates/admin-shell/notification/NotificationContext.ts +8 -0
  228. package/templates/admin-shell/notification/NotificationPanel.tsx +194 -0
  229. package/templates/admin-shell/notification/NotificationProvider.tsx +59 -0
  230. package/templates/admin-shell/notification/index.ts +12 -0
  231. package/templates/admin-shell/notification/mock.ts +59 -0
  232. package/templates/admin-shell/notification/notification-store.ts +438 -0
  233. package/templates/admin-shell/notification/notification.css +60 -0
  234. package/templates/admin-shell/notification/types.ts +104 -0
  235. package/templates/admin-shell/notification/use-notification.ts +51 -0
  236. package/templates/admin-shell/notification/useNotificationContext.ts +14 -0
  237. package/templates/admin-shell/runtime/app-update.ts +156 -0
  238. package/templates/admin-shell/runtime/dayjs.ts +20 -0
  239. package/templates/admin-shell/runtime/iconify.ts +17 -0
  240. package/templates/admin-shell/runtime/index.ts +10 -0
  241. package/templates/admin-shell/runtime/nprogress.ts +25 -0
  242. package/templates/admin-shell/runtime/plugins.ts +62 -0
  243. package/templates/admin-shell/styles/global.css +54 -0
  244. package/templates/admin-shell/styles/nprogress.css +85 -0
  245. package/templates/admin-shell/styles/reset.css +378 -0
  246. package/templates/admin-shell/theme/antd/AntdProvider.tsx +106 -0
  247. package/templates/admin-shell/theme/antd/index.ts +23 -0
  248. package/templates/admin-shell/theme/antd/shared.ts +80 -0
  249. package/templates/admin-shell/theme/antd/ui.ts +250 -0
  250. package/templates/admin-shell/theme/antd-algorithm/algorithm/dark/colors.ts +99 -0
  251. package/templates/admin-shell/theme/antd-algorithm/algorithm/dark/index.ts +87 -0
  252. package/templates/admin-shell/theme/antd-algorithm/algorithm/default/colors.ts +91 -0
  253. package/templates/admin-shell/theme/antd-algorithm/algorithm/default/index.ts +77 -0
  254. package/templates/admin-shell/theme/antd-algorithm/index.ts +80 -0
  255. package/templates/admin-shell/theme/antd-algorithm/seed/index.ts +41 -0
  256. package/templates/admin-shell/theme/antd-algorithm/shared/colorAlgorithm.ts +10 -0
  257. package/templates/admin-shell/theme/antd-algorithm/shared/genColorMapToken.ts +165 -0
  258. package/templates/admin-shell/theme/antd-algorithm/shared/genCommonMapToken.ts +23 -0
  259. package/templates/admin-shell/theme/antd-algorithm/shared/genControlHeight.ts +14 -0
  260. package/templates/admin-shell/theme/antd-algorithm/shared/genFontMapToken.ts +274 -0
  261. package/templates/admin-shell/theme/antd-algorithm/shared/genRadiusMapToken.ts +139 -0
  262. package/templates/admin-shell/theme/antd-algorithm/shared/genSizeMapToken.ts +114 -0
  263. package/templates/admin-shell/theme/antd-algorithm/types/index.ts +20 -0
  264. package/templates/admin-shell/theme/components/ThemeEffect.tsx +55 -0
  265. package/templates/admin-shell/theme/components/ThemeSchemaSegmented.tsx +27 -0
  266. package/templates/admin-shell/theme/components/ThemeSchemaSwitch.tsx +77 -0
  267. package/templates/admin-shell/theme/components/shared.ts +5 -0
  268. package/templates/admin-shell/theme/config/default.ts +108 -0
  269. package/templates/admin-shell/theme/config/index.ts +1 -0
  270. package/templates/admin-shell/theme/hooks/index.ts +2 -0
  271. package/templates/admin-shell/theme/hooks/use-theme.ts +244 -0
  272. package/templates/admin-shell/theme/index.ts +78 -0
  273. package/templates/admin-shell/theme/presets/azir.json +39 -0
  274. package/templates/admin-shell/theme/presets/compact.json +38 -0
  275. package/templates/admin-shell/theme/presets/dark.json +93 -0
  276. package/templates/admin-shell/theme/presets/default.json +95 -0
  277. package/templates/admin-shell/theme/presets/index.ts +29 -0
  278. package/templates/admin-shell/theme/presets/shadcn.json +99 -0
  279. package/templates/admin-shell/theme/setup.ts +115 -0
  280. package/templates/admin-shell/theme/types/index.ts +27 -0
  281. package/templates/admin-shell/theme/types/theme.d.ts +316 -0
  282. package/templates/admin-shell/theme/utils/dark-mode.ts +46 -0
  283. package/templates/admin-shell/theme/utils/filters.ts +20 -0
  284. package/templates/admin-shell/theme/utils/index.ts +3 -0
  285. package/templates/admin-shell/theme/utils/settings.ts +43 -0
  286. package/templates/admin-shell/types/api/auth.d.ts +148 -0
  287. package/templates/admin-shell/types/api/common.d.ts +54 -0
  288. package/templates/admin-shell/types/api/route.d.ts +104 -0
  289. package/templates/admin-shell/types/api/service.d.ts +51 -0
  290. package/templates/admin-shell/types/api/system-manage.d.ts +160 -0
  291. package/templates/admin-shell/types/app/common.d.ts +31 -0
  292. package/templates/admin-shell/types/app/global.d.ts +71 -0
  293. package/templates/admin-shell/types/app/menu.d.ts +57 -0
  294. package/templates/admin-shell/types/app/router.d.ts +201 -0
  295. package/templates/admin-shell/types/app/storage.d.ts +10 -0
  296. package/templates/admin-shell/types/app/union-key.d.ts +156 -0
  297. package/templates/admin-shell/types/locales/i18n.d.ts +135 -0
  298. package/templates/admin-shell/ui/antd/components/AppTree.tsx +62 -0
  299. package/templates/admin-shell/ui/antd/components/BeyondHiding.tsx +42 -0
  300. package/templates/admin-shell/ui/antd/components/ButtonIcon.tsx +123 -0
  301. package/templates/admin-shell/ui/antd/components/ButtonLink.tsx +30 -0
  302. package/templates/admin-shell/ui/antd/components/ErrorBoundary.tsx +45 -0
  303. package/templates/admin-shell/ui/antd/components/ExceptionBase.tsx +69 -0
  304. package/templates/admin-shell/ui/antd/components/FullScreen.tsx +33 -0
  305. package/templates/admin-shell/ui/antd/components/PinToggler.tsx +35 -0
  306. package/templates/admin-shell/ui/antd/components/ReloadButton.tsx +20 -0
  307. package/templates/admin-shell/ui/antd/components/index.ts +12 -0
  308. package/templates/admin-shell/ui/antd/components/styles/button-icon-animations.css +246 -0
  309. package/templates/admin-shell/ui/antd/index.ts +1 -0
  310. package/templates/admin-shell/ui/antd/styles.d.ts +1 -0
  311. package/templates/admin-shell/ui/compose/animate-feature.ts +5 -0
  312. package/templates/admin-shell/ui/compose/components/BetterScroll.tsx +51 -0
  313. package/templates/admin-shell/ui/compose/components/DarkModeContainer.tsx +22 -0
  314. package/templates/admin-shell/ui/compose/components/FlipText.tsx +41 -0
  315. package/templates/admin-shell/ui/compose/components/I18nLabel.tsx +18 -0
  316. package/templates/admin-shell/ui/compose/components/LazyAnimate.tsx +10 -0
  317. package/templates/admin-shell/ui/compose/components/LookForward.tsx +24 -0
  318. package/templates/admin-shell/ui/compose/components/NumberTicker.tsx +105 -0
  319. package/templates/admin-shell/ui/compose/components/Portal.tsx +74 -0
  320. package/templates/admin-shell/ui/compose/components/SvgIcon.tsx +39 -0
  321. package/templates/admin-shell/ui/compose/components/TypingAnimation.tsx +83 -0
  322. package/templates/admin-shell/ui/compose/components/WaveBg.tsx +56 -0
  323. package/templates/admin-shell/ui/compose/components/index.ts +11 -0
  324. package/templates/admin-shell/ui/compose/index.ts +2 -0
  325. package/templates/admin-shell/ui/compose/table/DragContent.tsx +239 -0
  326. package/templates/admin-shell/ui/compose/table/TableHeaderOperation.tsx +210 -0
  327. package/templates/admin-shell/ui/compose/table/hooks.ts +196 -0
  328. package/templates/admin-shell/ui/compose/table/index.ts +16 -0
  329. package/templates/admin-shell/ui/compose/table/types.ts +244 -0
  330. package/templates/admin-shell/ui/compose/table/use-table-operate.ts +136 -0
  331. package/templates/admin-shell/ui/compose/table/use-table-scroll.ts +49 -0
  332. package/templates/admin-shell/ui/compose/table/use-table.ts +303 -0
  333. package/templates/admin.meta.json +756 -0
@@ -0,0 +1,173 @@
1
+ {
2
+ "themeDrawerTitle": "主题配置",
3
+ "tabs": {
4
+ "appearance": "外观",
5
+ "layout": "布局",
6
+ "general": "通用",
7
+ "preset": "预设"
8
+ },
9
+ "appearance": {
10
+ "themeSchema": {
11
+ "title": "主题模式",
12
+ "light": "亮色模式",
13
+ "dark": "暗黑模式",
14
+ "auto": "跟随系统"
15
+ },
16
+ "isOnlyExpandCurrentParentMenu": "仅展开当前父菜单",
17
+ "grayscale": "灰色模式",
18
+ "colourWeakness": "色弱模式",
19
+ "themeColor": {
20
+ "title": "主题颜色",
21
+ "primary": "主色",
22
+ "info": "信息色",
23
+ "success": "成功色",
24
+ "warning": "警告色",
25
+ "error": "错误色",
26
+ "followPrimary": "跟随主色"
27
+ },
28
+ "themeBase": {
29
+ "title": "基础配置",
30
+ "radius": "圆角",
31
+ "textSize": "字体大小"
32
+ },
33
+ "recommendColor": "应用推荐算法的颜色",
34
+ "recommendColorDesc": "推荐颜色的算法参照",
35
+ "preset": {
36
+ "title": "主题预设",
37
+ "apply": "应用",
38
+ "applySuccess": "预设应用成功",
39
+ "default": {
40
+ "name": "默认预设",
41
+ "desc": "Soybean 默认主题预设"
42
+ },
43
+ "dark": {
44
+ "name": "暗色预设",
45
+ "desc": "适用于夜间使用的暗色主题预设"
46
+ },
47
+ "compact": {
48
+ "name": "紧凑型",
49
+ "desc": "适用于小屏幕的紧凑布局预设"
50
+ },
51
+ "azir": {
52
+ "name": "Azir的预设",
53
+ "desc": "是 Azir 比较喜欢的莫兰迪色系冷淡风"
54
+ },
55
+ "skyroc": {
56
+ "name": "Skyroc预设",
57
+ "desc": "专业主题配色,灵感来自 Skyroc 设计,充满活力的靛蓝主色"
58
+ },
59
+ "shadcn": {
60
+ "name": "Shadcn预设",
61
+ "desc": "现代优雅的主题,灵感来自 shadcn/ui 设计系统,采用中性色调"
62
+ }
63
+ }
64
+ },
65
+ "layout": {
66
+ "layoutMode": {
67
+ "title": "布局模式",
68
+ "vertical": "左侧菜单模式",
69
+ "vertical-mix": "左侧菜单混合模式",
70
+ "vertical-hybrid-header-first": "左侧混合-顶部优先",
71
+ "horizontal": "顶部菜单模式",
72
+ "top-hybrid-sidebar-first": "顶部混合-侧边优先",
73
+ "top-hybrid-header-first": "顶部混合-顶部优先",
74
+ "vertical_detail": "左侧菜单布局,菜单在左,内容在右。",
75
+ "vertical-mix_detail": "左侧双菜单布局,一级菜单在左侧深色区域,二级菜单在左侧浅色区域。",
76
+ "vertical-hybrid-header-first_detail": "左侧混合布局,一级菜单在顶部,二级菜单在左侧深色区域,三级菜单在左侧浅色区域。",
77
+ "horizontal_detail": "顶部菜单布局,菜单在顶部,内容在下方。",
78
+ "top-hybrid-sidebar-first_detail": "顶部混合布局,一级菜单在左侧,二级菜单在顶部。",
79
+ "top-hybrid-header-first_detail": "顶部混合布局,一级菜单在顶部,二级菜单在左侧。"
80
+ },
81
+ "tab": {
82
+ "title": "标签栏设置",
83
+ "visible": "显示标签栏",
84
+ "cache": "标签栏信息缓存",
85
+ "cacheTip": "一键开启/关闭全局 keepalive",
86
+ "height": "标签栏高度",
87
+ "mode": {
88
+ "title": "标签栏风格",
89
+ "slider": "滑块风格",
90
+ "chrome": "谷歌风格",
91
+ "button": "按钮风格"
92
+ },
93
+ "closeByMiddleClick": "鼠标中键关闭标签页",
94
+ "closeByMiddleClickTip": "启用后可以使用鼠标中键点击标签页进行关闭"
95
+ },
96
+ "header": {
97
+ "title": "头部设置",
98
+ "height": "头部高度",
99
+ "breadcrumb": {
100
+ "visible": "显示面包屑",
101
+ "showIcon": "显示面包屑图标"
102
+ }
103
+ },
104
+ "sider": {
105
+ "title": "侧边栏设置",
106
+ "inverted": "深色侧边栏",
107
+ "width": "侧边栏宽度",
108
+ "collapsedWidth": "侧边栏折叠宽度",
109
+ "mixWidth": "混合布局侧边栏宽度",
110
+ "mixCollapsedWidth": "混合布局侧边栏折叠宽度",
111
+ "mixChildMenuWidth": "混合布局子菜单宽度",
112
+ "autoSelectFirstMenu": "自动选择第一个子菜单",
113
+ "autoSelectFirstMenuTip": "点击一级菜单时,自动选择并导航到第一个子菜单的最深层级"
114
+ },
115
+ "footer": {
116
+ "title": "底部设置",
117
+ "visible": "显示底部",
118
+ "fixed": "固定底部",
119
+ "height": "底部高度",
120
+ "right": "底部居右"
121
+ },
122
+ "content": {
123
+ "title": "内容区域设置",
124
+ "scrollMode": {
125
+ "title": "滚动模式",
126
+ "tip": "主题滚动仅 main 部分滚动,外层滚动可携带头部底部一起滚动",
127
+ "wrapper": "外层滚动",
128
+ "content": "主体滚动"
129
+ },
130
+ "page": {
131
+ "animate": "页面切换动画",
132
+ "mode": {
133
+ "title": "页面切换动画类型",
134
+ "fade-slide": "滑动",
135
+ "fade": "淡入淡出",
136
+ "fade-bottom": "底部消退",
137
+ "fade-scale": "缩放消退",
138
+ "zoom-fade": "渐变",
139
+ "zoom-out": "闪现",
140
+ "none": "无"
141
+ }
142
+ },
143
+ "fixedHeaderAndTab": "固定头部和标签栏"
144
+ }
145
+ },
146
+ "general": {
147
+ "title": "通用设置",
148
+ "watermark": {
149
+ "title": "水印设置",
150
+ "visible": "显示全屏水印",
151
+ "text": "自定义水印文本",
152
+ "enableUserName": "启用用户名水印",
153
+ "enableCustomText": "启用自定义水印文本",
154
+ "enableTime": "显示当前时间",
155
+ "timeFormat": "时间格式"
156
+ },
157
+ "multilingual": {
158
+ "title": "多语言设置",
159
+ "visible": "显示多语言按钮"
160
+ },
161
+ "globalSearch": {
162
+ "title": "全局搜索设置",
163
+ "visible": "显示全局搜索按钮"
164
+ }
165
+ },
166
+ "configOperation": {
167
+ "copyConfig": "复制配置",
168
+ "copyFailedMsg": "复制失败",
169
+ "copySuccessMsg": "复制成功,请替换 src/theme/settings.ts 中的变量 themeSettings",
170
+ "resetConfig": "重置配置",
171
+ "resetSuccessMsg": "重置成功"
172
+ }
173
+ }
@@ -0,0 +1,29 @@
1
+ import type { AdminLocaleMessages } from '../langs';
2
+
3
+ type DatatableMessages = AdminLocaleMessages['datatable'];
4
+ type FormMessages = AdminLocaleMessages['form'];
5
+ type IconMessages = AdminLocaleMessages['icon'];
6
+ type NotificationMessages = AdminLocaleMessages['notification'];
7
+ type PageMessages = AdminLocaleMessages['page'];
8
+ type RequestMessages = AdminLocaleMessages['request'];
9
+ type SystemMessages = AdminLocaleMessages['system'];
10
+ type ThemeMessages = AdminLocaleMessages['theme'];
11
+
12
+ declare global {
13
+ namespace I18n {
14
+ interface LocaleMessages {
15
+ notification: Notification;
16
+ }
17
+
18
+ interface Datatable extends DatatableMessages {}
19
+ interface Form extends FormMessages {}
20
+ interface Icon extends IconMessages {}
21
+ interface Notification extends NotificationMessages {}
22
+ interface Page extends PageMessages {}
23
+ interface Request extends RequestMessages {}
24
+ interface System extends SystemMessages {}
25
+ interface Theme extends ThemeMessages {}
26
+ }
27
+ }
28
+
29
+
@@ -0,0 +1,53 @@
1
+ import type { InitOptions, Resource } from 'i18next';
2
+
3
+ /** Supported language code. */
4
+ export type LangType = 'en-US' | 'zh-CN';
5
+
6
+ /** Display option for a language switcher. */
7
+ export interface LangOption<TLang extends string = LangType> {
8
+ /** Menu key used by UI components and locale switching. */
9
+ key: TLang;
10
+ /** Human readable language label. */
11
+ label: string;
12
+ }
13
+
14
+ /** Runtime language configuration. */
15
+ export interface LangConfig<TLang extends string = LangType> {
16
+ /** Initial language used when storage does not contain a valid value. */
17
+ defaultLang: TLang;
18
+ /** Language used when a translation key is missing. */
19
+ fallbackLang: TLang;
20
+ /** Languages exposed to language switch UI. */
21
+ langOptions: LangOption<TLang>[];
22
+ }
23
+
24
+ /** Storage adapter owned by the consuming app. */
25
+ export interface LocaleStorage<TLang extends string = LangType> {
26
+ /** Read the persisted locale. */
27
+ getLocale: () => TLang | null;
28
+ /** Persist the selected locale. */
29
+ setLocale: (lang: TLang) => void;
30
+ }
31
+
32
+ /** Callback fired after the active locale changes. */
33
+ export type LocaleChangeHandler<TLang extends string = LangType> = (lang: TLang) => void | Promise<void>;
34
+
35
+ /** i18n setup options shared by apps. */
36
+ export interface LocaleSetupOptions<TLang extends string = LangType> {
37
+ /** Initial language, usually resolved from app storage. */
38
+ defaultLocale?: TLang;
39
+ /** Fallback language for i18next. */
40
+ fallbackLocale?: TLang;
41
+ /** Extra i18next init options. */
42
+ i18nextOptions?: Omit<InitOptions, 'fallbackLng' | 'lng' | 'resources'>;
43
+ /** Language options exposed to shared hooks. */
44
+ localeOptions?: LangOption<TLang>[];
45
+ /** Whether missing translation keys should be logged. */
46
+ missingWarn?: boolean;
47
+ /** Side effects that must run after a locale changes. */
48
+ onLocaleChange?: LocaleChangeHandler<TLang>;
49
+ /** Preloaded i18next resources. */
50
+ resources?: Resource;
51
+ /** App-owned persistence adapter. */
52
+ storage?: LocaleStorage<TLang>;
53
+ }
@@ -0,0 +1,18 @@
1
+ import { getStoredLocale, saveLocale } from '../i18n';
2
+ import type { LangOption, LangType } from '../types';
3
+
4
+ /** Get language from storage */
5
+ export function getLangFromStorage(): LangType | null {
6
+ return getStoredLocale();
7
+ }
8
+
9
+ /** Save language to storage */
10
+ export function saveLangToStorage(lang: LangType): void {
11
+ saveLocale(lang);
12
+ }
13
+
14
+ /** Get language label */
15
+ export function getLangLabel(lang: LangType, options: LangOption[]): string {
16
+ const option = options.find(opt => opt.key === lang);
17
+ return option?.label || lang;
18
+ }
@@ -0,0 +1,161 @@
1
+ import type { LayoutMode } from './materials';
2
+ import { AdminLayout as AdminLayoutComponent, LAYOUT_SCROLL_EL_ID } from './materials';
3
+ import { useSettingsTheme } from '@shell/theme';
4
+ import { Suspense, lazy } from 'react';
5
+
6
+ import {
7
+ LAYOUT_MODE_HORIZONTAL,
8
+ LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST,
9
+ LAYOUT_MODE_TOP_HYBRID_SIDEBAR_FIRST,
10
+ LAYOUT_MODE_VERTICAL,
11
+ LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST,
12
+ LAYOUT_MODE_VERTICAL_MIX,
13
+ VERTICAL_LAYOUT_MODES
14
+ } from './constant';
15
+ import type { AdminLayoutSlots } from './context';
16
+ import { AdminLayoutProvider, useAdminLayoutContext } from './context';
17
+ import AdminHeader from './modules/admin-header/AdminHeader';
18
+ import AdminMenu from './modules/admin-menu/AdminMenu';
19
+ import AdminTab from './modules/admin-tab/AdminTab';
20
+ import GlobalContent from './modules/AdminContent';
21
+ import GlobalSider from './modules/AdminSider';
22
+ import { getDefaultMenuCategoryKey } from './setup';
23
+ import { useAdminMenus } from './state/menus/use-admin-menus';
24
+ import { useAdminState } from './state/use-admin-state';
25
+
26
+ const ThemeDrawer = lazy(() => import('./modules/theme-drawer/ThemeDrawer'));
27
+
28
+ const AdminEffect = lazy(() => import('./state/AdminEffect'));
29
+
30
+ export interface AdminLayoutProps extends AdminLayoutSlots {
31
+ /** 当前布局使用的菜单分类。 */
32
+ categoryKey?: string;
33
+ }
34
+
35
+ const AdminLayoutContent = () => {
36
+ const { contentXScrollable, fullContent, isMobile, mixSiderFixed, siderCollapse, toggleSiderCollapse } =
37
+ useAdminState();
38
+ const { footer: footerSlot } = useAdminLayoutContext();
39
+
40
+ const { fixedHeaderAndTab, footer: themeFooter, header, layout, sider, tab } = useSettingsTheme();
41
+
42
+ const { childLevelMenus, isActiveFirstLevelMenuHasChildren, secondLevelMenus } = useAdminMenus();
43
+
44
+ const layoutMode = VERTICAL_LAYOUT_MODES.includes(layout.mode) ? LAYOUT_MODE_VERTICAL : LAYOUT_MODE_HORIZONTAL;
45
+
46
+ const isTopHybridHeaderFirst = layout.mode === LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST;
47
+
48
+ const isVerticalHybridHeaderFirst = layout.mode === LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST;
49
+
50
+ const isTopHybridSidebarFirst = layout.mode === LAYOUT_MODE_TOP_HYBRID_SIDEBAR_FIRST;
51
+
52
+ const isVerticalMix = layout.mode === LAYOUT_MODE_VERTICAL_MIX;
53
+
54
+ const siderVisible = layout.mode !== LAYOUT_MODE_HORIZONTAL;
55
+
56
+ const siderWidth = getSiderAndCollapsedWidth(false);
57
+
58
+ const siderCollapsedWidth = getSiderAndCollapsedWidth(true);
59
+
60
+ function getSiderAndCollapsedWidth(isCollapsed: boolean) {
61
+ const { collapsedWidth, mixChildMenuWidth, mixCollapsedWidth, mixWidth: themeMixWidth, width: themeWidth } = sider;
62
+
63
+ const width = isCollapsed ? collapsedWidth : themeWidth;
64
+ const mixWidth = isCollapsed ? mixCollapsedWidth : themeMixWidth;
65
+
66
+ if (isTopHybridHeaderFirst) {
67
+ return isActiveFirstLevelMenuHasChildren ? width : 0;
68
+ }
69
+
70
+ if (isVerticalHybridHeaderFirst && !isActiveFirstLevelMenuHasChildren) {
71
+ return 0;
72
+ }
73
+
74
+ const isMixMode = isVerticalMix || isTopHybridSidebarFirst || isVerticalHybridHeaderFirst;
75
+ let finalWidth = isMixMode ? mixWidth : width;
76
+
77
+ if (isVerticalMix && mixSiderFixed && secondLevelMenus.length) {
78
+ finalWidth += mixChildMenuWidth;
79
+ }
80
+
81
+ if (isVerticalHybridHeaderFirst && mixSiderFixed && childLevelMenus.length) {
82
+ finalWidth += mixChildMenuWidth;
83
+ }
84
+
85
+ return finalWidth;
86
+ }
87
+
88
+ return (
89
+ <AdminLayoutComponent
90
+ contentClass={contentXScrollable ? 'overflow-x-hidden' : ''}
91
+ fixedFooter={themeFooter.fixed}
92
+ fixedTop={fixedHeaderAndTab}
93
+ Footer={footerSlot}
94
+ footerHeight={themeFooter.height}
95
+ footerVisible={Boolean(footerSlot) && themeFooter.visible}
96
+ fullContent={fullContent}
97
+ Header={<AdminHeader />}
98
+ headerHeight={header.height}
99
+ isMobile={isMobile}
100
+ mode={layoutMode as LayoutMode}
101
+ rightFooter={themeFooter.right}
102
+ scrollElId={LAYOUT_SCROLL_EL_ID}
103
+ scrollMode={layout.scrollMode}
104
+ Sider={<GlobalSider />}
105
+ siderCollapse={siderCollapse}
106
+ siderCollapsedWidth={siderCollapsedWidth}
107
+ siderVisible={siderVisible}
108
+ siderWidth={siderWidth}
109
+ Tab={<AdminTab />}
110
+ tabHeight={tab.height}
111
+ tabVisible={tab.visible}
112
+ updateSiderCollapse={toggleSiderCollapse}
113
+ >
114
+ <GlobalContent />
115
+
116
+ <AdminMenu />
117
+
118
+ <Suspense fallback={null}>
119
+ <ThemeDrawer />
120
+ </Suspense>
121
+
122
+ <Suspense fallback={null}>
123
+ <AdminEffect />
124
+ </Suspense>
125
+ </AdminLayoutComponent>
126
+ );
127
+ };
128
+
129
+ const AdminLayout = (props: AdminLayoutProps) => {
130
+ const {
131
+ categoryKey = getDefaultMenuCategoryKey(),
132
+ content,
133
+ footer,
134
+ headerLeftActions,
135
+ headerMiddleActions,
136
+ headerRightActions,
137
+ logo,
138
+ logoComponent,
139
+ logoTitle,
140
+ logoTo
141
+ } = props;
142
+
143
+ return (
144
+ <AdminLayoutProvider
145
+ categoryKey={categoryKey}
146
+ content={content}
147
+ footer={footer}
148
+ headerLeftActions={headerLeftActions}
149
+ headerMiddleActions={headerMiddleActions}
150
+ headerRightActions={headerRightActions}
151
+ logo={logo}
152
+ logoComponent={logoComponent}
153
+ logoTitle={logoTitle}
154
+ logoTo={logoTo}
155
+ >
156
+ <AdminLayoutContent />
157
+ </AdminLayoutProvider>
158
+ );
159
+ };
160
+
161
+ export default AdminLayout;
@@ -0,0 +1,56 @@
1
+ export const LAYOUT_MODE = {
2
+ HORIZONTAL: 'horizontal',
3
+ TOP_HYBRID_HEADER_FIRST: 'top-hybrid-header-first',
4
+ TOP_HYBRID_SIDEBAR_FIRST: 'top-hybrid-sidebar-first',
5
+ VERTICAL: 'vertical',
6
+ VERTICAL_HYBRID_HEADER_FIRST: 'vertical-hybrid-header-first',
7
+ VERTICAL_MIX: 'vertical-mix'
8
+ } as const satisfies Record<string, UnionKey.ThemeLayoutMode>;
9
+
10
+ export const LAYOUT_MODE_VERTICAL = LAYOUT_MODE.VERTICAL;
11
+
12
+ export const LAYOUT_MODE_HORIZONTAL = LAYOUT_MODE.HORIZONTAL;
13
+
14
+ export const LAYOUT_MODE_VERTICAL_MIX = LAYOUT_MODE.VERTICAL_MIX;
15
+
16
+ export const LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST = LAYOUT_MODE.VERTICAL_HYBRID_HEADER_FIRST;
17
+
18
+ export const LAYOUT_MODE_TOP_HYBRID_SIDEBAR_FIRST = LAYOUT_MODE.TOP_HYBRID_SIDEBAR_FIRST;
19
+
20
+ export const LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST = LAYOUT_MODE.TOP_HYBRID_HEADER_FIRST;
21
+
22
+ export const VERTICAL_LAYOUT_MODES: UnionKey.ThemeLayoutMode[] = [
23
+ LAYOUT_MODE_VERTICAL,
24
+ LAYOUT_MODE_VERTICAL_MIX,
25
+ LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST
26
+ ];
27
+
28
+ export const TOP_HYBRID_LAYOUT_MODES: UnionKey.ThemeLayoutMode[] = [
29
+ LAYOUT_MODE_TOP_HYBRID_SIDEBAR_FIRST,
30
+ LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST
31
+ ];
32
+
33
+ export const HYBRID_LAYOUT_MODES: UnionKey.ThemeLayoutMode[] = [
34
+ LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST,
35
+ LAYOUT_MODE_TOP_HYBRID_SIDEBAR_FIRST,
36
+ LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST
37
+ ];
38
+
39
+ export const MIX_OR_HYBRID_LAYOUT_MODES: UnionKey.ThemeLayoutMode[] = [
40
+ LAYOUT_MODE_VERTICAL_MIX,
41
+ ...HYBRID_LAYOUT_MODES
42
+ ];
43
+
44
+ export const FIRST_LEVEL_LAYOUT_MODES: UnionKey.ThemeLayoutMode[] = [
45
+ LAYOUT_MODE_VERTICAL_HYBRID_HEADER_FIRST,
46
+ LAYOUT_MODE_TOP_HYBRID_SIDEBAR_FIRST,
47
+ LAYOUT_MODE_TOP_HYBRID_HEADER_FIRST
48
+ ];
49
+
50
+ export const GLOBAL_HEADER_MENU_ID = '__GLOBAL_HEADER_MENU__';
51
+
52
+ export const GLOBAL_HEADER_MENU_SELECTOR = `#${GLOBAL_HEADER_MENU_ID}`;
53
+
54
+ export const GLOBAL_SIDER_MENU_ID = '__GLOBAL_SIDER_MENU__';
55
+
56
+ export const GLOBAL_SIDER_MENU_SELECTOR = `#${GLOBAL_SIDER_MENU_ID}`;
@@ -0,0 +1,101 @@
1
+ import { createContext, useContext } from 'react';
2
+ import type { CSSProperties, ReactNode } from 'react';
3
+
4
+ import { getDefaultMenuCategoryKey } from './setup';
5
+
6
+ export type AdminLayoutLogoComponent = ((style: CSSProperties) => ReactNode) | ReactNode;
7
+
8
+ export interface AdminLayoutLogoProps {
9
+ /** Logo wrapper class supplied by each layout position. */
10
+ className?: string;
11
+ /** Brand mark rendered before the title. */
12
+ logo?: ReactNode;
13
+ /** Whether the title should be visible in the current layout position. */
14
+ showTitle?: boolean;
15
+ /** Logo wrapper style supplied by each layout position. */
16
+ style?: CSSProperties;
17
+ /** Brand title rendered by the default logo component. */
18
+ title?: ReactNode;
19
+ /** Route path used when clicking the logo. */
20
+ to?: Router.RoutePath;
21
+ }
22
+
23
+ export interface AdminLayoutSlots {
24
+ /** 主内容区域,默认使用 TanStack Router 的 Outlet。 */
25
+ content?: ReactNode;
26
+ /** 页脚区域。 */
27
+ footer?: ReactNode;
28
+ /** 头部操作区左侧插槽,位于搜索和全屏按钮之间。 */
29
+ headerLeftActions?: ReactNode;
30
+ /** 头部操作区中间插槽,位于语言切换和主题按钮之间。 */
31
+ headerMiddleActions?: ReactNode;
32
+ /** 头部操作区右侧插槽,位于所有内置操作之后。 */
33
+ headerRightActions?: ReactNode;
34
+ /** 品牌图标,由默认 Logo 组件渲染。 */
35
+ logo?: ReactNode;
36
+ /** 自定义完整 Logo 插槽,可直接传节点或通过布局样式渲染。 */
37
+ logoComponent?: AdminLayoutLogoComponent;
38
+ /** 品牌标题,由默认 Logo 组件渲染。 */
39
+ logoTitle?: ReactNode;
40
+ /** 点击 Logo 时跳转的路径,默认使用布局配置的 defaultHome。 */
41
+ logoTo?: Router.RoutePath;
42
+ }
43
+
44
+ export interface AdminLayoutContextValue extends AdminLayoutSlots {
45
+ /** 当前布局使用的菜单分类。 */
46
+ categoryKey: string;
47
+ }
48
+
49
+ export interface AdminLayoutProviderProps extends AdminLayoutContextValue {
50
+ /** 布局子节点。 */
51
+ children: ReactNode;
52
+ }
53
+
54
+ const AdminLayoutContext = createContext<AdminLayoutContextValue | null>(null);
55
+
56
+ export const AdminLayoutProvider = (props: AdminLayoutProviderProps) => {
57
+ const {
58
+ categoryKey,
59
+ children,
60
+ content,
61
+ footer,
62
+ headerLeftActions,
63
+ headerMiddleActions,
64
+ headerRightActions,
65
+ logo,
66
+ logoComponent,
67
+ logoTitle,
68
+ logoTo
69
+ } = props;
70
+
71
+ return (
72
+ <AdminLayoutContext
73
+ value={{
74
+ categoryKey,
75
+ content,
76
+ footer,
77
+ headerLeftActions,
78
+ headerMiddleActions,
79
+ headerRightActions,
80
+ logo,
81
+ logoComponent,
82
+ logoTitle,
83
+ logoTo
84
+ }}
85
+ >
86
+ {children}
87
+ </AdminLayoutContext>
88
+ );
89
+ };
90
+
91
+ export function useAdminLayoutContext() {
92
+ const context = useContext(AdminLayoutContext);
93
+
94
+ if (context) {
95
+ return context;
96
+ }
97
+
98
+ return {
99
+ categoryKey: getDefaultMenuCategoryKey()
100
+ };
101
+ }
@@ -0,0 +1,76 @@
1
+ import { Badge as ABadge } from 'antd';
2
+
3
+ import { useAdminMenuBadges } from '../../state/menus/use-admin-menu-badges';
4
+
5
+ interface MenuBadgeProps {
6
+ /** Standard badge configuration from the route menu metadata. */
7
+ badge: Router.MenuBadge;
8
+ }
9
+
10
+ function getBadgeValue(badge: Router.MenuBadge, badgeValues: Record<string, Router.MenuBadgeValue | undefined>) {
11
+ if (!badge.valueKey) {
12
+ return badge.value;
13
+ }
14
+
15
+ if (Object.hasOwn(badgeValues, badge.valueKey)) {
16
+ return badgeValues[badge.valueKey];
17
+ }
18
+
19
+ return badge.value;
20
+ }
21
+
22
+ function shouldRenderValue(value: Router.MenuBadgeValue | undefined, showZero?: boolean) {
23
+ if (value === 0) return Boolean(showZero);
24
+
25
+ return value !== undefined && value !== null && value !== '';
26
+ }
27
+
28
+ function getBadgeColor(variant: Router.MenuBadgeVariant) {
29
+ switch (variant) {
30
+ case 'error':
31
+ return 'red';
32
+ case 'info':
33
+ return 'blue';
34
+ case 'primary':
35
+ return 'blue';
36
+ case 'success':
37
+ return 'green';
38
+ case 'warning':
39
+ return 'orange';
40
+ default:
41
+ return undefined;
42
+ }
43
+ }
44
+
45
+ const MenuBadge = (props: MenuBadgeProps) => {
46
+ const { badge } = props;
47
+
48
+ const { badgeValues } = useAdminMenuBadges();
49
+ const { showZero = false, type = 'normal', variant = 'default' } = badge;
50
+ const color = getBadgeColor(variant);
51
+
52
+ if (type === 'dot') {
53
+ return (
54
+ <ABadge
55
+ color={color}
56
+ data-menu-badge="dot"
57
+ dot
58
+ />
59
+ );
60
+ }
61
+
62
+ const value = getBadgeValue(badge, badgeValues);
63
+
64
+ if (!shouldRenderValue(value, showZero)) return null;
65
+
66
+ return (
67
+ <ABadge
68
+ color={color}
69
+ count={value}
70
+ data-menu-badge="normal"
71
+ showZero={showZero}
72
+ />
73
+ );
74
+ };
75
+
76
+ export default MenuBadge;