ops-console v1.0.2 (versionCode 8) 源码入库
This commit is contained in:
55
lib/config/app_config.dart
Normal file
55
lib/config/app_config.dart
Normal file
@@ -0,0 +1,55 @@
|
||||
import '../utils/constants.dart';
|
||||
import 'environment.dart';
|
||||
import 'prod_config.dart';
|
||||
import 'staging_config.dart';
|
||||
import 'test_config.dart';
|
||||
|
||||
/// 运行时环境配置解析。
|
||||
///
|
||||
/// 当前环境 [environment] 默认 [AppEnvironment.test],并受 [ProductionGuard]
|
||||
/// 在启动时强制校验,绝不可能进入生产模式。
|
||||
class AppConfig {
|
||||
AppConfig._();
|
||||
|
||||
/// 接口统一前缀。
|
||||
static const String apiPrefix = '/api';
|
||||
|
||||
/// 当前环境,默认生产(正式版,域名 https://ips.ainetv.com)。
|
||||
/// 如需回归测试构建,改回 [AppEnvironment.test] 即可。
|
||||
static AppEnvironment _environment = AppEnvironment.production;
|
||||
|
||||
/// 当前环境(只读)。
|
||||
static AppEnvironment get environment => _environment;
|
||||
|
||||
/// 切换环境:接受 [AppEnvironment.test] / [AppEnvironment.staging] / [AppEnvironment.production]。
|
||||
static void switchEnvironment(AppEnvironment env) {
|
||||
_environment = env;
|
||||
}
|
||||
|
||||
/// 当前环境的后端 origin。
|
||||
static String get apiBaseUrl {
|
||||
switch (_environment) {
|
||||
case AppEnvironment.test:
|
||||
return TestConfig.apiBaseUrl;
|
||||
case AppEnvironment.staging:
|
||||
return StagingConfig.apiBaseUrl;
|
||||
case AppEnvironment.production:
|
||||
return ProdConfig.apiBaseUrl;
|
||||
}
|
||||
}
|
||||
|
||||
/// 完整 API 基础地址(origin + 前缀)。
|
||||
static String get apiFullBaseUrl => apiBaseUrl + apiPrefix;
|
||||
|
||||
/// 当前环境是否启用登录验证码。
|
||||
static bool get enableCaptcha {
|
||||
switch (_environment) {
|
||||
case AppEnvironment.test:
|
||||
return TestConfig.enableCaptcha;
|
||||
case AppEnvironment.staging:
|
||||
return StagingConfig.enableCaptcha;
|
||||
case AppEnvironment.production:
|
||||
return ProdConfig.enableCaptcha;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user