create-lupine 1.0.30 → 1.2.0
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 +25 -0
- package/index.js +35 -13
- package/package.json +1 -1
- package/templates/common/.agents/skills/lupine-framework/SKILL.md +63 -0
- package/templates/common/.agents/skills/lupine-framework/references/backend-api.md +98 -0
- package/templates/common/.agents/skills/lupine-framework/references/icon-handling.md +71 -0
- package/templates/common/.agents/skills/lupine-framework/references/mobile-interactions.md +100 -0
- package/templates/common/.agents/skills/lupine-framework/references/native-apps.md +167 -0
- package/templates/common/.agents/skills/lupine-framework/references/navigation-and-routing.md +54 -0
- package/templates/common/.agents/skills/lupine-framework/references/reactivity-and-state.md +108 -0
- package/templates/common/.agents/skills/lupine-framework/references/styling-and-themes.md +119 -0
- package/templates/common/_env +12 -2
- package/templates/common/apps/server/src/index.ts +2 -1
- package/templates/lupine-template-cv-starter/README.md +5 -0
- package/templates/lupine-template-cv-starter/web/src/index.tsx +1 -10
- package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.tsx +1 -10
- package/templates/lupine-template-doc-starter/README.md +5 -0
- package/templates/lupine-template-doc-starter/web/src/index.tsx +1 -10
- package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.tsx +1 -10
- package/templates/lupine-template-fullstack-starter/README.md +21 -0
- package/templates/lupine-template-fullstack-starter/api/package.json +10 -0
- package/templates/lupine-template-fullstack-starter/api/resources/install.mysql.sql +107 -0
- package/templates/lupine-template-fullstack-starter/api/resources/install.sqlite.sql +75 -0
- package/templates/lupine-template-fullstack-starter/api/src/lang/api-lang-en.ts +39 -0
- package/templates/lupine-template-fullstack-starter/api/src/lang/api-lang-zh-cn.ts +37 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/admin-api.ts +139 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/api.ts +111 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/contact-api.ts +50 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/file-api-base.ts +30 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/root-api.ts +28 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/send-email.ts +47 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/setting-api.ts +60 -0
- package/templates/lupine-template-fullstack-starter/api/src/service/user-api.ts +1041 -0
- package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/lupine.json +10 -1
- package/templates/lupine-template-fullstack-starter/web/assets/android-chrome-192x192.png +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/apple-touch-icon.png +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/favicon-16x16.png +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/favicon-32x32.png +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/icons-font/License-carbon-icons.txt +71 -0
- package/templates/lupine-template-fullstack-starter/web/assets/icons-font/License-material-design.txt +20 -0
- package/templates/lupine-template-fullstack-starter/web/assets/icons-font/i-font.woff2 +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/icons-font/sample.html +124 -0
- package/templates/lupine-template-fullstack-starter/web/assets/icons-font/style.css +103 -0
- package/templates/lupine-template-fullstack-starter/web/assets/images/sample.png +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/lupine-flower.png +0 -0
- package/templates/lupine-template-fullstack-starter/web/assets/lupine.svg +71 -0
- package/templates/lupine-template-fullstack-starter/web/assets/site.webmanifest +14 -0
- package/templates/lupine-template-fullstack-starter/web/icons-font.config.js +129 -0
- package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/package.json +1 -1
- package/templates/lupine-template-fullstack-starter/web/src/admin_dev/admin-about.tsx +16 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin_dev/admin-patch.ts +22 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin_dev/index.html +22 -0
- package/templates/lupine-template-fullstack-starter/web/src/admin_dev/index.tsx +64 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/footer-menu.tsx +52 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/footer.tsx +15 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/header.tsx +75 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/home-search-component.tsx +132 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/login-code-zh.tsx +162 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/login-code.tsx +165 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/login-zh.tsx +118 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/login.tsx +122 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/not-found-page.tsx +12 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/register-zh.tsx +161 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/register.tsx +163 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/reset-password-zh.tsx +166 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/reset-password.tsx +177 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/story-card.tsx +96 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/story-list.tsx +106 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/story-props.ts +34 -0
- package/templates/lupine-template-fullstack-starter/web/src/components/user-info.tsx +84 -0
- package/templates/lupine-template-fullstack-starter/web/src/frames/admin-page-frame.tsx +48 -0
- package/templates/lupine-template-fullstack-starter/web/src/frames/frame1-page-frame.tsx +61 -0
- package/templates/lupine-template-fullstack-starter/web/src/frames/frame2-page-frame.tsx +61 -0
- package/templates/lupine-template-fullstack-starter/web/src/frames/top-frame.tsx +23 -0
- package/templates/lupine-template-fullstack-starter/web/src/frames/user-page-frame.tsx +90 -0
- package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/index.html +6 -0
- package/templates/lupine-template-fullstack-starter/web/src/index.tsx +155 -0
- package/templates/lupine-template-fullstack-starter/web/src/models/client-env-keys.ts +5 -0
- package/templates/lupine-template-fullstack-starter/web/src/models/index.ts +15 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/admin-cfg.tsx +140 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/admin-item-edit.tsx +21 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/admin-item-list.tsx +24 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/admin-user.tsx +150 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/contact.tsx +105 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/page1-page.tsx +38 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/page2-page.tsx +38 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/user-favorite-page.tsx +58 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/user-home-page.tsx +27 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/user-mine-page.tsx +54 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/user-profile-page-zh.tsx +112 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/user-profile-page.tsx +112 -0
- package/templates/lupine-template-fullstack-starter/web/src/pages/user1-page.tsx +57 -0
- package/templates/lupine-template-fullstack-starter/web/src/services/fetch-data.ts +55 -0
- package/templates/lupine-template-fullstack-starter/web/src/services/shared-data.ts +19 -0
- package/templates/lupine-template-fullstack-starter/web/src/styles/base-css.ts +17 -0
- package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/global.css +10 -57
- package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/theme.ts +3 -1
- package/templates/lupine-template-responsive-starter/README.md +7 -0
- package/templates/lupine-template-responsive-starter/web/src/components/input-history-component.tsx +1 -1
- package/templates/lupine-template-responsive-starter/web/src/components/mine-about-page.tsx +2 -1
- package/templates/lupine-template-responsive-starter/web/src/components/mine-premium-page.tsx +2 -1
- package/templates/lupine-template-responsive-starter/web/src/components/mine-settings-page.tsx +8 -17
- package/templates/lupine-template-responsive-starter/web/src/components/mobile-top-search-menu.tsx +15 -27
- package/templates/lupine-template-responsive-starter/web/src/components/note-detail.tsx +2 -8
- package/templates/lupine-template-responsive-starter/web/src/components/note-edit.tsx +26 -36
- package/templates/lupine-template-responsive-starter/web/src/components/note-search-page.tsx +16 -21
- package/templates/lupine-template-responsive-starter/web/src/components/search-input.tsx +9 -9
- package/templates/lupine-template-responsive-starter/web/src/components/side-menu-content.tsx +3 -16
- package/templates/lupine-template-responsive-starter/web/src/frames/app-responsive-frame.tsx +3 -2
- package/templates/lupine-template-responsive-starter/web/src/index.tsx +2 -11
- package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.tsx +1 -10
- package/templates/lupine-template-responsive-starter/web/src/pages/about-page.tsx +3 -14
- package/templates/lupine-template-responsive-starter/web/src/pages/finance-page.tsx +3 -14
- package/templates/lupine-template-responsive-starter/web/src/pages/home-page.tsx +7 -15
- package/templates/lupine-template-responsive-starter/web/src/pages/mine-page.tsx +7 -14
- package/templates/lupine-template-responsive-starter/web/src/pages/tools-page.tsx +3 -14
- package/templates/lupine-template-responsive-starter/web/src/styles/theme.ts +2 -1
- package/templates/common/AI_CONTEXT.md +0 -1002
- package/templates/lupine-template-hello-world/api/package.json +0 -6
- package/templates/lupine-template-hello-world/api/resources/install.sqlite.sql +0 -4
- package/templates/lupine-template-hello-world/api/src/service/root-api.ts +0 -18
- package/templates/lupine-template-hello-world/web/src/index.tsx +0 -73
- package/templates/lupine-template-hello-world/web/src/styles/base-css.ts +0 -1
- /package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/api/resources/config_default.json +0 -0
- /package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/api/src/index.ts +0 -0
- /package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/assets/favicon.ico +0 -0
- /package/templates/{lupine-template-hello-world → lupine-template-fullstack-starter}/web/src/styles/app.css +0 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { CssProps, PageProps, getRenderPageProps, initializePage } from 'lupine.web';
|
|
2
|
+
import { DomUtils, NotificationColor, NotificationMessage } from 'lupine.web.components';
|
|
3
|
+
import { Footer } from './footer';
|
|
4
|
+
import { setCookieUser } from '../services/shared-data';
|
|
5
|
+
|
|
6
|
+
const fetchLogin = async (username: string, code: string) => {
|
|
7
|
+
const data = await getRenderPageProps().renderPageFunctions.fetchData('/api/login', {
|
|
8
|
+
u: username,
|
|
9
|
+
c: code,
|
|
10
|
+
});
|
|
11
|
+
return data.json;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const fetchCode = async (username: string) => {
|
|
15
|
+
const data = await getRenderPageProps().renderPageFunctions.fetchData('/api/reset-code', { u: username });
|
|
16
|
+
return data.json;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const LoginCodePage = async (props: PageProps) => {
|
|
20
|
+
const css: CssProps = {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
flexDirection: 'column',
|
|
23
|
+
width: '100%',
|
|
24
|
+
minHeight: '100%',
|
|
25
|
+
overflowY: 'auto',
|
|
26
|
+
'.top-header': {
|
|
27
|
+
padding: '50px 0',
|
|
28
|
+
margin: 'auto',
|
|
29
|
+
fontSize: '200%',
|
|
30
|
+
},
|
|
31
|
+
'.top-content': {
|
|
32
|
+
flex: '1',
|
|
33
|
+
padding: '8px 16px',
|
|
34
|
+
margin: 'auto',
|
|
35
|
+
// '.login-button, .login-tip': {
|
|
36
|
+
// justifyContent: 'center',
|
|
37
|
+
// },
|
|
38
|
+
'.top-content-box': {
|
|
39
|
+
padding: '20px 40px',
|
|
40
|
+
boxShadow: 'var(--cover-box-shadow)',
|
|
41
|
+
},
|
|
42
|
+
'.login-button button': {
|
|
43
|
+
width: '100%',
|
|
44
|
+
fontSize: '150%',
|
|
45
|
+
height: '40px',
|
|
46
|
+
},
|
|
47
|
+
'.login-tip': {
|
|
48
|
+
color: 'gray',
|
|
49
|
+
fontSize: '90%',
|
|
50
|
+
},
|
|
51
|
+
'.login-tip a': {
|
|
52
|
+
paddingLeft: '10px',
|
|
53
|
+
},
|
|
54
|
+
'.label': {
|
|
55
|
+
width: '200px',
|
|
56
|
+
},
|
|
57
|
+
'.row-box': {
|
|
58
|
+
marginBottom: '16px',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
'.top-footer': {
|
|
62
|
+
padding: '16px 16px 4px 16px',
|
|
63
|
+
margin: 'auto',
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const onCode = async () => {
|
|
68
|
+
const codeButton = DomUtils.bySelector('.code-button') as HTMLButtonElement;
|
|
69
|
+
if (codeButton.classList.contains('disabled')) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const username = DomUtils.getValue('.u-name')!;
|
|
74
|
+
if (!username) {
|
|
75
|
+
NotificationMessage.sendMessage('请输入用户名(邮箱)', NotificationColor.Error);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const auth = await fetchCode(username);
|
|
80
|
+
if (auth.status === 'ok') {
|
|
81
|
+
NotificationMessage.sendMessage('验证码已发送到您的邮箱,请复制到这里登录。', NotificationColor.Success);
|
|
82
|
+
|
|
83
|
+
codeButton.classList.add('disabled');
|
|
84
|
+
setTimeout(() => {
|
|
85
|
+
codeButton.classList.remove('disabled');
|
|
86
|
+
}, 60000);
|
|
87
|
+
} else {
|
|
88
|
+
NotificationMessage.sendMessage(auth.message, NotificationColor.Error);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const onLogin = async () => {
|
|
93
|
+
const codeDom = DomUtils.bySelector('.u-code') as HTMLInputElement;
|
|
94
|
+
const userDom = DomUtils.bySelector('.u-name') as HTMLInputElement;
|
|
95
|
+
const username = userDom.value;
|
|
96
|
+
const code = codeDom.value;
|
|
97
|
+
if (!username || !code) {
|
|
98
|
+
NotificationMessage.sendMessage('请输入用户名和验证码', NotificationColor.Error);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const auth = await fetchLogin(username, code);
|
|
102
|
+
// console.log('====auth', auth);
|
|
103
|
+
if (auth.status === 'error') {
|
|
104
|
+
NotificationMessage.sendMessage(auth.message, NotificationColor.Error);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (auth.result) {
|
|
109
|
+
setCookieUser(auth.user || {});
|
|
110
|
+
initializePage('/');
|
|
111
|
+
// window.location.href = '/';
|
|
112
|
+
} else {
|
|
113
|
+
NotificationMessage.sendMessage(auth.message, NotificationColor.Error);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<div css={css} class='admin-login'>
|
|
119
|
+
<div class='top-header'>
|
|
120
|
+
<div class='top-title'>登录</div>
|
|
121
|
+
</div>
|
|
122
|
+
<div class='top-content login-form-width'>
|
|
123
|
+
<div class='top-content-box'>
|
|
124
|
+
<div class='row-box'>
|
|
125
|
+
<div class='label'>用户名(邮箱):</div>
|
|
126
|
+
<input class='input-base u-name' type='text' value={props.query['email'] || ''} />
|
|
127
|
+
</div>
|
|
128
|
+
<div class='row-box'>
|
|
129
|
+
<button onClick={() => onCode()} class='button-base button-s code-button'>
|
|
130
|
+
发送验证码
|
|
131
|
+
</button>
|
|
132
|
+
</div>
|
|
133
|
+
<div class='row-box'>
|
|
134
|
+
<div class='label'>验证码:</div>
|
|
135
|
+
<div>
|
|
136
|
+
<input class='input-base u-code' type='text' />
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
<div class='row-box login-button'>
|
|
140
|
+
<button onClick={() => onLogin()} class='button-base'>
|
|
141
|
+
登录
|
|
142
|
+
</button>
|
|
143
|
+
</div>
|
|
144
|
+
<div class='row-box login-tip'>* 登录以使用此系统。</div>
|
|
145
|
+
<div class='row-box login-tip'>
|
|
146
|
+
* 没有账号?
|
|
147
|
+
<a href='/register' class='pr-m'>
|
|
148
|
+
注册
|
|
149
|
+
</a>{' '}
|
|
150
|
+
or <a href='/'>首页</a>
|
|
151
|
+
</div>
|
|
152
|
+
<div class='row-box login-tip'>
|
|
153
|
+
* 使用密码登录?<a href='/login'>使用密码登录</a>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
<div class='top-footer'>
|
|
158
|
+
<Footer title="Copyright© 2025 <a href='/'>Home</a>. All Rights Reserved."></Footer>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
162
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { CssProps, PageProps, getRenderPageProps, initializePage } from 'lupine.web';
|
|
2
|
+
import { DomUtils, NotificationColor, NotificationMessage } from 'lupine.web.components';
|
|
3
|
+
import { Footer } from './footer';
|
|
4
|
+
import { setCookieUser } from '../services/shared-data';
|
|
5
|
+
|
|
6
|
+
const fetchLogin = async (username: string, code: string) => {
|
|
7
|
+
const data = await getRenderPageProps().renderPageFunctions.fetchData('/api/login', {
|
|
8
|
+
u: username,
|
|
9
|
+
c: code,
|
|
10
|
+
});
|
|
11
|
+
return data.json;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const fetchCode = async (username: string) => {
|
|
15
|
+
const data = await getRenderPageProps().renderPageFunctions.fetchData('/api/reset-code', { u: username });
|
|
16
|
+
return data.json;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const LoginCodePage = async (props: PageProps) => {
|
|
20
|
+
const css: CssProps = {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
flexDirection: 'column',
|
|
23
|
+
width: '100%',
|
|
24
|
+
minHeight: '100%',
|
|
25
|
+
overflowY: 'auto',
|
|
26
|
+
'.top-header': {
|
|
27
|
+
padding: '50px 0',
|
|
28
|
+
margin: 'auto',
|
|
29
|
+
fontSize: '200%',
|
|
30
|
+
},
|
|
31
|
+
'.top-content': {
|
|
32
|
+
flex: '1',
|
|
33
|
+
padding: '8px 16px',
|
|
34
|
+
margin: 'auto',
|
|
35
|
+
// '.login-button, .login-tip': {
|
|
36
|
+
// justifyContent: 'center',
|
|
37
|
+
// },
|
|
38
|
+
'.top-content-box': {
|
|
39
|
+
padding: '20px 40px',
|
|
40
|
+
boxShadow: 'var(--cover-box-shadow)',
|
|
41
|
+
},
|
|
42
|
+
'.login-button button': {
|
|
43
|
+
width: '100%',
|
|
44
|
+
fontSize: '150%',
|
|
45
|
+
height: '40px',
|
|
46
|
+
},
|
|
47
|
+
'.login-tip': {
|
|
48
|
+
color: 'gray',
|
|
49
|
+
fontSize: '90%',
|
|
50
|
+
},
|
|
51
|
+
'.login-tip a': {
|
|
52
|
+
paddingLeft: '10px',
|
|
53
|
+
},
|
|
54
|
+
'.label': {
|
|
55
|
+
width: '200px',
|
|
56
|
+
},
|
|
57
|
+
'.row-box': {
|
|
58
|
+
marginBottom: '16px',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
'.top-footer': {
|
|
62
|
+
padding: '16px 16px 4px 16px',
|
|
63
|
+
margin: 'auto',
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const onCode = async () => {
|
|
68
|
+
const codeButton = DomUtils.bySelector('.code-button') as HTMLButtonElement;
|
|
69
|
+
if (codeButton.classList.contains('disabled')) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const username = DomUtils.getValue('.u-name')!;
|
|
74
|
+
if (!username) {
|
|
75
|
+
NotificationMessage.sendMessage('Please input username (Email)', NotificationColor.Error);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const auth = await fetchCode(username);
|
|
80
|
+
if (auth.status === 'ok') {
|
|
81
|
+
NotificationMessage.sendMessage(
|
|
82
|
+
'Authentication code is sent to your email, please copy it here to login.',
|
|
83
|
+
NotificationColor.Success
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
codeButton.classList.add('disabled');
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
codeButton.classList.remove('disabled');
|
|
89
|
+
}, 60000);
|
|
90
|
+
} else {
|
|
91
|
+
NotificationMessage.sendMessage(auth.message, NotificationColor.Error);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const onLogin = async () => {
|
|
96
|
+
const codeDom = DomUtils.bySelector('.u-code') as HTMLInputElement;
|
|
97
|
+
const userDom = DomUtils.bySelector('.u-name') as HTMLInputElement;
|
|
98
|
+
const username = userDom.value;
|
|
99
|
+
const code = codeDom.value;
|
|
100
|
+
if (!username || !code) {
|
|
101
|
+
NotificationMessage.sendMessage('Please input username and authentication code', NotificationColor.Error);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const auth = await fetchLogin(username, code);
|
|
105
|
+
// console.log('====auth', auth);
|
|
106
|
+
if (auth.status === 'error') {
|
|
107
|
+
NotificationMessage.sendMessage(auth.message, NotificationColor.Error);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (auth.result) {
|
|
112
|
+
setCookieUser(auth.user || {});
|
|
113
|
+
initializePage('/');
|
|
114
|
+
// window.location.href = '/';
|
|
115
|
+
} else {
|
|
116
|
+
NotificationMessage.sendMessage(auth.message, NotificationColor.Error);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<div css={css} class='admin-login'>
|
|
122
|
+
<div class='top-header'>
|
|
123
|
+
<div class='top-title'>Login</div>
|
|
124
|
+
</div>
|
|
125
|
+
<div class='top-content login-form-width'>
|
|
126
|
+
<div class='top-content-box'>
|
|
127
|
+
<div class='row-box'>
|
|
128
|
+
<div class='label'>Username (Email):</div>
|
|
129
|
+
<input class='input-base u-name' type='text' value={props.query['email'] || ''} />
|
|
130
|
+
</div>
|
|
131
|
+
<div class='row-box'>
|
|
132
|
+
<button onClick={() => onCode()} class='button-base button-s code-button'>
|
|
133
|
+
Send Authentication Code
|
|
134
|
+
</button>
|
|
135
|
+
</div>
|
|
136
|
+
<div class='row-box'>
|
|
137
|
+
<div class='label'>Authentication Code:</div>
|
|
138
|
+
<div>
|
|
139
|
+
<input class='input-base u-code' type='text' />
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
<div class='row-box login-button'>
|
|
143
|
+
<button onClick={() => onLogin()} class='button-base'>
|
|
144
|
+
Login
|
|
145
|
+
</button>
|
|
146
|
+
</div>
|
|
147
|
+
<div class='row-box login-tip'>* Login to use this system.</div>
|
|
148
|
+
<div class='row-box login-tip'>
|
|
149
|
+
* Don't have an account?
|
|
150
|
+
<a href='/register' class='pr-m'>
|
|
151
|
+
Go to Register
|
|
152
|
+
</a>{' '}
|
|
153
|
+
or <a href='/'>Home</a>
|
|
154
|
+
</div>
|
|
155
|
+
<div class='row-box login-tip'>
|
|
156
|
+
* Password login?<a href='/login'>Login with password</a>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
<div class='top-footer'>
|
|
161
|
+
<Footer title="Copyright© 2025 <a href='/'>Home</a>. All Rights Reserved."></Footer>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { CssProps, PageProps, getRenderPageProps, initializePage } from 'lupine.web';
|
|
2
|
+
import { DomUtils, NotificationColor, NotificationMessage } from 'lupine.web.components';
|
|
3
|
+
import { Footer } from './footer';
|
|
4
|
+
import { setCookieUser } from '../services/shared-data';
|
|
5
|
+
|
|
6
|
+
const fetchLogin = async (username: string, password: string) => {
|
|
7
|
+
const data = await getRenderPageProps().renderPageFunctions.fetchData('/api/login', { u: username, p: password });
|
|
8
|
+
return data.json;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const LoginPage = async (props: PageProps) => {
|
|
12
|
+
const css: CssProps = {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
width: '100%',
|
|
16
|
+
minHeight: '100%',
|
|
17
|
+
overflowY: 'auto',
|
|
18
|
+
'.top-header': {
|
|
19
|
+
padding: '50px 0',
|
|
20
|
+
margin: 'auto',
|
|
21
|
+
fontSize: '200%',
|
|
22
|
+
},
|
|
23
|
+
'.top-content': {
|
|
24
|
+
flex: '1',
|
|
25
|
+
padding: '8px 16px',
|
|
26
|
+
margin: 'auto',
|
|
27
|
+
'.top-content-box': {
|
|
28
|
+
padding: '20px 40px',
|
|
29
|
+
boxShadow: 'var(--cover-box-shadow)',
|
|
30
|
+
},
|
|
31
|
+
'.login-button button': {
|
|
32
|
+
width: '100%',
|
|
33
|
+
fontSize: '150%',
|
|
34
|
+
height: '40px',
|
|
35
|
+
},
|
|
36
|
+
'.login-tip': {
|
|
37
|
+
color: 'gray',
|
|
38
|
+
fontSize: '90%',
|
|
39
|
+
},
|
|
40
|
+
'.login-tip a': {
|
|
41
|
+
paddingLeft: '10px',
|
|
42
|
+
},
|
|
43
|
+
'.label': {
|
|
44
|
+
width: '200px',
|
|
45
|
+
},
|
|
46
|
+
'.row-box': {
|
|
47
|
+
marginBottom: '16px',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
'.top-footer': {
|
|
51
|
+
padding: '16px 16px 4px 16px',
|
|
52
|
+
margin: 'auto',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const onLogin = async () => {
|
|
57
|
+
const username = DomUtils.getValue('.u-name')!;
|
|
58
|
+
const password = DomUtils.getValue('.u-pass')!;
|
|
59
|
+
if (!username || !password) {
|
|
60
|
+
NotificationMessage.sendMessage('Please input username and password', NotificationColor.Error);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const auth = await fetchLogin(username, password);
|
|
64
|
+
// console.log('====auth', auth);
|
|
65
|
+
if (auth.status === 'error' && auth.action === 'activate') {
|
|
66
|
+
NotificationMessage.sendMessage(auth.message, NotificationColor.Error);
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
initializePage('/login-code?email=' + username);
|
|
69
|
+
}, 1000);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (auth.result) {
|
|
74
|
+
setCookieUser(auth.user || {});
|
|
75
|
+
initializePage('/');
|
|
76
|
+
} else {
|
|
77
|
+
NotificationMessage.sendMessage(auth.message, NotificationColor.Error);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div css={css} class='admin-login'>
|
|
83
|
+
<div class='top-header'>
|
|
84
|
+
<div class='top-title'>登陆</div>
|
|
85
|
+
</div>
|
|
86
|
+
<div class='top-content login-form-width'>
|
|
87
|
+
<div class='top-content-box'>
|
|
88
|
+
<div class='row-box'>
|
|
89
|
+
<div class='label'>用户名 (Email):</div>
|
|
90
|
+
<input class='input-base u-name' type='text' />
|
|
91
|
+
</div>
|
|
92
|
+
<div class='row-box'>
|
|
93
|
+
<div class='label'>密码:</div>
|
|
94
|
+
<input class='input-base u-pass' type='password' />
|
|
95
|
+
</div>
|
|
96
|
+
<div class='row-box login-button'>
|
|
97
|
+
<button onClick={() => onLogin()} class='button-base'>
|
|
98
|
+
登录
|
|
99
|
+
</button>
|
|
100
|
+
</div>
|
|
101
|
+
<div class='row-box login-tip'>* 登录系统</div>
|
|
102
|
+
<div class='row-box login-tip'>
|
|
103
|
+
* 还没有账户?<a href='/register'>去注册</a>或者<a href='/'>首页</a>
|
|
104
|
+
</div>
|
|
105
|
+
<div class='row-box login-tip'>
|
|
106
|
+
* 忘记了密码?<a href='/reset-pw'>重新设置密码</a>
|
|
107
|
+
</div>
|
|
108
|
+
<div class='row-box login-tip'>
|
|
109
|
+
* 无密码登录?<a href='/login-code'>用验证码登录</a>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
<div class='top-footer'>
|
|
114
|
+
<Footer title="Copyright© 2025 <a href='/'>Home</a>. All Rights Reserved."></Footer>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { CssProps, PageProps, getRenderPageProps, initializePage } from 'lupine.web';
|
|
2
|
+
import { DomUtils, NotificationColor, NotificationMessage } from 'lupine.web.components';
|
|
3
|
+
import { Footer } from './footer';
|
|
4
|
+
import { setCookieUser } from '../services/shared-data';
|
|
5
|
+
|
|
6
|
+
const fetchLogin = async (username: string, password: string) => {
|
|
7
|
+
const data = await getRenderPageProps().renderPageFunctions.fetchData('/api/login', { u: username, p: password });
|
|
8
|
+
return data.json;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const LoginPage = async (props: PageProps) => {
|
|
12
|
+
const css: CssProps = {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
width: '100%',
|
|
16
|
+
minHeight: '100%',
|
|
17
|
+
overflowY: 'auto',
|
|
18
|
+
'.top-header': {
|
|
19
|
+
padding: '50px 0',
|
|
20
|
+
margin: 'auto',
|
|
21
|
+
fontSize: '200%',
|
|
22
|
+
},
|
|
23
|
+
'.top-content': {
|
|
24
|
+
flex: '1',
|
|
25
|
+
padding: '8px 16px',
|
|
26
|
+
margin: 'auto',
|
|
27
|
+
'.top-content-box': {
|
|
28
|
+
padding: '20px 40px',
|
|
29
|
+
boxShadow: 'var(--cover-box-shadow)',
|
|
30
|
+
},
|
|
31
|
+
'.login-button button': {
|
|
32
|
+
width: '100%',
|
|
33
|
+
fontSize: '150%',
|
|
34
|
+
height: '40px',
|
|
35
|
+
},
|
|
36
|
+
'.login-tip': {
|
|
37
|
+
color: 'gray',
|
|
38
|
+
fontSize: '90%',
|
|
39
|
+
},
|
|
40
|
+
'.login-tip a': {
|
|
41
|
+
paddingLeft: '10px',
|
|
42
|
+
},
|
|
43
|
+
'.label': {
|
|
44
|
+
width: '200px',
|
|
45
|
+
},
|
|
46
|
+
'.row-box': {
|
|
47
|
+
marginBottom: '16px',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
'.top-footer': {
|
|
51
|
+
padding: '16px 16px 4px 16px',
|
|
52
|
+
margin: 'auto',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const onLogin = async () => {
|
|
57
|
+
const username = DomUtils.getValue('.u-name')!;
|
|
58
|
+
const password = DomUtils.getValue('.u-pass')!;
|
|
59
|
+
if (!username || !password) {
|
|
60
|
+
NotificationMessage.sendMessage('Please input username and password', NotificationColor.Error);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const auth = await fetchLogin(username, password);
|
|
64
|
+
// console.log('====auth', auth);
|
|
65
|
+
if (auth.status === 'error' && auth.action === 'activate') {
|
|
66
|
+
NotificationMessage.sendMessage(auth.message, NotificationColor.Error);
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
initializePage('/login-code?email=' + username);
|
|
69
|
+
}, 1000);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (auth.result) {
|
|
74
|
+
setCookieUser(auth.user || {});
|
|
75
|
+
initializePage('/');
|
|
76
|
+
} else {
|
|
77
|
+
NotificationMessage.sendMessage(auth.message, NotificationColor.Error);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div css={css} class='admin-login'>
|
|
83
|
+
<div class='top-header'>
|
|
84
|
+
<div class='top-title'>Login</div>
|
|
85
|
+
</div>
|
|
86
|
+
<div class='top-content login-form-width'>
|
|
87
|
+
<div class='top-content-box'>
|
|
88
|
+
<div class='row-box'>
|
|
89
|
+
<div class='label'>Username (Email):</div>
|
|
90
|
+
<input class='input-base u-name' type='text' />
|
|
91
|
+
</div>
|
|
92
|
+
<div class='row-box'>
|
|
93
|
+
<div class='label'>Password:</div>
|
|
94
|
+
<input class='input-base u-pass' type='password' />
|
|
95
|
+
</div>
|
|
96
|
+
<div class='row-box login-button'>
|
|
97
|
+
<button onClick={() => onLogin()} class='button-base'>
|
|
98
|
+
Login
|
|
99
|
+
</button>
|
|
100
|
+
</div>
|
|
101
|
+
<div class='row-box login-tip'>* Login to use this system.</div>
|
|
102
|
+
<div class='row-box login-tip'>
|
|
103
|
+
* Don't have an account?
|
|
104
|
+
<a href='/register' class='pr-m'>
|
|
105
|
+
Go to Register
|
|
106
|
+
</a>{' '}
|
|
107
|
+
or <a href='/'>Home</a>
|
|
108
|
+
</div>
|
|
109
|
+
<div class='row-box login-tip'>
|
|
110
|
+
* Forgot password?<a href='/reset-pw'>Reset Password</a>
|
|
111
|
+
</div>
|
|
112
|
+
<div class='row-box login-tip'>
|
|
113
|
+
* Passwordless login?<a href='/login-code'>Login with code</a>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
<div class='top-footer'>
|
|
118
|
+
<Footer title="Copyright© 2025 <a href='/'>Home</a>. All Rights Reserved."></Footer>
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
};
|