lupine.api 1.1.57 → 1.1.59
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 +3 -3
- package/admin/admin-about.tsx +12 -16
- package/admin/admin-config.tsx +47 -44
- package/admin/admin-css.tsx +3 -3
- package/admin/admin-db.tsx +75 -75
- package/admin/admin-frame-helper.tsx +364 -364
- package/admin/admin-frame.tsx +164 -164
- package/admin/admin-index.tsx +65 -65
- package/admin/admin-login.tsx +111 -111
- package/admin/admin-menu-edit.tsx +637 -637
- package/admin/admin-menu-list.tsx +87 -87
- package/admin/admin-page-edit.tsx +564 -564
- package/admin/admin-page-list.tsx +83 -83
- package/admin/admin-performance.tsx +28 -28
- package/admin/admin-release.tsx +427 -404
- package/admin/admin-resources.tsx +382 -382
- package/admin/admin-shell.tsx +89 -89
- package/admin/admin-table-data.tsx +146 -146
- package/admin/admin-table-list.tsx +230 -230
- package/admin/admin-test-animations.tsx +395 -395
- package/admin/admin-test-component.tsx +823 -808
- package/admin/admin-test-edit.tsx +319 -319
- package/admin/admin-test-themes.tsx +56 -56
- package/admin/admin-tokens.tsx +338 -338
- package/admin/design/admin-design.tsx +174 -174
- package/admin/design/block-grid.tsx +36 -36
- package/admin/design/block-grid1.tsx +21 -21
- package/admin/design/block-paragraph.tsx +19 -19
- package/admin/design/block-title.tsx +19 -19
- package/admin/design/design-block-box.tsx +140 -140
- package/admin/design/drag-data.tsx +24 -24
- package/admin/index.ts +9 -9
- package/admin/package.json +15 -15
- package/admin/tsconfig.json +127 -127
- package/dev/copy-folder.js +32 -32
- package/dev/cp-index-html.js +69 -69
- package/dev/file-utils.js +12 -12
- package/dev/index.js +18 -19
- package/dev/package.json +12 -12
- package/dev/plugin-ifelse.js +168 -168
- package/dev/plugin-ifelse.test.js +37 -37
- package/dev/run-cmd.js +14 -14
- package/dev/send-request.js +12 -12
- package/package.json +55 -55
- package/src/admin-api/admin-api-helper.ts +210 -205
- package/src/admin-api/admin-api.ts +65 -65
- package/src/admin-api/admin-auth.ts +152 -146
- package/src/admin-api/admin-config.ts +94 -84
- package/src/admin-api/admin-csv.ts +94 -94
- package/src/admin-api/admin-db.ts +269 -269
- package/src/admin-api/admin-menu.ts +135 -135
- package/src/admin-api/admin-page.ts +135 -135
- package/src/admin-api/admin-performance.ts +128 -128
- package/src/admin-api/admin-release.ts +703 -700
- package/src/admin-api/admin-resources.ts +318 -318
- package/src/admin-api/admin-token-helper.ts +82 -79
- package/src/admin-api/admin-tokens.ts +90 -90
- package/src/admin-api/index.ts +2 -2
- package/src/admin-api/web-config-api.ts +19 -19
- package/src/api/api-cache.ts +103 -103
- package/src/api/api-helper.ts +44 -44
- package/src/api/api-module.ts +67 -60
- package/src/api/api-router.ts +177 -177
- package/src/api/api-shared-storage.ts +64 -64
- package/src/api/async-storage.ts +5 -5
- package/src/api/debug-service.ts +56 -56
- package/src/api/encode-html.ts +27 -27
- package/src/api/handle-status.ts +75 -75
- package/src/api/index.ts +15 -16
- package/src/api/mini-web-socket.ts +270 -270
- package/src/api/server-content-type.ts +82 -82
- package/src/api/server-render.ts +235 -215
- package/src/api/shell-service.ts +74 -74
- package/src/api/simple-storage.ts +80 -80
- package/src/api/static-server.ts +128 -125
- package/src/api/to-client-delivery.ts +26 -26
- package/src/app/app-cache.ts +55 -55
- package/src/app/app-helper.ts +62 -62
- package/src/app/app-message.ts +109 -109
- package/src/app/app-shared-storage.ts +363 -363
- package/src/app/app-start.ts +136 -136
- package/src/app/cleanup-exit.ts +16 -16
- package/src/app/host-to-path.ts +38 -38
- package/src/app/index.ts +11 -11
- package/src/app/process-dev-requests.ts +130 -130
- package/src/app/web-listener.ts +294 -294
- package/src/app/web-processor.ts +47 -42
- package/src/app/web-server.ts +100 -100
- package/src/common-js/web-env.js +104 -104
- package/src/index.ts +7 -7
- package/src/lang/api-lang-en.ts +26 -26
- package/src/lang/api-lang-zh-cn.ts +27 -27
- package/src/lang/index.ts +2 -2
- package/src/lang/lang-helper.ts +76 -76
- package/src/lang/lang-props.ts +6 -6
- package/src/lib/db/db-helper.ts +23 -23
- package/src/lib/db/db-mysql.ts +249 -250
- package/src/lib/db/db-sqlite.ts +101 -101
- package/src/lib/db/db.spec.ts +28 -28
- package/src/lib/db/db.ts +325 -325
- package/src/lib/db/index.ts +5 -5
- package/src/lib/index.ts +3 -3
- package/src/lib/logger.spec.ts +214 -214
- package/src/lib/logger.ts +281 -281
- package/src/lib/runtime-require.ts +37 -37
- package/src/lib/utils/cookie-util.ts +34 -34
- package/src/lib/utils/crypto.ts +58 -58
- package/src/lib/utils/date-utils.ts +317 -317
- package/src/lib/utils/deep-merge.ts +37 -37
- package/src/lib/utils/delay.ts +12 -12
- package/src/lib/utils/file-setting.ts +55 -55
- package/src/lib/utils/format-bytes.ts +11 -11
- package/src/lib/utils/fs-utils.ts +158 -158
- package/src/lib/utils/get-env.ts +27 -27
- package/src/lib/utils/index.ts +12 -12
- package/src/lib/utils/is-type.ts +48 -48
- package/src/lib/utils/load-env.ts +14 -14
- package/src/lib/utils/pad.ts +6 -6
- package/src/models/api-base.ts +5 -5
- package/src/models/api-module-props.ts +10 -11
- package/src/models/api-router-props.ts +26 -26
- package/src/models/app-cache-props.ts +33 -33
- package/src/models/app-data-props.ts +10 -10
- package/src/models/app-helper-props.ts +6 -6
- package/src/models/app-shared-storage-props.ts +38 -38
- package/src/models/app-start-props.ts +18 -18
- package/src/models/async-storage-props.ts +13 -13
- package/src/models/db-config.ts +30 -30
- package/src/models/host-to-path-props.ts +12 -12
- package/src/models/index.ts +16 -16
- package/src/models/json-object.ts +8 -8
- package/src/models/locals-props.ts +36 -36
- package/src/models/logger-props.ts +84 -84
- package/src/models/simple-storage-props.ts +13 -14
- package/src/models/to-client-delivery-props.ts +6 -6
- package/tsconfig.json +115 -115
- package/dev/plugin-gen-versions.js +0 -20
package/admin/admin-frame.tsx
CHANGED
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
import { bindGlobalStyle, CssProps, RefProps, clearCookie, TabsPageProps, getRenderPageProps } from 'lupine.components';
|
|
2
|
-
import { MenuSidebar, ThemeSelector, TabsHookProps, Tabs } from 'lupine.components';
|
|
3
|
-
import { adminCss } from './admin-css';
|
|
4
|
-
import { adminFrameHelper } from './admin-frame-helper';
|
|
5
|
-
|
|
6
|
-
type AdminPanelProps = {
|
|
7
|
-
title?: string;
|
|
8
|
-
css?: CssProps;
|
|
9
|
-
refUpdate: TabsHookProps;
|
|
10
|
-
};
|
|
11
|
-
const AdminPanel = (props: AdminPanelProps) => {
|
|
12
|
-
const css: CssProps = {
|
|
13
|
-
height: '100%',
|
|
14
|
-
};
|
|
15
|
-
const pages: TabsPageProps[] = [];
|
|
16
|
-
return (
|
|
17
|
-
<div css={css}>
|
|
18
|
-
<Tabs pages={pages} hook={props.refUpdate} pagePadding='8px'></Tabs>
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type AdminFrameProps = {
|
|
24
|
-
title?: string;
|
|
25
|
-
css?: CssProps;
|
|
26
|
-
};
|
|
27
|
-
export const AdminFrame = (props: AdminFrameProps) => {
|
|
28
|
-
const refUpdate = adminFrameHelper.getTabsHook();
|
|
29
|
-
const maxWidthMobileMenu = adminFrameHelper.getMobileMenuMaxWidth();
|
|
30
|
-
const css: CssProps = {
|
|
31
|
-
backgroundColor: 'var(--primary-bg-color)',
|
|
32
|
-
color: 'var(--primary-color)',
|
|
33
|
-
...adminCss,
|
|
34
|
-
display: 'flex',
|
|
35
|
-
flexDirection: 'column',
|
|
36
|
-
// padding: '10px',
|
|
37
|
-
width: '100%',
|
|
38
|
-
height: '100%',
|
|
39
|
-
minHeight: '100%',
|
|
40
|
-
overflowY: 'auto',
|
|
41
|
-
'.f-header': {
|
|
42
|
-
display: 'flex',
|
|
43
|
-
alignItems: 'center',
|
|
44
|
-
padding: '4px 16px 4px 0px',
|
|
45
|
-
fontSize: '80%',
|
|
46
|
-
},
|
|
47
|
-
'.top-logo': {
|
|
48
|
-
marginLeft: '16px',
|
|
49
|
-
marginRight: '16px',
|
|
50
|
-
},
|
|
51
|
-
'.top-title': {
|
|
52
|
-
flex: '1',
|
|
53
|
-
fontSize: '160%',
|
|
54
|
-
margin: 'auto',
|
|
55
|
-
},
|
|
56
|
-
'.top-menu': {
|
|
57
|
-
display: 'flex',
|
|
58
|
-
},
|
|
59
|
-
'.top-menu .item': {
|
|
60
|
-
padding: '0px 2px',
|
|
61
|
-
},
|
|
62
|
-
'.f-body': {
|
|
63
|
-
flex: '1',
|
|
64
|
-
display: 'flex',
|
|
65
|
-
borderTop: 'var(--primary-border)',
|
|
66
|
-
minHeight: '0',
|
|
67
|
-
},
|
|
68
|
-
'.body-menu': {
|
|
69
|
-
width: '165px',
|
|
70
|
-
// padding: '8px 16px',
|
|
71
|
-
borderRight: 'var(--primary-border)',
|
|
72
|
-
overflowX: 'hidden',
|
|
73
|
-
overflowY: 'auto',
|
|
74
|
-
color: 'var(--sidebar-color)',
|
|
75
|
-
backgroundColor: 'var(--sidebar-bg-color)',
|
|
76
|
-
},
|
|
77
|
-
'.close-menu-icon': {
|
|
78
|
-
position: 'relative',
|
|
79
|
-
},
|
|
80
|
-
'.close-menu-icon.hide + .body-menu': {
|
|
81
|
-
display: 'none',
|
|
82
|
-
},
|
|
83
|
-
'.close-menu-icon::after': {
|
|
84
|
-
content: '""',
|
|
85
|
-
position: 'absolute',
|
|
86
|
-
top: '-13px',
|
|
87
|
-
left: '-1px',
|
|
88
|
-
transform: 'rotate(90deg)',
|
|
89
|
-
width: '0',
|
|
90
|
-
height: '0',
|
|
91
|
-
borderLeft: '7px solid transparent',
|
|
92
|
-
borderRight: '7px solid transparent',
|
|
93
|
-
borderTop: '7px solid var(--primary-color)',
|
|
94
|
-
transition: 'all 300ms ease-in-out',
|
|
95
|
-
zIndex: 'var(--layer-sidebar)',
|
|
96
|
-
},
|
|
97
|
-
['@media only screen and (max-width: ' + maxWidthMobileMenu + ')']: {
|
|
98
|
-
'.body-menu, .close-menu-icon': {
|
|
99
|
-
display: 'none',
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
'.body-content': {
|
|
103
|
-
flex: '1',
|
|
104
|
-
overflowX: 'auto',
|
|
105
|
-
// padding: '8px 16px',
|
|
106
|
-
},
|
|
107
|
-
...props.css,
|
|
108
|
-
};
|
|
109
|
-
const onLogoutClick = async () => {
|
|
110
|
-
clearCookie('_token_dev', '/');
|
|
111
|
-
await adminFrameHelper.getAppAdminHookLogout()?.();
|
|
112
|
-
await getRenderPageProps().renderPageFunctions.fetchData('/api/admin/logout');
|
|
113
|
-
window.location.href = '/admin_dev';
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
bindGlobalStyle('admin-frame-box', css);
|
|
117
|
-
|
|
118
|
-
const refCloseMenu: RefProps = {};
|
|
119
|
-
const adminTopMenu = adminFrameHelper.getAdminTopMenu();
|
|
120
|
-
const onCloseMenuClick = () => {
|
|
121
|
-
refCloseMenu.current.classList.toggle('hide');
|
|
122
|
-
};
|
|
123
|
-
return (
|
|
124
|
-
<div class='admin-frame-box'>
|
|
125
|
-
<div class='f-header'>
|
|
126
|
-
<MenuSidebar
|
|
127
|
-
items={adminTopMenu}
|
|
128
|
-
maxWidthMobileMenu={maxWidthMobileMenu}
|
|
129
|
-
color='var(--sidebar-color)'
|
|
130
|
-
backgroundColor='var(--sidebar-bg-color)'
|
|
131
|
-
mobileMenu={true}
|
|
132
|
-
isDevAdmin={adminFrameHelper.getIsDevAdmin()}
|
|
133
|
-
></MenuSidebar>
|
|
134
|
-
<div class='top-logo'>Lupine.Dev</div>
|
|
135
|
-
<div class='top-title'>{props.title}</div>
|
|
136
|
-
<div class='top-menu'>
|
|
137
|
-
<ThemeSelector></ThemeSelector>
|
|
138
|
-
<button onClick={() => window.open('/')} class='button-base button-s'>
|
|
139
|
-
Home
|
|
140
|
-
</button>
|
|
141
|
-
<button onClick={onLogoutClick} class='button-base button-s'>
|
|
142
|
-
Logout
|
|
143
|
-
</button>
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
146
|
-
<div class='f-body'>
|
|
147
|
-
<div ref={refCloseMenu} class='close-menu-icon' onClick={onCloseMenuClick} title='Hide / Show Side Menu'></div>
|
|
148
|
-
<div class='body-menu'>
|
|
149
|
-
<MenuSidebar
|
|
150
|
-
items={adminTopMenu}
|
|
151
|
-
maxWidthMobileMenu={maxWidthMobileMenu}
|
|
152
|
-
color='var(--sidebar-color)'
|
|
153
|
-
backgroundColor='var(--sidebar-bg-color)'
|
|
154
|
-
desktopMenu={true}
|
|
155
|
-
isDevAdmin={adminFrameHelper.getIsDevAdmin()}
|
|
156
|
-
></MenuSidebar>
|
|
157
|
-
</div>
|
|
158
|
-
<div class='body-content'>
|
|
159
|
-
<AdminPanel refUpdate={refUpdate} title='Panel'></AdminPanel>
|
|
160
|
-
</div>
|
|
161
|
-
</div>
|
|
162
|
-
</div>
|
|
163
|
-
);
|
|
164
|
-
};
|
|
1
|
+
import { bindGlobalStyle, CssProps, RefProps, clearCookie, TabsPageProps, getRenderPageProps } from 'lupine.components';
|
|
2
|
+
import { MenuSidebar, ThemeSelector, TabsHookProps, Tabs } from 'lupine.components';
|
|
3
|
+
import { adminCss } from './admin-css';
|
|
4
|
+
import { adminFrameHelper } from './admin-frame-helper';
|
|
5
|
+
|
|
6
|
+
type AdminPanelProps = {
|
|
7
|
+
title?: string;
|
|
8
|
+
css?: CssProps;
|
|
9
|
+
refUpdate: TabsHookProps;
|
|
10
|
+
};
|
|
11
|
+
const AdminPanel = (props: AdminPanelProps) => {
|
|
12
|
+
const css: CssProps = {
|
|
13
|
+
height: '100%',
|
|
14
|
+
};
|
|
15
|
+
const pages: TabsPageProps[] = [];
|
|
16
|
+
return (
|
|
17
|
+
<div css={css}>
|
|
18
|
+
<Tabs pages={pages} hook={props.refUpdate} pagePadding='8px'></Tabs>
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type AdminFrameProps = {
|
|
24
|
+
title?: string;
|
|
25
|
+
css?: CssProps;
|
|
26
|
+
};
|
|
27
|
+
export const AdminFrame = (props: AdminFrameProps) => {
|
|
28
|
+
const refUpdate = adminFrameHelper.getTabsHook();
|
|
29
|
+
const maxWidthMobileMenu = adminFrameHelper.getMobileMenuMaxWidth();
|
|
30
|
+
const css: CssProps = {
|
|
31
|
+
backgroundColor: 'var(--primary-bg-color)',
|
|
32
|
+
color: 'var(--primary-color)',
|
|
33
|
+
...adminCss,
|
|
34
|
+
display: 'flex',
|
|
35
|
+
flexDirection: 'column',
|
|
36
|
+
// padding: '10px',
|
|
37
|
+
width: '100%',
|
|
38
|
+
height: '100%',
|
|
39
|
+
minHeight: '100%',
|
|
40
|
+
overflowY: 'auto',
|
|
41
|
+
'.f-header': {
|
|
42
|
+
display: 'flex',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
padding: '4px 16px 4px 0px',
|
|
45
|
+
fontSize: '80%',
|
|
46
|
+
},
|
|
47
|
+
'.top-logo': {
|
|
48
|
+
marginLeft: '16px',
|
|
49
|
+
marginRight: '16px',
|
|
50
|
+
},
|
|
51
|
+
'.top-title': {
|
|
52
|
+
flex: '1',
|
|
53
|
+
fontSize: '160%',
|
|
54
|
+
margin: 'auto',
|
|
55
|
+
},
|
|
56
|
+
'.top-menu': {
|
|
57
|
+
display: 'flex',
|
|
58
|
+
},
|
|
59
|
+
'.top-menu .item': {
|
|
60
|
+
padding: '0px 2px',
|
|
61
|
+
},
|
|
62
|
+
'.f-body': {
|
|
63
|
+
flex: '1',
|
|
64
|
+
display: 'flex',
|
|
65
|
+
borderTop: 'var(--primary-border)',
|
|
66
|
+
minHeight: '0',
|
|
67
|
+
},
|
|
68
|
+
'.body-menu': {
|
|
69
|
+
width: '165px',
|
|
70
|
+
// padding: '8px 16px',
|
|
71
|
+
borderRight: 'var(--primary-border)',
|
|
72
|
+
overflowX: 'hidden',
|
|
73
|
+
overflowY: 'auto',
|
|
74
|
+
color: 'var(--sidebar-color)',
|
|
75
|
+
backgroundColor: 'var(--sidebar-bg-color)',
|
|
76
|
+
},
|
|
77
|
+
'.close-menu-icon': {
|
|
78
|
+
position: 'relative',
|
|
79
|
+
},
|
|
80
|
+
'.close-menu-icon.hide + .body-menu': {
|
|
81
|
+
display: 'none',
|
|
82
|
+
},
|
|
83
|
+
'.close-menu-icon::after': {
|
|
84
|
+
content: '""',
|
|
85
|
+
position: 'absolute',
|
|
86
|
+
top: '-13px',
|
|
87
|
+
left: '-1px',
|
|
88
|
+
transform: 'rotate(90deg)',
|
|
89
|
+
width: '0',
|
|
90
|
+
height: '0',
|
|
91
|
+
borderLeft: '7px solid transparent',
|
|
92
|
+
borderRight: '7px solid transparent',
|
|
93
|
+
borderTop: '7px solid var(--primary-color)',
|
|
94
|
+
transition: 'all 300ms ease-in-out',
|
|
95
|
+
zIndex: 'var(--layer-sidebar)',
|
|
96
|
+
},
|
|
97
|
+
['@media only screen and (max-width: ' + maxWidthMobileMenu + ')']: {
|
|
98
|
+
'.body-menu, .close-menu-icon': {
|
|
99
|
+
display: 'none',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
'.body-content': {
|
|
103
|
+
flex: '1',
|
|
104
|
+
overflowX: 'auto',
|
|
105
|
+
// padding: '8px 16px',
|
|
106
|
+
},
|
|
107
|
+
...props.css,
|
|
108
|
+
};
|
|
109
|
+
const onLogoutClick = async () => {
|
|
110
|
+
clearCookie('_token_dev', '/');
|
|
111
|
+
await adminFrameHelper.getAppAdminHookLogout()?.();
|
|
112
|
+
await getRenderPageProps().renderPageFunctions.fetchData('/api/admin/logout');
|
|
113
|
+
window.location.href = '/admin_dev';
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
bindGlobalStyle('admin-frame-box', css);
|
|
117
|
+
|
|
118
|
+
const refCloseMenu: RefProps = {};
|
|
119
|
+
const adminTopMenu = adminFrameHelper.getAdminTopMenu();
|
|
120
|
+
const onCloseMenuClick = () => {
|
|
121
|
+
refCloseMenu.current.classList.toggle('hide');
|
|
122
|
+
};
|
|
123
|
+
return (
|
|
124
|
+
<div class='admin-frame-box'>
|
|
125
|
+
<div class='f-header'>
|
|
126
|
+
<MenuSidebar
|
|
127
|
+
items={adminTopMenu}
|
|
128
|
+
maxWidthMobileMenu={maxWidthMobileMenu}
|
|
129
|
+
color='var(--sidebar-color)'
|
|
130
|
+
backgroundColor='var(--sidebar-bg-color)'
|
|
131
|
+
mobileMenu={true}
|
|
132
|
+
isDevAdmin={adminFrameHelper.getIsDevAdmin()}
|
|
133
|
+
></MenuSidebar>
|
|
134
|
+
<div class='top-logo'>Lupine.Dev</div>
|
|
135
|
+
<div class='top-title'>{props.title}</div>
|
|
136
|
+
<div class='top-menu'>
|
|
137
|
+
<ThemeSelector></ThemeSelector>
|
|
138
|
+
<button onClick={() => window.open('/')} class='button-base button-s'>
|
|
139
|
+
Home
|
|
140
|
+
</button>
|
|
141
|
+
<button onClick={onLogoutClick} class='button-base button-s'>
|
|
142
|
+
Logout
|
|
143
|
+
</button>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
<div class='f-body'>
|
|
147
|
+
<div ref={refCloseMenu} class='close-menu-icon' onClick={onCloseMenuClick} title='Hide / Show Side Menu'></div>
|
|
148
|
+
<div class='body-menu'>
|
|
149
|
+
<MenuSidebar
|
|
150
|
+
items={adminTopMenu}
|
|
151
|
+
maxWidthMobileMenu={maxWidthMobileMenu}
|
|
152
|
+
color='var(--sidebar-color)'
|
|
153
|
+
backgroundColor='var(--sidebar-bg-color)'
|
|
154
|
+
desktopMenu={true}
|
|
155
|
+
isDevAdmin={adminFrameHelper.getIsDevAdmin()}
|
|
156
|
+
></MenuSidebar>
|
|
157
|
+
</div>
|
|
158
|
+
<div class='body-content'>
|
|
159
|
+
<AdminPanel refUpdate={refUpdate} title='Panel'></AdminPanel>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
};
|
package/admin/admin-index.tsx
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import { PageProps, PageRouter, DomUtils, Redirect } from 'lupine.components';
|
|
2
|
-
import { adminFrameHelper } from './admin-frame-helper';
|
|
3
|
-
import { AdminLoginPage } from './admin-login';
|
|
4
|
-
import { AdminMenuSinglePage } from './admin-menu-list';
|
|
5
|
-
import { AdminDesignPage } from './design/admin-design';
|
|
6
|
-
import { AdminFrame } from './admin-frame';
|
|
7
|
-
|
|
8
|
-
const fetchAuth = async (props: PageProps) => {
|
|
9
|
-
const data = await props.renderPageFunctions.fetchData('/api/admin/auth');
|
|
10
|
-
return data.json;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const checkAuth = async (props: PageProps) => {
|
|
14
|
-
if (typeof document === 'undefined') {
|
|
15
|
-
// no ssr for admin pages
|
|
16
|
-
return <div></div>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const json = await fetchAuth(props);
|
|
20
|
-
console.log('======auth', json);
|
|
21
|
-
if ((typeof json === 'undefined' || !json.result) && props.url !== '/admin_dev/login') {
|
|
22
|
-
return Redirect({ url: '/admin_dev/login' });
|
|
23
|
-
}
|
|
24
|
-
adminFrameHelper.setIsDevAdmin(true);
|
|
25
|
-
return null;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// export const bindAdmin = async (props: PageProps) => {
|
|
29
|
-
// MetaData({ name: 'robots', content: 'noindex, nofollow' });
|
|
30
|
-
|
|
31
|
-
// if (typeof document === 'undefined') {
|
|
32
|
-
// // no ssr for admin pages
|
|
33
|
-
// return <div></div>;
|
|
34
|
-
// }
|
|
35
|
-
|
|
36
|
-
// const json = await fetchAuth(props);
|
|
37
|
-
// console.log('======auth', json);
|
|
38
|
-
// if ((typeof json === 'undefined' || !json.result) && props.url !== '/admin_dev/login') {
|
|
39
|
-
// return Redirect({ url: '/admin_dev/login' });
|
|
40
|
-
// }
|
|
41
|
-
|
|
42
|
-
// if (props.urlSections[1] === 'login') {
|
|
43
|
-
// if (json && json.result) {
|
|
44
|
-
// return Redirect({ url: '/admin_dev' });
|
|
45
|
-
// }
|
|
46
|
-
// return await AdminLoginPage(props);
|
|
47
|
-
// }
|
|
48
|
-
|
|
49
|
-
// return await AdminIndexPage(props);
|
|
50
|
-
// };
|
|
51
|
-
|
|
52
|
-
export const AdminIndexPage = async (props: PageProps) => {
|
|
53
|
-
return <AdminFrame title='Welcome...' />;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const devAdminPageRouter = new PageRouter();
|
|
57
|
-
// need to be override for app and dev admins
|
|
58
|
-
devAdminPageRouter.setFilter(checkAuth);
|
|
59
|
-
|
|
60
|
-
devAdminPageRouter.use('/menu', AdminMenuSinglePage);
|
|
61
|
-
devAdminPageRouter.use('/design', AdminDesignPage);
|
|
62
|
-
devAdminPageRouter.use('/login', AdminLoginPage);
|
|
63
|
-
devAdminPageRouter.use('/*', AdminIndexPage);
|
|
64
|
-
|
|
65
|
-
export { devAdminPageRouter };
|
|
1
|
+
import { PageProps, PageRouter, DomUtils, Redirect } from 'lupine.components';
|
|
2
|
+
import { adminFrameHelper } from './admin-frame-helper';
|
|
3
|
+
import { AdminLoginPage } from './admin-login';
|
|
4
|
+
import { AdminMenuSinglePage } from './admin-menu-list';
|
|
5
|
+
import { AdminDesignPage } from './design/admin-design';
|
|
6
|
+
import { AdminFrame } from './admin-frame';
|
|
7
|
+
|
|
8
|
+
const fetchAuth = async (props: PageProps) => {
|
|
9
|
+
const data = await props.renderPageFunctions.fetchData('/api/admin/auth');
|
|
10
|
+
return data.json;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const checkAuth = async (props: PageProps) => {
|
|
14
|
+
if (typeof document === 'undefined') {
|
|
15
|
+
// no ssr for admin pages
|
|
16
|
+
return <div></div>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const json = await fetchAuth(props);
|
|
20
|
+
console.log('======auth', json);
|
|
21
|
+
if ((typeof json === 'undefined' || !json.result) && props.url !== '/admin_dev/login') {
|
|
22
|
+
return Redirect({ url: '/admin_dev/login' });
|
|
23
|
+
}
|
|
24
|
+
adminFrameHelper.setIsDevAdmin(true);
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// export const bindAdmin = async (props: PageProps) => {
|
|
29
|
+
// MetaData({ name: 'robots', content: 'noindex, nofollow' });
|
|
30
|
+
|
|
31
|
+
// if (typeof document === 'undefined') {
|
|
32
|
+
// // no ssr for admin pages
|
|
33
|
+
// return <div></div>;
|
|
34
|
+
// }
|
|
35
|
+
|
|
36
|
+
// const json = await fetchAuth(props);
|
|
37
|
+
// console.log('======auth', json);
|
|
38
|
+
// if ((typeof json === 'undefined' || !json.result) && props.url !== '/admin_dev/login') {
|
|
39
|
+
// return Redirect({ url: '/admin_dev/login' });
|
|
40
|
+
// }
|
|
41
|
+
|
|
42
|
+
// if (props.urlSections[1] === 'login') {
|
|
43
|
+
// if (json && json.result) {
|
|
44
|
+
// return Redirect({ url: '/admin_dev' });
|
|
45
|
+
// }
|
|
46
|
+
// return await AdminLoginPage(props);
|
|
47
|
+
// }
|
|
48
|
+
|
|
49
|
+
// return await AdminIndexPage(props);
|
|
50
|
+
// };
|
|
51
|
+
|
|
52
|
+
export const AdminIndexPage = async (props: PageProps) => {
|
|
53
|
+
return <AdminFrame title='Welcome...' />;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const devAdminPageRouter = new PageRouter();
|
|
57
|
+
// need to be override for app and dev admins
|
|
58
|
+
devAdminPageRouter.setFilter(checkAuth);
|
|
59
|
+
|
|
60
|
+
devAdminPageRouter.use('/menu', AdminMenuSinglePage);
|
|
61
|
+
devAdminPageRouter.use('/design', AdminDesignPage);
|
|
62
|
+
devAdminPageRouter.use('/login', AdminLoginPage);
|
|
63
|
+
devAdminPageRouter.use('/*', AdminIndexPage);
|
|
64
|
+
|
|
65
|
+
export { devAdminPageRouter };
|