2023-02-19 16:17:49 +03:00
|
|
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
2021-04-11 01:09:09 +03:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2023-02-18 22:23:09 +03:00
|
|
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
2021-02-12 03:50:39 +03:00
|
|
|
|
2024-01-24 17:05:18 +03:00
|
|
|
use tauri::{webview::PageLoadEvent, WebviewWindowBuilder};
|
2021-02-17 17:15:04 +03:00
|
|
|
|
2021-02-12 03:50:39 +03:00
|
|
|
fn main() {
|
2021-04-06 23:50:53 +03:00
|
|
|
tauri::Builder::default()
|
2024-01-24 17:05:18 +03:00
|
|
|
.on_page_load(|webview, payload| {
|
2023-10-27 16:00:59 +03:00
|
|
|
if payload.event() == PageLoadEvent::Finished {
|
2024-01-24 17:05:18 +03:00
|
|
|
let label = webview.label().to_string();
|
|
|
|
webview.listen("clicked".to_string(), move |_payload| {
|
2023-10-27 16:00:59 +03:00
|
|
|
println!("got 'clicked' event on window '{label}'");
|
|
|
|
});
|
|
|
|
}
|
2021-02-12 03:50:39 +03:00
|
|
|
})
|
2022-03-31 20:50:33 +03:00
|
|
|
.setup(|app| {
|
2022-10-19 15:20:17 +03:00
|
|
|
#[allow(unused_mut)]
|
2024-01-24 17:05:18 +03:00
|
|
|
let mut builder =
|
|
|
|
WebviewWindowBuilder::new(app, "Rust", tauri::WebviewUrl::App("index.html".into()));
|
2022-10-19 15:20:17 +03:00
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
{
|
|
|
|
builder = builder.tabbing_identifier("Rust");
|
|
|
|
}
|
2024-01-24 17:05:18 +03:00
|
|
|
let _webview = builder.title("Tauri - Rust").build()?;
|
|
|
|
|
2022-03-31 20:50:33 +03:00
|
|
|
Ok(())
|
|
|
|
})
|
2022-07-04 02:26:32 +03:00
|
|
|
.run(tauri::generate_context!(
|
|
|
|
"../../examples/multiwindow/tauri.conf.json"
|
|
|
|
))
|
2021-04-04 03:41:04 +03:00
|
|
|
.expect("failed to run tauri application");
|
2021-02-12 03:50:39 +03:00
|
|
|
}
|