@spacego/fe-components 0.0.1-alpha.1

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 (113) hide show
  1. package/README.md +37 -0
  2. package/lib/assets/svg/chrome-bg-after.svg.js +4 -0
  3. package/lib/assets/svg/chrome-bg-before.svg.js +4 -0
  4. package/lib/assets/svg/icon-arrows-right.svg.js +4 -0
  5. package/lib/assets/svg/icon-bell.svg.js +4 -0
  6. package/lib/assets/svg/icon-custom.svg.js +4 -0
  7. package/lib/assets/svg/icon-sun-moon.svg.js +4 -0
  8. package/lib/assets/svg/icon-system.svg.js +4 -0
  9. package/lib/assets/svg/login-view.svg.js +4 -0
  10. package/lib/config/constants.js +10 -0
  11. package/lib/config/theme.js +8 -0
  12. package/lib/fe-layouts/auth-layout/index.js +95 -0
  13. package/lib/fe-layouts/basics-layout/components/basics-layout/header.js +102 -0
  14. package/lib/fe-layouts/basics-layout/components/basics-layout/setting-custom-color.js +34 -0
  15. package/lib/fe-layouts/basics-layout/components/basics-layout/setting-drawer.js +118 -0
  16. package/lib/fe-layouts/basics-layout/components/basics-layout/sidebar.js +60 -0
  17. package/lib/fe-layouts/basics-layout/components/basics-layout/tabs.js +60 -0
  18. package/lib/fe-layouts/basics-layout/components/utils/index.js +72 -0
  19. package/lib/fe-layouts/basics-layout/index.js +98 -0
  20. package/lib/fe-layouts/blank-layout/index.js +8 -0
  21. package/lib/fe-layouts/context/context.js +6 -0
  22. package/lib/fe-layouts/context/global-context.provider.js +53 -0
  23. package/lib/fe-layouts/layout.js +49 -0
  24. package/lib/hooks/use-auth.hook.js +23 -0
  25. package/lib/index.css +1 -0
  26. package/lib/index.js +48 -0
  27. package/lib/router/index.js +43 -0
  28. package/lib/router/permission.js +43 -0
  29. package/lib/router/routes.js +57 -0
  30. package/lib/router/utils.js +105 -0
  31. package/lib/store/modules/layout-config.store.js +217 -0
  32. package/lib/store/modules/theme.store.js +60 -0
  33. package/lib/types/config/constants.d.ts +9 -0
  34. package/lib/types/config/index.d.ts +2 -0
  35. package/lib/types/config/theme.d.ts +7 -0
  36. package/lib/types/fe-layouts/auth-layout/index.d.ts +1 -0
  37. package/lib/types/fe-layouts/basics-layout/components/basics-layout/header.d.ts +7 -0
  38. package/lib/types/fe-layouts/basics-layout/components/basics-layout/setting-custom-color.d.ts +3 -0
  39. package/lib/types/fe-layouts/basics-layout/components/basics-layout/setting-drawer.d.ts +6 -0
  40. package/lib/types/fe-layouts/basics-layout/components/basics-layout/sidebar.d.ts +11 -0
  41. package/lib/types/fe-layouts/basics-layout/components/basics-layout/tabs.d.ts +9 -0
  42. package/lib/types/fe-layouts/basics-layout/components/utils/index.d.ts +41 -0
  43. package/lib/types/fe-layouts/basics-layout/index.d.ts +1 -0
  44. package/lib/types/fe-layouts/blank-layout/index.d.ts +1 -0
  45. package/lib/types/fe-layouts/context/context.d.ts +7 -0
  46. package/lib/types/fe-layouts/context/global-context.provider.d.ts +2 -0
  47. package/lib/types/fe-layouts/context/index.d.ts +3 -0
  48. package/lib/types/fe-layouts/index.d.ts +6 -0
  49. package/lib/types/fe-layouts/layout.d.ts +7 -0
  50. package/lib/types/hooks/index.d.ts +1 -0
  51. package/lib/types/hooks/use-auth.hook.d.ts +8 -0
  52. package/lib/types/index.d.ts +10 -0
  53. package/lib/types/router/index.d.ts +40 -0
  54. package/lib/types/router/permission.d.ts +23 -0
  55. package/lib/types/router/routes.d.ts +11 -0
  56. package/lib/types/router/utils.d.ts +56 -0
  57. package/lib/types/store/index.d.ts +2 -0
  58. package/lib/types/store/modules/layout-config.store.d.ts +612 -0
  59. package/lib/types/store/modules/theme.store.d.ts +186 -0
  60. package/lib/types/utils/icon.d.ts +14 -0
  61. package/lib/types/utils/index.d.ts +2 -0
  62. package/lib/types/utils/theme.d.ts +43 -0
  63. package/lib/utils/icon.js +13 -0
  64. package/lib/utils/theme.js +100 -0
  65. package/package.json +60 -0
  66. package/src/assets/styles/animate.css +62 -0
  67. package/src/assets/styles/index.css +49 -0
  68. package/src/assets/svg/chrome-bg-after.svg +1 -0
  69. package/src/assets/svg/chrome-bg-before.svg +1 -0
  70. package/src/assets/svg/icon-arrows-right.svg +1 -0
  71. package/src/assets/svg/icon-bell.svg +1 -0
  72. package/src/assets/svg/icon-custom.svg +1 -0
  73. package/src/assets/svg/icon-sun-moon.svg +1 -0
  74. package/src/assets/svg/icon-system.svg +1 -0
  75. package/src/assets/svg/loading.svg +13 -0
  76. package/src/assets/svg/login-view.svg +193 -0
  77. package/src/config/constants.ts +19 -0
  78. package/src/config/index.ts +2 -0
  79. package/src/config/theme.ts +20 -0
  80. package/src/fe-layouts/auth-layout/index.scss +34 -0
  81. package/src/fe-layouts/auth-layout/index.tsx +121 -0
  82. package/src/fe-layouts/basics-layout/components/basics-layout/header.tsx +148 -0
  83. package/src/fe-layouts/basics-layout/components/basics-layout/setting-custom-color.tsx +52 -0
  84. package/src/fe-layouts/basics-layout/components/basics-layout/setting-drawer.tsx +165 -0
  85. package/src/fe-layouts/basics-layout/components/basics-layout/sidebar.tsx +88 -0
  86. package/src/fe-layouts/basics-layout/components/basics-layout/tabs.tsx +94 -0
  87. package/src/fe-layouts/basics-layout/components/utils/index.ts +142 -0
  88. package/src/fe-layouts/basics-layout/index.scss +110 -0
  89. package/src/fe-layouts/basics-layout/index.tsx +207 -0
  90. package/src/fe-layouts/blank-layout/index.tsx +12 -0
  91. package/src/fe-layouts/context/context.ts +11 -0
  92. package/src/fe-layouts/context/global-context.d.ts +241 -0
  93. package/src/fe-layouts/context/global-context.provider.tsx +81 -0
  94. package/src/fe-layouts/context/index.ts +10 -0
  95. package/src/fe-layouts/index.ts +13 -0
  96. package/src/fe-layouts/layout.tsx +74 -0
  97. package/src/hooks/index.ts +1 -0
  98. package/src/hooks/use-auth.hook.ts +54 -0
  99. package/src/index.ts +21 -0
  100. package/src/router/index.ts +110 -0
  101. package/src/router/permission.tsx +134 -0
  102. package/src/router/routes.tsx +94 -0
  103. package/src/router/utils.ts +283 -0
  104. package/src/store/index.ts +9 -0
  105. package/src/store/modules/layout-config.store.ts +343 -0
  106. package/src/store/modules/theme.store.ts +99 -0
  107. package/src/typings/index.d.ts +59 -0
  108. package/src/typings/shims-axios.d.ts +38 -0
  109. package/src/utils/icon.tsx +32 -0
  110. package/src/utils/index.ts +9 -0
  111. package/src/utils/theme.ts +219 -0
  112. package/tsconfig.json +28 -0
  113. package/vite.config.ts +85 -0
