Skip to content

Commit

Permalink
fix #114
Browse files Browse the repository at this point in the history
  • Loading branch information
MuiseDestiny committed May 30, 2024
1 parent 0c90776 commit c26494e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zotero-attanger",
"version": "1.2.2",
"version": "1.2.3",
"description": "Attanger for Zotero",
"config": {
"addonName": "Zotero Attanger",
Expand Down Expand Up @@ -133,4 +133,4 @@
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
}
}
}
}
29 changes: 23 additions & 6 deletions src/modules/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,23 @@ export default class Menu {
label: getString("attachment-manager"),
icon: addon.data.icons.favicon,
subElementOptions: [
{
tag: "menuitem",
label: getString("rename-move-attachment"),
icon: addon.data.icons.renameMoveAttachment,
commandListener: async (_ev) => {
for (const item of getAttachmentItems()) {
try {
const attItem = await renameFile(item) as Zotero.Item;
attItem && await moveFile(attItem);
attItem && showAttachmentItem(attItem);
} catch (e) {
ztoolkit.log(e);
}
}
},
},
{ tag: "menuseparator" },
{
tag: "menuitem",
label: getString("rename-attachment"),
Expand Down Expand Up @@ -219,7 +236,7 @@ export default class Menu {
label: getString("undo-move-attachment"),
icon: addon.data.icons.undoMoveFile,
commandListener: async () => {
await ZoteroPane.convertLinkedFilesToStoredFiles()
await ZoteroPane.convertLinkedFilesToStoredFiles();
},
},
],
Expand Down Expand Up @@ -549,7 +566,9 @@ export async function moveFile(attItem: Zotero.Item) {
// @ts-ignore 未添加属性
const _getValidFileName = Zotero.File.getValidFileName;
// @ts-ignore 未添加属性
Zotero.File.getValidFileName = fileName => fileName.replace(/[?\*:|"<>]/g, '');
Zotero.File.getValidFileName = (fileName) =>
// @ts-ignore
fileName.replace(/[?\*:|"<>]/g, "");
if (subfolderFormat.length > 0) {
subfolder = subfolderFormat
.split(/[\\/]/)
Expand Down Expand Up @@ -584,7 +603,7 @@ export async function moveFile(attItem: Zotero.Item) {
if (sourcePath == destPath) return;
// window.alert(destPath)
if (
await IOUtils.exists(destPath) &&
(await IOUtils.exists(destPath)) &&
file2md5(sourcePath) != file2md5(destPath)
) {
await Zotero.Promise.delay(1000);
Expand Down Expand Up @@ -718,9 +737,8 @@ function removeFile(file: any, force = false) {
}
}


function file2md5(filepath: string) {
Zotero.Utilities.Internal.md5(Zotero.File.pathToFile(filepath))
Zotero.Utilities.Internal.md5(Zotero.File.pathToFile(filepath));
}
/**
* 获取Item的分类路径
Expand Down Expand Up @@ -1016,7 +1034,6 @@ function cleanLigature(filename: string) {
return result;
}


/**
* 对Zotero.PDFWorker.getRecognizerData的重写,以便支持直接给出路径。
*/
Expand Down
2 changes: 1 addition & 1 deletion update-beta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"[email protected]": {
"updates": [
{
"version": "1.2.2",
"version": "1.2.3",
"update_link": "https://github.com/muisedestiny/zotero-attanger/releases/latest/download/zotero-attanger.xpi",
"applications": {
"zotero": {
Expand Down
2 changes: 1 addition & 1 deletion update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"[email protected]": {
"updates": [
{
"version": "1.2.2",
"version": "1.2.3",
"update_link": "https://github.com/muisedestiny/zotero-attanger/releases/latest/download/zotero-attanger.xpi",
"applications": {
"zotero": {
Expand Down

0 comments on commit c26494e

Please sign in to comment.