import 'package:yumi/app/config/app_config.dart'; import 'package:yumi/app/config/business_logic_strategy.dart'; class SCGlobalConfig { static const Set _knownLowPerformanceModels = {"redmi 14c"}; static const String floatingBroadcastScopeOff = "off"; static const String floatingBroadcastScopeRoom = "room"; static const String floatingBroadcastScopeAll = "all"; static String get apiHost => AppConfig.current.apiHost; static String get imgHost => AppConfig.current.imgHost; static String get privacyAgreementUrl => AppConfig.current.privacyAgreementUrl; static String get userAgreementUrl => AppConfig.current.userAgreementUrl; // 以下URL从AppConfig获取 static String get anchorAgentUrl => AppConfig.current.anchorAgentUrl; static String get hostCenterUrl => AppConfig.current.hostCenterUrl; static String get bdCenterUrl => AppConfig.current.bdCenterUrl; static String get bdLeaderUrl => AppConfig.current.bdLeaderUrl; static String get coinSellerUrl => AppConfig.current.coinSellerUrl; static String get adminUrl => AppConfig.current.adminUrl; static String get managerCenterUrl => AppConfig.current.managerCenterUrl; static String get agencyCenterUrl => AppConfig.current.agencyCenterUrl; static String get gamesKingUrl => AppConfig.current.gamesKingUrl; // 应用下载链接需要根据Flavor调整 static String get appDownloadUrlGoogle => AppConfig.current.appDownloadUrlGoogle; static String get appDownloadUrlApple => AppConfig.current.appDownloadUrlApple; ///语言 static String lang = "en"; ///设备号 static String imei = ""; ///版本 static String version = "1.0.0"; static String build = "1"; static String model = "SM-G9550"; static String sysVersion = "9"; static int sdkInt = 28; static int processorCount = 0; static bool isLowRamDevice = false; static bool _isLowPerformanceDevice = false; ///高于这个值才播放特效,避免低性能手机卡顿 static int maxSdkNoAnim = 27; ///渠道SocialChat static String channel = "Google"; static String origin = "LIKEI"; static String originChild = "LIKEI"; static String get tencentImAppid => AppConfig.current.tencentImAppid; static int get trtcSdkAppId => AppConfig.current.trtcSdkAppId; static num get gameAppid => AppConfig.current.gameAppid; static String get gameAppChannel => AppConfig.current.gameAppChannel; ///全服广播大群 static String get bigBroadcastGroup => AppConfig.current.bigBroadcastGroup; static String get imAdmin => AppConfig.current.imAdmin; static const Set _extraSystemUserIds = {"yuminotice"}; static String _normalizeConversationUserId(String conversationId) { return conversationId.startsWith("c2c_") ? conversationId.replaceFirst("c2c_", "") : conversationId; } static Set get systemUserIds { return { "administrator", _normalizeConversationUserId(imAdmin), ..._extraSystemUserIds, }.where((element) => element.isNotEmpty).toSet(); } static Set get systemConversationIds { return { for (final userId in systemUserIds) ...{userId, "c2c_$userId"}, }; } static String get primarySystemUserId => _normalizeConversationUserId(imAdmin); static String get primarySystemConversationId => "c2c_$primarySystemUserId"; static bool isSystemConversationId(String? conversationId) { if (conversationId == null || conversationId.isEmpty) { return false; } return systemUserIds.contains(_normalizeConversationUserId(conversationId)); } static bool isSystemUserId(String? userId) { if (userId == null || userId.isEmpty) { return false; } return systemUserIds.contains(userId); } ///财富榜单 static String get wealthRankUrl => AppConfig.current.wealthRankUrl; ///魅力榜 static String get charmRankUrl => AppConfig.current.charmRankUrl; ///房间榜单 static String get roomRankUrl => AppConfig.current.roomRankUrl; ///邀请新用户活动链接 static String get inviteNewUserUrl => AppConfig.current.inviteNewUserUrl; ///是否在审核 static bool? _isReviewOverride; static bool get isReview => _isReviewOverride ?? AppConfig.current.isReview; static set isReview(bool value) => _isReviewOverride = value; ///礼物特效开关 static bool _isGiftSpecialEffects = true; static bool get isGiftSpecialEffects => _isGiftSpecialEffects; static set isGiftSpecialEffects(bool value) => _isGiftSpecialEffects = value; ///入场秀 static bool _isEntryVehicleAnimation = true; static bool get isEntryVehicleAnimation => _isEntryVehicleAnimation; static set isEntryVehicleAnimation(bool value) => _isEntryVehicleAnimation = value; ///全局飘屏 static bool _isFloatingAnimationInGlobal = true; static String _floatingBroadcastScope = floatingBroadcastScopeAll; static bool get isFloatingAnimationInGlobal => _isFloatingAnimationInGlobal; static set isFloatingAnimationInGlobal(bool value) { _isFloatingAnimationInGlobal = value; _floatingBroadcastScope = value ? floatingBroadcastScopeAll : floatingBroadcastScopeOff; } static String get floatingBroadcastScope => _floatingBroadcastScope; static set floatingBroadcastScope(String value) { _floatingBroadcastScope = normalizeFloatingBroadcastScope(value); _isFloatingAnimationInGlobal = _floatingBroadcastScope != floatingBroadcastScopeOff; } static bool get isFloatingBroadcastClosed => _floatingBroadcastScope == floatingBroadcastScopeOff; static bool get isFloatingBroadcastRoomOnly => _floatingBroadcastScope == floatingBroadcastScopeRoom; static bool get isFloatingBroadcastAll => _floatingBroadcastScope == floatingBroadcastScopeAll; static String normalizeFloatingBroadcastScope(String? value) { switch (value) { case floatingBroadcastScopeOff: case floatingBroadcastScopeRoom: case floatingBroadcastScopeAll: return value!; default: return floatingBroadcastScopeAll; } } static String clampFloatingBroadcastScope(String value) { return normalizeFloatingBroadcastScope(value); } static String floatingBroadcastScopeStorageKey(String? account) { return "$account-FloatingBroadcastScope"; } static String legacyFloatingAnimationInGlobalStorageKey(String? account) { return "$account-FloatingAnimationInGlobal"; } ///幸运礼物特效开关 static bool _isLuckGiftSpecialEffects = true; static bool get isLuckGiftSpecialEffects => _isLuckGiftSpecialEffects; static set isLuckGiftSpecialEffects(bool value) => _isLuckGiftSpecialEffects = value; static bool get isLowPerformanceDevice => _isLowPerformanceDevice; static bool get allowsHighCostAnimations => true; static int get recommendedImageCacheBytes => _isLowPerformanceDevice ? 40 * 1024 * 1024 : 100 * 1024 * 1024; static int get recommendedImageCacheEntries => _isLowPerformanceDevice ? 80 : 200; static void applyDevicePerformanceProfile({ required bool isLowRamDevice, required int processorCount, }) { final normalizedModel = model.toLowerCase().replaceAll('-', ' '); final matchesKnownLowPerformanceModel = _knownLowPerformanceModels.any( normalizedModel.contains, ); SCGlobalConfig.isLowRamDevice = isLowRamDevice; SCGlobalConfig.processorCount = processorCount; _isLowPerformanceDevice = isLowRamDevice || processorCount <= 6 || matchesKnownLowPerformanceModel; } static bool clampVisualEffectPreference(bool enabled) { return enabled; } static void resetVisualEffectSwitchesToRecommendedDefaults() { isEntryVehicleAnimation = true; isGiftSpecialEffects = true; isFloatingAnimationInGlobal = true; isLuckGiftSpecialEffects = true; } /// 获取当前业务逻辑策略 static BusinessLogicStrategy get businessLogicStrategy { return AppConfig.current.businessLogicStrategy; } }