Skip to content

Commit

Permalink
refactor: 优化逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb committed Sep 1, 2024
1 parent cbf9b21 commit c8bf461
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 权限查询的插件
Expand Down
9 changes: 9 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -36,6 +37,14 @@ const App = () => {

showWindow();
});

appWindow.onMoved(() => {
saveWindowState(StateFlags.POSITION);
});

appWindow.onResized(() => {
saveWindowState(StateFlags.SIZE);
});
});

const handleSystemThemeChanged = async () => {
Expand Down
9 changes: 0 additions & 9 deletions src/pages/Clipboard/History/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -126,14 +125,6 @@ const ClipboardHistory = () => {

merge(clipboardStore, payload);
});

appWindow.onMoved(() => {
saveWindowState(StateFlags.POSITION);
});

appWindow.onResized(() => {
saveWindowState(StateFlags.SIZE);
});
});

useRegister(async () => {
Expand Down

0 comments on commit c8bf461

Please sign in to comment.