Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Splashscreen example doesn't work out of the box #2185

Closed
jacobq opened this issue Jul 8, 2021 · 0 comments · Fixed by #2186
Closed

[docs] Splashscreen example doesn't work out of the box #2185

jacobq opened this issue Jul 8, 2021 · 0 comments · Fixed by #2186

Comments

@jacobq
Copy link

jacobq commented Jul 8, 2021

Disclaimer: I'm brand new to Rust and to Tauri; just spun up my first app with the beta today.

The docs provide some example code to illustrate how to make a "splash screen" (separate window / webview) and display it while the main application loads. However, when I tried it I encountered errors.

Error messages during compilation
   Compiling app v0.1.0 (/home/jquant/tmp/tauri-app-hello/src-tauri)
error: only a single item `async` is currently allowed
  --> src/main.rs:10:18
   |
10 | #[tauri::command(with_window)]
   |                  ^^^^^^^^^^^
...
23 |     .invoke_handler(tauri::generate_handler![close_splashscreen])
   |                     -------------------------------------------- in this macro invocation
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0405]: cannot find trait `Params` in this scope
  --> src/main.rs:11:26
   |
11 | fn close_splashscreen<M: Params>(window: tauri::Window<M>) {
   |                          ^^^^^^ not found in this scope
   |
help: consider importing this trait
   |
11 | use tauri::Params;
   |

error: aborting due to 2 previous errors

Then I tried adding use tauri::Params; (at the top of main.rs)

Second round of error messages
   Compiling app v0.1.0 (/home/jquant/tmp/tauri-app-hello/src-tauri)
error: only a single item `async` is currently allowed
  --> src/main.rs:11:18
   |
11 | #[tauri::command(with_window)]
   |                  ^^^^^^^^^^^
...
24 |     .invoke_handler(tauri::generate_handler![close_splashscreen])
   |                     -------------------------------------------- in this macro invocation
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `get_webview` found for struct `Window<M>` in the current scope
  --> src/main.rs:14:36
   |
14 |   if let Ok(splashscreen) = window.get_webview("splash") {
   |                                    ^^^^^^^^^^^ method not found in `Window<M>`

error[E0599]: no method named `get_webview` found for struct `Window<M>` in the current scope
  --> src/main.rs:18:10
   |
18 |   window.get_webview("main").unwrap().show().unwrap();
   |          ^^^^^^^^^^^ method not found in `Window<M>`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0599`.
error: could not compile `app`

Looking at the API docs, I see window.struct, but it has no get_webview method, so I'm not sure where this functionality is. In fact, doing a GitHub search for get_webview produced exactly 1 result, which was the splash screen example where I obtained the code that doesn't seem to work. Digging a little more, I found a method of the same name in WRY's webview2 source.

yarn tauri info
Operating System - Debian, version 11 X64

Node.js environment
  Node.js - 14.17.3
  @tauri-apps/cli - 1.0.0-beta.5
  @tauri-apps/api - 1.0.0-beta.4

Global packages
  npm - 6.14.13
  yarn - 1.22.5

Rust environment
  rustc - 1.53.0
  cargo - 1.53.0

App directory structure
/front-end
/.idea
/node_modules
/src-tauri
/.git

App
  tauri.rs - 1.0.0-beta.4
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - front-end/dist
  devPath - http://localhost:4200/

Done in 3.49s.

FWIW, my code is available at jacobq/tauri-hello-world/tree/broken-splash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant