mirror of
https://github.com/infinilabs/coco-app.git
synced 2026-02-24 04:01:27 +01:00
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:
@@ -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>
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user