mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-06-06 13:53:54 +02:00
feat: update to tauri beta, add permissions (#862)
Co-authored-by: Lucas Nogueira <lucas@tauri.app> Co-authored-by: Lucas Nogueira <lucas@crabnebula.dev>
This commit is contained in:
@@ -6,10 +6,14 @@ authors = { workspace = true }
|
||||
license = { workspace = true }
|
||||
edition = { workspace = true }
|
||||
rust-version = { workspace = true }
|
||||
links = "tauri-plugin-window-state"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
rustc-args = [ "--cfg", "docsrs" ]
|
||||
rustdoc-args = [ "--cfg", "docsrs" ]
|
||||
rustc-args = ["--cfg", "docsrs"]
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-plugin = { workspace = true, features = ["build"] }
|
||||
|
||||
[dependencies]
|
||||
serde = { workspace = true }
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
const COMMANDS: &[&str] = &["save_window_state", "restore_window_state"];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
}
|
||||
@@ -24,6 +24,6 @@
|
||||
"LICENSE"
|
||||
],
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "2.0.0-alpha.13"
|
||||
"@tauri-apps/api": "2.0.0-beta.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
schemas/
|
||||
@@ -0,0 +1 @@
|
||||
schemas/
|
||||
@@ -0,0 +1,13 @@
|
||||
# Automatically generated - DO NOT EDIT!
|
||||
|
||||
"$schema" = "../../schemas/schema.json"
|
||||
|
||||
[[permission]]
|
||||
identifier = "allow-restore-window-state"
|
||||
description = "Enables the restore_window_state command without any pre-configured scope."
|
||||
commands.allow = ["restore_window_state"]
|
||||
|
||||
[[permission]]
|
||||
identifier = "deny-restore-window-state"
|
||||
description = "Denies the restore_window_state command without any pre-configured scope."
|
||||
commands.deny = ["restore_window_state"]
|
||||
@@ -0,0 +1,13 @@
|
||||
# Automatically generated - DO NOT EDIT!
|
||||
|
||||
"$schema" = "../../schemas/schema.json"
|
||||
|
||||
[[permission]]
|
||||
identifier = "allow-save-window-state"
|
||||
description = "Enables the save_window_state command without any pre-configured scope."
|
||||
commands.allow = ["save_window_state"]
|
||||
|
||||
[[permission]]
|
||||
identifier = "deny-save-window-state"
|
||||
description = "Denies the save_window_state command without any pre-configured scope."
|
||||
commands.deny = ["save_window_state"]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Permissions
|
||||
|
||||
## allow-restore-window-state
|
||||
|
||||
Enables the restore_window_state command without any pre-configured scope.
|
||||
|
||||
## deny-restore-window-state
|
||||
|
||||
Denies the restore_window_state command without any pre-configured scope.
|
||||
|
||||
## allow-save-window-state
|
||||
|
||||
Enables the save_window_state command without any pre-configured scope.
|
||||
|
||||
## deny-save-window-state
|
||||
|
||||
Denies the save_window_state command without any pre-configured scope.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -24,8 +24,10 @@ pub async fn restore_state<R: Runtime>(
|
||||
) -> std::result::Result<(), String> {
|
||||
let flags = StateFlags::from_bits(flags)
|
||||
.ok_or_else(|| format!("Invalid state flags bits: {}", flags))?;
|
||||
app.get_window(&label)
|
||||
app.get_webview_window(&label)
|
||||
.ok_or_else(|| format!("Couldn't find window with label: {}", label))?
|
||||
.as_ref()
|
||||
.window()
|
||||
.restore_state(flags)
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(())
|
||||
|
||||
@@ -101,8 +101,8 @@ impl<R: Runtime> AppHandleExt for tauri::AppHandle<R> {
|
||||
let cache = self.state::<WindowStateCache>();
|
||||
let mut state = cache.0.lock().unwrap();
|
||||
for (label, s) in state.iter_mut() {
|
||||
if let Some(window) = self.get_window(label) {
|
||||
window.update_state(s, flags)?;
|
||||
if let Some(window) = self.get_webview_window(label) {
|
||||
window.as_ref().window().update_state(s, flags)?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ impl Builder {
|
||||
app.manage(WindowStateCache(cache));
|
||||
Ok(())
|
||||
})
|
||||
.on_webview_ready(move |window| {
|
||||
.on_window_ready(move |window| {
|
||||
if self.denylist.contains(window.label()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user