mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-24 11:14:40 +03:00
8d16a80d2f
* refactor(core): capabilities must be referenced on the Tauri config file * add all capabilities by default * feat(codegen): allow defining additional capabilities, closes #8798 * undo example * lint * move add_capability to runtime authority * add change files * go through code review * fix tests * remove tokens option
46 lines
1.3 KiB
Rust
46 lines
1.3 KiB
Rust
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
|
|
|
use tauri::{webview::PageLoadEvent, WebviewWindowBuilder};
|
|
use tauri_utils::acl::ExecutionContext;
|
|
|
|
fn main() {
|
|
let mut context = tauri::generate_context!("../../examples/multiwindow/tauri.conf.json");
|
|
for cmd in [
|
|
"plugin:event|listen",
|
|
"plugin:event|emit",
|
|
"plugin:event|emit_to",
|
|
] {
|
|
context
|
|
.runtime_authority_mut()
|
|
.__allow_command(cmd.to_string(), ExecutionContext::Local);
|
|
}
|
|
|
|
tauri::Builder::default()
|
|
.on_page_load(|webview, payload| {
|
|
if payload.event() == PageLoadEvent::Finished {
|
|
let label = webview.label().to_string();
|
|
webview.listen("clicked".to_string(), move |_payload| {
|
|
println!("got 'clicked' event on window '{label}'");
|
|
});
|
|
}
|
|
})
|
|
.setup(|app| {
|
|
#[allow(unused_mut)]
|
|
let mut builder =
|
|
WebviewWindowBuilder::new(app, "Rust", tauri::WebviewUrl::App("index.html".into()));
|
|
#[cfg(target_os = "macos")]
|
|
{
|
|
builder = builder.tabbing_identifier("Rust");
|
|
}
|
|
let _webview = builder.title("Tauri - Rust").build()?;
|
|
|
|
Ok(())
|
|
})
|
|
.run(context)
|
|
.expect("failed to run tauri application");
|
|
}
|