From 05457d106737428f8f3c6a42084ef348f2b2f954 Mon Sep 17 00:00:00 2001 From: redleafnew Date: Sun, 6 Aug 2023 20:41:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E8=B0=83=E7=94=A8=E4=BB=85=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/modules/examples.ts | 50 +++++------------------------------------ update.json | 2 +- 3 files changed, 8 insertions(+), 46 deletions(-) diff --git a/package.json b/package.json index 1f65f7e..17de349 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "delitemwithatt", - "version": "0.2.2", + "version": "0.2.3", "description": "Delete item(s) with attachment(s)", "config": { "addonName": "Del Item With Attachment", diff --git a/src/modules/examples.ts b/src/modules/examples.ts index 2f7994b..b8ebb94 100644 --- a/src/modules/examples.ts +++ b/src/modules/examples.ts @@ -526,58 +526,20 @@ export class HelperExampleFactory { // var iaInfo = items.length > 1 ? 'delete-item-and-attachment-mul' : 'delete-item-and-attachment-sig'; // var truthBeTold = ztoolkit.getGlobal("confirm")(getString(iaInfo)) var truthBeTold = ztoolkit.getGlobal("confirm")(getString("delete-item-and-attachment", { args: { count: items.length } })); - if (truthBeTold) { + HelperExampleFactory.delAttDo(items); // 调用仅删除附件的函数 for (let item of items) { - if (item && !item.isNote()) { //2 if - if (item.isRegularItem()) { // Regular Item 一般条目//3 if - let attachmentIDs = item.getAttachments(); - for (let id of attachmentIDs) { //4 for - let attachment = Zotero.Items.get(id); - let ifLinks = (attachment.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE); // 检测是否为链接模式 - var file = await attachment.getFilePathAsync(); - if (file && ifLinks) { //如果文件存在(文件可能已经被删除)且为链接模式删除文件 - try { - await Zotero.File.removeIfExists(file); // 尝试删除文件 - } catch (error) { // 弹出错误 - alert(getString("file-is-open")); - return; // 弹出错误后终止执行 - } - } - // if (attachment.attachmentContentType == 'text/html' ) { //可以筛选删除的附件类型 - attachment.deleted = true; //删除附件(快照) - await attachment.saveTx(); - // } - - } //4 for - - } // 3 if - if (item.isAttachment()) { //附件条目 5 if - var ifLinksAtt = (item.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE); //检测是否为链接模式 - var file = await item.getFilePathAsync(); - if (file && ifLinksAtt) { // 如果文件存在(文件可能已经被删除)且为链接模式删除文件 - try { - await Zotero.File.removeIfExists(file); // 尝试删除文件 - } catch (error) { // 弹出错误 - alert(getString("file-is-open")); - return; // 弹出错误后终止执行 - } - } - - }//5if - } //2 if - item.deleted = true; - await item.saveTx(); - + if (item && !item.isNote()) { + item.deleted = true; + await item.saveTx(); + } } BasicExampleFactory.delItemAttSucess(items); // 附件条目删除成功提示; - } } //删除分类条目包括附件 static async delColItemAtt() { - var collection = ZoteroPane.getSelectedCollection(); var items = collection!.getChildItems(); var truthBeTold = window.confirm(getString("delete-collection-and-attachment")) @@ -607,7 +569,7 @@ export class HelperExampleFactory { var truthBeTold = ztoolkit.getGlobal("confirm")(getString("delete-attachment-only", { args: { count: items.length } })); if (truthBeTold) { - HelperExampleFactory.delAttDo(items); // 调用删除条目及附件的函数 + HelperExampleFactory.delAttDo(items); // 调用仅删除附件的函数 BasicExampleFactory.delAttSucess(); // 附件删除成功提示; } } diff --git a/update.json b/update.json index bdae83f..e3d8e85 100644 --- a/update.json +++ b/update.json @@ -12,7 +12,7 @@ } }, { - "version": "0.2.2", + "version": "0.2.3", "update_link": "https://github.com/redleafnew/delitemwithatt/releases/latest/download/delitemwithatt.xpi", "applications": { "zotero": {