Skip to content

Commit

Permalink
Update using tabs to show code
Browse files Browse the repository at this point in the history
  • Loading branch information
dklassic committed Mar 4, 2024
1 parent 235865e commit f0416f2
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions src/content/docs/features/window-state.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,33 +74,35 @@ fn main() {

Afterwards all windows will remember their state when the app is being closed and will restore to their previous state on the next launch.

Optionally you can also tell the plugin to save the state of all open window to disk by using the `save_window_state()` method exposed by the `AppHandleExt` trait:
Optionally the window-state plugin can also be access with both JavaScript and Rust.

```rust
use tauri_plugin_window_state::{AppHandleExt, StateFlags};

// `tauri::AppHandle` now has the following additional method
app.save_window_state(StateFlags::all()); // will save the state of all open windows to disk
```

or through Javascript
<Tabs>
<TabItem label="JavaScript">

```javascript
import { saveWindowState, StateFlags } from "@tauri-apps/plugin-window-state";

saveWindowState(StateFlags.ALL);
```

To manually restore a windows state from disk you can call the `restore_state()` method exposed by the `WindowExt` trait:
</TabItem>
<TabItem label="Rust">

You can use the `save_window_state()` method exposed by the `AppHandleExt` trait:
```rust
use tauri_plugin_window_state::{WindowExt, StateFlags};
use tauri_plugin_window_state::{AppHandleExt, StateFlags};

// all `Window` types now have the following additional method
window.restore_state(StateFlags::all()); // will restore the windows state from disk
// `tauri::AppHandle` now has the following additional method
app.save_window_state(StateFlags::all()); // will save the state of all open windows to disk
```

or through Javascript
</TabItem>
</Tabs>

Similarly you can manually restore a windows state from disk through JavaScript and Rust.

<Tabs>
<TabItem label="JavaScript">

```javascript
import {
Expand All @@ -111,6 +113,22 @@ import {
restoreStateCurrent(StateFlags.ALL);
```

</TabItem>
<TabItem label="Rust">

You can call the `restore_state()` method exposed by the `WindowExt` trait:

```rust
use tauri_plugin_window_state::{WindowExt, StateFlags};

// all `Window` types now have the following additional method
window.restore_state(StateFlags::all()); // will restore the windows state from disk
```


</TabItem>
</Tabs>

## Permissions

By default all plugin commands are blocked and cannot be accessed.
Expand Down

0 comments on commit f0416f2

Please sign in to comment.