splash screen
This commit is contained in:
parent
17abe0b71d
commit
052251be03
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
@ -1049,6 +1049,7 @@ dependencies = [
|
||||
"tauri-plugin-http",
|
||||
"tauri-plugin-os",
|
||||
"tauri-plugin-shell",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-appender",
|
||||
"tracing-subscriber",
|
||||
|
@ -27,4 +27,5 @@ tracing = "0.1.40"
|
||||
tracing-subscriber = "0.3.18"
|
||||
tauri-plugin-http = "2"
|
||||
tracing-appender = "0.2.3"
|
||||
tokio = "1.40.0"
|
||||
|
||||
|
@ -1,4 +1,8 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use tauri::{async_runtime::spawn, AppHandle, Manager};
|
||||
use tauri_plugin_http::reqwest;
|
||||
use tokio::{time::sleep};
|
||||
|
||||
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
||||
#[tauri::command]
|
||||
@ -23,6 +27,17 @@ async fn quote() -> String {
|
||||
text
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn setup_complete(app: AppHandle) -> Result<(), ()> {
|
||||
|
||||
let splash_window = app.get_webview_window("splashscreen").unwrap();
|
||||
let main_window = app.get_webview_window("main").unwrap();
|
||||
splash_window.close().unwrap();
|
||||
main_window.show().unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tracing::info!("Starting up tauri app");
|
||||
@ -31,6 +46,18 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.invoke_handler(tauri::generate_handler![greet, os_info, quote])
|
||||
.setup(|app| {
|
||||
spawn(setup(app.handle().clone()));
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
async fn setup(app: AppHandle) -> Result<(), ()> {
|
||||
tracing::info!("Faking a lengthy setup");
|
||||
sleep(Duration::from_secs(3)).await;
|
||||
tracing::info!("Setup complete");
|
||||
setup_complete(app).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -10,10 +10,15 @@
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"label": "main",
|
||||
"title": "gensoukyou-tauri",
|
||||
"width": 800,
|
||||
"height": 600
|
||||
|
||||
"height": 600,
|
||||
"visible": false
|
||||
},
|
||||
{
|
||||
"label": "splashscreen",
|
||||
"url": "/splashscreen"
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
|
17
src/splashscreen.html
Normal file
17
src/splashscreen.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="stylesheet" href="/src/styles.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Tauri App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Tauri used Splash!</h1>
|
||||
<div class="row">
|
||||
<h5>It was super effective!</h5>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user