Skip to content

Commit cc96684

Browse files
committed
修正菜单重复的问题 Fix the menu duplication issue.
2 parents e33e256 + 56fb342 commit cc96684

4 files changed

Lines changed: 37 additions & 36 deletions

File tree

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "custom-image-auto-uploader",
33
"name": "Custom Image Auto Uploader",
4-
"version": "2.9.1",
4+
"version": "2.9.3",
55
"minAppVersion": "1.6.5",
66
"description": "You can batch download images from your notes on desktop, iOS, and Android platforms, and batch upload and save them to a remote server, home NAS, or cloud storage (such as Alibaba Cloud OSS, Amazon S3, Cloudflare R2, MinIO). Additionally, you can stretch, crop, and resize the images.",
77
"author": "HaierKeys",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Custom Image Auto Uploader",
3-
"version": "2.9.1",
3+
"version": "2.9.3",
44
"description": "You can upload and save images from your notes to your remote server, home NAS, or sync them to your cloud storage (Alibaba Cloud OSS, Amazon S3, Cloudflare R2).",
55
"main": "main.js",
66
"scripts": {

src/lib/utils.ts

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ export function statusCheck(plugin: CustomImageAutoUploader): void {
481481
plugin.statusBar[2].setText(title)
482482
}
483483

484-
export function setMenu(menu: Menu, plugin: CustomImageAutoUploader, isShowAuto: boolean = false) {
484+
export function setMenu(menu: Menu, plugin: CustomImageAutoUploader, isShowAuto: boolean = false, isNoteMenu: boolean = false) {
485485
if (isShowAuto) {
486486

487487
//ddddd
@@ -525,39 +525,40 @@ export function setMenu(menu: Menu, plugin: CustomImageAutoUploader, isShowAuto:
525525
})
526526
})
527527

528+
if (!isNoteMenu) {
528529

530+
menu.addSeparator()
529531

530-
menu.addSeparator()
531-
532-
menu.addItem((item: MenuItem) => {
533-
item
534-
.setIcon("download-cloud")
535-
.setTitle($("下载全库图片"))
536-
.onClick(async () => {
537-
plugin.resetStatus("download", true)
538-
await plugin.VaultDownImage()
539-
showTaskNotice(plugin, "download")
540-
statusCheck(plugin)
541-
})
542-
})
543-
menu.addItem((item: MenuItem) => {
544-
item
545-
.setIcon("upload-cloud")
546-
.setTitle($("上传全库图片"))
547-
.onClick(async () => {
548-
plugin.resetStatus("upload", true)
549-
await plugin.VaultUploadImage()
550-
showTaskNotice(plugin, "upload")
551-
statusCheck(plugin)
552-
})
553-
})
532+
menu.addItem((item: MenuItem) => {
533+
item
534+
.setIcon("download-cloud")
535+
.setTitle($("下载全库图片"))
536+
.onClick(async () => {
537+
plugin.resetStatus("download", true)
538+
await plugin.VaultDownImage()
539+
showTaskNotice(plugin, "download")
540+
statusCheck(plugin)
541+
})
542+
})
543+
menu.addItem((item: MenuItem) => {
544+
item
545+
.setIcon("upload-cloud")
546+
.setTitle($("上传全库图片"))
547+
.onClick(async () => {
548+
plugin.resetStatus("upload", true)
549+
await plugin.VaultUploadImage()
550+
showTaskNotice(plugin, "upload")
551+
statusCheck(plugin)
552+
})
553+
})
554554

555-
menu.addItem((item: MenuItem) => {
556-
item
557-
.setIcon("trash")
558-
.setTitle($("删除未引用图片(全库)"))
559-
.onClick(async () => {
560-
await plugin.VaultDeleteUnreferencedImages()
561-
})
562-
})
555+
menu.addItem((item: MenuItem) => {
556+
item
557+
.setIcon("trash")
558+
.setTitle($("删除未引用图片(全库)"))
559+
.onClick(async () => {
560+
await plugin.VaultDeleteUnreferencedImages()
561+
})
562+
})
563+
}
563564
}

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default class CustomImageAutoUploader extends Plugin {
114114
// 注册菜单
115115
this.registerEvent(
116116
this.app.workspace.on("file-menu", (menu: Menu) => {
117-
setMenu(menu, this)
117+
setMenu(menu, this, true, true)
118118
})
119119
)
120120
// this.registerEvent(

0 commit comments

Comments
 (0)