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 chromeHandle;
// 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
// 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"
].getService(Components.interfaces.amIAddonManagerStartup);
var manifestURI = Services.io.newURI(rootURI + "manifest.json");
var chromeHandle = aomStartup.registerChrome(manifestURI, [
["content", "__addonRef__", "chrome/content/"],
["locale", "__addonRef__", "en-US", "chrome/locale/en-US/"],
["locale", "__addonRef__", "zh-CN", "chrome/locale/zh-CN/"],
chromeHandle = aomStartup.registerChrome(manifestURI, [
["content", "__addonRef__", rootURI + "chrome/content/"],
["locale", "__addonRef__", "en-US", rootURI + "chrome/locale/en-US/"],
["locale", "__addonRef__", "zh-CN", rootURI + "chrome/locale/zh-CN/"],
]);
Zotero.PreferencePanes.register({
pluginID: "__addonID__",
src: `${rootURI}/chrome/content/preferences.xhtml`,
src: rootURI + "chrome/content/preferences.xhtml",
extraDTD: [`chrome://__addonRef__/locale/overlay.dtd`],
defaultXUL: true,
});
}
}

View File

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

View File

@ -62,11 +62,6 @@ class AddonViews extends AddonModule {
public initPrefs() {
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() {