@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhang_libo/resource-hub",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "资源导航系统 - 集中整理与维护站点、工具、知识库与链接,支持用户登录、收藏、访问历史与后台管理",
5
5
  "keywords": [
6
6
  "resource",
@@ -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)}