From aca80ec6fc7629bc7c43e94faa9a20b37d2c737b Mon Sep 17 00:00:00 2001 From: Linxzh Date: Tue, 12 Dec 2023 16:48:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DPDFtk=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=B7=AF=E5=BE=84=E6=A3=80=E6=B5=8B=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/preferenceScript.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/modules/preferenceScript.ts b/src/modules/preferenceScript.ts index cf14964..d8157bd 100644 --- a/src/modules/preferenceScript.ts +++ b/src/modules/preferenceScript.ts @@ -7,11 +7,12 @@ export async function checkPath(pathvalue: string): Promise { if (!pathvalue) return; let pdftk = ""; if (ztoolkit.getGlobal("Zotero").isWin) { - pdftk = OS.Path.join(pathvalue, "pdftk.exe"); + pdftk = PathUtils.join(pathvalue, "pdftk.exe"); } else { - pdftk = OS.Path.join(pathvalue, "pdftk"); + pdftk = PathUtils.join(pathvalue, "pdftk"); } - const check = await OS.File.exists(pdftk); + const check = await IOUtils.exists(pdftk); + ztoolkit.log(check); addon.data .prefs!.window.document.querySelector("#path-accept") ?.setAttribute("hidden", `${!check}`); @@ -21,13 +22,13 @@ export async function checkPath(pathvalue: string): Promise { } async function getLastUpdateFromFile(filename: string): Promise { - const desPath = ztoolkit - .getGlobal("OS") - .Path.join( + const desPath = PathUtils.join( + PathUtils.join( ztoolkit.getGlobal("Zotero").Prefs.get("dataDir") as string, "translators", filename - ); + ) + ); Zotero.debug(desPath); if (!(await ztoolkit.getGlobal("OS").File.exists(desPath))) { Zotero.debug(filename + " not exists"); @@ -238,14 +239,12 @@ async function updatePrefsUI() { // You can initialize some UI elements on prefs window // with addon.data.prefs.window.document // Or bind some events to the elements + if (addon.data.prefs?.window == undefined) return; + ztoolkit.log("***** update UI"); const renderLock = ztoolkit.getGlobal("Zotero").Promise.defer(); - - if (addon.data.prefs?.window == undefined) return; // Update pdftk check icon - await checkPath( - ztoolkit.getGlobal("Zotero").Prefs.get("jasminum.pdftkpath") as string - ); + await checkPath(getPref("pdftkpath") as string); // Update translator table await insertTable(true, true); await renderLock.promise;