157 lines
3.2 KiB
Dart
157 lines
3.2 KiB
Dart
import 'package:flutter/foundation.dart';
|
||
import 'package:aslan/chatvibe_core/config/configs/variant1_config.dart';
|
||
import 'package:aslan/chatvibe_core/config/business_logic_strategy.dart';
|
||
|
||
/// 应用配置基类
|
||
/// 定义单一应用配置接口
|
||
abstract class AppConfig {
|
||
/// 应用显示名称
|
||
String get appName;
|
||
|
||
/// 包名/应用ID
|
||
String get packageName;
|
||
|
||
/// API服务器地址
|
||
String get apiHost;
|
||
|
||
/// 图片服务器地址
|
||
String get imgHost;
|
||
|
||
/// 隐私协议URL
|
||
String get privacyAgreementUrl;
|
||
|
||
/// 用户协议URL
|
||
String get userAgreementUrl;
|
||
|
||
/// 应用下载链接(Google Play)
|
||
String get appDownloadUrlGoogle;
|
||
|
||
/// 应用下载链接(App Store)
|
||
String get appDownloadUrlApple;
|
||
|
||
/// 第三方支付ID
|
||
String get payApplicationId;
|
||
|
||
/// 主播代理URL
|
||
String get anchorAgentUrl;
|
||
|
||
/// 主持人中心URL
|
||
String get hostCenterUrl;
|
||
|
||
/// BD中心URL
|
||
String get bdCenterUrl;
|
||
|
||
/// BD领导中心URL
|
||
String get bdLeaderUrl;
|
||
|
||
/// 代币销售URL
|
||
String get coinSellerUrl;
|
||
|
||
/// 管理员URL
|
||
String get adminUrl;
|
||
|
||
/// 代理中心URL
|
||
String get agencyCenterUrl;
|
||
|
||
/// 游戏国王URL
|
||
String get gamesKingUrl;
|
||
|
||
/// 充值URL
|
||
String get rechargeUrl;
|
||
|
||
/// CP奖励URL
|
||
String get cpRewardUrl;
|
||
|
||
/// 财富榜URL
|
||
String get wealthRankUrl;
|
||
|
||
/// 魅力榜URL
|
||
String get charmRankUrl;
|
||
|
||
/// 房间榜URL
|
||
String get roomRankUrl;
|
||
|
||
/// 邀请新用户URL
|
||
String get inviteNewUserUrl;
|
||
|
||
/// 主题主颜色
|
||
int get primaryColor;
|
||
|
||
/// 腾讯IM App ID
|
||
String get tencentImAppid;
|
||
|
||
/// Agora RTC App ID
|
||
String get agoraRtcAppid;
|
||
|
||
/// 游戏App ID
|
||
num get gameAppid;
|
||
|
||
/// 游戏渠道
|
||
String get gameAppChannel;
|
||
|
||
/// 全服广播大群ID
|
||
String get bigBroadcastGroup;
|
||
|
||
/// 管理账号
|
||
String get imAdmin;
|
||
|
||
/// 是否审核模式
|
||
bool get isReview;
|
||
|
||
/// 礼物特效开关
|
||
bool get isGiftSpecialEffects;
|
||
|
||
/// 入场秀开关
|
||
bool get isEntryVehicleAnimation;
|
||
|
||
/// 全局飘屏开关
|
||
bool get isFloatingAnimationInGlobal;
|
||
|
||
/// 幸运礼物特效开关
|
||
bool get isLuckGiftSpecialEffects;
|
||
|
||
/// 获取功能开关
|
||
Map<String, bool> get featureFlags;
|
||
|
||
/// 获取业务逻辑策略
|
||
BusinessLogicStrategy get businessLogicStrategy;
|
||
|
||
/// 获取所有配置的Map(用于调试)
|
||
Map<String, dynamic> toMap();
|
||
|
||
/// 验证配置是否有效
|
||
/// 检查必要的配置项是否已正确设置
|
||
/// 如果配置无效,抛出 [StateError]
|
||
void validate();
|
||
|
||
/// 当前应用的配置实例
|
||
static AppConfig? _current;
|
||
|
||
/// 获取当前配置实例
|
||
static AppConfig get current {
|
||
if (_current == null) {
|
||
throw StateError(
|
||
'AppConfig not initialized. Call AppConfig.initialize() first.',
|
||
);
|
||
}
|
||
return _current!;
|
||
}
|
||
|
||
/// 初始化应用配置
|
||
/// 使用variant1(马甲包)配置
|
||
static void initialize() {
|
||
_current = Variant1Config();
|
||
debugPrint('AppConfig initialized for variant1');
|
||
|
||
// 验证配置是否有效
|
||
try {
|
||
_current!.validate();
|
||
} catch (e) {
|
||
// validate方法在调试模式下不会抛出异常
|
||
// 只有在发布模式下验证失败才会抛出异常
|
||
debugPrint('应用配置验证失败: $e');
|
||
rethrow;
|
||
}
|
||
}
|
||
}
|