diff --git a/src/components/Common/TogglePin.tsx b/src/components/Common/TogglePin.tsx index 36d9ff19..56c0eb09 100644 --- a/src/components/Common/TogglePin.tsx +++ b/src/components/Common/TogglePin.tsx @@ -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 { setIsPinnedWeb?: (value: boolean) => void; @@ -14,6 +18,13 @@ const TogglePin: FC = (props) => { const { className, setIsPinnedWeb } = props; const { isPinned, setIsPinned } = useAppStore(); const { fixedWindow } = useShortcutsStore(); + const [windowLabel, setWindowLabel] = useState(); + + useMount(async () => { + const label = await platformAdapter.getCurrentWindowLabel(); + + setWindowLabel(label); + }); const togglePin = async () => { const { isTauri, isPinned } = useAppStore.getState(); @@ -34,16 +45,18 @@ const TogglePin: FC = (props) => { }; return ( - + windowLabel === MAIN_WINDOW_LABEL && ( + + ) ); };