From 20837dedb357e7015bdd187cf5f7c9353e92a13c Mon Sep 17 00:00:00 2001 From: ousugo Date: Sun, 19 Jan 2025 01:53:29 +0800 Subject: [PATCH] feat: add pinning functionality for MinApp component --- src/renderer/src/components/MinApp/index.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/MinApp/index.tsx b/src/renderer/src/components/MinApp/index.tsx index a59a7c344..109f28b91 100644 --- a/src/renderer/src/components/MinApp/index.tsx +++ b/src/renderer/src/components/MinApp/index.tsx @@ -1,7 +1,8 @@ /* eslint-disable react/no-unknown-property */ -import { CloseOutlined, ExportOutlined, ReloadOutlined } from '@ant-design/icons' +import { CloseOutlined, ExportOutlined, PushpinOutlined, ReloadOutlined } from '@ant-design/icons' import { isMac, isWindows } from '@renderer/config/constant' import { useBridge } from '@renderer/hooks/useBridge' +import { useMinapps } from '@renderer/hooks/useMinapps' import store from '@renderer/store' import { setMinappShow } from '@renderer/store/runtime' import { MinAppType } from '@renderer/types' @@ -20,6 +21,8 @@ interface Props { } const PopupContainer: React.FC = ({ app, resolve }) => { + const { pinned, updatePinnedMinapps } = useMinapps() + const isPinned = pinned.some((p) => p.id === app.id) const [open, setOpen] = useState(true) const [opened, setOpened] = useState(false) const [isReady, setIsReady] = useState(false) @@ -47,6 +50,10 @@ const PopupContainer: React.FC = ({ app, resolve }) => { window.api.openWebsite(app.url) } + const onTogglePin = () => { + const newPinned = isPinned ? pinned.filter((item) => item.id !== app.id) : [...pinned, app] + updatePinnedMinapps(newPinned) + } const Title = () => { return ( @@ -55,6 +62,9 @@ const PopupContainer: React.FC = ({ app, resolve }) => { + {canOpenExternalLink && (