[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,4 +1,4 @@
import { getCurrentWindow } from "@tauri-apps/api/window";
import { store } from "@store";
import {
useStore_TranslationStatus,
@@ -6,10 +6,11 @@ import {
useStore_TranscriptionReceiveStatus,
useStore_ForegroundStatus,
} from "@store";
import { useCallback } from "react";
import { useStdoutToPython } from "@logics/useStdoutToPython";
export const useMainFunction = () => {
const appWindow = store.appWindow;
const {
currentTranslationStatus,
updateTranslationStatus,
@@ -76,9 +77,8 @@ export const useMainFunction = () => {
const toggleForeground = async () => {
const main_page = await getCurrentWindow();
const is_foreground_enabled = !currentForegroundStatus.data;
main_page.setAlwaysOnTop(is_foreground_enabled);
await appWindow.setAlwaysOnTop(is_foreground_enabled);
updateForegroundStatus(is_foreground_enabled);
};

View File

@@ -1,8 +1,9 @@
import { getCurrentWindow } from "@tauri-apps/api/window";
import { store } from "@store";
import { useStore_MessageInputBoxRatio } from "@store";
import { useStdoutToPython } from "@logics/useStdoutToPython";
import { clampMinMax } from "@utils";
export const useMessageInputBoxRatio = () => {
const appWindow = store.appWindow;
const { asyncStdoutToPython } = useStdoutToPython();
const { currentMessageInputBoxRatio, updateMessageInputBoxRatio } = useStore_MessageInputBoxRatio();
@@ -12,7 +13,6 @@ export const useMessageInputBoxRatio = () => {
};
const asyncSetMessageInputBoxRatio = async (ratio) => {
const appWindow = getCurrentWindow();
const minimized = await appWindow.isMinimized();
if (minimized === true) return; // don't save while the window is minimized.
const parsed = parseFloat(ratio.toFixed(2));