mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-04 20:16:34 +02:00
* feat(window-state): add js api, closes #254 * symlink tsconfig.json * update symlink * Update plugins/window-state/package.json Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de> * Update Cargo.toml * move to cmd.rs * Update plugins/window-state/guest-js/index.ts --------- Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
This commit is contained in:
co-authored by
Fabian-Lars
parent
6f39921dbe
commit
e5b07f4af2
@@ -0,0 +1,35 @@
|
||||
import { invoke } from "@tauri-apps/api/tauri";
|
||||
import { WindowLabel, getCurrent } from "@tauri-apps/api/window";
|
||||
|
||||
export enum StateFlags {
|
||||
SIZE = 1 << 0,
|
||||
POSITION = 1 << 1,
|
||||
MAXIMIZED = 1 << 2,
|
||||
VISIBLE = 1 << 3,
|
||||
DECORATIONS = 1 << 4,
|
||||
FULLSCREEN = 1 << 5,
|
||||
ALL = SIZE | POSITION | MAXIMIZED | VISIBLE | DECORATIONS | FULLSCREEN,
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the state of all open windows to disk.
|
||||
*/
|
||||
async function saveWindowState(flags: StateFlags) {
|
||||
invoke("plugin:window-state|js_save_window_state", { flags });
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the state for the specified window from disk.
|
||||
*/
|
||||
async function restoreState(label: WindowLabel, flags: StateFlags) {
|
||||
invoke("plugin:window-state|js_restore_state", { label, flags });
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the state for the current window from disk.
|
||||
*/
|
||||
async function restoreStateCurrent(flags: StateFlags) {
|
||||
restoreState(getCurrent().label, flags);
|
||||
}
|
||||
|
||||
export { restoreState, restoreStateCurrent, saveWindowState };
|
||||
Reference in New Issue
Block a user