tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
78.09k stars 2.31k forks source link

[bug] How do I know if remote content in webview has been loaded normally? #9689

Open gusxodnjs opened 1 week ago

gusxodnjs commented 1 week ago

Describe the bug

I have received a URL from the user and am showing this page in webview. When an invalid url is entered as follows, webview is showing an empty screen. I want to catch this error and expose the error page. How can I do it?

https://www.yahoo.co.jp밍낢ㄴㅇㄹㅁㄴㅇㄹ

image

let _ = WebviewWindowBuilder::new(&app_handle, "test", WebviewUrl::External(url.parse().unwrap()))
                .decorations(false)
                .resizable(false)
                .on_page_load(move |window, payload| {
                    match payload.event() {
                        PageLoadEvent::Started => {}
                        PageLoadEvent::Finished => {
                            // on load
                        }
                    }
                })
                .build()
                .unwrap();

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.2.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.76.0 (07dca489a 2024-02-04)
    ✔ cargo: 1.76.0 (c84b36747 2024-01-18)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 18.17.1
    - yarn: 1.22.19
    - npm: 9.6.7

[-] Packages
    - tauri [RUST]: 2.0.0-beta.18
    - tauri-build [RUST]: 2.0.0-beta.14
    - wry [RUST]: 0.39.3
    - tao [RUST]: 0.27.1
    - tauri-cli [RUST]: 2.0.0-beta.9
    - @tauri-apps/api [NPM]: 2.0.0-beta.6
    - @tauri-apps/cli [NPM]: 2.0.0-beta.10

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace

No response

Additional context

No response