diff --git a/src-ui/app/_app_controllers/CornerRadiusController.jsx b/src-ui/app/_app_controllers/CornerRadiusController.jsx index 1b84b9ad..b56d20c5 100644 --- a/src-ui/app/_app_controllers/CornerRadiusController.jsx +++ b/src-ui/app/_app_controllers/CornerRadiusController.jsx @@ -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(); diff --git a/src-ui/app/error_boundary/AppErrorBoundary.jsx b/src-ui/app/error_boundary/AppErrorBoundary.jsx index 0cc5dfb2..4aeb34a2 100644 --- a/src-ui/app/error_boundary/AppErrorBoundary.jsx +++ b/src-ui/app/error_boundary/AppErrorBoundary.jsx @@ -1,5 +1,4 @@ import { useState } from "react"; -import { getCurrentWindow } from "@tauri-apps/api/window"; import { ErrorBoundary } from "react-error-boundary"; import XMarkSvg from "@images/cancel.svg?react"; import CopySvg from "@images/copy.svg?react"; @@ -7,6 +6,8 @@ import CheckMarkSvg from "@images/check_mark.svg?react"; import { ContactsContainer } from "./contacts_container/ContactsContainer"; +import { useWindow } from "@logics_common"; + import styles from "./AppErrorBoundary.module.scss"; export const AppErrorBoundary = ({children}) => { @@ -65,14 +66,9 @@ const ErrorContainer = ({error}) => { }; const CloseButtonContainer = () => { - - const asyncClose = async () => { - const appWindow = await getCurrentWindow(); - appWindow.close(); - }; - + const { asyncCloseApp } = useWindow(); return ( -