import 'package:package_info_plus/package_info_plus.dart'; /// 全局配置常量(域名发现、公共请求头、版本号,对应《01-开发文档》5.5/5.6/5.7) class AppConfig { AppConfig._(); /// App 版本(运行时从 PackageInfo 读取,始终与 APK 真实 versionName/versionCode 一致; /// 不要改回硬编码——硬编码一旦与 pubspec 脱节,老用户会无限收到更新提示) static late final String appVersion; static late final int appVersionCode; /// 启动时初始化版本信息(main() 中 runApp 前必须调用) static Future initVersion() async { final info = await PackageInfo.fromPlatform(); appVersion = info.version; appVersionCode = int.tryParse(info.buildNumber) ?? 0; } /// 平台标识(运行时按 iOS/Android 判定,见 platformName) static const String platformNameIOS = 'ios'; static const String platformNameAndroid = 'android'; /// 域名发现:DNS TXT 记录域名与兜底域名后缀 static const String dnsTxtHost = 'txt.256kb.top'; static const String fallbackDomainSuffix = '_jsnbhh.vip'; /// DoH 服务(阿里 / 腾讯),TXT 解析走 JSON API static const List dohServers = [ 'https://223.5.5.5/resolve', 'https://119.29.29.29/dns-query', ]; /// 缓存域名连续失败达到该阈值后,重新走完整发现流程 static const int domainFailureThreshold = 3; /// 开发调试:--dart-define=API_BASE=http://localhost:8000 可直接指定本地服务, /// 跳过域名发现(生产构建不传即走 TXT/兜底逻辑) static const String devApiBase = String.fromEnvironment('API_BASE'); /// 微信支付 iOS 回跳 Universal Link: /// --dart-define=WECHAT_UNIVERSAL_LINK=https://app.256kb.top/wechat /// 须与 pubspec.yaml 中 fluwx.ios.universal_link 保持一致;未传时 iOS 端无法回跳 static const String wechatUniversalLink = String.fromEnvironment('WECHAT_UNIVERSAL_LINK'); /// 请求超时 static const Duration connectTimeout = Duration(seconds: 10); static const Duration receiveTimeout = Duration(seconds: 20); }