diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index b7fd63f1a..374ae9771 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -89,7 +89,7 @@ fn main() { // 记住窗口状态的插件:https://github.com/tauri-apps/plugins-workspace/tree/v1/plugins/window-state .plugin( tauri_plugin_window_state::Builder::default() - .with_state_flags(StateFlags::POSITION & StateFlags::SIZE) + .with_state_flags(StateFlags::all() & !StateFlags::VISIBLE) .build(), ) // macos 权限查询的插件 diff --git a/src/App.tsx b/src/App.tsx index b2e293ef2..0b4d1a667 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,6 +8,7 @@ const { defaultAlgorithm, darkAlgorithm } = theme; import { listen } from "@tauri-apps/api/event"; import { isString } from "arcdash"; import { error } from "tauri-plugin-log-api"; +import { StateFlags, saveWindowState } from "tauri-plugin-window-state-api"; const App = () => { const { appearance } = useSnapshot(globalStore); @@ -36,6 +37,14 @@ const App = () => { showWindow(); }); + + appWindow.onMoved(() => { + saveWindowState(StateFlags.POSITION); + }); + + appWindow.onResized(() => { + saveWindowState(StateFlags.SIZE); + }); }); const handleSystemThemeChanged = async () => { diff --git a/src/pages/Clipboard/History/index.tsx b/src/pages/Clipboard/History/index.tsx index 6e0ada4ec..89f230c62 100644 --- a/src/pages/Clipboard/History/index.tsx +++ b/src/pages/Clipboard/History/index.tsx @@ -11,7 +11,6 @@ import { isEqual } from "arcdash"; import clsx from "clsx"; import { merge } from "lodash-es"; import { createContext } from "react"; -import { StateFlags, saveWindowState } from "tauri-plugin-window-state-api"; import { useSnapshot } from "valtio"; import Header from "./components/Header"; import List from "./components/List"; @@ -126,14 +125,6 @@ const ClipboardHistory = () => { merge(clipboardStore, payload); }); - - appWindow.onMoved(() => { - saveWindowState(StateFlags.POSITION); - }); - - appWindow.onResized(() => { - saveWindowState(StateFlags.SIZE); - }); }); useRegister(async () => {