Skip to content

Commit 78921f9

Browse files
committed
optimize: 登录时的输入兼容性优化
1 parent c8a64cc commit 78921f9

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

CHANGELOG.MD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
# 20.3.13
66

7+
## 优化
8+
9+
- 登录时的输入兼容性优化
10+
711
# 20.3.12
812

913
## 优化

lib/user/login.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,19 @@ class LoginState extends State<LoginView> {
170170
}
171171
state.save();
172172
try {
173+
// 对字符串做简单的兼容性处理
174+
if (_baseUrl.endsWith("/")) {
175+
_baseUrl = _baseUrl.substring(0, _baseUrl.length - 1);
176+
}
177+
_username = _username.trim();
178+
_password = _password.trim();
173179
await AuthApi().login(_baseUrl, _username, _password);
174180
Toast.show(context, "登录成功");
175-
Navigator.pushReplacement(context,
176-
MaterialPageRoute(builder: (context) => const MyApp()));
181+
Navigator.pushReplacement(
182+
context, MaterialPageRoute(builder: (context) => const MyApp()));
177183
} catch (e) {
178-
Toast.show(context, "登录失败 by username: $_username, password: $_password, error: $e");
184+
Toast.show(context,
185+
"登录失败 by username: $_username, password: $_password, error: $e");
179186
} finally {}
180187
}
181188
}

0 commit comments

Comments
 (0)