refactor: remove the pin button in the standalone window (#1041)

* refactor: remove the pin button in the standalone window

* refactor: update
This commit is contained in:
ayangweb
2025-12-31 14:13:22 +08:00
committed by GitHub
parent a6b6a09af0
commit d00c07e8ec

View File

@@ -1,10 +1,14 @@
import { useAppStore } from "@/stores/appStore";
import { useShortcutsStore } from "@/stores/shortcutsStore";
import { FC, HTMLAttributes, useState } from "react";
import { useMount } from "ahooks";
import clsx from "clsx";
import VisibleKey from "./VisibleKey";
import { FC, HTMLAttributes } from "react";
import PinOffIcon from "@/icons/PinOff";
import PinIcon from "@/icons/Pin";
import platformAdapter from "@/utils/platformAdapter";
import { MAIN_WINDOW_LABEL } from "@/constants";
import { useAppStore } from "@/stores/appStore";
import { useShortcutsStore } from "@/stores/shortcutsStore";
interface TogglePinProps extends HTMLAttributes<HTMLButtonElement> {
setIsPinnedWeb?: (value: boolean) => void;
@@ -14,6 +18,13 @@ const TogglePin: FC<TogglePinProps> = (props) => {
const { className, setIsPinnedWeb } = props;
const { isPinned, setIsPinned } = useAppStore();
const { fixedWindow } = useShortcutsStore();
const [windowLabel, setWindowLabel] = useState<string>();
useMount(async () => {
const label = await platformAdapter.getCurrentWindowLabel();
setWindowLabel(label);
});
const togglePin = async () => {
const { isTauri, isPinned } = useAppStore.getState();
@@ -34,16 +45,18 @@ const TogglePin: FC<TogglePinProps> = (props) => {
};
return (
<button
onClick={togglePin}
className={clsx(className, {
"text-blue-500": isPinned,
})}
>
<VisibleKey shortcut={fixedWindow} onKeyPress={togglePin}>
{isPinned ? <PinIcon /> : <PinOffIcon />}
</VisibleKey>
</button>
windowLabel === MAIN_WINDOW_LABEL && (
<button
onClick={togglePin}
className={clsx(className, {
"text-blue-500": isPinned,
})}
>
<VisibleKey shortcut={fixedWindow} onKeyPress={togglePin}>
{isPinned ? <PinIcon /> : <PinOffIcon />}
</VisibleKey>
</button>
)
);
};