[bugfix] Fix window geometry bug that was not save and restore. changes the way how to get appWindow instance from Tauri.

This commit is contained in:
Sakamoto Shiina
2025-05-11 15:26:05 +09:00
parent 61e333401f
commit b2bc1e62cb
10 changed files with 53 additions and 68 deletions

View File

@@ -1,10 +1,12 @@
import { useState, useEffect } from "react";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { store } from "@store";
export const CornerRadiusController = () => {
const [is_win11, setIsWin11] = useState(false);
const [is_maximized, setIsMaximized] = useState(false);
const appWindow = store.appWindow;
// OS 判定Win11 なら platformVersion の major ≥13
useEffect(() => {
if (navigator.userAgentData?.getHighEntropyValues) {
@@ -27,12 +29,11 @@ export const CornerRadiusController = () => {
useEffect(() => {
let unlisten;
const setup = async () => {
const window = await getCurrentWindow();
// 初期状態取得
setIsMaximized(await window.isMaximized());
setIsMaximized(await appWindow.isMaximized());
// リサイズ時にも再取得
const updateMax = () => window.isMaximized().then(setIsMaximized);
unlisten = await window.listen("tauri://resize", updateMax);
const updateMax = () => appWindow.isMaximized().then(setIsMaximized);
unlisten = await appWindow.listen("tauri://resize", updateMax);
}
setup();