@jiangood/open-admin 2.5.9 → 3.0.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/package.json +20 -8
- package/src/framework/GlobalData.ts +85 -0
- package/src/framework/biz/OrgTree.tsx +2 -7
- package/src/framework/biz/Perm.tsx +11 -0
- package/src/framework/biz/PermActions.tsx +18 -15
- package/src/framework/biz/index.tsx +34 -19
- package/src/framework/components/ContextMenu/index.tsx +105 -78
- package/src/framework/components/DownloadModal/index.tsx +15 -17
- package/src/framework/components/ErrorBoundary/index.tsx +2 -2
- package/src/framework/components/FormModal/index.tsx +76 -0
- package/src/framework/components/Gap/index.tsx +1 -1
- package/src/framework/components/NamedIcon/index.tsx +55 -9
- package/src/framework/components/Page/index.less +0 -1
- package/src/framework/components/Page/index.tsx +34 -27
- package/src/framework/components/PageLoading/index.less +15 -0
- package/src/framework/components/PageLoading/index.tsx +32 -16
- package/src/framework/components/ProTable/index.tsx +86 -15
- package/src/framework/components/index.ts +1 -0
- package/src/framework/config/index.ts +1 -0
- package/src/framework/config/themeConfig.ts +39 -0
- package/src/framework/fields/FieldBoolean/index.tsx +11 -2
- package/src/framework/fields/FieldDate/index.tsx +22 -7
- package/src/framework/fields/FieldDateRange/index.tsx +24 -6
- package/src/framework/fields/FieldDictSelect/index.tsx +1 -0
- package/src/framework/fields/FieldEditor/index.tsx +7 -1
- package/src/framework/fields/FieldNumberRange/index.tsx +14 -5
- package/src/framework/fields/FieldPercent/index.tsx +16 -5
- package/src/framework/fields/FieldRemoteSelect/index.tsx +4 -2
- package/src/framework/fields/FieldRemoteTreeSelect/index.tsx +2 -1
- package/src/framework/fields/FieldSysOrgTree/index.tsx +6 -1
- package/src/framework/fields/FieldSysOrgTreeSelect/index.tsx +6 -1
- package/src/framework/fields/FieldTable/index.tsx +35 -6
- package/src/framework/fields/FieldTableSelect/index.tsx +18 -2
- package/src/framework/fields/FieldUploadFile/index.tsx +69 -28
- package/src/framework/fields/index.ts +0 -1
- package/src/framework/index.ts +2 -0
- package/src/framework/router/Link.tsx +26 -0
- package/src/framework/router/PageFrame.tsx +31 -0
- package/src/framework/router/history.ts +50 -0
- package/src/framework/router/index.ts +4 -0
- package/src/framework/router/matcher.ts +58 -0
- package/src/framework/utils/{ArrayUtils.js → ArrayUtils.ts} +5 -5
- package/src/framework/utils/{DateUtils.js → DateUtils.ts} +19 -19
- package/src/framework/utils/{DeviceUtils.js → DeviceUtils.ts} +8 -1
- package/src/framework/utils/{EventBus.js → EventBus.ts} +13 -6
- package/src/framework/utils/MessageApi.ts +5 -0
- package/src/framework/utils/ModalApi.ts +5 -0
- package/src/framework/utils/ObjectUtils.ts +15 -0
- package/src/framework/utils/{StorageUtils.js → StorageUtils.ts} +7 -7
- package/src/framework/utils/{StringUtils.js → StringUtils.ts} +15 -15
- package/src/framework/utils/{TreeUtils.js → TreeUtils.ts} +19 -12
- package/src/framework/utils/{UrlUtils.js → UrlUtils.ts} +10 -10
- package/src/framework/utils/index.ts +2 -1
- package/src/framework/utils/system/{DictUtils.js → DictUtils.ts} +16 -4
- package/src/framework/utils/system/{HttpUtils.js → HttpUtils.ts} +25 -21
- package/src/framework/utils/system/PageUtils.ts +49 -0
- package/src/framework/utils/system/{PermUtils.js → PermUtils.ts} +5 -6
- package/src/framework/utils/system/index.ts +0 -2
- package/src/framework/views/ViewBoolean/index.tsx +6 -3
- package/src/framework/views/ViewFileButton/index.tsx +13 -8
- package/src/framework/views/ViewImage/index.tsx +19 -14
- package/src/framework/views/ViewRange/index.tsx +10 -7
- package/src/framework/views/ViewText/index.tsx +9 -11
- package/src/layouts/admin/AdminTabs.jsx +79 -0
- package/src/layouts/admin/AdminTabs.less +63 -0
- package/src/layouts/admin/HeaderRight.jsx +27 -13
- package/src/layouts/admin/TabLayout.jsx +124 -0
- package/src/layouts/admin/index.jsx +5 -6
- package/src/layouts/admin/index.less +1 -82
- package/src/layouts/index.tsx +148 -0
- package/src/main.jsx +8 -0
- package/src/pages/account/changePassword.jsx +14 -10
- package/src/pages/article/$code.jsx +2 -2
- package/src/pages/index.jsx +6 -4
- package/src/pages/{login.jsx → public/login.jsx} +7 -10
- package/src/pages/public/test.jsx +30 -0
- package/src/pages/{forceUpdatePwd.jsx → standalone/forceUpdatePwd.jsx} +3 -24
- package/src/pages/system/article/index.jsx +51 -56
- package/src/pages/system/dict/index.jsx +60 -91
- package/src/pages/system/file/index.jsx +23 -17
- package/src/pages/system/job/index.jsx +63 -72
- package/src/pages/system/log/index.jsx +11 -8
- package/src/pages/system/org/index.jsx +60 -80
- package/src/pages/system/role/index.jsx +50 -86
- package/src/pages/system/role/rolePerm.jsx +2 -2
- package/src/pages/system/user/index.jsx +120 -73
- package/src/pages/system/user/userPerm.jsx +2 -2
- package/vite-plugin/index.js +107 -0
- package/config/common-plugin.js +0 -145
- package/config/config.js +0 -5
- package/config/utils.js +0 -73
- package/src/.umi-production/appData.json +0 -2257
- package/src/.umi-production/core/EmptyRoute.tsx +0 -9
- package/src/.umi-production/core/defineApp.ts +0 -16
- package/src/.umi-production/core/helmet.ts +0 -10
- package/src/.umi-production/core/helmetContext.ts +0 -4
- package/src/.umi-production/core/history.ts +0 -72
- package/src/.umi-production/core/historyIntelli.ts +0 -132
- package/src/.umi-production/core/plugin.ts +0 -40
- package/src/.umi-production/core/pluginConfig.ts +0 -330
- package/src/.umi-production/core/pluginConfigJoi.d.ts +0 -7
- package/src/.umi-production/core/polyfill.ts +0 -220
- package/src/.umi-production/core/route.tsx +0 -47
- package/src/.umi-production/core/routeProps.js +0 -5
- package/src/.umi-production/core/routeProps.ts +0 -6
- package/src/.umi-production/core/terminal.ts +0 -37
- package/src/.umi-production/exports.ts +0 -17
- package/src/.umi-production/testBrowser.tsx +0 -90
- package/src/.umi-production/tsconfig.json +0 -43
- package/src/.umi-production/typings.d.ts +0 -136
- package/src/.umi-production/umi.ts +0 -83
- package/src/framework/GlobalData.d.ts +0 -10
- package/src/framework/GlobalData.js +0 -42
- package/src/framework/biz/HasPerm.tsx +0 -14
- package/src/framework/fields/FieldRemoteSelectMultiple/index.tsx +0 -29
- package/src/framework/utils/ArrayUtils.d.ts +0 -6
- package/src/framework/utils/DateUtils.d.ts +0 -20
- package/src/framework/utils/DeviceUtils.d.ts +0 -3
- package/src/framework/utils/EventBus.d.ts +0 -6
- package/src/framework/utils/MessageUtils.d.ts +0 -10
- package/src/framework/utils/MessageUtils.js +0 -43
- package/src/framework/utils/ObjectUtils.d.ts +0 -14
- package/src/framework/utils/ObjectUtils.js +0 -12
- package/src/framework/utils/StorageUtils.d.ts +0 -4
- package/src/framework/utils/StringUtils.d.ts +0 -17
- package/src/framework/utils/TreeUtils.d.ts +0 -13
- package/src/framework/utils/UrlUtils.d.ts +0 -6
- package/src/framework/utils/system/DictUtils.d.ts +0 -20
- package/src/framework/utils/system/FormRegistry.d.ts +0 -8
- package/src/framework/utils/system/FormRegistry.js +0 -31
- package/src/framework/utils/system/HttpUtils.d.ts +0 -14
- package/src/framework/utils/system/PageUtils.d.ts +0 -14
- package/src/framework/utils/system/PageUtils.js +0 -59
- package/src/framework/utils/system/PermUtils.d.ts +0 -5
- package/src/framework/utils/system/ThemeUtils.d.ts +0 -6
- package/src/framework/utils/system/ThemeUtils.js +0 -52
- package/src/layouts/PageRender.tsx +0 -29
- package/src/layouts/admin/TabPageRender.jsx +0 -210
- package/src/layouts/index.jsx +0 -120
- package/src/loading.jsx +0 -19
- package/src/pages/about.jsx +0 -16
- /package/src/pages/{login.less → public/login.less} +0 -0
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export class ThemeUtils {
|
|
2
|
-
static defaultTheme = {
|
|
3
|
-
"primary-color": "#1961AC",
|
|
4
|
-
"success-color": "#52c41a",
|
|
5
|
-
"warning-color": "#faad14",
|
|
6
|
-
"error-color": "#ff4d4f",
|
|
7
|
-
"background-color": "#f5f5f5",
|
|
8
|
-
"primary-color-hover": "#4990CD",
|
|
9
|
-
"primary-color-click": "#124B93"
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
static cachedTheme = null;
|
|
13
|
-
|
|
14
|
-
static get theme() {
|
|
15
|
-
if (this.cachedTheme) return this.cachedTheme;
|
|
16
|
-
this.cachedTheme = this.loadTheme();
|
|
17
|
-
return this.cachedTheme;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** 调亮/调暗十六进制颜色 */
|
|
21
|
-
static _lightenHex(hex, percent) {
|
|
22
|
-
const num = parseInt(hex.replace('#', ''), 16);
|
|
23
|
-
const r = num >> 16 & 255, g = num >> 8 & 255, b = num & 255;
|
|
24
|
-
const t = percent < 0 ? 0 : 255;
|
|
25
|
-
const p = Math.abs(percent) / 100;
|
|
26
|
-
return '#' + (0x1000000 + (Math.round((t - r) * p) + r) * 0x10000
|
|
27
|
-
+ (Math.round((t - g) * p) + g) * 0x100 + (Math.round((t - b) * p) + b)).toString(16).slice(1);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static loadTheme() {
|
|
31
|
-
let custom = {};
|
|
32
|
-
try {
|
|
33
|
-
if (typeof OPEN_ADMIN_THEME !== 'undefined' && OPEN_ADMIN_THEME) {
|
|
34
|
-
custom = OPEN_ADMIN_THEME;
|
|
35
|
-
}
|
|
36
|
-
} catch (e) {}
|
|
37
|
-
const result = {...this.defaultTheme, ...custom};
|
|
38
|
-
if (custom["primary-color"]) {
|
|
39
|
-
if (!custom["primary-color-hover"]) {
|
|
40
|
-
result["primary-color-hover"] = ThemeUtils._lightenHex(result["primary-color"], 20);
|
|
41
|
-
}
|
|
42
|
-
if (!custom["primary-color-click"]) {
|
|
43
|
-
result["primary-color-click"] = ThemeUtils._lightenHex(result["primary-color"], -10);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static getColor(key) {
|
|
50
|
-
return ThemeUtils.theme[key];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import {matchRoutes, useAppData} from "umi";
|
|
2
|
-
import {Result} from "antd";
|
|
3
|
-
|
|
4
|
-
interface PageRenderProps {
|
|
5
|
-
pathname: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 通过指定 pathname 渲染页面
|
|
10
|
-
*/
|
|
11
|
-
export function PageRender({pathname}: PageRenderProps) {
|
|
12
|
-
const appData = useAppData()
|
|
13
|
-
const matchArr = matchRoutes(appData.clientRoutes, pathname)
|
|
14
|
-
|
|
15
|
-
if (matchArr != null) {
|
|
16
|
-
const matchResult = matchArr[matchArr.length - 1].route
|
|
17
|
-
if (matchResult && matchResult.element) {
|
|
18
|
-
return matchResult.element
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<Result
|
|
24
|
-
status={404}
|
|
25
|
-
title='页面不存在!'
|
|
26
|
-
subTitle={<div>路由地址:{pathname}</div>}
|
|
27
|
-
/>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import React, {useState, useEffect, useRef} from "react";
|
|
2
|
-
import {history} from "umi";
|
|
3
|
-
import {PageRender} from "../PageRender";
|
|
4
|
-
import {UrlUtils, ContextMenu} from "../../framework";
|
|
5
|
-
|
|
6
|
-
const MAX_TABS = 20;
|
|
7
|
-
|
|
8
|
-
function getLabel(pathname, search, pathMenuMap) {
|
|
9
|
-
if (pathname === '/') return '首页';
|
|
10
|
-
const params = UrlUtils.getParams(search);
|
|
11
|
-
if (params._label) return params._label;
|
|
12
|
-
const menu = pathMenuMap[pathname];
|
|
13
|
-
if (menu) return menu.name;
|
|
14
|
-
return '未命名';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function TabPageRender({pathMenuMap}) {
|
|
18
|
-
const [tabs, setTabs] = useState([]);
|
|
19
|
-
const [activeKey, setActiveKey] = useState(null);
|
|
20
|
-
const [contextMenu, setContextMenu] = useState(null);
|
|
21
|
-
const accessOrderRef = useRef([]);
|
|
22
|
-
const lastClickTimeRef = useRef({});
|
|
23
|
-
const activeKeyRef = useRef(activeKey);
|
|
24
|
-
activeKeyRef.current = activeKey;
|
|
25
|
-
const pathMenuMapRef = useRef(pathMenuMap);
|
|
26
|
-
pathMenuMapRef.current = pathMenuMap;
|
|
27
|
-
|
|
28
|
-
const recordAccess = (key) => {
|
|
29
|
-
accessOrderRef.current = accessOrderRef.current.filter(k => k !== key);
|
|
30
|
-
accessOrderRef.current.push(key);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// Use history.listen to monitor route changes
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const unlisten = history.listen(({location}) => {
|
|
36
|
-
const {pathname, search} = location;
|
|
37
|
-
const key = pathname + (search || '');
|
|
38
|
-
recordAccess(key);
|
|
39
|
-
|
|
40
|
-
setTabs(prev => {
|
|
41
|
-
if (prev.find(t => t.key === key)) return prev;
|
|
42
|
-
const content = <PageRender pathname={pathname}/>;
|
|
43
|
-
const label = getLabel(pathname, search, pathMenuMapRef.current);
|
|
44
|
-
const next = [...prev, {key, label, closable: true, content}];
|
|
45
|
-
if (next.length > MAX_TABS) {
|
|
46
|
-
const keep = new Set([key, ...accessOrderRef.current.slice(-3)]);
|
|
47
|
-
const removeIdx = next.findIndex(t => !keep.has(t.key));
|
|
48
|
-
if (removeIdx > -1) next.splice(removeIdx, 1);
|
|
49
|
-
}
|
|
50
|
-
return next;
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
setActiveKey(key);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// Trigger for initial route
|
|
57
|
-
const {pathname, search} = history.location;
|
|
58
|
-
const key = pathname + (search || '');
|
|
59
|
-
recordAccess(key);
|
|
60
|
-
setTabs([{key, label: getLabel(pathname, search, pathMenuMap), closable: true, content: <PageRender pathname={pathname}/>}]);
|
|
61
|
-
setActiveKey(key);
|
|
62
|
-
|
|
63
|
-
return unlisten;
|
|
64
|
-
}, []);
|
|
65
|
-
|
|
66
|
-
// Listen for close-page-event (stable listener, no re-registration)
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
const handler = (e) => {
|
|
69
|
-
const url = e.detail.url;
|
|
70
|
-
setTabs(prev => {
|
|
71
|
-
const next = prev.filter(t => t.key !== url);
|
|
72
|
-
accessOrderRef.current = accessOrderRef.current.filter(k => k !== url);
|
|
73
|
-
if (url === activeKeyRef.current && next.length > 0) {
|
|
74
|
-
history.push(next[next.length - 1].key);
|
|
75
|
-
}
|
|
76
|
-
return next;
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
document.addEventListener('close-page-event', handler);
|
|
80
|
-
return () => document.removeEventListener('close-page-event', handler);
|
|
81
|
-
}, []);
|
|
82
|
-
|
|
83
|
-
const handleTabRefresh = (key) => {
|
|
84
|
-
setTabs(prev => {
|
|
85
|
-
const idx = prev.findIndex(t => t.key === key);
|
|
86
|
-
if (idx === -1) return prev;
|
|
87
|
-
const originalContent = prev[idx].content;
|
|
88
|
-
const next = [...prev];
|
|
89
|
-
next[idx] = {...next[idx], content: '刷新中...'};
|
|
90
|
-
requestAnimationFrame(() => {
|
|
91
|
-
setTabs(prev2 => {
|
|
92
|
-
const idx2 = prev2.findIndex(t => t.key === key);
|
|
93
|
-
if (idx2 === -1) return prev2;
|
|
94
|
-
const next2 = [...prev2];
|
|
95
|
-
next2[idx2] = {...next2[idx2], content: originalContent};
|
|
96
|
-
return next2;
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
return next;
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const handleTabClick = (key) => {
|
|
104
|
-
const now = Date.now();
|
|
105
|
-
const last = lastClickTimeRef.current[key] || 0;
|
|
106
|
-
lastClickTimeRef.current[key] = now;
|
|
107
|
-
if (now - last < 300) {
|
|
108
|
-
handleTabRefresh(key);
|
|
109
|
-
} else if (key !== activeKey) {
|
|
110
|
-
history.push(key);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const closeTab = (key) => {
|
|
115
|
-
setTabs(prev => {
|
|
116
|
-
const next = prev.filter(t => t.key !== key);
|
|
117
|
-
accessOrderRef.current = accessOrderRef.current.filter(k => k !== key);
|
|
118
|
-
if (next.length === 0) {
|
|
119
|
-
history.push('/');
|
|
120
|
-
} else if (key === activeKeyRef.current) {
|
|
121
|
-
history.push(next[next.length - 1].key);
|
|
122
|
-
}
|
|
123
|
-
return next;
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const handleClose = (key, e) => {
|
|
128
|
-
e.stopPropagation();
|
|
129
|
-
closeTab(key);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const handleTabContextMenu = (e, key) => {
|
|
133
|
-
e.preventDefault();
|
|
134
|
-
setContextMenu({x: e.clientX, y: e.clientY, tabKey: key});
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const handleContextMenuClick = ({key: actionKey}) => {
|
|
138
|
-
const {tabKey} = contextMenu;
|
|
139
|
-
setContextMenu(null);
|
|
140
|
-
if (actionKey === 'refresh') {
|
|
141
|
-
handleTabRefresh(tabKey);
|
|
142
|
-
} else if (actionKey === 'close') {
|
|
143
|
-
closeTab(tabKey);
|
|
144
|
-
} else if (actionKey === 'closeOthers') {
|
|
145
|
-
setTabs(prev => {
|
|
146
|
-
const next = prev.filter(t => t.key === tabKey || !t.closable);
|
|
147
|
-
accessOrderRef.current = [tabKey];
|
|
148
|
-
if (tabKey !== activeKeyRef.current) {
|
|
149
|
-
history.push(tabKey);
|
|
150
|
-
}
|
|
151
|
-
return next;
|
|
152
|
-
});
|
|
153
|
-
} else if (actionKey === 'closeAll') {
|
|
154
|
-
accessOrderRef.current = [];
|
|
155
|
-
setTabs([]);
|
|
156
|
-
setTimeout(() => history.push('/'), 0);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
if (tabs.length === 0) return null;
|
|
161
|
-
|
|
162
|
-
return (
|
|
163
|
-
<div className="oa-tabs">
|
|
164
|
-
<div className="oa-tab-bar">
|
|
165
|
-
{tabs.map(tab => (
|
|
166
|
-
<div
|
|
167
|
-
key={tab.key}
|
|
168
|
-
className={'oa-tab' + (tab.key === activeKey ? ' active' : '')}
|
|
169
|
-
onClick={() => handleTabClick(tab.key)}
|
|
170
|
-
onContextMenu={(e) => handleTabContextMenu(e, tab.key)}
|
|
171
|
-
>
|
|
172
|
-
<span className="oa-tab-label">{tab.label}</span>
|
|
173
|
-
{tab.closable && tabs.length > 1 && (
|
|
174
|
-
<span className="oa-tab-close" onClick={(e) => handleClose(tab.key, e)}>×</span>
|
|
175
|
-
)}
|
|
176
|
-
</div>
|
|
177
|
-
))}
|
|
178
|
-
</div>
|
|
179
|
-
{contextMenu && (() => {
|
|
180
|
-
const tab = tabs.find(t => t.key === contextMenu.tabKey);
|
|
181
|
-
const closableCount = tabs.filter(t => t.closable).length;
|
|
182
|
-
return (
|
|
183
|
-
<ContextMenu
|
|
184
|
-
x={contextMenu.x}
|
|
185
|
-
y={contextMenu.y}
|
|
186
|
-
items={[
|
|
187
|
-
{key: 'refresh', label: '刷新'},
|
|
188
|
-
{key: 'close', label: '关闭', disabled: !tab?.closable},
|
|
189
|
-
{key: 'closeOthers', label: '关闭其他', disabled: tabs.length <= 1},
|
|
190
|
-
{key: 'closeAll', label: '关闭全部', disabled: closableCount === 0},
|
|
191
|
-
]}
|
|
192
|
-
onClick={handleContextMenuClick}
|
|
193
|
-
onClose={() => setContextMenu(null)}
|
|
194
|
-
/>
|
|
195
|
-
);
|
|
196
|
-
})()}
|
|
197
|
-
<div className="oa-tabs-content">
|
|
198
|
-
{tabs.map(tab => (
|
|
199
|
-
<div
|
|
200
|
-
key={tab.key}
|
|
201
|
-
style={{display: tab.key === activeKey ? undefined : 'none'}}
|
|
202
|
-
className="oa-tab-pane"
|
|
203
|
-
>
|
|
204
|
-
{tab.content}
|
|
205
|
-
</div>
|
|
206
|
-
))}
|
|
207
|
-
</div>
|
|
208
|
-
</div>
|
|
209
|
-
);
|
|
210
|
-
}
|
package/src/layouts/index.jsx
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import {useState, useEffect} from "react";
|
|
2
|
-
import {App, ConfigProvider} from "antd";
|
|
3
|
-
import zhCN from 'antd/locale/zh_CN';
|
|
4
|
-
import dayjs from 'dayjs';
|
|
5
|
-
import 'dayjs/locale/zh-cn';
|
|
6
|
-
import {Outlet, useLocation, history} from "umi";
|
|
7
|
-
|
|
8
|
-
import AdminLayout from "./admin"
|
|
9
|
-
import {HttpUtils, PageLoading, PageUtils, GlobalData, ThemeUtils, DownloadModal} from "../framework";
|
|
10
|
-
import {ErrorBoundary} from "../framework";
|
|
11
|
-
|
|
12
|
-
import '../style/global.less'
|
|
13
|
-
import './index.less'
|
|
14
|
-
|
|
15
|
-
dayjs.locale('zh-cn');
|
|
16
|
-
|
|
17
|
-
const configProps = {
|
|
18
|
-
input: {autoComplete: 'off'},
|
|
19
|
-
form: {validateMessages: {required: '必填项'}, colon: false},
|
|
20
|
-
button: {autoInsertSpace: false},
|
|
21
|
-
locale: zhCN,
|
|
22
|
-
theme: {
|
|
23
|
-
token: {
|
|
24
|
-
colorPrimary: ThemeUtils.getColor("primary-color"),
|
|
25
|
-
colorSuccess: ThemeUtils.getColor("success-color"),
|
|
26
|
-
colorWarning: ThemeUtils.getColor("warning-color"),
|
|
27
|
-
colorError: ThemeUtils.getColor("error-color"),
|
|
28
|
-
borderRadius: 4,
|
|
29
|
-
},
|
|
30
|
-
components: {
|
|
31
|
-
Layout: {
|
|
32
|
-
headerBg: 'white',
|
|
33
|
-
triggerHeight: 32,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
function AppWrapper({children}) {
|
|
40
|
-
return <ConfigProvider {...configProps}><App><DownloadModal />{children}</App></ConfigProvider>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const PUBLIC_PAGES = (() => {
|
|
44
|
-
const raw = typeof OPEN_ADMIN_PUBLIC_PAGES !== 'undefined' && OPEN_ADMIN_PUBLIC_PAGES;
|
|
45
|
-
return raw ? raw.split(',').map(s => s.trim()) : ['/login', '/test', '/forceUpdatePwd'];
|
|
46
|
-
})();
|
|
47
|
-
|
|
48
|
-
function isPublicPage(pathname, search) {
|
|
49
|
-
if (pathname === '/' || pathname === '/index') return false;
|
|
50
|
-
|
|
51
|
-
for (const pattern of PUBLIC_PAGES) {
|
|
52
|
-
if (pattern.endsWith('/**')) {
|
|
53
|
-
if (pathname.startsWith(pattern.slice(0, -3))) return true;
|
|
54
|
-
} else if (pathname === pattern) {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (new URLSearchParams(search).has('_noLayout')) return true;
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function Layouts() {
|
|
64
|
-
const location = useLocation();
|
|
65
|
-
const {pathname, search} = location;
|
|
66
|
-
const [siteInfoLoaded, setSiteInfoLoaded] = useState(false);
|
|
67
|
-
const [loginChecked, setLoginChecked] = useState(false);
|
|
68
|
-
|
|
69
|
-
const ready = siteInfoLoaded && loginChecked;
|
|
70
|
-
const isPublic = isPublicPage(pathname, search);
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
if (isPublic) {
|
|
74
|
-
setSiteInfoLoaded(false);
|
|
75
|
-
setLoginChecked(false);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (ready) return;
|
|
79
|
-
|
|
80
|
-
Promise.all([
|
|
81
|
-
HttpUtils.get("/admin/public/site-info").then(data => {
|
|
82
|
-
GlobalData.setSiteInfo(data);
|
|
83
|
-
setSiteInfoLoaded(true);
|
|
84
|
-
}),
|
|
85
|
-
HttpUtils.get('/admin/public/user-info').then(data => {
|
|
86
|
-
GlobalData.setDictInfo(data.dictInfo);
|
|
87
|
-
GlobalData.setLoginInfo(data.loginInfo);
|
|
88
|
-
GlobalData.setSiteArticles(data.siteArticles);
|
|
89
|
-
|
|
90
|
-
if (data.needUpdatePwd && pathname !== '/forceUpdatePwd') {
|
|
91
|
-
history.push('/forceUpdatePwd');
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
setLoginChecked(true);
|
|
96
|
-
}),
|
|
97
|
-
]).catch(() => {
|
|
98
|
-
console.error('[Layout] 初始化应用失败');
|
|
99
|
-
PageUtils.redirectToLogin();
|
|
100
|
-
});
|
|
101
|
-
}, [location]);
|
|
102
|
-
|
|
103
|
-
if (isPublic) return <ErrorBoundary minimal><AppWrapper><Outlet/></AppWrapper></ErrorBoundary>;
|
|
104
|
-
|
|
105
|
-
return (
|
|
106
|
-
<ErrorBoundary minimal>
|
|
107
|
-
<AppWrapper>
|
|
108
|
-
{ready ? <AdminLayout/> : (
|
|
109
|
-
<PageLoading messages={[
|
|
110
|
-
!siteInfoLoaded && '加载站点信息...',
|
|
111
|
-
!loginChecked && '检查登录中...',
|
|
112
|
-
].filter(Boolean)}/>
|
|
113
|
-
)}
|
|
114
|
-
</AppWrapper>
|
|
115
|
-
</ErrorBoundary>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export default Layouts;
|
|
120
|
-
export * from './PageRender'
|
package/src/loading.jsx
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Spin } from "antd";
|
|
3
|
-
import { ThemeUtils } from "./framework";
|
|
4
|
-
|
|
5
|
-
const Loading = () => (
|
|
6
|
-
<div
|
|
7
|
-
style={{
|
|
8
|
-
display: 'flex',
|
|
9
|
-
alignItems: 'center',
|
|
10
|
-
justifyContent: 'center',
|
|
11
|
-
height: '100vh',
|
|
12
|
-
background: ThemeUtils.getColor("background-color")
|
|
13
|
-
}}
|
|
14
|
-
>
|
|
15
|
-
<Spin size='large' />
|
|
16
|
-
</div>
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
export default Loading;
|
package/src/pages/about.jsx
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {history} from "umi";
|
|
3
|
-
import {Page} from "../framework";
|
|
4
|
-
|
|
5
|
-
export default class extends React.Component {
|
|
6
|
-
|
|
7
|
-
componentDidMount() {
|
|
8
|
-
history.push('/article/about')
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
render() {
|
|
12
|
-
return <Page title="关于系统">
|
|
13
|
-
<div>跳转中...</div>
|
|
14
|
-
</Page>
|
|
15
|
-
}
|
|
16
|
-
}
|
|
File without changes
|