[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,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