feat: 添加环境枚举和兼容性处理,优化 H5 线路配置
This commit is contained in:
@@ -12,6 +12,12 @@ class H5Line {
|
||||
Uri get uri => Uri.parse(url);
|
||||
}
|
||||
|
||||
enum Environment {
|
||||
development,
|
||||
staging,
|
||||
production,
|
||||
}
|
||||
|
||||
class AppConfig {
|
||||
static const String appName = '本地打包';
|
||||
static const String appLogo = '';
|
||||
@@ -25,11 +31,19 @@ class AppConfig {
|
||||
static const String _bootstrapH5LineUrl = String.fromEnvironment(
|
||||
'BOOTSTRAP_H5_LINE_URL',
|
||||
defaultValue: 'https://h5-test.imharry.work/');
|
||||
static const Environment currentEnvironment = Environment.production;
|
||||
// Compatibility for the packaging service's legacy domain rewrite step.
|
||||
static final Map<Environment, List<String>> _environmentHosts = {
|
||||
Environment.production: [
|
||||
_bootstrapH5LineUrl,
|
||||
],
|
||||
};
|
||||
static final Random _wildcardRandom = Random.secure();
|
||||
|
||||
static List<H5Line> get h5Lines {
|
||||
final configuredUrls = _dartDefinedH5LineUrls.trim().isEmpty
|
||||
? _normalizedUniqueUrls(const [_bootstrapH5LineUrl])
|
||||
? _normalizedUniqueUrls(_environmentHosts[currentEnvironment] ??
|
||||
const [_bootstrapH5LineUrl])
|
||||
: _normalizedUniqueUrls(_dartDefinedH5LineUrls.split(','));
|
||||
final urls = configuredUrls.isEmpty
|
||||
? _normalizedUniqueUrls(const [_bootstrapH5LineUrl])
|
||||
|
||||
Reference in New Issue
Block a user