import 'package:flutter/foundation.dart'; import 'package:yumi/app/config/app_config.dart'; import 'package:yumi/app/config/business_logic_strategy.dart'; import 'package:yumi/app/config/strategies/variant1_business_logic_strategy.dart'; /// 马甲包配置 class SCVariant1Config implements AppConfig { BusinessLogicStrategy? _businessLogicStrategy; @override String get appName => 'yumi'; // 马甲包应用名称 @override String get packageName => 'com.org.yumi'; @override String get apiHost => const String.fromEnvironment( 'API_HOST', defaultValue: 'https://jvapi.haiyihy.com/', ); // 默认连线上环境,本地调试可通过 --dart-define=API_HOST 覆盖 @override String get imgHost => 'https://img.atuchat.com/'; // 测试图片服务器,上架前需替换为正式域名 @override String get privacyAgreementUrl => 'https://h5.haiyihy.com/privacy.html'; // 正式隐私政策页面 @override String get userAgreementUrl => 'https://h5.haiyihy.com/service.html'; // 正式用户协议页面 @override String get appDownloadUrlGoogle => 'https://play.google.com/store/apps/details?id=$packageName'; @override String get appDownloadUrlApple => 'https://apps.apple.com/us/app/atuchat/id1234567890'; // 需要更新为真实App Store ID @override String get anchorAgentUrl => 'https://h5.haiyihy.com/apply/index.html'; // 正式 H5 页面 @override String get hostCenterUrl => 'https://h5.haiyihy.com/host-center/index.html'; // 正式 H5 页面 @override String get bdCenterUrl => 'https://h5.haiyihy.com/bd-center/index.html'; // 正式 H5 页面 @override String get bdLeaderUrl => 'https://h5.haiyihy.com/bd-leader-center/index.html'; // 正式 H5 页面 @override String get coinSellerUrl => 'https://h5.haiyihy.com/coin-seller/index.html'; // 正式 H5 页面 @override String get adminUrl => 'https://h5.haiyihy.com/admin-center/index.html'; // 正式 H5 页面 @override String get agencyCenterUrl => 'https://h5.haiyihy.com/agency-center/index.html'; // 正式 H5 页面 @override String get gamesKingUrl => 'https://h5.haiyihy.com/games-king/index.html'; // 正式 H5 页面 @override String get wealthRankUrl => 'https://h5.haiyihy.com/ranking/index.html?first=Wealth'; // 正式 H5 页面 @override String get charmRankUrl => 'https://h5.haiyihy.com/ranking/index.html?first=Charm'; // 正式 H5 页面 @override String get roomRankUrl => 'https://h5.haiyihy.com/ranking/index.html?first=Room'; // 正式 H5 页面 @override String get inviteNewUserUrl => 'https://h5.haiyihy.com/invitation/invite-new-user/index.html'; // 正式 H5 页面 @override int get primaryColor => 0xffFF5722; // 不同主色(橙色) @override String get tencentImAppid => '20036101'; @override String get agoraRtcAppid => 'ceb9e2620d454bca9725f7a7f11d4019'; @override num get gameAppid => 9999999999; // 需要注册新的游戏服务账户并获取独立App ID @override String get gameAppChannel => 'yumi'; @override String get bigBroadcastGroup => '@TGS#2RUK4PK5C2'; @override String get imAdmin => 'c2c_yumiadmin'; @override bool get isReview => true; @override bool get isGiftSpecialEffects => true; @override bool get isEntryVehicleAnimation => true; @override bool get isFloatingAnimationInGlobal => true; @override bool get isLuckGiftSpecialEffects => true; @override Map get featureFlags => { 'giftSpecialEffects': isGiftSpecialEffects, 'entryVehicleAnimation': isEntryVehicleAnimation, 'floatingAnimationInGlobal': isFloatingAnimationInGlobal, 'luckGiftSpecialEffects': isLuckGiftSpecialEffects, }; @override BusinessLogicStrategy get businessLogicStrategy { return _businessLogicStrategy ??= Variant1BusinessLogicStrategy(); } @override Map toMap() { return { 'appName': appName, 'packageName': packageName, 'apiHost': apiHost, 'imgHost': imgHost, 'privacyAgreementUrl': privacyAgreementUrl, 'userAgreementUrl': userAgreementUrl, 'primaryColor': primaryColor, 'tencentImAppid': tencentImAppid, 'agoraRtcAppid': agoraRtcAppid, 'gameAppid': gameAppid, 'gameAppChannel': gameAppChannel, 'bigBroadcastGroup': bigBroadcastGroup, 'imAdmin': imAdmin, 'isReview': isReview, 'isGiftSpecialEffects': isGiftSpecialEffects, 'isEntryVehicleAnimation': isEntryVehicleAnimation, 'isFloatingAnimationInGlobal': isFloatingAnimationInGlobal, 'isLuckGiftSpecialEffects': isLuckGiftSpecialEffects, 'featureFlags': featureFlags, 'businessLogicStrategy': 'Variant1BusinessLogicStrategy', }; } @override void validate() { final errors = []; // 检查API主机地址 if (apiHost.isEmpty || !apiHost.startsWith('http')) { errors.add('API主机地址无效或未设置'); } // 如果有错误,根据模式处理 if (errors.isNotEmpty) { final errorMessage = '应用配置验证失败:\n${errors.join('\n')}'; if (kDebugMode) { // 调试模式下只输出警告,不阻止应用启动(方便开发) debugPrint('⚠️ 警告: $errorMessage'); debugPrint('⚠️ 在调试模式下,应用将继续启动,但某些功能可能无法正常工作'); } else { // 发布模式下抛出异常,阻止应用启动 throw StateError(errorMessage); } } else { debugPrint('应用配置验证通过'); } } }