mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-30 17:48:50 +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
@@ -21,6 +21,18 @@ Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
|
||||
```
|
||||
|
||||
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
||||
|
||||
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
||||
|
||||
```sh
|
||||
pnpm add https://github.com/tauri-apps/tauri-plugin-window-state
|
||||
# or
|
||||
npm add https://github.com/tauri-apps/tauri-plugin-window-state
|
||||
# or
|
||||
yarn add https://github.com/tauri-apps/tauri-plugin-window-state
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
First you need to register the core plugin with Tauri:
|
||||
@@ -47,6 +59,14 @@ use tauri_plugin_window_state::{AppHandleExt, StateFlags};
|
||||
app.save_window_state(StateFlags::all()); // will save the state of all open windows to disk
|
||||
```
|
||||
|
||||
or through Javascript
|
||||
|
||||
```javascript
|
||||
import { saveWindowState, StateFlags } from "tauri-plugin-window-state-api";
|
||||
|
||||
saveWindowState(StateFlags.ALL);
|
||||
```
|
||||
|
||||
To manually restore a windows state from disk you can call the `restore_state()` method exposed by the `WindowExt` trait:
|
||||
|
||||
```rust
|
||||
@@ -56,6 +76,14 @@ use tauri_plugin_window_state::{WindowExt, StateFlags};
|
||||
window.restore_state(StateFlags::all()); // will restore the windows state from disk
|
||||
```
|
||||
|
||||
or through Javascript
|
||||
|
||||
```javascript
|
||||
import { restoreStateCurrent, StateFlags } from "tauri-plugin-window-state-api";
|
||||
|
||||
restoreStateCurrent(StateFlags.ALL);
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||
|
||||
Reference in New Issue
Block a user