@@ -0,0 +1,102 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ import { LogoutOutlined as v } from "@ant-design/icons";
3
+ import { useSelector as N } from "@spacego/zustand";
4
+ import { Breadcrumb as y, Space as k, Popover as w, Badge as T, Dropdown as S, Avatar as M } from "antd";
5
+ import { useState as E } from "react";
6
+ import { IoMoon as C } from "react-icons/io5";
7
+ import { MdWbSunny as G } from "react-icons/md";
8
+ import { Link as O } from "react-router-dom";
9
+ import j from "../../../../assets/svg/icon-arrows-right.svg.js";
10
+ import A from "../../../../assets/svg/icon-bell.svg.js";
11
+ import B from "../../../../assets/svg/icon-system.svg.js";
12
+ import { useAuth as L } from "../../../../hooks/use-auth.hook.js";
13
+ import "../../../../store/modules/layout-config.store.js";
14
+ import { useThemeStore as R } from "../../../../store/modules/theme.store.js";
15
+ import { applyThemeWithTransition as z } from "../../../../utils/theme.js";
16
+ import { useGlobal as H } from "../../../context/context.js";
17
+ import _ from "./setting-drawer.js";
18
+ function oe({ breadcrumbItems: n }) {
19
+ const { logout: l } = L(), { appName: s, logo: c, headerActionsRender: m, userInfo: r, userMenuItems: d = [] } = H(), { theme: a, TOGGLE_THEME: h } = R(N(["theme", "TOGGLE_THEME"])), [p, i] = E(!1), g = (f) => {
20
+ const o = f.currentTarget.getBoundingClientRect(), x = o.left + o.width / 2, b = o.top + o.height / 2;
21
+ z(a === "light" ? "dark" : "light", x, b).then(() => {
22
+ h();
23
+ });
24
+ }, u = [
25
+ ...d,
26
+ {
27
+ key: "logout",
28
+ label: "退出登录",
29
+ icon: /* @__PURE__ */ e(v, {}),
30
+ onClick: () => {
31
+ l();
32
+ }
33
+ }
34
+ ];
35
+ return /* @__PURE__ */ t("header", { className: "layout-header h-[50px] px-4 flex items-center justify-between bg-(--global-background-color) border-b border-(--border-color) z-10", children: [
36
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
37
+ /* @__PURE__ */ e("div", { className: "min-w-[204px]", children: /* @__PURE__ */ t(O, { to: "/", className: "flex items-center gap-2 no-underline", children: [
38
+ c,
39
+ /* @__PURE__ */ e("span", { className: "text-lg font-semibold text-gray-800 dark:text-[#f2f2f2] tracking-wide", children: s })
40
+ ] }) }),
41
+ /* @__PURE__ */ e(
42
+ y,
43
+ {
44
+ items: n,
45
+ className: "items-center basics-breadcrumb text-sm! hidden md:flex",
46
+ separator: /* @__PURE__ */ e(j, { className: "w-4 h-4 text-gray-400" })
47
+ }
48
+ )
49
+ ] }),
50
+ /* @__PURE__ */ e("div", { className: "flex items-center", children: /* @__PURE__ */ t(k, { size: 6, children: [
51
+ m,
52
+ /* @__PURE__ */ e(
53
+ "div",
54
+ {
55
+ className: "cursor-pointer w-8 h-8 text-(--icon-text-color) hover:text-primary transition-colors p-2 rounded-full hover:bg-(--hover-background-color) hover-scale-animation",
56
+ onClick: () => i(!0),
57
+ children: /* @__PURE__ */ e(B, {})
58
+ }
59
+ ),
60
+ /* @__PURE__ */ e(
61
+ "div",
62
+ {
63
+ onClick: g,
64
+ className: "cursor-pointer w-8 h-8 text-(--icon-text-color) hover:text-primary transition-colors p-2 rounded-full hover:bg-(--hover-background-color) hover-scale-animation flex items-center justify-center",
65
+ title: a === "light" ? "切换到暗色主题" : "切换到亮色主题",
66
+ children: a === "light" ? /* @__PURE__ */ e(C, { className: "text-lg" }) : /* @__PURE__ */ e(G, { className: "text-lg" })
67
+ }
68
+ ),
69
+ /* @__PURE__ */ e("div", { className: "cursor-pointer w-8 h-8 text-(--icon-text-color) hover:text-primary transition-colors p-2 rounded-full hover:bg-(--hover-background-color) hover-scale-animation", children: /* @__PURE__ */ e(
70
+ w,
71
+ {
72
+ placement: "bottom",
73
+ arrow: !1,
74
+ trigger: "click",
75
+ classNames: {
76
+ container: "p-0!"
77
+ },
78
+ content: 1,
79
+ children: /* @__PURE__ */ e(T, { dot: !0, color: "var(--color-primary)", children: /* @__PURE__ */ e(A, {}) })
80
+ }
81
+ ) }),
82
+ /* @__PURE__ */ e(S, { menu: { items: u }, placement: "bottomRight", arrow: !0, children: /* @__PURE__ */ t("div", { className: "flex items-center gap-2 cursor-pointer hover:bg-(--hover-background-color) px-2 py-1 rounded-full transition-all border border-transparent", children: [
83
+ /* @__PURE__ */ e(
84
+ M,
85
+ {
86
+ size: "default",
87
+ className: "bg-primary/10 text-primary border border-primary/20",
88
+ src: r == null ? void 0 : r.avatar
89
+ }
90
+ ),
91
+ /* @__PURE__ */ t("div", { className: "hidden lg:flex flex-col items-start", children: [
92
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium text-gray-700 dark:text-[#f2f2f2] leading-tight", children: r == null ? void 0 : r.username }),
93
+ /* @__PURE__ */ e("span", { className: "text-xs text-gray-400 dark:text-[#a1a1aa] leading-tight", children: r == null ? void 0 : r.roleName })
94
+ ] })
95
+ ] }) })
96
+ ] }) }),
97
+ /* @__PURE__ */ e(_, { open: p, onClose: () => i(!1) })
98
+ ] });
99
+ }
100
+ export {
101
+ oe as default
102
+ };
@@ -0,0 +1,34 @@
1
+ import { jsxs as i, jsx as r } from "react/jsx-runtime";
2
+ import { useSelector as p } from "@spacego/zustand";
3
+ import { memo as f, useRef as l, useCallback as u } from "react";
4
+ import C from "../../../../assets/svg/icon-custom.svg.js";
5
+ import "../../../../store/modules/layout-config.store.js";
6
+ import { useThemeStore as h } from "../../../../store/modules/theme.store.js";
7
+ import "@ant-design/icons";
8
+ import { applyThemeColor as S } from "../../../../utils/theme.js";
9
+ function v() {
10
+ const { themeColor: t, SET_THEME_COLOR: n } = h(p(["themeColor", "SET_THEME_COLOR"])), m = l(null), o = l(t), s = u((a) => {
11
+ const e = a.target.value;
12
+ o.current = e, S(e);
13
+ }, []), c = u(() => {
14
+ o.current && n(o.current);
15
+ }, []);
16
+ return /* @__PURE__ */ i("div", { className: "w-5 h-5 relative z-10", children: [
17
+ /* @__PURE__ */ r(C, {}),
18
+ /* @__PURE__ */ r(
19
+ "input",
20
+ {
21
+ ref: m,
22
+ type: "color",
23
+ value: t,
24
+ className: "absolute w-full h-full z-10 opacity-0 cursor-pointer",
25
+ onInput: s,
26
+ onBlur: c
27
+ }
28
+ )
29
+ ] });
30
+ }
31
+ const y = f(v);
32
+ export {
33
+ y as default
34
+ };
@@ -0,0 +1,118 @@
1
+ import { jsxs as o, jsx as e } from "react/jsx-runtime";
2
+ import { CloseOutlined as g } from "@ant-design/icons";
3
+ import { useSelector as N } from "@spacego/zustand";
4
+ import { Drawer as b } from "antd";
5
+ import { IoMoon as y } from "react-icons/io5";
6
+ import { MdWbSunny as C } from "react-icons/md";
7
+ import S from "../../../../assets/svg/icon-sun-moon.svg.js";
8
+ import { THEME_COLORS as T } from "../../../../config/theme.js";
9
+ import "../../../../store/modules/layout-config.store.js";
10
+ import { useThemeStore as d } from "../../../../store/modules/theme.store.js";
11
+ import k from "./setting-custom-color.js";
12
+ function z({ open: m, onClose: a }) {
13
+ const { theme: i, themeColor: s, isCustomThemeColor: l, SET_THEME_COLOR: u, SET_IS_CUSTOM_THEME_COLOR: n } = d(N(["theme", "themeColor", "isCustomThemeColor", "SET_THEME_COLOR", "SET_IS_CUSTOM_THEME_COLOR"])), p = [
14
+ { mode: "light", icon: C, label: "浅色" },
15
+ { mode: "dark", icon: y, label: "深色" },
16
+ { mode: "system", icon: S, label: "跟随系统" }
17
+ ], f = ["默认", "紫罗兰", "樱花粉", "柠檬黄", "天蓝色", "浅绿色", "中性色", "自定义"], h = [
18
+ ...T.map((r, t) => ({ color: r, name: f[t], isCustom: !1 })),
19
+ { color: s, name: "自定义", isCustom: !0 }
20
+ ], x = (r) => {
21
+ i !== r && d.getState().SET_THEME(r);
22
+ };
23
+ return /* @__PURE__ */ o(
24
+ b,
25
+ {
26
+ title: /* @__PURE__ */ o("div", { className: "flex items-end", children: [
27
+ "偏好设置",
28
+ /* @__PURE__ */ e("span", { className: "text-xs text-[#71717a] dark:text-[#a1a1aa] mb-[2px]", children: "自定义偏好设置 & 实时预览" })
29
+ ] }),
30
+ placement: "right",
31
+ onClose: a,
32
+ open: m,
33
+ width: 380,
34
+ closable: !1,
35
+ maskStyle: { backdropFilter: "none" },
36
+ className: "dark:bg-[#1a1c1f]!",
37
+ extra: /* @__PURE__ */ e("div", { className: "cursor-pointer hover:text-primary transition-colors", onClick: a, children: /* @__PURE__ */ e(g, { className: "text-sm" }) }),
38
+ styles: {
39
+ header: {
40
+ padding: "18px",
41
+ borderBottom: "1px solid var(--border-color)"
42
+ },
43
+ body: {
44
+ padding: "18px"
45
+ }
46
+ },
47
+ children: [
48
+ /* @__PURE__ */ o("div", { className: "mb-8", children: [
49
+ /* @__PURE__ */ e("h3", { className: "text-base font-medium mb-4 text-(--text-color)", children: "主题" }),
50
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-3 gap-6", children: p.map(({ mode: r, icon: t, label: v }) => {
51
+ const c = i === r;
52
+ return /* @__PURE__ */ o(
53
+ "div",
54
+ {
55
+ className: "group flex flex-col items-center gap-2 cursor-pointer",
56
+ onClick: () => x(r),
57
+ children: [
58
+ /* @__PURE__ */ o("div", { className: `w-full aspect-[2] rounded-lg outline flex items-center justify-center transition-all relative overflow-hidden ${c ? "outline-(--color-primary) outline-2" : "outline-[#e4e4e7] dark:outline-[#36363a]"}`, children: [
59
+ !c && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center pointer-events-none", children: /* @__PURE__ */ e("div", { className: "w-full h-full rounded-lg border-2 border-(--color-primary) opacity-0 scale-0 transition-all duration-300 group-hover:opacity-100 group-hover:scale-100" }) }),
60
+ /* @__PURE__ */ e(t, { className: "text-xl text-[#2d2f32] dark:text-[#f0f0f0] relative z-10" })
61
+ ] }),
62
+ /* @__PURE__ */ e("span", { className: "text-xs text-[#71717a] dark:text-[#a1a1aa]", children: v })
63
+ ]
64
+ },
65
+ r
66
+ );
67
+ }) })
68
+ ] }),
69
+ /* @__PURE__ */ o("div", { children: [
70
+ /* @__PURE__ */ e("h3", { className: "text-base font-medium mb-4 text-(--text-color)", children: "内置主题" }),
71
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-3 gap-6", children: h.map((r) => {
72
+ const t = s === r.color && !l;
73
+ return r.isCustom ? /* @__PURE__ */ o(
74
+ "div",
75
+ {
76
+ className: "cursor-pointer group flex flex-col items-center gap-2",
77
+ onClick: () => n(!0),
78
+ children: [
79
+ /* @__PURE__ */ o("div", { className: `w-full aspect-[2] rounded-lg outline flex items-center justify-center transition-all relative overflow-hidden ${l ? "outline-(--color-primary) outline-2" : "outline-[#e4e4e7] dark:outline-[#36363a]"}`, children: [
80
+ !l && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center pointer-events-none", children: /* @__PURE__ */ e("div", { className: "w-full h-full rounded-lg border-2 border-(--color-primary) opacity-0 scale-0 transition-all duration-300 group-hover:opacity-100 group-hover:scale-100" }) }),
81
+ /* @__PURE__ */ e(k, {})
82
+ ] }),
83
+ /* @__PURE__ */ e("span", { className: "text-xs text-[#71717a] dark:text-[#a1a1aa]", children: r.name })
84
+ ]
85
+ },
86
+ `custom-${r.color}`
87
+ ) : /* @__PURE__ */ o(
88
+ "div",
89
+ {
90
+ className: "cursor-pointer group flex flex-col items-center gap-2",
91
+ onClick: () => {
92
+ u(r.color), n(!1);
93
+ },
94
+ children: [
95
+ /* @__PURE__ */ o("div", { className: `w-full aspect-[2] rounded-lg outline flex items-center justify-center transition-all relative overflow-hidden ${t ? "outline-(--color-primary) outline-2" : "outline-[#e4e4e7] dark:outline-[#36363a]"}`, children: [
96
+ !t && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center pointer-events-none", children: /* @__PURE__ */ e("div", { className: "w-full h-full rounded-lg border-2 border-(--color-primary) opacity-0 scale-0 transition-all duration-300 group-hover:opacity-100 group-hover:scale-100" }) }),
97
+ /* @__PURE__ */ e(
98
+ "div",
99
+ {
100
+ className: "w-5 h-5 rounded-md shadow-sm relative z-10",
101
+ style: { backgroundColor: r.color }
102
+ }
103
+ )
104
+ ] }),
105
+ /* @__PURE__ */ e("span", { className: "text-xs text-[#71717a] dark:text-[#a1a1aa]", children: r.name })
106
+ ]
107
+ },
108
+ r.color
109
+ );
110
+ }) })
111
+ ] })
112
+ ]
113
+ }
114
+ );
115
+ }
116
+ export {
117
+ z as default
118
+ };
@@ -0,0 +1,60 @@
1
+ import { jsx as e, jsxs as b } from "react/jsx-runtime";
2
+ import { Layout as h, Menu as p } from "antd";
3
+ import { useState as y, useEffect as x, useMemo as g } from "react";
4
+ import { MdOutlineKeyboardDoubleArrowRight as v, MdOutlineKeyboardDoubleArrowLeft as k } from "react-icons/md";
5
+ import { renderIcon as K } from "../../../../utils/icon.js";
6
+ import "../../../../store/modules/layout-config.store.js";
7
+ import "../../../../store/modules/theme.store.js";
8
+ const { Sider: w } = h;
9
+ function A(a) {
10
+ const { collapsed: l, menus: n, activeKey: s, openKeys: o = [], onMenuClick: d, onCollapse: c } = a, [f, i] = y(o);
11
+ x(() => {
12
+ o.length > 0 && i(o);
13
+ }, [o]);
14
+ const m = g(() => {
15
+ const t = (u) => u.map((r) => ({
16
+ key: r.key,
17
+ label: r.label,
18
+ icon: K(r.icon),
19
+ children: r.children ? t(r.children) : void 0
20
+ }));
21
+ return t(n);
22
+ }, [n]);
23
+ return /* @__PURE__ */ e(
24
+ w,
25
+ {
26
+ trigger: null,
27
+ collapsible: !0,
28
+ collapsed: l,
29
+ width: 224,
30
+ className: "layout-sidebar border-r border-(--border-color) bg-(--global-background-color)! h-full relative",
31
+ theme: "light",
32
+ children: /* @__PURE__ */ b("div", { className: "h-full flex flex-col", children: [
33
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto overflow-x-hidden py-2 custom-scrollbar", children: /* @__PURE__ */ e(
34
+ p,
35
+ {
36
+ mode: "inline",
37
+ selectedKeys: [s],
38
+ openKeys: f,
39
+ onOpenChange: i,
40
+ items: m,
41
+ onClick: ({ key: t }) => d(t),
42
+ className: "sidebar-menu border-none",
43
+ inlineIndent: 16
44
+ }
45
+ ) }),
46
+ /* @__PURE__ */ e("div", { className: "flex items-center justify-start pl-4 mb-2", children: /* @__PURE__ */ e(
47
+ "div",
48
+ {
49
+ onClick: () => c(!l),
50
+ className: "text-gray-500 dark:text-[#a1a1a2] text-xl hover:text-[#323639] dark:hover:text-[#f0f0f0] hover:bg-[#dfe3e4] dark:hover:bg-[#333538] transition-all duration-300 w-7 h-7 rounded-sm bg-[#f4f4f5] dark:bg-[#292a2d] cursor-pointer flex items-center justify-center",
51
+ children: l ? /* @__PURE__ */ e(v, {}) : /* @__PURE__ */ e(k, {})
52
+ }
53
+ ) })
54
+ ] })
55
+ }
56
+ );
57
+ }
58
+ export {
59
+ A as default
60
+ };
@@ -0,0 +1,60 @@
1
+ import { jsx as r, jsxs as i, Fragment as u } from "react/jsx-runtime";
2
+ import { classnames as s } from "@spacego/turbo-utils";
3
+ import { Divider as x } from "antd";
4
+ import { useRef as b, useState as v, useEffect as k } from "react";
5
+ import { MdClear as g } from "react-icons/md";
6
+ import y from "../../../../assets/svg/chrome-bg-after.svg.js";
7
+ import w from "../../../../assets/svg/chrome-bg-before.svg.js";
8
+ function z(c) {
9
+ const { tabs: o, activeKey: d, onChange: f, onClose: h } = c, n = b(null), [l, m] = v(!1), a = () => {
10
+ const e = n.current;
11
+ if (e) {
12
+ const t = e.scrollWidth > e.clientWidth;
13
+ m(t);
14
+ }
15
+ };
16
+ return k(() => (a(), window.addEventListener("resize", a), () => {
17
+ window.removeEventListener("resize", a);
18
+ }), [o]), /* @__PURE__ */ r(
19
+ "div",
20
+ {
21
+ ref: n,
22
+ className: s("layout-tabs bg-(--global-background-color) border-b border-(--border-color) overflow-x-auto overflow-y-hidden relative transition-all duration-300 shrink-0", {
23
+ "h-[38px]": !l,
24
+ // 出现滚动条时增加高度,留出滚动条的空间,防止挤压内容
25
+ "h-[46px]": l
26
+ }),
27
+ children: /* @__PURE__ */ r("div", { className: "flex items-center h-[38px] px-2 pt-1 min-w-fit", children: o.map((e, t) => /* @__PURE__ */ i(u, { children: [
28
+ /* @__PURE__ */ i(
29
+ "div",
30
+ {
31
+ className: s("layout-tabs-item group cursor-pointer px-[16px] h-full flex items-center justify-center rounded-tl-[8px] rounded-tr-[8px] transition-all duration-500 relative hover:bg-[#f4f4f5] dark:hover:bg-[#292a2d] shrink-0", {
32
+ "bg-(--background-primary-light)! text-(--color-primary) dark:text-[#f9f9f9]! is-active": d === e.key
33
+ }),
34
+ onClick: () => f(e.key),
35
+ children: [
36
+ /* @__PURE__ */ r(w, {}),
37
+ e.label,
38
+ /* @__PURE__ */ r(y, {}),
39
+ e.closable !== !1 && /* @__PURE__ */ r(
40
+ "div",
41
+ {
42
+ className: "w-4 h-4 flex ml-1 mr-[-10px] items-center justify-center text-[#18181bcc] hover:text-[#18181b] hover:bg-[#f4f4f5] dark:hover:bg-transparent rounded-full transition-all duration-300",
43
+ onClick: (p) => {
44
+ p.stopPropagation(), h(e.key);
45
+ },
46
+ children: /* @__PURE__ */ r(g, { className: "text-xs text-[#333333] dark:text-[#cfd0d0] hover:text-black dark:hover:text-white transition-all" })
47
+ }
48
+ )
49
+ ]
50
+ },
51
+ `${e.key}-${t}`
52
+ ),
53
+ t !== o.length - 1 && /* @__PURE__ */ r(x, { orientation: "vertical", className: "mx-1! shrink-0" })
54
+ ] }, `${e.key}-${t}`)) })
55
+ }
56
+ );
57
+ }
58
+ export {
59
+ z as default
60
+ };
@@ -0,0 +1,72 @@
1
+ function d(e) {
2
+ return e ? e === "/" ? "/" : e.replace(/\/+$/, "") : "";
3
+ }
4
+ function f(e, i) {
5
+ const t = d(e);
6
+ for (const n of i) {
7
+ if (n.children && n.children.length > 0) {
8
+ const u = f(e, n.children);
9
+ if (u) return u;
10
+ }
11
+ if (n.id === "Home" && t === "/")
12
+ return n;
13
+ const r = d(n.path);
14
+ if (r && r === t && !["root", "blank", "auth"].includes(n.id || ""))
15
+ return n;
16
+ }
17
+ return null;
18
+ }
19
+ function s(e) {
20
+ const i = /* @__PURE__ */ new Map(), t = (n) => {
21
+ n.forEach((r) => {
22
+ r.id && i.set(r.id, r), r.children && r.children.length > 0 && t(r.children);
23
+ });
24
+ };
25
+ return t(e), i;
26
+ }
27
+ function o(e, i) {
28
+ return i.get(e) || null;
29
+ }
30
+ function a(e, i) {
31
+ var r;
32
+ const t = [e];
33
+ let n = e;
34
+ for (; n.parentId && n.parentId !== "/"; ) {
35
+ const u = o(n.parentId, i);
36
+ if (u)
37
+ ((r = n.handle) == null ? void 0 : r.isIndependentMenu) === !0 || t.unshift(u), n = u;
38
+ else
39
+ break;
40
+ }
41
+ return t;
42
+ }
43
+ function c(e, i, t = []) {
44
+ for (const n of i) {
45
+ if (n.key === e)
46
+ return t;
47
+ if (n.children && n.children.length > 0) {
48
+ const r = c(e, n.children, [...t, n.key]);
49
+ if (r) return r;
50
+ }
51
+ }
52
+ return null;
53
+ }
54
+ function l(e, i) {
55
+ for (const t of i) {
56
+ if (t.key === e) return t;
57
+ if (t.children) {
58
+ const n = l(e, t.children);
59
+ if (n) return n;
60
+ }
61
+ }
62
+ return null;
63
+ }
64
+ export {
65
+ s as buildRouteMap,
66
+ l as findMenuByKey,
67
+ c as findMenuParentKeys,
68
+ a as findParentRoutes,
69
+ f as findRouteByPath,
70
+ o as getRouteById,
71
+ d as normalizePath
72
+ };
@@ -0,0 +1,98 @@
1
+ import { jsxs as f, jsx as i } from "react/jsx-runtime";
2
+ import { useSelector as N } from "@spacego/zustand";
3
+ import { Layout as g, Spin as I } from "antd";
4
+ import { useMemo as d, useEffect as O } from "react";
5
+ import { useLocation as P, useNavigate as V, Outlet as j } from "react-router-dom";
6
+ import { useLayoutConfigStore as Y } from "../../store/modules/layout-config.store.js";
7
+ import "../../store/modules/theme.store.js";
8
+ import { useGlobal as z } from "../context/context.js";
9
+ import G from "./components/basics-layout/header.js";
10
+ import H from "./components/basics-layout/sidebar.js";
11
+ import q from "./components/basics-layout/tabs.js";
12
+ import { findRouteByPath as b, findMenuParentKeys as F, buildRouteMap as J, findParentRoutes as Q, findMenuByKey as U } from "./components/utils/index.js";
13
+ /* empty css */
14
+ /* empty css */
15
+ const { Content: W } = g;
16
+ function fe() {
17
+ const a = P(), m = V(), { token: C, menus: s, routes: n } = z(), { tabsAttribute: A, sidebarCollapsed: v, loadingConfig: _, ADD_TAB: x, REMOVE_TAB: L, SET_ACTIVE_TAB_KEY: E, SET_SIDEBAR_COLLAPSED: S } = Y(N(["tabsAttribute", "sidebarCollapsed", "loadingConfig", "ADD_TAB", "REMOVE_TAB", "SET_ACTIVE_TAB_KEY", "SET_SIDEBAR_COLLAPSED"])), { tabsList: h, tabsActiveKey: r } = A, l = d(() => {
18
+ var t;
19
+ if (!n || n.length === 0)
20
+ return r;
21
+ const e = b(a.pathname, n);
22
+ return e && (((t = e.handle) == null ? void 0 : t.activeRouteMenuId) || e.id) || r;
23
+ }, [a.pathname, n, r]), M = d(() => {
24
+ const e = [];
25
+ if (!s || s.length === 0 || !l)
26
+ return e;
27
+ const t = F(l, s);
28
+ return t && e.push(...t), e;
29
+ }, [l, s]), B = d(() => {
30
+ const e = [];
31
+ if (!n || n.length === 0)
32
+ return a.pathname === "/" && e.push({ title: "首页" }), e;
33
+ const t = n, o = J(t), c = b(a.pathname, t);
34
+ return c ? Q(c, o).forEach((u) => {
35
+ var y;
36
+ const T = ((y = u.handle) == null ? void 0 : y.title) || u.id || "";
37
+ T && e.push({ title: T });
38
+ }) : a.pathname === "/" && e.push({ title: "首页" }), e;
39
+ }, [a.pathname, n]), K = (e) => {
40
+ var o;
41
+ const t = U(e, s);
42
+ m(((o = t == null ? void 0 : t.routeNode) == null ? void 0 : o.path) ?? "/");
43
+ }, k = (e) => {
44
+ E(e);
45
+ const t = h.find((o) => o.key === e);
46
+ t && m(t.path);
47
+ }, R = (e) => {
48
+ const t = L(e);
49
+ m(t.path ?? "/");
50
+ }, p = d(() => !n || n.length === 0 ? null : (e) => b(e, n), [n]), D = () => {
51
+ var t;
52
+ const e = p == null ? void 0 : p(a.pathname);
53
+ if (e && e.id && !["root", "blank", "auth"].includes(e.id)) {
54
+ const o = e.id, c = ((t = e.handle) == null ? void 0 : t.title) || e.id;
55
+ h.find((u) => u.key === o) ? E(o) : x({
56
+ key: o,
57
+ label: c,
58
+ path: a.pathname
59
+ });
60
+ }
61
+ };
62
+ return O(() => {
63
+ C && D();
64
+ }, [a.pathname, C]), /* @__PURE__ */ f(g, { className: "basics-layout w-full h-screen overflow-hidden flex flex-col", children: [
65
+ /* @__PURE__ */ i(G, { breadcrumbItems: B }),
66
+ /* @__PURE__ */ f(g, { className: "flex-1 overflow-hidden", children: [
67
+ /* @__PURE__ */ i(
68
+ H,
69
+ {
70
+ collapsed: v,
71
+ onCollapse: S,
72
+ menus: s,
73
+ activeKey: l,
74
+ openKeys: M,
75
+ onMenuClick: K
76
+ }
77
+ ),
78
+ /* @__PURE__ */ f(W, { className: "flex flex-col flex-1 overflow-hidden bg-[#eff1f4] dark:bg-[#141619]", children: [
79
+ /* @__PURE__ */ i(
80
+ q,
81
+ {
82
+ tabs: h,
83
+ activeKey: r,
84
+ onChange: k,
85
+ onClose: R
86
+ }
87
+ ),
88
+ /* @__PURE__ */ f("div", { className: "flex-1 overflow-auto p-3 custom-scrollbar relative", children: [
89
+ /* @__PURE__ */ i(j, {}),
90
+ _.show && /* @__PURE__ */ i("div", { className: "absolute inset-0 z-9999 flex items-center justify-center bg-white/80 dark:bg-[#1a1c1f]/80", children: /* @__PURE__ */ i(I, { spinning: !0 }) })
91
+ ] })
92
+ ] })
93
+ ] })
94
+ ] });
95
+ }
96
+ export {
97
+ fe as default
98
+ };
@@ -0,0 +1,8 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { Outlet as o } from "react-router-dom";
3
+ function a() {
4
+ return /* @__PURE__ */ t(o, {});
5
+ }
6
+ export {
7
+ a as default
8
+ };
@@ -0,0 +1,6 @@
1
+ import { createContext as t, useContext as o } from "react";
2
+ const e = t({}), l = () => o(e);
3
+ export {
4
+ e as GlobalContext,
5
+ l as useGlobal
6
+ };
@@ -0,0 +1,53 @@
1
+ import { jsx as w } from "react/jsx-runtime";
2
+ import { useState as t } from "react";
3
+ import { GlobalContext as z } from "./context.js";
4
+ function K(e) {
5
+ const [n, r] = t(e.appName), [s, o] = t(e.logo), [c, i] = t(e.noticeRender), [a, d] = t(e.description), [f, u] = t(e.descriptionDetail), [b, m] = t(e.copyright), [l, R] = t(e.userMenuItems), [h, A] = t(e.userInfo), [B, g] = t(e.sidebarBefore), [I, D] = t(e.sidebarAfter), [x, M] = t(e.tabsBefore), [N, S] = t(e.tabsAfter), [k, v] = t(e.headerActionsRender), [y, C] = t(e.searchRender), [T, G] = t(e.breadcrumbBeforeRender), [P, U] = t(e.token), [j, H] = t(e.menus), [L, q] = t(e.routes);
6
+ return /* @__PURE__ */ w(
7
+ z.Provider,
8
+ {
9
+ value: {
10
+ appName: n,
11
+ logo: s,
12
+ noticeRender: c,
13
+ description: a,
14
+ descriptionDetail: f,
15
+ copyright: b,
16
+ userMenuItems: l,
17
+ userInfo: h,
18
+ sidebarBefore: B,
19
+ sidebarAfter: I,
20
+ tabsBefore: x,
21
+ tabsAfter: N,
22
+ headerActionsRender: k,
23
+ searchRender: y,
24
+ breadcrumbBeforeRender: T,
25
+ token: P,
26
+ menus: j,
27
+ routes: L,
28
+ setAppName: r,
29
+ setLogo: o,
30
+ setNoticeRender: i,
31
+ setDescription: d,
32
+ setDescriptionDetail: u,
33
+ setCopyright: m,
34
+ setUserMenuItems: R,
35
+ setUserInfo: A,
36
+ setSidebarBefore: g,
37
+ setSidebarAfter: D,
38
+ setTabsBefore: M,
39
+ setTabsAfter: S,
40
+ setHeaderActionsRender: v,
41
+ setSearchRender: C,
42
+ setBreadcrumbBeforeRender: G,
43
+ setToken: U,
44
+ setMenus: H,
45
+ setRoutes: q
46
+ },
47
+ children: e.children
48
+ }
49
+ );
50
+ }
51
+ export {
52
+ K as default
53
+ };
@@ -0,0 +1,49 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { useSelector as n } from "@spacego/zustand";
3
+ import { theme as i, ConfigProvider as h, Spin as c } from "antd";
4
+ import { useMemo as u } from "react";
5
+ import "@ant-design/icons";
6
+ import { getRealTheme as g } from "../utils/theme.js";
7
+ import { useLayoutConfigStore as d } from "../store/modules/layout-config.store.js";
8
+ import { useThemeStore as C } from "../store/modules/theme.store.js";
9
+ import a from "../config/theme.js";
10
+ import "react-router-dom";
11
+ import y from "./auth-layout/index.js";
12
+ import k from "./basics-layout/index.js";
13
+ import L from "./blank-layout/index.js";
14
+ import "./context/context.js";
15
+ import M from "./context/global-context.provider.js";
16
+ function q(p) {
17
+ const { layoutType: e } = p, { loadingConfig: s } = d(n(["loadingConfig"])), { theme: t, themeColor: r } = C(n(["theme", "themeColor"])), l = u(() => {
18
+ const f = g(t);
19
+ return {
20
+ cssVar: {
21
+ prefix: "ant"
22
+ },
23
+ // 启用 CSS 变量模式,生成 --ant-color-primary 等变量
24
+ algorithm: f === "dark" ? i.darkAlgorithm : i.defaultAlgorithm,
25
+ token: {
26
+ colorPrimary: r,
27
+ ...a.token
28
+ },
29
+ components: {
30
+ ...a.components
31
+ }
32
+ };
33
+ }, [t, r]), m = (/* @__PURE__ */ new Map([
34
+ ["blank", L],
35
+ ["basic", k],
36
+ ["auth", y]
37
+ ])).get(e);
38
+ return /* @__PURE__ */ o(h, { theme: l, children: /* @__PURE__ */ o(M, { children: /* @__PURE__ */ o(
39
+ c,
40
+ {
41
+ spinning: s.show && e !== "basic",
42
+ wrapperClassName: "spin-wrapper-full",
43
+ children: m && /* @__PURE__ */ o(m, {}, e)
44
+ }
45
+ ) }) });
46
+ }
47
+ export {
48
+ q as default
49
+ };