fix: 修复手机连不上服务器时启动页无限转圈(B-58)

- 启动页先读本地凭证:无凭证(首次打开)直接进登录页,不再先等 SDK 初始化
- SDK init/login 加 20s 超时;init 用共享 Future 防止超时后重复触发 initSDK
- 登录页对 IM 登录超时给出明确提示(确认手机连着公司内网 WiFi)
- 修复 flutter create 模板遗留的 widget_test(引用不存在的 MyApp),改为登录页渲染冒烟测试
- 版本号 1.0.1+2
This commit is contained in:
KIMI
2026-08-15 14:54:52 +08:00
parent d481e1bc2f
commit 3b5c76cac4
5 changed files with 45 additions and 40 deletions
+16 -10
View File
@@ -77,18 +77,24 @@ class _SplashGateState extends State<SplashGate> {
Future<void> _boot() async {
final im = IMService.instance;
// 先读本地凭证:没有凭证(首次打开)直接去登录页,
// 不在启动页等 SDK 初始化——服务器连不上时 initSDK 可能长时间不返回,
// 不能让启动页一直转圈。
final credential = await LoginScreen.readCredential();
if (credential == null) {
if (!mounted) return;
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_) => const LoginScreen()));
return;
}
try {
await im.init();
final credential = await LoginScreen.readCredential();
if (credential != null) {
await im.login(userID: credential.$1, token: credential.$2);
CallService.instance.start();
if (!mounted) return;
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_) => const HomeScreen()));
return;
}
await im.init().timeout(const Duration(seconds: 20));
await im.login(userID: credential.$1, token: credential.$2).timeout(const Duration(seconds: 20));
CallService.instance.start();
if (!mounted) return;
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_) => const HomeScreen()));
return;
} catch (_) {
// 自动登录失败(token 失效等):清凭证回登录页
// 自动登录失败(token 失效、服务器连不上等):清凭证回登录页
await LoginScreen.clearCredential();
}
if (!mounted) return;