fix(mobile-next): 登录失败改为顶部 toast,2 秒后自动消失
改 company_login_page.dart 与 company_login_logic.dart。 保留「工号或密码不正确」「网络异常,请稍后重试」;去掉按钮下方常驻错误字。 Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Cursor
multica-agent
parent
87a5930906
commit
092f513708
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:openim/core/controller/im_controller.dart';
|
||||
@@ -15,12 +17,14 @@ class CompanyLoginLogic extends GetxController {
|
||||
final staffError = RxnString();
|
||||
final pwdError = RxnString();
|
||||
final toast = RxnString();
|
||||
Timer? _toastTimer;
|
||||
|
||||
final _auth = AuthApi();
|
||||
final _im = Get.find<IMController>();
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_toastTimer?.cancel();
|
||||
staffCtrl.dispose();
|
||||
pwdCtrl.dispose();
|
||||
super.onClose();
|
||||
@@ -28,6 +32,14 @@ class CompanyLoginLogic extends GetxController {
|
||||
|
||||
void toggleObscure() => obscure.toggle();
|
||||
|
||||
void _showToast(String msg) {
|
||||
toast.value = msg;
|
||||
_toastTimer?.cancel();
|
||||
_toastTimer = Timer(const Duration(seconds: 2), () {
|
||||
toast.value = null;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> submit() async {
|
||||
if (submitting.value) return;
|
||||
final staffNo = staffCtrl.text.trim();
|
||||
@@ -58,10 +70,10 @@ class CompanyLoginLogic extends GetxController {
|
||||
Get.find<CacheController>().resetCache();
|
||||
AppNavigator.startMain(conversations: conversations);
|
||||
} on AuthException catch (e) {
|
||||
toast.value = e.network ? '网络异常,请稍后重试' : '工号或密码不正确';
|
||||
_showToast(e.network ? '网络异常,请稍后重试' : '工号或密码不正确');
|
||||
} catch (e, s) {
|
||||
Logger.print('company login e: $e $s');
|
||||
toast.value = '网络异常,请稍后重试';
|
||||
_showToast('网络异常,请稍后重试');
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user