feat: 优化 H5 URL 生成逻辑,移除品牌参数;更新测试用例以反映更改
This commit is contained in:
@@ -21,39 +21,25 @@ class AppConfig {
|
||||
final host = environmentHosts.isNotEmpty
|
||||
? environmentHosts.first
|
||||
: 'h5-im.imharry.work';
|
||||
return withFreshShellParams(
|
||||
_normalizeHomeUrl(host),
|
||||
appName: appName,
|
||||
appLogo: appLogo,
|
||||
);
|
||||
return withFreshShellParams(_normalizeHomeUrl(host));
|
||||
}
|
||||
|
||||
static String withFreshShellParams(
|
||||
String url, {
|
||||
String? appName,
|
||||
String? appLogo,
|
||||
}) {
|
||||
static String withFreshShellParams(String url) {
|
||||
final uri = Uri.parse(url);
|
||||
final queryParameters = Map<String, String>.from(uri.queryParameters)
|
||||
..['flutter_shell'] = '1'
|
||||
..['shell_cache_bust'] = DateTime.now().millisecondsSinceEpoch.toString();
|
||||
queryParameters.remove('shell_app_name');
|
||||
queryParameters.remove('shell_app_logo');
|
||||
final fragmentParameters = Uri.splitQueryString(uri.fragment);
|
||||
|
||||
final trimmedName = (appName ?? AppConfig.appName).trim();
|
||||
if (trimmedName.isNotEmpty) {
|
||||
queryParameters['shell_app_name'] = trimmedName;
|
||||
}
|
||||
|
||||
final trimmedLogo = (appLogo ?? AppConfig.appLogo).trim();
|
||||
if (trimmedLogo.isNotEmpty) {
|
||||
fragmentParameters['shell_app_logo'] = trimmedLogo;
|
||||
}
|
||||
fragmentParameters.remove('shell_app_name');
|
||||
fragmentParameters.remove('shell_app_logo');
|
||||
|
||||
return uri
|
||||
.replace(
|
||||
queryParameters: queryParameters,
|
||||
fragment: fragmentParameters.isEmpty
|
||||
? null
|
||||
? ''
|
||||
: Uri(queryParameters: fragmentParameters).query,
|
||||
)
|
||||
.toString();
|
||||
|
||||
Reference in New Issue
Block a user