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
|
|
|
|
2023-10-27 16:00:59 +03:00
|
|
|
use tauri::{window::PageLoadEvent, WindowBuilder};
|
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()
|
2023-10-27 16:00:59 +03:00
|
|
|
.on_page_load(|window, payload| {
|
|
|
|
if payload.event() == PageLoadEvent::Finished {
|
|
|
|
let label = window.label().to_string();
|
|
|
|
window.listen("clicked".to_string(), move |_payload| {
|
|
|
|
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)]
|
|
|
|
let mut builder = WindowBuilder::new(
|
2022-03-31 20:50:33 +03:00
|
|
|
app,
|
|
|
|
"Rust".to_string(),
|
|
|
|
tauri::WindowUrl::App("index.html".into()),
|
2022-10-19 15:20:17 +03:00
|
|
|
);
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
{
|
|
|
|
builder = builder.tabbing_identifier("Rust");
|
|
|
|
}
|
|
|
|
let _window = 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
|
|
|
}
|