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:
hailin 2026-03-06 08:48:09 -08:00
parent ce9cc5b72e
commit 4369aecf60
3 changed files with 8 additions and 5 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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();
}
}