nsgm-cli 2.1.19 → 2.1.21
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/client/components/Button.tsx +3 -3
- package/client/components/ClientProviders.tsx +12 -12
- package/client/components/LanguageSwitcher.tsx +26 -26
- package/client/components/SSRSafeAntdProvider.tsx +7 -7
- package/client/components/SuppressHydrationWarnings.tsx +30 -30
- package/client/components/__tests__/Button.test.tsx +12 -12
- package/client/layout/index.tsx +124 -124
- package/client/redux/reducers.ts +2 -2
- package/client/redux/store.ts +24 -24
- package/client/redux/template/manage/actions.ts +40 -40
- package/client/redux/template/manage/reducers.ts +32 -32
- package/client/redux/template/manage/types.ts +19 -19
- package/client/service/template/manage.ts +29 -29
- package/client/styled/common.ts +6 -6
- package/client/styled/layout/index.ts +17 -17
- package/client/styled/template/manage.ts +19 -19
- package/client/utils/common.ts +54 -54
- package/client/utils/cookie.ts +30 -30
- package/client/utils/fetch.ts +111 -111
- package/client/utils/i18n.ts +41 -41
- package/client/utils/menu.tsx +12 -12
- package/client/utils/navigation.ts +22 -22
- package/client/utils/sso.ts +124 -124
- package/client/utils/suppressWarnings.ts +17 -17
- package/generation/prettierrc +6 -0
- package/lib/args.js +19 -19
- package/lib/cli/app.d.ts +1 -1
- package/lib/cli/app.js +2 -2
- package/lib/cli/commands/build.d.ts +1 -1
- package/lib/cli/commands/build.js +9 -9
- package/lib/cli/commands/create.d.ts +1 -1
- package/lib/cli/commands/create.js +36 -36
- package/lib/cli/commands/delete.d.ts +1 -1
- package/lib/cli/commands/delete.js +55 -55
- package/lib/cli/commands/export.d.ts +1 -1
- package/lib/cli/commands/export.js +12 -12
- package/lib/cli/commands/help.d.ts +1 -1
- package/lib/cli/commands/help.js +29 -29
- package/lib/cli/commands/init.d.ts +1 -1
- package/lib/cli/commands/init.js +31 -31
- package/lib/cli/commands/server.d.ts +1 -1
- package/lib/cli/commands/server.js +12 -12
- package/lib/cli/commands/upgrade.d.ts +1 -1
- package/lib/cli/commands/upgrade.js +13 -13
- package/lib/cli/commands/version.d.ts +1 -1
- package/lib/cli/commands/version.js +7 -7
- package/lib/cli/index.d.ts +13 -13
- package/lib/cli/parser.d.ts +1 -1
- package/lib/cli/parser.js +12 -12
- package/lib/cli/registry.d.ts +1 -1
- package/lib/cli/types.d.ts +2 -2
- package/lib/cli/utils/console.d.ts +2 -2
- package/lib/cli/utils/console.js +22 -22
- package/lib/cli/utils/index.d.ts +2 -2
- package/lib/cli/utils/prompt.d.ts +1 -1
- package/lib/cli/utils/prompt.js +98 -98
- package/lib/constants.js +28 -28
- package/lib/generate.d.ts +2 -2
- package/lib/generate.js +19 -19
- package/lib/generate_create.d.ts +1 -1
- package/lib/generate_create.js +38 -38
- package/lib/generate_delete.js +63 -63
- package/lib/generate_init.js +94 -94
- package/lib/generators/base-generator.d.ts +1 -1
- package/lib/generators/base-generator.js +23 -23
- package/lib/generators/file-generator.js +15 -15
- package/lib/generators/generator-factory.d.ts +5 -5
- package/lib/generators/i18n-generator.d.ts +1 -1
- package/lib/generators/i18n-generator.js +127 -127
- package/lib/generators/page-generator.d.ts +1 -1
- package/lib/generators/page-generator.js +25 -25
- package/lib/generators/resolver-generator.d.ts +1 -1
- package/lib/generators/resolver-generator.js +27 -27
- package/lib/generators/schema-generator.d.ts +1 -1
- package/lib/generators/schema-generator.js +4 -4
- package/lib/generators/service-generator.d.ts +1 -1
- package/lib/generators/service-generator.js +29 -29
- package/lib/generators/sql-generator.d.ts +1 -1
- package/lib/generators/sql-generator.js +10 -10
- package/lib/index.js +23 -23
- package/lib/server/csrf.d.ts +3 -3
- package/lib/server/csrf.js +20 -20
- package/lib/server/db.d.ts +1 -1
- package/lib/server/db.js +21 -21
- package/lib/server/graphql.js +26 -26
- package/lib/server/plugins/date.d.ts +1 -1
- package/lib/server/plugins/date.js +6 -6
- package/lib/server/utils/graphql-cache.js +5 -5
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/lib/utils/project-config.d.ts +1 -1
- package/lib/utils/project-config.js +20 -20
- package/lib/utils.js +3 -3
- package/package.json +1 -1
- package/pages/_app.tsx +62 -62
- package/pages/_document.tsx +15 -15
- package/pages/_error.tsx +26 -26
- package/pages/index.tsx +48 -48
- package/pages/login.tsx +64 -64
- package/pages/template/manage.tsx +175 -175
package/client/layout/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useEffect, useState } from
|
|
2
|
-
import { Layout, Menu, Dropdown, Space } from
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { Layout, Menu, Dropdown, Space } from "antd";
|
|
3
3
|
import {
|
|
4
4
|
Container,
|
|
5
5
|
FlexLayout,
|
|
@@ -9,140 +9,140 @@ import {
|
|
|
9
9
|
StyledHeader,
|
|
10
10
|
StyledBreadcrumb,
|
|
11
11
|
StyledContent,
|
|
12
|
-
} from
|
|
13
|
-
import { useRouter } from
|
|
14
|
-
import _ from
|
|
15
|
-
import menuConfig, { getMenuConfig } from
|
|
16
|
-
import getConfig from
|
|
17
|
-
import { LogoutOutlined } from
|
|
18
|
-
import LanguageSwitcher from
|
|
19
|
-
import { useTranslation } from
|
|
20
|
-
import { navigateToLogin } from
|
|
12
|
+
} from "@/styled/layout";
|
|
13
|
+
import { useRouter } from "next/router";
|
|
14
|
+
import _ from "lodash";
|
|
15
|
+
import menuConfig, { getMenuConfig } from "@/utils/menu";
|
|
16
|
+
import getConfig from "next/config";
|
|
17
|
+
import { LogoutOutlined } from "@ant-design/icons";
|
|
18
|
+
import LanguageSwitcher from "@/components/LanguageSwitcher";
|
|
19
|
+
import { useTranslation } from "next-i18next";
|
|
20
|
+
import { navigateToLogin } from "@/utils/navigation";
|
|
21
21
|
|
|
22
22
|
interface SubMenuItem {
|
|
23
|
-
key: string
|
|
24
|
-
text: string
|
|
25
|
-
url: string
|
|
23
|
+
key: string;
|
|
24
|
+
text: string;
|
|
25
|
+
url: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
interface MenuItem {
|
|
29
|
-
key: string
|
|
30
|
-
text: string
|
|
31
|
-
url: string
|
|
32
|
-
icon?: React.ReactNode
|
|
33
|
-
subMenus?: SubMenuItem[]
|
|
29
|
+
key: string;
|
|
30
|
+
text: string;
|
|
31
|
+
url: string;
|
|
32
|
+
icon?: React.ReactNode;
|
|
33
|
+
subMenus?: SubMenuItem[];
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const nextConfig = getConfig()
|
|
37
|
-
const { publicRuntimeConfig } = nextConfig
|
|
38
|
-
const { prefix } = publicRuntimeConfig
|
|
36
|
+
const nextConfig = getConfig();
|
|
37
|
+
const { publicRuntimeConfig } = nextConfig;
|
|
38
|
+
const { prefix } = publicRuntimeConfig;
|
|
39
39
|
|
|
40
40
|
const getLocationKey = () => {
|
|
41
41
|
const result = {
|
|
42
|
-
topMenu:
|
|
43
|
-
slideMenu:
|
|
44
|
-
}
|
|
42
|
+
topMenu: "1",
|
|
43
|
+
slideMenu: "0",
|
|
44
|
+
};
|
|
45
45
|
|
|
46
|
-
if (typeof window !==
|
|
47
|
-
const locationHref = window.location.href
|
|
46
|
+
if (typeof window !== "undefined") {
|
|
47
|
+
const locationHref = window.location.href;
|
|
48
48
|
|
|
49
|
-
let locationHrefArr = locationHref.split(
|
|
49
|
+
let locationHrefArr = locationHref.split("?");
|
|
50
50
|
if (locationHrefArr.length > 0) {
|
|
51
|
-
locationHrefArr = locationHrefArr[0].split(
|
|
51
|
+
locationHrefArr = locationHrefArr[0].split("//");
|
|
52
52
|
|
|
53
53
|
if (locationHrefArr.length > 1) {
|
|
54
|
-
let locationStr = locationHrefArr[1]
|
|
55
|
-
const locationIndex = locationStr.indexOf(
|
|
56
|
-
locationStr = locationStr.substring(locationIndex)
|
|
54
|
+
let locationStr = locationHrefArr[1];
|
|
55
|
+
const locationIndex = locationStr.indexOf("/");
|
|
56
|
+
locationStr = locationStr.substring(locationIndex);
|
|
57
57
|
|
|
58
58
|
if (prefix && locationStr.indexOf(prefix) !== -1) {
|
|
59
|
-
locationStr = locationStr.split(prefix)[1]
|
|
59
|
+
locationStr = locationStr.split(prefix)[1];
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
_.each(menuConfig, (item) => {
|
|
63
|
-
const { key, url, subMenus } = item
|
|
63
|
+
const { key, url, subMenus } = item;
|
|
64
64
|
|
|
65
65
|
if (subMenus) {
|
|
66
66
|
_.each(subMenus, (subItem: MenuItem) => {
|
|
67
|
-
const { key: subKey, url: subUrl } = subItem
|
|
67
|
+
const { key: subKey, url: subUrl } = subItem;
|
|
68
68
|
|
|
69
|
-
if (locationStr === subUrl.split(
|
|
70
|
-
const subKeyArr = subKey.split(
|
|
71
|
-
const subKeyArrLen = subKeyArr.length
|
|
69
|
+
if (locationStr === subUrl.split("?")[0]) {
|
|
70
|
+
const subKeyArr = subKey.split("_");
|
|
71
|
+
const subKeyArrLen = subKeyArr.length;
|
|
72
72
|
|
|
73
|
-
if (subKeyArrLen > 0) result.topMenu = subKeyArr[0]
|
|
73
|
+
if (subKeyArrLen > 0) result.topMenu = subKeyArr[0];
|
|
74
74
|
|
|
75
|
-
if (subKeyArrLen > 1) result.slideMenu = subKeyArr[1]
|
|
75
|
+
if (subKeyArrLen > 1) result.slideMenu = subKeyArr[1];
|
|
76
76
|
|
|
77
|
-
return false
|
|
77
|
+
return false;
|
|
78
78
|
}
|
|
79
|
-
return true
|
|
80
|
-
})
|
|
79
|
+
return true;
|
|
80
|
+
});
|
|
81
81
|
} else {
|
|
82
|
-
if (url && locationStr === url.split(
|
|
83
|
-
result.topMenu = key
|
|
84
|
-
return false
|
|
82
|
+
if (url && locationStr === url.split("?")[0]) {
|
|
83
|
+
result.topMenu = key;
|
|
84
|
+
return false;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
return true
|
|
88
|
-
})
|
|
87
|
+
return true;
|
|
88
|
+
});
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
return result
|
|
93
|
-
}
|
|
92
|
+
return result;
|
|
93
|
+
};
|
|
94
94
|
|
|
95
95
|
const routerPush = (router: any, url: string) => {
|
|
96
|
-
if (router && url && typeof window !==
|
|
96
|
+
if (router && url && typeof window !== "undefined") {
|
|
97
97
|
if (prefix && url.indexOf(prefix) === -1) {
|
|
98
|
-
url = prefix + url
|
|
98
|
+
url = prefix + url;
|
|
99
99
|
}
|
|
100
|
-
router.push(url)
|
|
100
|
+
router.push(url);
|
|
101
101
|
}
|
|
102
|
-
}
|
|
102
|
+
};
|
|
103
103
|
|
|
104
104
|
const LayoutComponent = ({ user, children }) => {
|
|
105
|
-
const { t } = useTranslation([
|
|
106
|
-
const router = useRouter()
|
|
107
|
-
const [topMenuKey, setTopMenuKey] = useState(
|
|
108
|
-
const [sliderMenuKey, setSliderMenuKey] = useState(
|
|
109
|
-
const [collapsed, setCollapsed] = useState(false)
|
|
110
|
-
const [mounted, setMounted] = useState(false)
|
|
105
|
+
const { t } = useTranslation(["layout", "common"]);
|
|
106
|
+
const router = useRouter();
|
|
107
|
+
const [topMenuKey, setTopMenuKey] = useState("1");
|
|
108
|
+
const [sliderMenuKey, setSliderMenuKey] = useState("1");
|
|
109
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
110
|
+
const [mounted, setMounted] = useState(false);
|
|
111
111
|
|
|
112
112
|
useEffect(() => {
|
|
113
|
-
setMounted(true)
|
|
114
|
-
}, [])
|
|
113
|
+
setMounted(true);
|
|
114
|
+
}, []);
|
|
115
115
|
|
|
116
116
|
// 使用翻译后的菜单配置
|
|
117
|
-
const translatedMenuConfig = getMenuConfig(t)
|
|
117
|
+
const translatedMenuConfig = getMenuConfig(t);
|
|
118
118
|
|
|
119
119
|
// 自定义退出登录函数,保持语言设置
|
|
120
120
|
const handleLogout = () => {
|
|
121
|
-
if (!mounted || typeof window ===
|
|
121
|
+
if (!mounted || typeof window === "undefined") return;
|
|
122
122
|
|
|
123
123
|
// 删除登录相关的 cookie
|
|
124
124
|
const deleteCookie = (name: string) => {
|
|
125
|
-
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path
|
|
126
|
-
}
|
|
125
|
+
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
|
|
126
|
+
};
|
|
127
127
|
|
|
128
|
-
deleteCookie(
|
|
129
|
-
deleteCookie(
|
|
128
|
+
deleteCookie("_cas_nsgm");
|
|
129
|
+
deleteCookie("_cas_nsgm_user");
|
|
130
130
|
|
|
131
131
|
// 跳转到登录页面,保持当前语言
|
|
132
|
-
navigateToLogin(router)
|
|
133
|
-
}
|
|
132
|
+
navigateToLogin(router);
|
|
133
|
+
};
|
|
134
134
|
|
|
135
135
|
useEffect(() => {
|
|
136
|
-
const { topMenu, slideMenu } = getLocationKey()
|
|
137
|
-
setTopMenuKey(topMenu)
|
|
138
|
-
setSliderMenuKey(slideMenu)
|
|
139
|
-
}, [])
|
|
136
|
+
const { topMenu, slideMenu } = getLocationKey();
|
|
137
|
+
setTopMenuKey(topMenu);
|
|
138
|
+
setSliderMenuKey(slideMenu);
|
|
139
|
+
}, []);
|
|
140
140
|
|
|
141
|
-
const menuItems: any = []
|
|
142
|
-
const menuItemsVertical: any = []
|
|
141
|
+
const menuItems: any = [];
|
|
142
|
+
const menuItemsVertical: any = [];
|
|
143
143
|
|
|
144
144
|
_.each(translatedMenuConfig, (item) => {
|
|
145
|
-
const { key, text, url, icon, subMenus } = item
|
|
145
|
+
const { key, text, url, icon, subMenus } = item;
|
|
146
146
|
|
|
147
147
|
if (key && text && url) {
|
|
148
148
|
const menuObj = {
|
|
@@ -150,26 +150,26 @@ const LayoutComponent = ({ user, children }) => {
|
|
|
150
150
|
key,
|
|
151
151
|
onClick: () => {
|
|
152
152
|
if (mounted) {
|
|
153
|
-
routerPush(router, url)
|
|
154
|
-
setTopMenuKey(key)
|
|
153
|
+
routerPush(router, url);
|
|
154
|
+
setTopMenuKey(key);
|
|
155
155
|
|
|
156
156
|
if (subMenus) {
|
|
157
|
-
setSliderMenuKey(
|
|
157
|
+
setSliderMenuKey("1");
|
|
158
158
|
} else {
|
|
159
|
-
setSliderMenuKey(
|
|
159
|
+
setSliderMenuKey("0");
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
},
|
|
163
|
-
}
|
|
163
|
+
};
|
|
164
164
|
|
|
165
|
-
menuItems.push(menuObj)
|
|
165
|
+
menuItems.push(menuObj);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
if (subMenus) {
|
|
169
|
-
const subMenusChildren: any = []
|
|
169
|
+
const subMenusChildren: any = [];
|
|
170
170
|
|
|
171
171
|
_.each(subMenus, (subItem: MenuItem) => {
|
|
172
|
-
const { key: subKey, text: subText, url: subUrl } = subItem
|
|
172
|
+
const { key: subKey, text: subText, url: subUrl } = subItem;
|
|
173
173
|
|
|
174
174
|
if (subKey && subText && subUrl) {
|
|
175
175
|
const subMenusChildrenObj = {
|
|
@@ -177,20 +177,20 @@ const LayoutComponent = ({ user, children }) => {
|
|
|
177
177
|
label: subText,
|
|
178
178
|
onClick: () => {
|
|
179
179
|
if (mounted) {
|
|
180
|
-
routerPush(router, subUrl)
|
|
180
|
+
routerPush(router, subUrl);
|
|
181
181
|
|
|
182
|
-
const subKeyArr = subKey.split(
|
|
183
|
-
const subKeyArrLen = subKeyArr.length
|
|
182
|
+
const subKeyArr = subKey.split("_");
|
|
183
|
+
const subKeyArrLen = subKeyArr.length;
|
|
184
184
|
|
|
185
|
-
if (subKeyArrLen >= 1) setTopMenuKey(subKeyArr[0])
|
|
186
|
-
if (subKeyArrLen >= 2) setSliderMenuKey(subKeyArr[1])
|
|
185
|
+
if (subKeyArrLen >= 1) setTopMenuKey(subKeyArr[0]);
|
|
186
|
+
if (subKeyArrLen >= 2) setSliderMenuKey(subKeyArr[1]);
|
|
187
187
|
}
|
|
188
188
|
},
|
|
189
|
-
}
|
|
189
|
+
};
|
|
190
190
|
|
|
191
|
-
subMenusChildren.push(subMenusChildrenObj)
|
|
191
|
+
subMenusChildren.push(subMenusChildrenObj);
|
|
192
192
|
}
|
|
193
|
-
})
|
|
193
|
+
});
|
|
194
194
|
|
|
195
195
|
if (key && text && icon) {
|
|
196
196
|
const subMenuObjVertical = {
|
|
@@ -198,13 +198,13 @@ const LayoutComponent = ({ user, children }) => {
|
|
|
198
198
|
icon,
|
|
199
199
|
label: text,
|
|
200
200
|
onTitleClick: () => {
|
|
201
|
-
setTopMenuKey(key)
|
|
202
|
-
setSliderMenuKey(
|
|
201
|
+
setTopMenuKey(key);
|
|
202
|
+
setSliderMenuKey("1");
|
|
203
203
|
},
|
|
204
204
|
children: subMenusChildren,
|
|
205
|
-
}
|
|
205
|
+
};
|
|
206
206
|
|
|
207
|
-
menuItemsVertical.push(subMenuObjVertical)
|
|
207
|
+
menuItemsVertical.push(subMenuObjVertical);
|
|
208
208
|
}
|
|
209
209
|
} else {
|
|
210
210
|
if (key && text && url) {
|
|
@@ -214,17 +214,17 @@ const LayoutComponent = ({ user, children }) => {
|
|
|
214
214
|
key: `slider_${key}_0`,
|
|
215
215
|
onClick: () => {
|
|
216
216
|
if (mounted) {
|
|
217
|
-
routerPush(router, url)
|
|
218
|
-
setTopMenuKey(key)
|
|
219
|
-
setSliderMenuKey(
|
|
217
|
+
routerPush(router, url);
|
|
218
|
+
setTopMenuKey(key);
|
|
219
|
+
setSliderMenuKey("0");
|
|
220
220
|
}
|
|
221
221
|
},
|
|
222
|
-
}
|
|
222
|
+
};
|
|
223
223
|
|
|
224
|
-
menuItemsVertical.push(menuObjVertical)
|
|
224
|
+
menuItemsVertical.push(menuObjVertical);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
})
|
|
227
|
+
});
|
|
228
228
|
|
|
229
229
|
return (
|
|
230
230
|
<Layout className="main-layout">
|
|
@@ -236,7 +236,7 @@ const LayoutComponent = ({ user, children }) => {
|
|
|
236
236
|
<Menu
|
|
237
237
|
theme="dark"
|
|
238
238
|
mode="horizontal"
|
|
239
|
-
defaultSelectedKeys={[
|
|
239
|
+
defaultSelectedKeys={["1"]}
|
|
240
240
|
selectedKeys={[topMenuKey]}
|
|
241
241
|
items={menuItems}
|
|
242
242
|
className="main-menu"
|
|
@@ -264,19 +264,19 @@ const LayoutComponent = ({ user, children }) => {
|
|
|
264
264
|
// label: t('layout:layout.userActions.settings'),
|
|
265
265
|
// },
|
|
266
266
|
{
|
|
267
|
-
type:
|
|
267
|
+
type: "divider",
|
|
268
268
|
},
|
|
269
269
|
{
|
|
270
|
-
key:
|
|
270
|
+
key: "3",
|
|
271
271
|
icon: <LogoutOutlined />,
|
|
272
|
-
label: t(
|
|
272
|
+
label: t("layout:layout.userActions.logout"),
|
|
273
273
|
onClick: () => handleLogout(),
|
|
274
274
|
},
|
|
275
275
|
],
|
|
276
276
|
}}
|
|
277
277
|
>
|
|
278
278
|
<Space className="user-dropdown">
|
|
279
|
-
<span className="username">{user?.displayName || t(
|
|
279
|
+
<span className="username">{user?.displayName || t("layout:layout.userActions.user")}</span>
|
|
280
280
|
</Space>
|
|
281
281
|
</Dropdown>
|
|
282
282
|
</Space>
|
|
@@ -293,8 +293,8 @@ const LayoutComponent = ({ user, children }) => {
|
|
|
293
293
|
<div>
|
|
294
294
|
<SideMenu
|
|
295
295
|
mode="inline"
|
|
296
|
-
defaultSelectedKeys={[
|
|
297
|
-
defaultOpenKeys={[
|
|
296
|
+
defaultSelectedKeys={["slider_1_0"]}
|
|
297
|
+
defaultOpenKeys={["slider_1"]}
|
|
298
298
|
selectedKeys={[`slider_${topMenuKey}_${sliderMenuKey}`]}
|
|
299
299
|
openKeys={[`slider_${topMenuKey}`]}
|
|
300
300
|
items={menuItemsVertical}
|
|
@@ -306,26 +306,26 @@ const LayoutComponent = ({ user, children }) => {
|
|
|
306
306
|
<StyledBreadcrumb
|
|
307
307
|
items={_.compact(
|
|
308
308
|
_.flatMap(translatedMenuConfig, (item, index) => {
|
|
309
|
-
const { key, text, subMenus } = item
|
|
309
|
+
const { key, text, subMenus } = item;
|
|
310
310
|
|
|
311
311
|
if (subMenus) {
|
|
312
|
-
const subItems: any = []
|
|
312
|
+
const subItems: any = [];
|
|
313
313
|
_.each(subMenus, (subItem: MenuItem, subIndex: number) => {
|
|
314
|
-
const { key: subKey, text: subText } = subItem
|
|
314
|
+
const { key: subKey, text: subText } = subItem;
|
|
315
315
|
if (subKey === `${topMenuKey}_${sliderMenuKey}`) {
|
|
316
|
-
subItems.push({ title: text, key: `breadcrumb${subIndex}` })
|
|
317
|
-
subItems.push({ title: subText, key: `breadcrumb${subIndex}_sub` })
|
|
318
|
-
return false
|
|
316
|
+
subItems.push({ title: text, key: `breadcrumb${subIndex}` });
|
|
317
|
+
subItems.push({ title: subText, key: `breadcrumb${subIndex}_sub` });
|
|
318
|
+
return false;
|
|
319
319
|
}
|
|
320
|
-
return true
|
|
321
|
-
})
|
|
322
|
-
return subItems
|
|
320
|
+
return true;
|
|
321
|
+
});
|
|
322
|
+
return subItems;
|
|
323
323
|
} else {
|
|
324
324
|
if (key && key === topMenuKey) {
|
|
325
|
-
return { title: text, key: `breadcrumb${index}` }
|
|
325
|
+
return { title: text, key: `breadcrumb${index}` };
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
return null
|
|
328
|
+
return null;
|
|
329
329
|
})
|
|
330
330
|
)}
|
|
331
331
|
/>
|
|
@@ -334,7 +334,7 @@ const LayoutComponent = ({ user, children }) => {
|
|
|
334
334
|
</FlexLayout>
|
|
335
335
|
</Container>
|
|
336
336
|
</Layout>
|
|
337
|
-
)
|
|
338
|
-
}
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
339
|
|
|
340
|
-
export default LayoutComponent
|
|
340
|
+
export default LayoutComponent;
|
package/client/redux/reducers.ts
CHANGED
package/client/redux/store.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { useMemo } from
|
|
2
|
-
import { combineReducers } from
|
|
3
|
-
import { configureStore, type EnhancedStore } from
|
|
4
|
-
import reducers from
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { combineReducers } from "redux";
|
|
3
|
+
import { configureStore, type EnhancedStore } from "@reduxjs/toolkit";
|
|
4
|
+
import reducers from "./reducers";
|
|
5
5
|
|
|
6
|
-
let store: EnhancedStore | undefined
|
|
6
|
+
let store: EnhancedStore | undefined;
|
|
7
7
|
|
|
8
|
-
const reducersKeysLen = Object.keys(reducers).length
|
|
8
|
+
const reducersKeysLen = Object.keys(reducers).length;
|
|
9
9
|
|
|
10
|
-
let combineReducer: any = () => ({})
|
|
10
|
+
let combineReducer: any = () => ({});
|
|
11
11
|
|
|
12
12
|
if (reducersKeysLen > 0) {
|
|
13
|
-
combineReducer = combineReducers({ ...reducers })
|
|
13
|
+
combineReducer = combineReducers({ ...reducers });
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export type RootState = ReturnType<typeof combineReducer
|
|
16
|
+
export type RootState = ReturnType<typeof combineReducer>;
|
|
17
17
|
|
|
18
18
|
// 创建一个临时 store 实例来获取正确的 dispatch 类型
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -22,46 +22,46 @@ const tempStore = configureStore({
|
|
|
22
22
|
middleware: (getDefaultMiddleware) =>
|
|
23
23
|
getDefaultMiddleware({
|
|
24
24
|
serializableCheck: {
|
|
25
|
-
ignoredActions: [
|
|
25
|
+
ignoredActions: ["persist/PERSIST", "persist/REHYDRATE"],
|
|
26
26
|
},
|
|
27
27
|
}),
|
|
28
|
-
})
|
|
28
|
+
});
|
|
29
29
|
|
|
30
|
-
export type AppDispatch = typeof tempStore.dispatch
|
|
30
|
+
export type AppDispatch = typeof tempStore.dispatch;
|
|
31
31
|
|
|
32
32
|
function initStore(initialState?: any): EnhancedStore {
|
|
33
33
|
return configureStore({
|
|
34
34
|
reducer: combineReducer,
|
|
35
35
|
preloadedState: initialState,
|
|
36
|
-
devTools: process.env.NODE_ENV !==
|
|
36
|
+
devTools: process.env.NODE_ENV !== "production",
|
|
37
37
|
middleware: (getDefaultMiddleware) =>
|
|
38
38
|
getDefaultMiddleware({
|
|
39
39
|
serializableCheck: {
|
|
40
|
-
ignoredActions: [
|
|
40
|
+
ignoredActions: ["persist/PERSIST", "persist/REHYDRATE"],
|
|
41
41
|
},
|
|
42
42
|
}),
|
|
43
|
-
})
|
|
43
|
+
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export const initializeStore = (preloadedState?: any): EnhancedStore => {
|
|
47
|
-
let _store = store ?? initStore(preloadedState)
|
|
47
|
+
let _store = store ?? initStore(preloadedState);
|
|
48
48
|
|
|
49
49
|
if (preloadedState && store) {
|
|
50
50
|
_store = initStore({
|
|
51
51
|
...store.getState(),
|
|
52
52
|
...preloadedState,
|
|
53
|
-
})
|
|
54
|
-
store = undefined
|
|
53
|
+
});
|
|
54
|
+
store = undefined;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
if (typeof window ===
|
|
57
|
+
if (typeof window === "undefined") return _store;
|
|
58
58
|
|
|
59
|
-
if (!store) store = _store
|
|
59
|
+
if (!store) store = _store;
|
|
60
60
|
|
|
61
|
-
return _store
|
|
62
|
-
}
|
|
61
|
+
return _store;
|
|
62
|
+
};
|
|
63
63
|
|
|
64
64
|
export function useStore(initialState?: any): EnhancedStore {
|
|
65
|
-
const store = useMemo(() => initializeStore(initialState), [initialState])
|
|
66
|
-
return store
|
|
65
|
+
const store = useMemo(() => initializeStore(initialState), [initialState]);
|
|
66
|
+
return store;
|
|
67
67
|
}
|