feat: 优化 H5 线路切换逻辑;实现独立 WebView 管理和状态控制

This commit is contained in:
Booker
2026-05-27 13:03:50 +07:00
parent 8659a2e66e
commit 6e3920972b
4 changed files with 141 additions and 124 deletions

View File

@@ -68,7 +68,7 @@ void main() {
isFalse);
});
test('keeps independent non-legacy H5 hosts when removing shell params', () {
test('keeps H5 runtime URLs untouched during shell routing', () {
final uri = Uri.parse(
AppConfig.canonicalizeMainFrameUrl(
'https://line-two.example/login?shell_app_name=Old'
@@ -78,13 +78,13 @@ void main() {
expect(uri.host, 'line-two.example');
expect(uri.path, '/login');
expect(uri.queryParameters.containsKey('shell_app_name'), isFalse);
expect(uri.queryParameters.containsKey('flutter_shell'), isFalse);
expect(uri.queryParameters['shell_app_name'], 'Old');
expect(uri.queryParameters['flutter_shell'], '1');
expect(Uri.splitQueryString(uri.fragment).containsKey('shell_app_logo'),
isFalse);
isTrue);
});
test('rewrites legacy H5 host main-frame URLs to the canonical host', () {
test('does not rewrite H5 main-frame URLs for line switching', () {
final uri = Uri.parse(
AppConfig.canonicalizeMainFrameUrl(
'https://h5-test.imharry.work/login?from=runtime'
@@ -96,8 +96,9 @@ void main() {
expect(uri.host, 'h5-test.imharry.work');
expect(uri.path, '/login');
expect(uri.queryParameters['from'], 'runtime');
expect(uri.queryParameters.containsKey('shell_app_name'), isFalse);
expect(uri.queryParameters['shell_app_name'], 'Old');
expect(Uri.splitQueryString(uri.fragment).containsKey('shell_app_logo'),
isFalse);
isTrue);
expect(AppConfig.shouldRewriteMainFrameUrl(uri.toString()), isFalse);
});
}