Skip to content

Commit

Permalink
✨ feat: 调整动态书签组项目的右键菜单
Browse files Browse the repository at this point in the history
1. 移除动态书签组中的删除按钮 close #9
2. 动态书签组增加「复制到其他组」的按钮 close #10
  • Loading branch information
frostime committed Jul 11, 2024
1 parent fc6e110 commit ce9fc9f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sy-bookmark-plus",
"version": "1.1.1",
"version": "1.1.2",
"type": "module",
"description": "A more powerful bookmark",
"repository": "",
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sy-bookmark-plus",
"author": "frostime",
"url": "https://github.com/frostime/sy-bookmark-plus",
"version": "1.1.1",
"version": "1.1.2",
"minAppVersion": "3.0.12",
"backends": [
"all"
Expand Down
3 changes: 2 additions & 1 deletion public/i18n/en_US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ item:
copylink: Copy as Link
msgcopy: Copy Successful
style: Style
transfer: Move to Other Group
transfer: Move to
move: Move
top: Move to Top
bottom: Move to Bottom
del: Delete Bookmark
checkerritem: Check detail
copyitem: Copy to
newgroup:
name:
- Bookmark Group Name
Expand Down
3 changes: 2 additions & 1 deletion public/i18n/zh_CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ item:
copylink: 复制为链接
msgcopy: 复制为引用
style: 样式
transfer: 移动到其他分组
transfer: 移动到
move: 移动
top: 置顶
bottom: 置底
del: 删除书签
checkerritem: 查看失效项详情
copyitem: 复制到
newgroup:
name:
- 书签组名称
Expand Down
51 changes: 34 additions & 17 deletions src/components/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { itemInfo, setGroups, groupMap } from "../model";

import { BookmarkContext, itemMoving, setItemMoving } from "./context";

import { i18n } from "@/utils/i18n";
import { i18n, renderI18n } from "@/utils/i18n";
import { simpleDialog } from "@/libs/dialog";
import Typography from "@/libs/components/typography";

Expand Down Expand Up @@ -183,20 +183,20 @@ const Item: Component<IProps> = (props) => {
]
})
menu.addSeparator();
const staticGroups = shownGroups().filter((g) => g.id !== props.group && g.type !== 'dynamic');
if (!inDynamicGroup()) {
const groups = shownGroups().filter((g) => g.id !== props.group && g.type !== 'dynamic').map((g) => {
return {
label: g.name,
click: () => {
model.transferItem(props.group, g.id, item());
},
};
});
menu.addItem({
label: i18n_.transfer,
icon: "iconFolder",
type: 'submenu',
submenu: groups
submenu: staticGroups.map((g) => {
return {
label: g.name,
click: () => {
model.transferItem(props.group, g.id, item());
},
};
})
});
menu.addItem({
label: i18n_.move,
Expand All @@ -220,14 +220,31 @@ const Item: Component<IProps> = (props) => {
}
]
});
menu.addItem({
label: i18n_.del,
icon: "iconTrashcan",
click: () => {
props.deleteItem(item());
},
});
} else {
menu.addItem({
label: i18n_.copyitem,
icon: "iconFolder",
type: 'submenu',
submenu: staticGroups.map((g) => {
return {
label: g.name,
click: () => {
let ans = model.addItem(g.id, item());
if (ans === 'exists') {
showMessage(renderI18n(i18n.group.msgexist, item().id), 3000, 'error');
}
},
};
})
});
}
menu.addItem({
label: i18n_.del,
icon: "iconTrashcan",
click: () => {
props.deleteItem(item());
},
});
menu.open({
x: e.clientX,
y: e.clientY,
Expand Down
4 changes: 2 additions & 2 deletions src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export class BookmarkDataModel {
}
}

addItem(gid: TBookmarkGroupId, item: IBookmarkItem) {
addItem(gid: TBookmarkGroupId, item: IBookmarkItem): boolean | 'exists' {
let group = groupMap().get(gid);
if (group) {
let exist = itemInfo[item.id] !== undefined;
Expand All @@ -357,7 +357,7 @@ export class BookmarkDataModel {
setItemInfo(item.id, iteminfo);
} else if (this.hasItem(item.id, gid)) {
console.warn(`addItem: item ${item.id} already in group ${gid}`);
return false;
return 'exists';
}

setGroups((g) => g.id === gid, 'items', (items) => {
Expand Down

0 comments on commit ce9fc9f

Please sign in to comment.