@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.
- package/README.md +37 -0
- package/lib/assets/svg/chrome-bg-after.svg.js +4 -0
- package/lib/assets/svg/chrome-bg-before.svg.js +4 -0
- package/lib/assets/svg/icon-arrows-right.svg.js +4 -0
- package/lib/assets/svg/icon-bell.svg.js +4 -0
- package/lib/assets/svg/icon-custom.svg.js +4 -0
- package/lib/assets/svg/icon-sun-moon.svg.js +4 -0
- package/lib/assets/svg/icon-system.svg.js +4 -0
- package/lib/assets/svg/login-view.svg.js +4 -0
- package/lib/config/constants.js +10 -0
- package/lib/config/theme.js +8 -0
- package/lib/fe-layouts/auth-layout/index.js +95 -0
- package/lib/fe-layouts/basics-layout/components/basics-layout/header.js +102 -0
- package/lib/fe-layouts/basics-layout/components/basics-layout/setting-custom-color.js +34 -0
- package/lib/fe-layouts/basics-layout/components/basics-layout/setting-drawer.js +118 -0
- package/lib/fe-layouts/basics-layout/components/basics-layout/sidebar.js +60 -0
- package/lib/fe-layouts/basics-layout/components/basics-layout/tabs.js +60 -0
- package/lib/fe-layouts/basics-layout/components/utils/index.js +72 -0
- package/lib/fe-layouts/basics-layout/index.js +98 -0
- package/lib/fe-layouts/blank-layout/index.js +8 -0
- package/lib/fe-layouts/context/context.js +6 -0
- package/lib/fe-layouts/context/global-context.provider.js +53 -0
- package/lib/fe-layouts/layout.js +49 -0
- package/lib/hooks/use-auth.hook.js +23 -0
- package/lib/index.css +1 -0
- package/lib/index.js +48 -0
- package/lib/router/index.js +43 -0
- package/lib/router/permission.js +43 -0
- package/lib/router/routes.js +57 -0
- package/lib/router/utils.js +105 -0
- package/lib/store/modules/layout-config.store.js +217 -0
- package/lib/store/modules/theme.store.js +60 -0
- package/lib/types/config/constants.d.ts +9 -0
- package/lib/types/config/index.d.ts +2 -0
- package/lib/types/config/theme.d.ts +7 -0
- package/lib/types/fe-layouts/auth-layout/index.d.ts +1 -0
- package/lib/types/fe-layouts/basics-layout/components/basics-layout/header.d.ts +7 -0
- package/lib/types/fe-layouts/basics-layout/components/basics-layout/setting-custom-color.d.ts +3 -0
- package/lib/types/fe-layouts/basics-layout/components/basics-layout/setting-drawer.d.ts +6 -0
- package/lib/types/fe-layouts/basics-layout/components/basics-layout/sidebar.d.ts +11 -0
- package/lib/types/fe-layouts/basics-layout/components/basics-layout/tabs.d.ts +9 -0
- package/lib/types/fe-layouts/basics-layout/components/utils/index.d.ts +41 -0
- package/lib/types/fe-layouts/basics-layout/index.d.ts +1 -0
- package/lib/types/fe-layouts/blank-layout/index.d.ts +1 -0
- package/lib/types/fe-layouts/context/context.d.ts +7 -0
- package/lib/types/fe-layouts/context/global-context.provider.d.ts +2 -0
- package/lib/types/fe-layouts/context/index.d.ts +3 -0
- package/lib/types/fe-layouts/index.d.ts +6 -0
- package/lib/types/fe-layouts/layout.d.ts +7 -0
- package/lib/types/hooks/index.d.ts +1 -0
- package/lib/types/hooks/use-auth.hook.d.ts +8 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/router/index.d.ts +40 -0
- package/lib/types/router/permission.d.ts +23 -0
- package/lib/types/router/routes.d.ts +11 -0
- package/lib/types/router/utils.d.ts +56 -0
- package/lib/types/store/index.d.ts +2 -0
- package/lib/types/store/modules/layout-config.store.d.ts +612 -0
- package/lib/types/store/modules/theme.store.d.ts +186 -0
- package/lib/types/utils/icon.d.ts +14 -0
- package/lib/types/utils/index.d.ts +2 -0
- package/lib/types/utils/theme.d.ts +43 -0
- package/lib/utils/icon.js +13 -0
- package/lib/utils/theme.js +100 -0
- package/package.json +60 -0
- package/src/assets/styles/animate.css +62 -0
- package/src/assets/styles/index.css +49 -0
- package/src/assets/svg/chrome-bg-after.svg +1 -0
- package/src/assets/svg/chrome-bg-before.svg +1 -0
- package/src/assets/svg/icon-arrows-right.svg +1 -0
- package/src/assets/svg/icon-bell.svg +1 -0
- package/src/assets/svg/icon-custom.svg +1 -0
- package/src/assets/svg/icon-sun-moon.svg +1 -0
- package/src/assets/svg/icon-system.svg +1 -0
- package/src/assets/svg/loading.svg +13 -0
- package/src/assets/svg/login-view.svg +193 -0
- package/src/config/constants.ts +19 -0
- package/src/config/index.ts +2 -0
- package/src/config/theme.ts +20 -0
- package/src/fe-layouts/auth-layout/index.scss +34 -0
- package/src/fe-layouts/auth-layout/index.tsx +121 -0
- package/src/fe-layouts/basics-layout/components/basics-layout/header.tsx +148 -0
- package/src/fe-layouts/basics-layout/components/basics-layout/setting-custom-color.tsx +52 -0
- package/src/fe-layouts/basics-layout/components/basics-layout/setting-drawer.tsx +165 -0
- package/src/fe-layouts/basics-layout/components/basics-layout/sidebar.tsx +88 -0
- package/src/fe-layouts/basics-layout/components/basics-layout/tabs.tsx +94 -0
- package/src/fe-layouts/basics-layout/components/utils/index.ts +142 -0
- package/src/fe-layouts/basics-layout/index.scss +110 -0
- package/src/fe-layouts/basics-layout/index.tsx +207 -0
- package/src/fe-layouts/blank-layout/index.tsx +12 -0
- package/src/fe-layouts/context/context.ts +11 -0
- package/src/fe-layouts/context/global-context.d.ts +241 -0
- package/src/fe-layouts/context/global-context.provider.tsx +81 -0
- package/src/fe-layouts/context/index.ts +10 -0
- package/src/fe-layouts/index.ts +13 -0
- package/src/fe-layouts/layout.tsx +74 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-auth.hook.ts +54 -0
- package/src/index.ts +21 -0
- package/src/router/index.ts +110 -0
- package/src/router/permission.tsx +134 -0
- package/src/router/routes.tsx +94 -0
- package/src/router/utils.ts +283 -0
- package/src/store/index.ts +9 -0
- package/src/store/modules/layout-config.store.ts +343 -0
- package/src/store/modules/theme.store.ts +99 -0
- package/src/typings/index.d.ts +59 -0
- package/src/typings/shims-axios.d.ts +38 -0
- package/src/utils/icon.tsx +32 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/theme.ts +219 -0
- package/tsconfig.json +28 -0
- package/vite.config.ts +85 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useSubmit as i, useFetcher as n, useSearchParams as c } from "react-router-dom";
|
|
2
|
+
import { useLayoutConfigStore as a } from "../store/modules/layout-config.store.js";
|
|
3
|
+
import "../store/modules/theme.store.js";
|
|
4
|
+
import { useGlobal as l } from "../fe-layouts/context/context.js";
|
|
5
|
+
import "react/jsx-runtime";
|
|
6
|
+
import "react";
|
|
7
|
+
function P() {
|
|
8
|
+
const t = i(), o = n(), [e] = c(), { setToken: r } = l();
|
|
9
|
+
return {
|
|
10
|
+
login: (s, u) => {
|
|
11
|
+
const m = u || e.get("from") || "/";
|
|
12
|
+
t({ token: s, redirectTo: m }, { method: "post", replace: !0 });
|
|
13
|
+
},
|
|
14
|
+
logout: () => {
|
|
15
|
+
r(void 0), o.submit(null, { action: "/logout", method: "post" }), setTimeout(() => {
|
|
16
|
+
a.getState().RESET();
|
|
17
|
+
}, 300);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
P as useAuth
|
|
23
|
+
};
|
package/lib/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.bg-background-deep{background-color:#f1f3f6}.bg-background-deep .login-background{background:linear-gradient(154deg,#07070915 30%,color-mix(in srgb,var(--color-primary) 30%,transparent) 48%,#07070915 64%);filter:blur(100px)}.bg-background-deep .-enter-x{animation:enter-x-animation .3s ease-in-out .2s forwards;opacity:0;transform:translate(-50px)}.bg-background-deep .animate-float{animation:float 5s linear 0s infinite}.login-side .side-content{animation-name:slide-right;animation-duration:.3s;animation-timing-function:cubic-bezier(.16,1,.3,1)}.login-side .side-content.exit-x{animation-name:exit-x-animation;animation-duration:.5s;animation-timing-function:cubic-bezier(.16,1,.3,1);animation-fill-mode:forwards}@keyframes enter-x-animation{to{opacity:1;transform:translate(0)}}@keyframes float{0%{transform:translateY(0)}50%{transform:translateY(-20px)}to{transform:translateY(0)}}@keyframes slide-right{0%{opacity:0;transform:translate(50px)}to{opacity:1;transform:translate(0)}}@keyframes exit-x-animation{0%{opacity:1;transform:translate(0)}to{opacity:0;transform:translate(50px)}}@keyframes scale-pulse{0%{transform:scale(1)}50%{transform:scale(.9)}to{transform:scale(1)}}.hover-scale-animation:hover{animation:scale-pulse .3s cubic-bezier(.4,0,.2,1)}@custom-variant dark (&:where(.dark,.dark *));:root{--color-primary: #006BE6;--global-background-color: white;--border-color: #e4e4e7;--text-color: #323639}[data-theme=dark]{--global-background-color: #1a1c1f;--border-color: #36363a;--text-color: #f2f2f2}html{background-color:var(--global-background-color);--hover-primary-color: color-mix(in srgb, var(--color-primary) 80%, transparent)}#root,body,html{height:100%;width:100%}body{min-height:100vh}.spin-wrapper-full,.spin-wrapper-full .ant-spin-container{width:100%;height:100%}.spin-wrapper-full .ant-spin{max-height:100%!important}.basics-layout{--sidebar-width: 220px;--header-height: 64px;--tabs-height: 44px;--background-primary-light: color-mix(in srgb, var(--color-primary) 10%, transparent);--hover-background-color: #f4f4f5;--icon-text-color: #323639}[data-theme=dark] .basics-layout{--hover-background-color: #2e3033;--icon-text-color: #dddddd;--background-primary-light: #292a2d}.basics-layout .layout-header{flex-shrink:0}.basics-layout .layout-header .basics-breadcrumb .ant-breadcrumb-separator{display:flex;align-items:center;margin-inline:6px}.basics-layout .layout-sidebar{z-index:20;flex-shrink:0}.basics-layout .layout-sidebar .sidebar-menu{background:var(--global-background-color);border:none}.basics-layout .layout-sidebar .sidebar-menu .ant-menu-item{margin:4px 8px;width:calc(100% - 16px);border-radius:8px;transition:all .3s cubic-bezier(.4,0,.2,1);padding-inline:30%}.basics-layout .layout-sidebar .sidebar-menu .ant-menu-item:hover{background:var(--hover-background-color)}.basics-layout .layout-sidebar .sidebar-menu .ant-menu-item:hover .ant-menu-item-icon{transition:transform .3s cubic-bezier(.4,0,.2,1);transform:scale(1.18)}.basics-layout .layout-sidebar .sidebar-menu .ant-menu-item.ant-menu-item-selected{background-color:var(--background-primary-light);color:var(--color-primary)}.basics-layout .layout-sidebar .sidebar-menu .ant-menu-item .ant-menu-title-content{margin-inline-start:8px}.basics-layout .layout-sidebar .sidebar-menu .ant-menu-submenu-title{margin:4px 8px;width:calc(100% - 16px);border-radius:8px;padding-inline:30%}.basics-layout .layout-sidebar .sidebar-menu .ant-menu-submenu-title:hover{background-color:var(--hover-background-color)}.basics-layout .layout-sidebar .sidebar-menu .ant-menu-submenu-title:hover .ant-menu-item-icon{transition:transform .3s cubic-bezier(.4,0,.2,1);transform:scale(1.18)}.basics-layout .layout-sidebar .sidebar-menu .ant-menu-sub{background:transparent}.basics-layout .custom-scrollbar::-webkit-scrollbar{width:8px;height:8px}.basics-layout .custom-scrollbar::-webkit-scrollbar-track{background:transparent}.basics-layout .custom-scrollbar::-webkit-scrollbar-thumb{background:#0000004d;border-radius:4px}.basics-layout .custom-scrollbar::-webkit-scrollbar-thumb:hover{background:#00000080}.basics-layout .layout-tabs{position:relative;scrollbar-width:thin}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getIcon as t, renderIcon as r } from "./utils/icon.js";
|
|
2
|
+
import { applyTheme as m, applyThemeColor as p, applyThemeWithTransition as f, getRealTheme as l, getTheme as s, initTheme as u, listenSystemTheme as x, toggleTheme as n } from "./utils/theme.js";
|
|
3
|
+
import { useLayoutConfigStore as T } from "./store/modules/layout-config.store.js";
|
|
4
|
+
import { useThemeStore as y } from "./store/modules/theme.store.js";
|
|
5
|
+
import { APP_KEY as g, NOOP as d, STORE_KEY as L } from "./config/constants.js";
|
|
6
|
+
import { THEME_COLORS as C } from "./config/theme.js";
|
|
7
|
+
import { createRouter as E, generateRouter as O } from "./router/index.js";
|
|
8
|
+
import { default as b } from "./fe-layouts/auth-layout/index.js";
|
|
9
|
+
import { default as _ } from "./fe-layouts/basics-layout/index.js";
|
|
10
|
+
import { default as B } from "./fe-layouts/blank-layout/index.js";
|
|
11
|
+
import { GlobalContext as I, useGlobal as K } from "./fe-layouts/context/context.js";
|
|
12
|
+
import { default as k } from "./fe-layouts/context/global-context.provider.js";
|
|
13
|
+
import { default as z } from "./fe-layouts/layout.js";
|
|
14
|
+
import { createDefaultRoutes as F } from "./router/routes.js";
|
|
15
|
+
import { createLazyComponent as N, getPath as W, processRoutes as j } from "./router/utils.js";
|
|
16
|
+
import { createPermissionHelpers as w } from "./router/permission.js";
|
|
17
|
+
export {
|
|
18
|
+
g as APP_KEY,
|
|
19
|
+
b as AuthLayout,
|
|
20
|
+
_ as BasicsLayout,
|
|
21
|
+
B as BlankLayout,
|
|
22
|
+
z as FeLayout,
|
|
23
|
+
I as GlobalContext,
|
|
24
|
+
k as GlobalContextProvider,
|
|
25
|
+
d as NOOP,
|
|
26
|
+
L as STORE_KEY,
|
|
27
|
+
C as THEME_COLORS,
|
|
28
|
+
m as applyTheme,
|
|
29
|
+
p as applyThemeColor,
|
|
30
|
+
f as applyThemeWithTransition,
|
|
31
|
+
F as createDefaultRoutes,
|
|
32
|
+
N as createLazyComponent,
|
|
33
|
+
w as createPermissionHelpers,
|
|
34
|
+
E as createRouter,
|
|
35
|
+
O as generateRouter,
|
|
36
|
+
t as getIcon,
|
|
37
|
+
W as getPath,
|
|
38
|
+
l as getRealTheme,
|
|
39
|
+
s as getTheme,
|
|
40
|
+
u as initTheme,
|
|
41
|
+
x as listenSystemTheme,
|
|
42
|
+
j as processRoutes,
|
|
43
|
+
r as renderIcon,
|
|
44
|
+
n as toggleTheme,
|
|
45
|
+
K as useGlobal,
|
|
46
|
+
T as useLayoutConfigStore,
|
|
47
|
+
y as useThemeStore
|
|
48
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createBrowserRouter as c } from "react-router-dom";
|
|
2
|
+
import { createPermissionHelpers as u } from "./permission.js";
|
|
3
|
+
import { createDefaultRoutes as a } from "./routes.js";
|
|
4
|
+
import "react";
|
|
5
|
+
function h(t) {
|
|
6
|
+
const { modules: n, token: o, BaseLayout: e, routes: s = [] } = t, r = u(o), i = a(n, r, e);
|
|
7
|
+
return {
|
|
8
|
+
/** 最终合并后的路由配置 */
|
|
9
|
+
routes: f(i, s),
|
|
10
|
+
/** 权限帮助函数,包含 ProtectedLoader 等,用于外部调用 processRoutes */
|
|
11
|
+
permissionHelpers: r
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function f(t, n) {
|
|
15
|
+
const o = /* @__PURE__ */ new Map();
|
|
16
|
+
return t.forEach((e) => {
|
|
17
|
+
e.id && o.set(e.id, e);
|
|
18
|
+
}), n.forEach((e) => {
|
|
19
|
+
if (e.id)
|
|
20
|
+
if (e.id === "root" && o.has("root")) {
|
|
21
|
+
const s = o.get("root"), r = e, i = [
|
|
22
|
+
...s.children || [],
|
|
23
|
+
...r.children || []
|
|
24
|
+
];
|
|
25
|
+
o.set("root", {
|
|
26
|
+
...s,
|
|
27
|
+
...r,
|
|
28
|
+
// 属性以 customRoot 为准
|
|
29
|
+
children: i
|
|
30
|
+
});
|
|
31
|
+
} else
|
|
32
|
+
o.set(e.id, e);
|
|
33
|
+
}), Array.from(o.values());
|
|
34
|
+
}
|
|
35
|
+
function g(t) {
|
|
36
|
+
return c(t);
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
a as createDefaultRoutes,
|
|
40
|
+
u as createPermissionHelpers,
|
|
41
|
+
h as createRouter,
|
|
42
|
+
g as generateRouter
|
|
43
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { message as o } from "antd";
|
|
2
|
+
import { redirect as e } from "react-router-dom";
|
|
3
|
+
function h(i) {
|
|
4
|
+
const { getToken: r, setToken: a, removeToken: s } = i;
|
|
5
|
+
function u() {
|
|
6
|
+
return { token: r() };
|
|
7
|
+
}
|
|
8
|
+
function m({ request: t }) {
|
|
9
|
+
if (!r()) {
|
|
10
|
+
const n = new URLSearchParams();
|
|
11
|
+
return n.set("from", new URL(t.url).pathname), e("/auth/login?" + n.toString());
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
async function f() {
|
|
16
|
+
return r() ? e("/") : null;
|
|
17
|
+
}
|
|
18
|
+
async function g({ request: t }) {
|
|
19
|
+
const c = await t.formData(), n = c.get("token");
|
|
20
|
+
if (!n)
|
|
21
|
+
return o.warning("You must provide a token to log in");
|
|
22
|
+
try {
|
|
23
|
+
a(n), o.success("登录成功");
|
|
24
|
+
} catch {
|
|
25
|
+
return o.warning("Invalid login attempt");
|
|
26
|
+
}
|
|
27
|
+
const l = c.get("redirectTo");
|
|
28
|
+
return e(l || "/");
|
|
29
|
+
}
|
|
30
|
+
function k() {
|
|
31
|
+
return s(), o.success("退出成功"), e("/auth/login");
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
RootLoader: u,
|
|
35
|
+
ProtectedLoader: m,
|
|
36
|
+
LoginLoader: f,
|
|
37
|
+
LoginAction: g,
|
|
38
|
+
LogoutAction: k
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
h as createPermissionHelpers
|
|
43
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { createLazyComponent as t } from "./utils.js";
|
|
3
|
+
function d(o, c, e) {
|
|
4
|
+
const { RootLoader: n, LoginLoader: a, LoginAction: i, LogoutAction: l } = c;
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
id: "root",
|
|
8
|
+
path: "/",
|
|
9
|
+
// 使用 element: 可以传递自定义 props
|
|
10
|
+
element: /* @__PURE__ */ r(e, { layoutType: "basic" }),
|
|
11
|
+
loader: n,
|
|
12
|
+
children: []
|
|
13
|
+
// ...dynamicRoutes
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "blank",
|
|
17
|
+
path: "/blank",
|
|
18
|
+
element: /* @__PURE__ */ r(e, { layoutType: "blank" }),
|
|
19
|
+
loader: n,
|
|
20
|
+
children: []
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "auth",
|
|
24
|
+
element: /* @__PURE__ */ r(e, { layoutType: "auth" }),
|
|
25
|
+
loader: n,
|
|
26
|
+
children: [
|
|
27
|
+
{
|
|
28
|
+
path: "/auth/login",
|
|
29
|
+
loader: a,
|
|
30
|
+
action: i,
|
|
31
|
+
// 使用 Component: 简洁,但不能传递自定义 props
|
|
32
|
+
Component: t("/basics/login", o)
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
path: "/auth/register",
|
|
36
|
+
loader: a,
|
|
37
|
+
action: i,
|
|
38
|
+
// 使用 Component: 简洁,但不能传递自定义 props
|
|
39
|
+
Component: t("/basics/register", o)
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
// logout路由只用来退出登录,不展示页面
|
|
45
|
+
path: "/logout",
|
|
46
|
+
action: l,
|
|
47
|
+
Component: t("/basics/error", o)
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
path: "*",
|
|
51
|
+
Component: t("/basics/error", o)
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
d as createDefaultRoutes
|
|
57
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { lazy as g } from "react";
|
|
2
|
+
function C(o) {
|
|
3
|
+
return `/src/pages/${o.replace(/^\/+/, "")}/index.tsx`;
|
|
4
|
+
}
|
|
5
|
+
function R(o, r) {
|
|
6
|
+
const d = r[C(o)];
|
|
7
|
+
if (!d) {
|
|
8
|
+
console.warn(`Module not found for path: ${o}`);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
return g(d);
|
|
12
|
+
}
|
|
13
|
+
function w(o) {
|
|
14
|
+
if (o)
|
|
15
|
+
return o.startsWith("/") ? o : `/${o}`;
|
|
16
|
+
}
|
|
17
|
+
function y(o, r) {
|
|
18
|
+
return (o.sort ?? 0) - (r.sort ?? 0);
|
|
19
|
+
}
|
|
20
|
+
function E(o, r, d) {
|
|
21
|
+
const p = [...o].sort(y).reduce((e, t) => {
|
|
22
|
+
const n = t.menuType || 2;
|
|
23
|
+
return e[n] || (e[n] = []), e[n].push(t), e;
|
|
24
|
+
}, {}), T = (p[3] || []).filter((e) => e.menuCode).map((e) => e.menuCode), l = [
|
|
25
|
+
...p[1] || [],
|
|
26
|
+
...p[2] || []
|
|
27
|
+
].sort(y), u = /* @__PURE__ */ new Map(), f = [];
|
|
28
|
+
l.forEach((e) => {
|
|
29
|
+
const t = e.parentId || "/", n = w(e.path), s = {
|
|
30
|
+
id: e.menuId,
|
|
31
|
+
path: n,
|
|
32
|
+
parentId: t,
|
|
33
|
+
// 将 title、icon 放入 handle 字段
|
|
34
|
+
handle: {
|
|
35
|
+
title: e.title,
|
|
36
|
+
icon: e.icon,
|
|
37
|
+
isShowMenu: e.isShowMenu ?? !0,
|
|
38
|
+
isIndependentMenu: e.isIndependentMenu ?? !1,
|
|
39
|
+
activeRouteMenuId: e.activeRouteMenuId ?? e.menuId
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
if (e.menuType === 2 && e.menuCode) {
|
|
43
|
+
const i = R(e.menuCode, r);
|
|
44
|
+
i && (s.Component = i), e.index && (s.index = !0, delete s.path), e.protected !== !1 && d && (s.loader = d);
|
|
45
|
+
}
|
|
46
|
+
u.set(e.menuId, s);
|
|
47
|
+
}), l.forEach((e) => {
|
|
48
|
+
const t = u.get(e.menuId), n = e.parentId;
|
|
49
|
+
if (n && n !== "/") {
|
|
50
|
+
const s = u.get(n);
|
|
51
|
+
s ? (s.children || (s.children = []), s.children.push(t)) : f.push(t);
|
|
52
|
+
} else
|
|
53
|
+
f.push(t);
|
|
54
|
+
});
|
|
55
|
+
const h = /* @__PURE__ */ new Map(), a = [], I = l.filter((e) => e.isShowMenu !== !1);
|
|
56
|
+
I.forEach((e) => {
|
|
57
|
+
const t = u.get(e.menuId), n = t ? (() => {
|
|
58
|
+
const { children: i, ...m } = t;
|
|
59
|
+
return m;
|
|
60
|
+
})() : void 0, s = {
|
|
61
|
+
key: e.menuId,
|
|
62
|
+
label: e.title || e.menuId,
|
|
63
|
+
icon: e.icon,
|
|
64
|
+
routeNode: n,
|
|
65
|
+
menuType: e.menuType,
|
|
66
|
+
isIndependentMenu: e.isIndependentMenu
|
|
67
|
+
};
|
|
68
|
+
h.set(e.menuId, s);
|
|
69
|
+
}), I.forEach((e) => {
|
|
70
|
+
const t = h.get(e.menuId), n = e.parentId;
|
|
71
|
+
if (n && n !== "/") {
|
|
72
|
+
const s = h.get(n);
|
|
73
|
+
s ? (s.children || (s.children = []), s.children.push(t)) : a.push(t);
|
|
74
|
+
} else
|
|
75
|
+
a.push(t);
|
|
76
|
+
});
|
|
77
|
+
function M(e) {
|
|
78
|
+
const t = [];
|
|
79
|
+
return e.forEach((n) => {
|
|
80
|
+
if (n.children && n.children.length > 0 && (n.children = M(n.children)), n.menuType === 1 && n.children && n.children.length > 0) {
|
|
81
|
+
const s = n.children.filter((i) => i.isIndependentMenu === !0 && i.menuType === 2 && !i.customType);
|
|
82
|
+
if (s.length > 0) {
|
|
83
|
+
const i = s.map((c) => ({
|
|
84
|
+
...c,
|
|
85
|
+
customType: "menu-promoted"
|
|
86
|
+
// 内部标识,表示这个菜单是被提升的
|
|
87
|
+
})), m = n.children.filter((c) => !(c.isIndependentMenu === !0 && c.menuType === 2 && !c.customType));
|
|
88
|
+
t.push(...i, ...m);
|
|
89
|
+
} else
|
|
90
|
+
t.push(n);
|
|
91
|
+
} else
|
|
92
|
+
t.push(n);
|
|
93
|
+
}), t;
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
routes: f,
|
|
97
|
+
menus: M(a),
|
|
98
|
+
permissions: T
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
R as createLazyComponent,
|
|
103
|
+
C as getPath,
|
|
104
|
+
E as processRoutes
|
|
105
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { create as u } from "zustand";
|
|
2
|
+
import { persist as d, combine as g, createJSONStorage as C } from "zustand/middleware";
|
|
3
|
+
import "react/jsx-runtime";
|
|
4
|
+
import "@ant-design/icons";
|
|
5
|
+
import "./theme.store.js";
|
|
6
|
+
import { STORE_KEY as E } from "../../config/constants.js";
|
|
7
|
+
import "react-router-dom";
|
|
8
|
+
import "antd";
|
|
9
|
+
import "react";
|
|
10
|
+
import "@spacego/zustand";
|
|
11
|
+
import "react-icons/fa6";
|
|
12
|
+
import "react-icons/io5";
|
|
13
|
+
import "react-icons/lu";
|
|
14
|
+
import "react-icons/md";
|
|
15
|
+
/* empty css */
|
|
16
|
+
import "../../fe-layouts/basics-layout/index.js";
|
|
17
|
+
import "../../fe-layouts/context/context.js";
|
|
18
|
+
const A = () => ({
|
|
19
|
+
tabsAttribute: {
|
|
20
|
+
tabsList: [{
|
|
21
|
+
key: "Home",
|
|
22
|
+
label: "首页",
|
|
23
|
+
path: "/",
|
|
24
|
+
closable: !1
|
|
25
|
+
// 首页标签不可关闭
|
|
26
|
+
}],
|
|
27
|
+
tabsActiveKey: ""
|
|
28
|
+
},
|
|
29
|
+
loadingConfig: {
|
|
30
|
+
show: !1,
|
|
31
|
+
limit: 0,
|
|
32
|
+
timer: null
|
|
33
|
+
},
|
|
34
|
+
sidebarCollapsed: !1
|
|
35
|
+
}), b = 0.1, B = u(d(
|
|
36
|
+
g(
|
|
37
|
+
A(),
|
|
38
|
+
(i, n) => ({
|
|
39
|
+
SET_STATE: (t) => i(t),
|
|
40
|
+
/**
|
|
41
|
+
* 添加标签页
|
|
42
|
+
*/
|
|
43
|
+
ADD_TAB: (t) => {
|
|
44
|
+
const { tabsAttribute: e } = n(), { tabsList: a } = e, l = a.find((o) => o.key === t.key);
|
|
45
|
+
i(l ? {
|
|
46
|
+
tabsAttribute: {
|
|
47
|
+
...e,
|
|
48
|
+
tabsActiveKey: t.key
|
|
49
|
+
}
|
|
50
|
+
} : {
|
|
51
|
+
tabsAttribute: {
|
|
52
|
+
...e,
|
|
53
|
+
tabsList: [...a, t],
|
|
54
|
+
tabsActiveKey: t.key
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* 移除标签页
|
|
60
|
+
*/
|
|
61
|
+
REMOVE_TAB: (t) => {
|
|
62
|
+
const { tabsAttribute: e } = n(), { tabsList: a, tabsActiveKey: l } = e, o = a.filter((s) => s.key !== t);
|
|
63
|
+
let r = l;
|
|
64
|
+
return l === t && o.length > 0 ? r = o[o.length - 1].key : o.length === 0 && (r = ""), i({
|
|
65
|
+
tabsAttribute: {
|
|
66
|
+
tabsList: o,
|
|
67
|
+
tabsActiveKey: r
|
|
68
|
+
}
|
|
69
|
+
}), a.find((s) => s.key === r) ?? {};
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* 设置当前激活的标签页
|
|
73
|
+
*/
|
|
74
|
+
SET_ACTIVE_TAB_KEY: (t) => {
|
|
75
|
+
const { tabsAttribute: e } = n();
|
|
76
|
+
i({
|
|
77
|
+
tabsAttribute: {
|
|
78
|
+
...e,
|
|
79
|
+
tabsActiveKey: t
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
/**
|
|
84
|
+
* 清空所有标签页
|
|
85
|
+
*/
|
|
86
|
+
CLEAR_TABS: () => {
|
|
87
|
+
i({
|
|
88
|
+
tabsAttribute: {
|
|
89
|
+
tabsList: [],
|
|
90
|
+
tabsActiveKey: ""
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* 设置loading配置
|
|
96
|
+
*/
|
|
97
|
+
SET_LOADING: (t) => {
|
|
98
|
+
if (t && t.showLoading === !1) return;
|
|
99
|
+
const { CLEAR_LOADING_TIMER: e, HIDE_LOADING: a } = n();
|
|
100
|
+
i((l) => {
|
|
101
|
+
const { loadingConfig: o } = l, r = o.show === !1, s = o.limit + 1, m = {
|
|
102
|
+
show: r ? !0 : o.show,
|
|
103
|
+
limit: s,
|
|
104
|
+
timer: o.timer
|
|
105
|
+
};
|
|
106
|
+
if (s === 1) {
|
|
107
|
+
e();
|
|
108
|
+
const c = setTimeout(() => {
|
|
109
|
+
const f = n();
|
|
110
|
+
f.loadingConfig.limit === 1 && f.loadingConfig.show && a(t);
|
|
111
|
+
}, 20 * 1e3);
|
|
112
|
+
return {
|
|
113
|
+
loadingConfig: {
|
|
114
|
+
...m,
|
|
115
|
+
timer: c
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
} else
|
|
119
|
+
return e(), {
|
|
120
|
+
loadingConfig: m
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
/**
|
|
125
|
+
* 取消loading
|
|
126
|
+
*/
|
|
127
|
+
HIDE_LOADING: (t) => {
|
|
128
|
+
if (t && t.showLoading === !1) return;
|
|
129
|
+
const { CLEAR_LOADING_TIMER: e, HIDE_LOADING: a } = n();
|
|
130
|
+
i((l) => {
|
|
131
|
+
const { loadingConfig: o } = l;
|
|
132
|
+
if (o.limit <= 0)
|
|
133
|
+
return l;
|
|
134
|
+
const r = o.limit - 1, s = {
|
|
135
|
+
...o,
|
|
136
|
+
limit: r
|
|
137
|
+
};
|
|
138
|
+
if (r === 0)
|
|
139
|
+
return s.show = !1, e(), {
|
|
140
|
+
loadingConfig: {
|
|
141
|
+
...s,
|
|
142
|
+
timer: null
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
if (r === 1) {
|
|
146
|
+
e();
|
|
147
|
+
const m = setTimeout(() => {
|
|
148
|
+
const c = n();
|
|
149
|
+
c.loadingConfig.limit === 1 && c.loadingConfig.show && a(t);
|
|
150
|
+
}, 20 * 1e3);
|
|
151
|
+
return {
|
|
152
|
+
loadingConfig: {
|
|
153
|
+
...s,
|
|
154
|
+
timer: m
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
loadingConfig: s
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
/**
|
|
164
|
+
* 清除loading定时器
|
|
165
|
+
*/
|
|
166
|
+
CLEAR_LOADING_TIMER() {
|
|
167
|
+
const { loadingConfig: t } = n();
|
|
168
|
+
t.timer && (clearTimeout(t.timer), i({
|
|
169
|
+
loadingConfig: {
|
|
170
|
+
...t,
|
|
171
|
+
timer: null
|
|
172
|
+
}
|
|
173
|
+
}));
|
|
174
|
+
},
|
|
175
|
+
/**
|
|
176
|
+
* 设置侧边栏折叠状态
|
|
177
|
+
*/
|
|
178
|
+
SET_SIDEBAR_COLLAPSED: (t) => {
|
|
179
|
+
i({ sidebarCollapsed: t });
|
|
180
|
+
},
|
|
181
|
+
/**
|
|
182
|
+
* 切换侧边栏折叠状态
|
|
183
|
+
*/
|
|
184
|
+
TOGGLE_SIDEBAR_COLLAPSED: () => {
|
|
185
|
+
const { sidebarCollapsed: t } = n();
|
|
186
|
+
i({ sidebarCollapsed: !t });
|
|
187
|
+
},
|
|
188
|
+
/**
|
|
189
|
+
* 重置
|
|
190
|
+
*/
|
|
191
|
+
RESET: () => {
|
|
192
|
+
const { sidebarCollapsed: t, ...e } = A();
|
|
193
|
+
i(e);
|
|
194
|
+
}
|
|
195
|
+
})
|
|
196
|
+
),
|
|
197
|
+
{
|
|
198
|
+
name: E.LAYOUT_CONFIG,
|
|
199
|
+
// unique name
|
|
200
|
+
storage: C(() => localStorage),
|
|
201
|
+
version: b,
|
|
202
|
+
// a migration will be triggered if the version in the storage mismatches this one
|
|
203
|
+
// 部分持久化
|
|
204
|
+
partialize: (i) => {
|
|
205
|
+
const { ...n } = i;
|
|
206
|
+
return n;
|
|
207
|
+
},
|
|
208
|
+
// migration logic
|
|
209
|
+
migrate: (i, n) => {
|
|
210
|
+
const t = A();
|
|
211
|
+
return n !== b && Object.assign(t, i), t;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
));
|
|
215
|
+
export {
|
|
216
|
+
B as useLayoutConfigStore
|
|
217
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { create as E } from "zustand";
|
|
2
|
+
import { devtools as s, persist as T, combine as l, createJSONStorage as h } from "zustand/middleware";
|
|
3
|
+
import "react/jsx-runtime";
|
|
4
|
+
import "@ant-design/icons";
|
|
5
|
+
import { applyThemeColor as n, applyTheme as m } from "../../utils/theme.js";
|
|
6
|
+
import "./layout-config.store.js";
|
|
7
|
+
import { STORE_KEY as i } from "../../config/constants.js";
|
|
8
|
+
import "react-router-dom";
|
|
9
|
+
import "antd";
|
|
10
|
+
import "react";
|
|
11
|
+
import "@spacego/zustand";
|
|
12
|
+
import "react-icons/fa6";
|
|
13
|
+
import "react-icons/io5";
|
|
14
|
+
import "react-icons/lu";
|
|
15
|
+
import "react-icons/md";
|
|
16
|
+
/* empty css */
|
|
17
|
+
import "../../fe-layouts/basics-layout/index.js";
|
|
18
|
+
import "../../fe-layouts/context/context.js";
|
|
19
|
+
const a = () => ({
|
|
20
|
+
theme: "light",
|
|
21
|
+
themeColor: "#006BE6",
|
|
22
|
+
// 默认主题色
|
|
23
|
+
isCustomThemeColor: !1
|
|
24
|
+
}), p = 0.1, G = E(s(
|
|
25
|
+
T(
|
|
26
|
+
l(
|
|
27
|
+
a(),
|
|
28
|
+
(t, r) => ({
|
|
29
|
+
SET_STATE: (e) => t(e),
|
|
30
|
+
SET_THEME: (e) => {
|
|
31
|
+
t({ theme: e }), m(e);
|
|
32
|
+
},
|
|
33
|
+
TOGGLE_THEME: () => {
|
|
34
|
+
const e = r().theme;
|
|
35
|
+
let o;
|
|
36
|
+
e === "system" ? o = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "dark" : o = e === "light" ? "dark" : "light", t({ theme: o }), m(o);
|
|
37
|
+
},
|
|
38
|
+
SET_THEME_COLOR: (e) => {
|
|
39
|
+
t({ themeColor: e }), n(e);
|
|
40
|
+
},
|
|
41
|
+
SET_IS_CUSTOM_THEME_COLOR: (e) => {
|
|
42
|
+
t({ isCustomThemeColor: e });
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
),
|
|
46
|
+
{
|
|
47
|
+
name: i.THEME,
|
|
48
|
+
storage: h(() => localStorage),
|
|
49
|
+
version: p,
|
|
50
|
+
migrate: (t, r) => {
|
|
51
|
+
const e = a();
|
|
52
|
+
return r !== p && Object.assign(e, t), e;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
{ name: i.THEME, enabled: !0 }
|
|
57
|
+
));
|
|
58
|
+
export {
|
|
59
|
+
G as useThemeStore
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function LoginLayout(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MenuItem } from '../../../../router';
|
|
2
|
+
interface SidebarProps {
|
|
3
|
+
collapsed: boolean;
|
|
4
|
+
menus: MenuItem[];
|
|
5
|
+
activeKey: string;
|
|
6
|
+
openKeys?: string[];
|
|
7
|
+
onMenuClick: (key: string) => void;
|
|
8
|
+
onCollapse: (collapsed: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
export default function Sidebar(props: SidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TabItem } from '../../../../store/modules/layout-config.store';
|
|
2
|
+
interface TabsComponentProps {
|
|
3
|
+
tabs: TabItem[];
|
|
4
|
+
activeKey: string;
|
|
5
|
+
onChange: (key: string) => void;
|
|
6
|
+
onClose: (key: string) => void;
|
|
7
|
+
}
|
|
8
|
+
export default function TabsComponent(props: TabsComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|