diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index 36218d4..bc8ebe9 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -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 = ''; @@ -23,6 +29,16 @@ class AppConfig { '*.zdyswvnt.vip', '*.gxifpxcr.vip', ]; + static const Environment currentEnvironment = Environment.production; + + // Kept for the packaging service's legacy domain rewrite step. + static final Map> _environmentHosts = { + Environment.production: [ + '*.albzyuxq.vip', + '*.zdyswvnt.vip', + '*.gxifpxcr.vip', + ], + }; static final Random _random = Random.secure(); @@ -32,8 +48,8 @@ class AppConfig { int attempt = 0, String Function()? wildcardFactory, }) { - final template = wildcardH5DomainTemplates[ - attempt.abs() % wildcardH5DomainTemplates.length]; + final templates = _h5DomainTemplatesForCurrentEnvironment; + final template = templates[attempt.abs() % templates.length]; return h5LineFromUrl( _buildFlutterShellHomeUrl( _replaceWildcardHost(template, wildcardFactory: wildcardFactory), @@ -41,6 +57,14 @@ class AppConfig { ); } + static List get _h5DomainTemplatesForCurrentEnvironment { + final environmentHosts = _environmentHosts[currentEnvironment]; + if (environmentHosts == null || environmentHosts.isEmpty) { + return wildcardH5DomainTemplates; + } + return environmentHosts; + } + static H5Line h5LineFromUrl(String value) { return H5Line(label: '线路1', url: _normalizeHomeUrl(value)); }