From a88618125df7f9b18d6b1699f2f9db8ff50e3751 Mon Sep 17 00:00:00 2001 From: Orchard Date: Wed, 8 May 2024 22:21:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=87=E7=AD=BE=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=EF=BC=8C=E5=B7=B2=E7=BD=AE=E9=A1=B6=E7=9A=84=E5=9C=A8=E5=89=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/svg/tag-pinned.svg | 1 + src/components/LarkIcon/SvgMap.ts | 2 ++ .../component/AddTagButton/TagMenu.module.less | 9 +++++++++ .../ClipAssistant/component/AddTagButton/TagMenu.tsx | 2 ++ .../SuperSideBar/impl/ClipAssistant/index.tsx | 10 ++++++++++ src/core/webProxy/tag.ts | 1 + 6 files changed, 25 insertions(+) create mode 100644 src/assets/svg/tag-pinned.svg diff --git a/src/assets/svg/tag-pinned.svg b/src/assets/svg/tag-pinned.svg new file mode 100644 index 00000000..cfadb6ea --- /dev/null +++ b/src/assets/svg/tag-pinned.svg @@ -0,0 +1 @@ + diff --git a/src/components/LarkIcon/SvgMap.ts b/src/components/LarkIcon/SvgMap.ts index 5504b829..b58e2002 100644 --- a/src/components/LarkIcon/SvgMap.ts +++ b/src/components/LarkIcon/SvgMap.ts @@ -22,6 +22,7 @@ import More from '@/assets/svg/more.svg'; import NoteLogo from '@/assets/svg/note-logo.svg'; import OcrIcon from '@/assets/svg/ocr-icon.svg'; import Setting from '@/assets/svg/setting.svg'; +import TagPinned from '@/assets/svg/tag-pinned.svg'; import TimeOutlined from '@/assets/svg/time-outlined.svg'; import Translate from '@/assets/svg/translate.svg'; import YuqueLogo from '@/assets/svg/yuque-logo.svg'; @@ -48,6 +49,7 @@ export const SvgMaps = { 'note-logo': NoteLogo, 'ocr-icon': OcrIcon, 'setting': Setting, + 'tag-pinned': TagPinned, 'time-outlined': TimeOutlined, 'translate': Translate, 'yuque-logo': YuqueLogo, diff --git a/src/components/SuperSideBar/impl/ClipAssistant/component/AddTagButton/TagMenu.module.less b/src/components/SuperSideBar/impl/ClipAssistant/component/AddTagButton/TagMenu.module.less index 31b8b399..1a9e61ac 100644 --- a/src/components/SuperSideBar/impl/ClipAssistant/component/AddTagButton/TagMenu.module.less +++ b/src/components/SuperSideBar/impl/ClipAssistant/component/AddTagButton/TagMenu.module.less @@ -43,6 +43,15 @@ margin-bottom: 5px; display: flex; align-items: center; + position: relative; + overflow: hidden; + + .pinnedIcon { + color: var(--yq-yuque-green-4); + position: absolute; + left: 0; + top: -3px; + } .tagName { flex: 1; diff --git a/src/components/SuperSideBar/impl/ClipAssistant/component/AddTagButton/TagMenu.tsx b/src/components/SuperSideBar/impl/ClipAssistant/component/AddTagButton/TagMenu.tsx index 810dd5b4..285c2953 100644 --- a/src/components/SuperSideBar/impl/ClipAssistant/component/AddTagButton/TagMenu.tsx +++ b/src/components/SuperSideBar/impl/ClipAssistant/component/AddTagButton/TagMenu.tsx @@ -7,6 +7,7 @@ import { ITag } from '@/core/webProxy/tag'; import { webProxy } from '@/core/webProxy'; import TagInput from './TagInput'; import styles from './TagMenu.module.less'; +import LarkIcon from '@/components/LarkIcon'; export interface ITagMenuProps { tags: ITag[]; @@ -128,6 +129,7 @@ function TagMenu(props: ITagMenuProps) { } }} > + {item.pinned_at ? : null} {item.name} {selected && } diff --git a/src/components/SuperSideBar/impl/ClipAssistant/index.tsx b/src/components/SuperSideBar/impl/ClipAssistant/index.tsx index cab9b376..d79206aa 100644 --- a/src/components/SuperSideBar/impl/ClipAssistant/index.tsx +++ b/src/components/SuperSideBar/impl/ClipAssistant/index.tsx @@ -28,6 +28,7 @@ import { superSidebar } from '@/components/SuperSideBar/index'; import AddTagButton from './component/AddTagButton'; import TagList from './component/TagList'; import styles from './index.module.less'; +import moment from 'moment'; const LoadingMessage = { ocr: __i18n('正在识别中'), @@ -236,6 +237,15 @@ function ClipContent() { const handleRequestTag = async () => { try { const tags = await webProxy.tag.index(); + tags.sort((a, b) => { + if (a.pinned_at && b.pinned_at) { + return moment(a.pinned_at).isBefore(moment(b.pinned_at)) ? 1 : -1; + } + if (a.pinned_at || b.pinned_at) { + return a.pinned_at ? -1 : 1; + } + return 0; + }); setUserTags(tags); } catch (error) { // diff --git a/src/core/webProxy/tag.ts b/src/core/webProxy/tag.ts index 407cc300..3b6dfac3 100644 --- a/src/core/webProxy/tag.ts +++ b/src/core/webProxy/tag.ts @@ -5,6 +5,7 @@ export interface ITag { name: string; created_at: Date; updated_at: Date; + pinned_at?: Date; } export function createTagProxy() {