feat: 添加环境枚举和配置,优化 H5 线路生成逻辑
This commit is contained in:
@@ -12,6 +12,12 @@ class H5Line {
|
|||||||
Uri get uri => Uri.parse(url);
|
Uri get uri => Uri.parse(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Environment {
|
||||||
|
development,
|
||||||
|
staging,
|
||||||
|
production,
|
||||||
|
}
|
||||||
|
|
||||||
class AppConfig {
|
class AppConfig {
|
||||||
static const String appName = '本地打包';
|
static const String appName = '本地打包';
|
||||||
static const String appLogo = '';
|
static const String appLogo = '';
|
||||||
@@ -23,6 +29,16 @@ class AppConfig {
|
|||||||
'*.zdyswvnt.vip',
|
'*.zdyswvnt.vip',
|
||||||
'*.gxifpxcr.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();
|
static final Random _random = Random.secure();
|
||||||
|
|
||||||
@@ -32,8 +48,8 @@ class AppConfig {
|
|||||||
int attempt = 0,
|
int attempt = 0,
|
||||||
String Function()? wildcardFactory,
|
String Function()? wildcardFactory,
|
||||||
}) {
|
}) {
|
||||||
final template = wildcardH5DomainTemplates[
|
final templates = _h5DomainTemplatesForCurrentEnvironment;
|
||||||
attempt.abs() % wildcardH5DomainTemplates.length];
|
final template = templates[attempt.abs() % templates.length];
|
||||||
return h5LineFromUrl(
|
return h5LineFromUrl(
|
||||||
_buildFlutterShellHomeUrl(
|
_buildFlutterShellHomeUrl(
|
||||||
_replaceWildcardHost(template, wildcardFactory: wildcardFactory),
|
_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) {
|
static H5Line h5LineFromUrl(String value) {
|
||||||
return H5Line(label: '线路1', url: _normalizeHomeUrl(value));
|
return H5Line(label: '线路1', url: _normalizeHomeUrl(value));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user