Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 标签排序,将有置顶标识的标签排在前面 #240

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/assets/svg/tag-pinned.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/components/LarkIcon/SvgMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -128,6 +129,7 @@ function TagMenu(props: ITagMenuProps) {
}
}}
>
{item.pinned_at ? <LarkIcon name='tag-pinned' className={styles.pinnedIcon} size={12} /> : null}
<span className={styles.tagName}>{item.name}</span>
{selected && <CheckOutlined width={16} className={styles.checkedIcon} />}
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/components/SuperSideBar/impl/ClipAssistant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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('正在识别中'),
Expand Down Expand Up @@ -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) {
//
Expand Down
1 change: 1 addition & 0 deletions src/core/webProxy/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface ITag {
name: string;
created_at: Date;
updated_at: Date;
pinned_at?: Date;
}

export function createTagProxy() {
Expand Down