fix: 修复上传版本500错误 + 优化App冷启动通知请求
- fix(admin-service): versionCode 兜底从 Date.now() 改为 1,避免超出 PostgreSQL integer 范围 - fix(genex-mobile): NotificationBadgeManager 加登录检查,未登录跳过API请求 - fix(genex-mobile): 将通知徽章初始化移至首帧后执行,消除冷启动DNS竞争 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ce9cc5b72e
commit
4369aecf60
|
|
@ -110,7 +110,7 @@ export class AdminVersionController {
|
|||
: (parsedInfo.platform as Platform);
|
||||
const versionCode = body.versionCode
|
||||
? parseInt(body.versionCode, 10)
|
||||
: parsedInfo.versionCode || Date.now();
|
||||
: parsedInfo.versionCode || 1;
|
||||
const versionName = body.versionName || parsedInfo.versionName || '1.0.0';
|
||||
const buildNumber = body.buildNumber || versionCode.toString();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:async';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import '../services/auth_service.dart';
|
||||
import '../services/notification_service.dart';
|
||||
|
||||
/// 未读通知徽章管理器
|
||||
|
|
@ -50,6 +51,7 @@ class NotificationBadgeManager with WidgetsBindingObserver {
|
|||
}
|
||||
|
||||
Future<void> _loadUnreadCount() async {
|
||||
if (AuthService.instance.authState.value == null) return;
|
||||
try {
|
||||
final notifCount = await _notificationService!.getUnreadCount();
|
||||
final announcementCount = await _notificationService!.getAnnouncementUnreadCount();
|
||||
|
|
|
|||
|
|
@ -64,9 +64,6 @@ Future<void> main() async {
|
|||
// 初始化推送服务(无 Firebase 配置时静默失败)
|
||||
await PushService().initialize();
|
||||
|
||||
// 初始化通知徽章管理器
|
||||
NotificationBadgeManager().initialize();
|
||||
|
||||
// 恢复用户语言偏好(无选择时跟随系统语言)
|
||||
await LocaleManager.init();
|
||||
|
||||
|
|
@ -110,7 +107,7 @@ class _GenexConsumerAppState extends ConsumerState<GenexConsumerApp> {
|
|||
});
|
||||
}
|
||||
|
||||
// 遥测服务初始化(需 BuildContext 采集设备信息,在首帧渲染后执行)
|
||||
// 遥测服务 + 通知徽章管理器:首帧渲染后初始化,避免冷启动 DNS 竞争
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
final auth = AuthService.instance.authState.value;
|
||||
await TelemetryService().initialize(
|
||||
|
|
@ -121,6 +118,7 @@ class _GenexConsumerAppState extends ConsumerState<GenexConsumerApp> {
|
|||
if (auth != null) {
|
||||
TelemetryService().setAccessToken(auth.accessToken);
|
||||
}
|
||||
NotificationBadgeManager().initialize();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -143,6 +141,9 @@ class _GenexConsumerAppState extends ConsumerState<GenexConsumerApp> {
|
|||
// Token 双重过期:AuthService 已清空,通知 Riverpod 同步
|
||||
ref.read(authProvider.notifier).onSessionExpired();
|
||||
_navigatorKey.currentState?.pushNamedAndRemoveUntil('/', (_) => false);
|
||||
} else if (legacyResult != null) {
|
||||
// 登录成功后立即刷新通知徽章
|
||||
NotificationBadgeManager().refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue