[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:
@@ -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();
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<button className={styles.close_button_wrapper} onClick={asyncClose}>
|
||||
<button className={styles.close_button_wrapper} onClick={asyncCloseApp}>
|
||||
<div className={styles.close_button}>
|
||||
<XMarkSvg className={styles.x_mark_svg}/>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,10 @@ import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import "@root/locales/config.js";
|
||||
import "./_index_css/root.css";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
|
||||
import { store } from "@store";
|
||||
store.appWindow = await getCurrentWindow();
|
||||
|
||||
import { App } from "./App";
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useMessage } from "@logics_common";
|
||||
import { useSendMessageButtonType, useEnableAutoClearMessageInputBox } from "@logics_configs";
|
||||
import { useMessageLogScroll } from "@logics_main";
|
||||
import { store } from "@store";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
|
||||
export const MessageInputBox = () => {
|
||||
const [message_history, setMessageHistory] = useState([]);
|
||||
@@ -41,8 +40,6 @@ export const MessageInputBox = () => {
|
||||
|
||||
const onSubmitFunction = (e) => {
|
||||
e.preventDefault();
|
||||
// const appWindow = getCurrentWindow();
|
||||
// appWindow.minimize();
|
||||
|
||||
if (!currentMessageInputValue.data.trim()) return updateMessageInputValue("");
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { StartUpProgressContainer } from "./start_up_progress_container/StartUpP
|
||||
import { DownloadModelsContainer } from "./download_models_container/DownloadModelsContainer/";
|
||||
import MegaphoneSvg from "@images/megaphone.svg?react";
|
||||
import XMarkSvg from "@images/cancel.svg?react";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { useWindow } from "@logics_common";
|
||||
import clsx from "clsx";
|
||||
|
||||
export const SplashComponent = () => {
|
||||
@@ -73,13 +73,10 @@ const AnnouncementsContainer = () => {
|
||||
|
||||
|
||||
const CloseButtonContainer = () => {
|
||||
const asyncClose = async () => {
|
||||
const appWindow = await getCurrentWindow();
|
||||
appWindow.close();
|
||||
};
|
||||
const { asyncCloseApp } = useWindow();
|
||||
|
||||
return (
|
||||
<button className={styles.close_button_wrapper} onClick={asyncClose}>
|
||||
<button className={styles.close_button_wrapper} onClick={asyncCloseApp}>
|
||||
<div className={styles.close_button}>
|
||||
<XMarkSvg className={styles.x_mark_svg}/>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useWindow } from "@logics_common";
|
||||
// import clsx from "clsx";
|
||||
import styles from "./WindowTitleBar.module.scss";
|
||||
import XMarkSvg from "@images/cancel.svg?react";
|
||||
@@ -5,29 +6,8 @@ import SquareSvg from "@images/square.svg?react";
|
||||
import LineSvg from "@images/line.svg?react";
|
||||
import VrctSvg from "@images/vrct.svg?react";
|
||||
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
|
||||
export const WindowTitleBar = () => {
|
||||
|
||||
const asyncMinimize = async () => {
|
||||
const appWindow = await getCurrentWindow();
|
||||
appWindow.minimize();
|
||||
};
|
||||
|
||||
const asyncMaximize = async () => {
|
||||
const appWindow = await getCurrentWindow();
|
||||
const maximizeState = await appWindow.isMaximized();
|
||||
if (!maximizeState) {
|
||||
appWindow.maximize();
|
||||
} else {
|
||||
appWindow.unmaximize();
|
||||
}
|
||||
};
|
||||
|
||||
const asyncClose = async () => {
|
||||
const appWindow = await getCurrentWindow();
|
||||
appWindow.close();
|
||||
};
|
||||
const { asyncCloseApp, asyncToggleMaximizeApp, asyncMinimizeApp} = useWindow();
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
@@ -37,13 +17,13 @@ export const WindowTitleBar = () => {
|
||||
</div>
|
||||
|
||||
<div className={styles.window_control_wrapper}>
|
||||
<div className={styles.minimize_button} onClick={asyncMinimize}>
|
||||
<div className={styles.minimize_button} onClick={asyncMinimizeApp}>
|
||||
<LineSvg className={styles.line_svg}/>
|
||||
</div>
|
||||
<div className={styles.maximize_button} onClick={asyncMaximize}>
|
||||
<div className={styles.maximize_button} onClick={asyncToggleMaximizeApp}>
|
||||
<SquareSvg className={styles.square_svg}/>
|
||||
</div>
|
||||
<div className={styles.close_button} onClick={asyncClose}>
|
||||
<div className={styles.close_button} onClick={asyncCloseApp}>
|
||||
<XMarkSvg className={styles.x_mark_svg}/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user