onload done

This commit is contained in:
frostime 2023-06-03 16:34:30 +08:00
parent 4dbc215a0e
commit 9f8f1fb69e

View file

@ -19,13 +19,13 @@ const STORAGE_NAME = "menu-config";
const TAB_TYPE = "custom_tab"; const TAB_TYPE = "custom_tab";
const DOCK_TYPE = "dock_tab"; const DOCK_TYPE = "dock_tab";
export default class SamplePlugin extends Plugin { export default class PluginSample extends Plugin {
private customTab: () => any; private customTab: () => IModel;
private isMobile: boolean; private isMobile: boolean;
async onload() { async onload() {
this.data[STORAGE_NAME] = { readonlyText: "Readonly" }; this.data[STORAGE_NAME] = {readonlyText: "Readonly"};
const frontEnd = getFrontend(); const frontEnd = getFrontend();
this.isMobile = frontEnd === "mobile" || frontEnd === "browser-mobile"; this.isMobile = frontEnd === "mobile" || frontEnd === "browser-mobile";
@ -60,7 +60,7 @@ export default class SamplePlugin extends Plugin {
statusIconTemp.content.firstElementChild.addEventListener("click", () => { statusIconTemp.content.firstElementChild.addEventListener("click", () => {
confirm("⚠️", this.i18n.confirmRemove.replace("${name}", this.name), () => { confirm("⚠️", this.i18n.confirmRemove.replace("${name}", this.name), () => {
this.removeData(STORAGE_NAME).then(() => { this.removeData(STORAGE_NAME).then(() => {
this.data[STORAGE_NAME] = { readonlyText: "Readonly" }; this.data[STORAGE_NAME] = {readonlyText: "Readonly"};
showMessage(`[${this.name}]: ${this.i18n.removedData}`); showMessage(`[${this.name}]: ${this.i18n.removedData}`);
}); });
}); });
@ -69,9 +69,9 @@ export default class SamplePlugin extends Plugin {
element: statusIconTemp.content.firstElementChild as HTMLElement, element: statusIconTemp.content.firstElementChild as HTMLElement,
}); });
let div = document.createElement("div"); let tabDiv = document.createElement("div");
new HelloExample({ new HelloExample({
target: div, target: tabDiv,
props: { props: {
name: this.i18n.name, name: this.i18n.name,
i18n: this.i18n.hello i18n: this.i18n.hello
@ -80,7 +80,7 @@ export default class SamplePlugin extends Plugin {
this.customTab = this.addTab({ this.customTab = this.addTab({
type: TAB_TYPE, type: TAB_TYPE,
init() { init() {
this.element.appendChild(div); this.element.appendChild(tabDiv);
console.log(this.element); console.log(this.element);
}, },
destroy() { destroy() {
@ -99,8 +99,8 @@ export default class SamplePlugin extends Plugin {
this.addDock({ this.addDock({
config: { config: {
position: "LeftBottom", position: "LeftBottom",
size: { width: 200, height: 0 }, size: {width: 200, height: 0},
icon: "iconEmoji", icon: "iconSaving",
title: "Custom Dock", title: "Custom Dock",
}, },
data: { data: {