@zhang_libo/resource-hub 1.0.12 → 1.0.13
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 +1 -1
- package/public/pages/LoginPage.jsx +12 -1
package/package.json
CHANGED
|
@@ -36,6 +36,8 @@ function LoginPage() {
|
|
|
36
36
|
}));
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
const formRef = React.useRef(null);
|
|
40
|
+
|
|
39
41
|
const handleFieldBlur = (field) => {
|
|
40
42
|
setErrors((prev) => ({
|
|
41
43
|
...prev,
|
|
@@ -43,6 +45,13 @@ function LoginPage() {
|
|
|
43
45
|
}));
|
|
44
46
|
};
|
|
45
47
|
|
|
48
|
+
const handleKeyDown = (e) => {
|
|
49
|
+
if (e.key === 'Enter' && !e.nativeEvent.isComposing) {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
formRef.current?.requestSubmit();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
46
55
|
const handleSubmit = async (e) => {
|
|
47
56
|
e.preventDefault();
|
|
48
57
|
const nextErrors = validateForm();
|
|
@@ -88,7 +97,7 @@ function LoginPage() {
|
|
|
88
97
|
subtitle={config.siteSubtitle || '统一管理与访问你的资源'}
|
|
89
98
|
logoLetter={logoLetter}
|
|
90
99
|
>
|
|
91
|
-
<form onSubmit={handleSubmit}>
|
|
100
|
+
<form ref={formRef} onSubmit={handleSubmit}>
|
|
92
101
|
<div style={authStyles.field}>
|
|
93
102
|
<label style={authStyles.label}>用户名</label>
|
|
94
103
|
<input
|
|
@@ -101,6 +110,7 @@ function LoginPage() {
|
|
|
101
110
|
aria-invalid={!!errors.username}
|
|
102
111
|
onChange={(e) => updateField('username', e.target.value)}
|
|
103
112
|
onBlur={() => handleFieldBlur('username')}
|
|
113
|
+
onKeyDown={handleKeyDown}
|
|
104
114
|
placeholder="请输入用户名"
|
|
105
115
|
disabled={loading}
|
|
106
116
|
style={authStyles.input(!!errors.username)}
|
|
@@ -120,6 +130,7 @@ function LoginPage() {
|
|
|
120
130
|
aria-invalid={!!errors.password}
|
|
121
131
|
onChange={(e) => updateField('password', e.target.value)}
|
|
122
132
|
onBlur={() => handleFieldBlur('password')}
|
|
133
|
+
onKeyDown={handleKeyDown}
|
|
123
134
|
placeholder="请输入密码"
|
|
124
135
|
disabled={loading}
|
|
125
136
|
style={authStyles.input(!!errors.password, true)}
|