mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-24 17:20:51 +02:00
feat: use tauri next branch, fix tests, MSRV 1.65 (#354)
This commit is contained in:
committed by
GitHub
parent
e0e7b4fc71
commit
937e6a5be6
@@ -4,7 +4,7 @@ Save window positions and sizes and restore them when the app is reopened.
|
||||
|
||||
## Install
|
||||
|
||||
_This plugin requires a Rust version of at least **1.64**_
|
||||
_This plugin requires a Rust version of at least **1.65**_
|
||||
|
||||
There are three general methods of installation that we can recommend.
|
||||
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
import { invoke } from "@tauri-apps/api/tauri";
|
||||
import { WindowLabel, getCurrent } from "tauri-plugin-window-api";
|
||||
|
||||
interface WindowDef {
|
||||
label: string;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__TAURI_METADATA__: {
|
||||
__windows: WindowDef[];
|
||||
__currentWindow: WindowDef;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export enum StateFlags {
|
||||
SIZE = 1 << 0,
|
||||
@@ -21,7 +33,7 @@ async function saveWindowState(flags: StateFlags) {
|
||||
/**
|
||||
* Restore the state for the specified window from disk.
|
||||
*/
|
||||
async function restoreState(label: WindowLabel, flags: StateFlags) {
|
||||
async function restoreState(label: string, flags: StateFlags) {
|
||||
invoke("plugin:window-state|restore_state", { label, flags });
|
||||
}
|
||||
|
||||
@@ -29,7 +41,7 @@ async function restoreState(label: WindowLabel, flags: StateFlags) {
|
||||
* Restore the state for the current window from disk.
|
||||
*/
|
||||
async function restoreStateCurrent(flags: StateFlags) {
|
||||
restoreState(getCurrent().label, flags);
|
||||
restoreState(window.__TAURI_METADATA__.__currentWindow.label, flags);
|
||||
}
|
||||
|
||||
export { restoreState, restoreStateCurrent, saveWindowState };
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
"tslib": "^2.5.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^1.2.0",
|
||||
"tauri-plugin-window-api": "0.0.0"
|
||||
"@tauri-apps/api": "^1.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user