diff --git a/src/hooks.ts b/src/hooks.ts index 8241782..cc5bc32 100644 --- a/src/hooks.ts +++ b/src/hooks.ts @@ -19,15 +19,13 @@ async function onStartup() { BasicExampleFactory.registerPrefs(); BasicExampleFactory.registerNotifier(); - + KeyExampleFactory.registerShortcuts(); await Promise.all( Zotero.getMainWindows().map((win) => onMainWindowLoad(win)), ); } async function onMainWindowLoad(win: Window) { - KeyExampleFactory.registerShortcuts(win); - UIExampleFactory.registerRightClickMenuItem(); // 右键菜单 // UIExampleFactory.registerRightClickMenuPopup(); // 右键弹出菜单 UIExampleFactory.registerWindowMenuWithSeprator(); diff --git a/src/modules/examples.ts b/src/modules/examples.ts index 5e42f80..a459202 100644 --- a/src/modules/examples.ts +++ b/src/modules/examples.ts @@ -273,7 +273,7 @@ export class KeyExampleFactory { } if (HX) { var HXLevel: any = await KeyExampleFactory.getCustomIFs( - item, + item, HXJourID, ); } @@ -1159,11 +1159,11 @@ export class KeyExampleFactory { } // 注册快捷键 @example - static registerShortcuts(win?: Window) { - if (!win) { - win = Zotero.getMainWindow(); - } - ztoolkit.Keyboard.unregisterAll(); + static registerShortcuts() { + // if (!win) { + // win = Zotero.getMainWindow(); + // } + // ztoolkit.Keyboard.unregisterAll(); // const keysetId = `${config.addonRef}-keyset`; // const cmdsetId = `${config.addonRef}-cmdset`; // const cmdSmallerId = `${config.addonRef}-cmd-smaller`; @@ -1210,112 +1210,35 @@ export class KeyExampleFactory { HelperExampleFactory.chPubTitleCase(); }); } - + ztoolkit.log(`${getString("dataDir")} ${Zotero.DataDirectory.dir}`) + Zotero.debug('数据目录是:'+ `${getString("dataDir")} ${Zotero.DataDirectory.dir}`) // 显示数据目录 if (ifDataDir) { - ztoolkit.Keyboard.register((event, { keyboard }) => { - if (!keyboard?.equals(`alt,${keyDataDir}`)) { - return; - } - - // HelperExampleFactory.progressWindow(`${ifPubTitleCase}${keyPubTitleCase}`, 'success') - // addon.hooks.onShortcuts("larger"); - // HelperExampleFactory.progressWindow(`${ifPubTitleCase} ${keyPubTitleCase} `, 'success'); - HelperExampleFactory.progressWindow( + ztoolkit.Keyboard.register((ev, keyOptions ) => { + ztoolkit.log(ev, keyOptions.keyboard); + if (keyOptions.keyboard?.equals(`alt,${keyDataDir}`)) { + HelperExampleFactory.progressWindow( `${getString("dataDir")} ${Zotero.DataDirectory.dir}`, "success", ); + } }); } - // Register an event key for Alt+P 配置目录 if (ifProfileDir) { - ztoolkit.Keyboard.register((event, { keyboard }) => { - if (!keyboard?.equals(`alt,${keyProfileDir}`)) { - return; - } - // addon.hooks.onShortcuts("larger"); - HelperExampleFactory.progressWindow( + ztoolkit.Keyboard.register((ev, keyOptions ) => { + ztoolkit.log(ev, keyOptions.keyboard); + if (keyOptions.keyboard?.equals(`alt,${keyProfileDir}`)) { + HelperExampleFactory.progressWindow( `${getString("proDir")} ${Zotero.Profile.dir}`, "success", ); - }); + } + }); } + } - // Register an element key using for Alt+S - /* - ztoolkit.Shortcut.register("element", { - id: `${config.addonRef}-key-smaller`, - key: "S", - modifiers: "alt", - xulData: { - document, - command: cmdSmallerId, - _parentId: keysetId, - _commandOptions: { - id: cmdSmallerId, - document, - _parentId: cmdsetId, - oncommand: `'Zotero.${config.addonInstance}.hooks.onShortcuts('smaller')'`, - }, - }, - }); - */ - // Here we register an conflict key for Alt+S - // just to show how the confliction check works. - // This is something you should avoid in your plugin. - /* - ztoolkit.Shortcut.register("event", { - id: `${config.addonRef}-key-smaller-conflict`, - key: "S", - modifiers: "alt", - callback: (keyOptions) => { - ztoolkit.getGlobal("alert")("Smaller! This is a conflict key."); - }, - }); - */ - // Register an event key to check confliction - /* - ztoolkit.Shortcut.register("event", { - id: `${config.addonRef}-key-check-conflict`, - key: "C", - modifiers: "alt", - callback: (keyOptions) => { - addon.hooks.onShortcuts("confliction"); - }, - }); - */ - /* - new ztoolkit.ProgressWindow(config.addonName) - .createLine({ - text: "Example Shortcuts: Alt+L/S/C", - type: "success", - }) - .show(); - */ - } - /* - @example - static exampleShortcutLargerCallback() { - new ztoolkit.ProgressWindow(config.addonName) - .createLine({ - text: "Larger!", - type: "default", - }) - .show(); - } - - @example - static exampleShortcutSmallerCallback() { - new ztoolkit.ProgressWindow(config.addonName) - .createLine({ - text: "Smaller!", - type: "default", - }) - .show(); - } -*/ @example static exampleShortcutConflictionCallback() { return;