fix: pref window

fix: bootstrap bug
This commit is contained in:
xiangyu 2022-12-16 12:17:18 +08:00
parent 0b34640100
commit 583fbf166e
3 changed files with 14 additions and 16 deletions

13
addon/bootstrap.js vendored
View File

@ -7,6 +7,8 @@ if (typeof Zotero == "undefined") {
var Zotero; var Zotero;
} }
var chromeHandle;
// In Zotero 6, bootstrap methods are called before Zotero is initialized, and using include.js // In Zotero 6, bootstrap methods are called before Zotero is initialized, and using include.js
// to get the Zotero XPCOM service would risk breaking Zotero startup. Instead, wait for the main // to get the Zotero XPCOM service would risk breaking Zotero startup. Instead, wait for the main
// Zotero window to open and get the Zotero object from there. // Zotero window to open and get the Zotero object from there.
@ -78,16 +80,17 @@ async function startup({ id, version, resourceURI, rootURI }, reason) {
"@mozilla.org/addons/addon-manager-startup;1" "@mozilla.org/addons/addon-manager-startup;1"
].getService(Components.interfaces.amIAddonManagerStartup); ].getService(Components.interfaces.amIAddonManagerStartup);
var manifestURI = Services.io.newURI(rootURI + "manifest.json"); var manifestURI = Services.io.newURI(rootURI + "manifest.json");
var chromeHandle = aomStartup.registerChrome(manifestURI, [ chromeHandle = aomStartup.registerChrome(manifestURI, [
["content", "__addonRef__", "chrome/content/"], ["content", "__addonRef__", rootURI + "chrome/content/"],
["locale", "__addonRef__", "en-US", "chrome/locale/en-US/"], ["locale", "__addonRef__", "en-US", rootURI + "chrome/locale/en-US/"],
["locale", "__addonRef__", "zh-CN", "chrome/locale/zh-CN/"], ["locale", "__addonRef__", "zh-CN", rootURI + "chrome/locale/zh-CN/"],
]); ]);
Zotero.PreferencePanes.register({ Zotero.PreferencePanes.register({
pluginID: "__addonID__", pluginID: "__addonID__",
src: `${rootURI}/chrome/content/preferences.xhtml`, src: rootURI + "chrome/content/preferences.xhtml",
extraDTD: [`chrome://__addonRef__/locale/overlay.dtd`], extraDTD: [`chrome://__addonRef__/locale/overlay.dtd`],
defaultXUL: true,
}); });
} }
} }

View File

@ -1,13 +1,13 @@
<xul:vbox <vbox
id="zotero-prefpane-__addonRef__" id="zotero-prefpane-__addonRef__"
onload="Zotero.AddonTemplate.prefs.initPreferences(window)" onload="Zotero.AddonTemplate.prefs.initPreferences(window)"
> >
<xul:groupbox> <groupbox>
<label><h2>Addon Template Example</h2></label> <label><html:h2>Addon Template Example</html:h2></label>
<xul:checkbox <checkbox
id="zotero-prefpane-__addonRef__-enable" id="zotero-prefpane-__addonRef__-enable"
preference="pref-__addonRef__-enable" preference="pref-__addonRef__-enable"
label="&zotero.__addonRef__.pref.enable.label;" label="&zotero.__addonRef__.pref.enable.label;"
/> />
</xul:groupbox> </groupbox>
</xul:vbox> </vbox>

View File

@ -62,11 +62,6 @@ class AddonViews extends AddonModule {
public initPrefs() { public initPrefs() {
const Zotero = this._Addon.Zotero; const Zotero = this._Addon.Zotero;
Zotero.PreferencePanes.register({
pluginID: addonID,
src: `${this._Addon.rootURI}/chrome/content/preferences.xhtml`,
extraDTD: [`chrome://${addonRef}/locale/overlay.dtd`],
});
} }
public unInitViews() { public unInitViews() {