feat: 优化 H5 URL 生成逻辑,移除品牌参数;更新测试用例以反映更改

This commit is contained in:
Booker
2026-05-26 20:09:38 +07:00
parent f47895d893
commit 2eef27a0e1
3 changed files with 20 additions and 411 deletions

View File

@@ -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();