Created
February 27, 2023 11:16
-
-
Save sujang958/cca59cbffec87a1de10d681f57639c8c to your computer and use it in GitHub Desktop.
Tauri remember a window's position in TypeScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LogicalPosition, appWindow } from "@tauri-apps/api/window" | |
appWindow.onMoved((position) => { | |
localStorage.setItem( | |
POSITION_KEY, | |
JSON.stringify({ | |
x: position.payload.x, | |
y: position.payload.y, | |
}) | |
) | |
}) | |
const { x, y } = JSON.parse(localStorage.getItem(POSITION_KEY)) | |
appWindow.setPosition(new LogicalPosition(x, y)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment