fix(genex-mobile): 还原 api.gogenex.com + 增加更新检测日志

.cn 域名因未 ICP 备案被 ISP 拦截,继续使用 api.gogenex.com (HK IP)。
增加 [UpdateService] 和 [VersionChecker] 详细日志便于调试。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-03 23:17:12 -08:00
parent 12a665f2ba
commit abb358100d
3 changed files with 11 additions and 3 deletions

View File

@ -41,6 +41,7 @@ class UpdateService {
Future<void> checkForUpdate(BuildContext context) async {
if (!_isInitialized || !_config.enabled) return;
debugPrint('[UpdateService] 开始检查更新 channel=${_config.channel} url=${_config.apiBaseUrl}');
_isShowingUpdateDialog = true;
try {
switch (_config.channel) {
@ -53,6 +54,7 @@ class UpdateService {
}
} finally {
_isShowingUpdateDialog = false;
debugPrint('[UpdateService] 更新检查完成');
}
}

View File

@ -67,12 +67,18 @@ class VersionChecker {
Future<VersionInfo?> checkForUpdate() async {
try {
final currentInfo = await getCurrentVersion();
debugPrint('[VersionChecker] 当前 buildNumber=${currentInfo.buildNumber} 开始检查...');
final latestInfo = await fetchLatestVersion();
if (latestInfo == null) return null;
if (latestInfo == null) {
debugPrint('[VersionChecker] 服务端返回无需更新');
return null;
}
final currentCode = int.tryParse(currentInfo.buildNumber) ?? 0;
debugPrint('[VersionChecker] 服务端最新 versionCode=${latestInfo.versionCode} 本地=$currentCode');
if (latestInfo.versionCode > currentCode) {
debugPrint('[VersionChecker] 发现新版本 ${latestInfo.version},准备弹窗');
return latestInfo;
}

View File

@ -40,9 +40,9 @@ import 'features/coupons/presentation/pages/wallet_coupons_page.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Nginx Kong .cn
// Nginx Kong
UpdateService().initialize(UpdateConfig.selfHosted(
apiBaseUrl: 'https://api.gogenex.cn',
apiBaseUrl: 'https://api.gogenex.com',
enabled: true,
));