mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-05-25 13:17:47 +02:00
faa89850d0
* chore(deps): replace dependency eslint-config-standard-with-typescript with eslint-config-love 43.1.0 * actually apply the rules lol * rebuild --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: FabianLars <fabianlars@fabianlars.de>
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import { invoke } from "@tauri-apps/api/core";
|
|
import { type 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): Promise<void> {
|
|
await invoke("plugin:window-state|save_window_state", { flags });
|
|
}
|
|
|
|
/**
|
|
* Restore the state for the specified window from disk.
|
|
*/
|
|
async function restoreState(
|
|
label: WindowLabel,
|
|
flags: StateFlags,
|
|
): Promise<void> {
|
|
await invoke("plugin:window-state|restore_state", { label, flags });
|
|
}
|
|
|
|
/**
|
|
* Restore the state for the current window from disk.
|
|
*/
|
|
async function restoreStateCurrent(flags: StateFlags): Promise<void> {
|
|
await restoreState(getCurrent().label, flags);
|
|
}
|
|
/**
|
|
* Get the name of the file used to store window state.
|
|
*/
|
|
async function filename(): Promise<string> {
|
|
return await invoke("plugin:window-state|filename");
|
|
}
|
|
|
|
export { restoreState, restoreStateCurrent, saveWindowState, filename };
|