fix: webview

This commit is contained in:
xkeyC 2025-12-13 16:14:12 +08:00
parent 39d571960b
commit c8962d509c
2 changed files with 11 additions and 7 deletions

View File

@ -166,6 +166,7 @@ class HomeGameLoginUIModel extends _$HomeGameLoginUIModel {
applicationSupportDir: appGlobalState.applicationSupportDir!,
appVersionData: appGlobalState.networkVersionData!,
);
await Future.delayed(Duration(milliseconds: 500));
await webViewModel.launch(url, appGlobalState.networkVersionData!);
}

View File

@ -434,6 +434,16 @@ fn run_webview_loop(
let proxy = proxy.clone();
move |event, url| {
if url == "about:blank" {
if matches!(event, PageLoadEvent::Finished) {
// if url is about:blank, show loading
let loading_script = format!(
r#"document.open(); document.write({}); document.close();"#,
serde_json::to_string(LOADING_PAGE_HTML).unwrap_or_default()
);
let _ = proxy.send_event(UserEvent::Command(
WebViewCommand::ExecuteScript(loading_script),
));
}
return;
}
@ -603,13 +613,6 @@ fn run_webview_loop(
.build(&window)
.expect("Failed to create webview");
// Show loading page while waiting for Navigate command
let loading_script = format!(
r#"document.open(); document.write({}); document.close();"#,
serde_json::to_string(LOADING_PAGE_HTML).unwrap_or_default()
);
let _ = webview.evaluate_script(&loading_script);
let webview = Arc::new(webview);
let webview_cmd = Arc::clone(&webview);