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 = '';
|
||||
@@ -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<Environment, List<String>> _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<String> 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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user