mirror of
https://github.com/siyuan-note/plugin-sample-vite-svelte.git
synced 2025-06-08 02:46:02 +00:00
Use hello both in tab and dialog
This commit is contained in:
parent
5cf4d6efd1
commit
de42dc1b55
2 changed files with 11 additions and 21 deletions
|
@ -8,7 +8,6 @@
|
||||||
import { showMessage } from "siyuan";
|
import { showMessage } from "siyuan";
|
||||||
export let name: string;
|
export let name: string;
|
||||||
export let i18n: any;
|
export let i18n: any;
|
||||||
export let opendCount: number;
|
|
||||||
|
|
||||||
let time;
|
let time;
|
||||||
let ver;
|
let ver;
|
||||||
|
@ -17,14 +16,6 @@
|
||||||
time = new Date();
|
time = new Date();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
let intv2 = setInterval(async () => {
|
|
||||||
ver = await version();
|
|
||||||
showMessage(
|
|
||||||
`[${opendCount}] Hello ${name} v${ver}`,
|
|
||||||
5000
|
|
||||||
);
|
|
||||||
}, 10000);
|
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
time = new Date();
|
time = new Date();
|
||||||
ver = await version();
|
ver = await version();
|
||||||
|
@ -36,7 +27,6 @@
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
showMessage("Hello panel closed");
|
showMessage("Hello panel closed");
|
||||||
clearInterval(intv1);
|
clearInterval(intv1);
|
||||||
clearInterval(intv2);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$: time_str = new Date(time).toLocaleTimeString();
|
$: time_str = new Date(time).toLocaleTimeString();
|
||||||
|
@ -46,7 +36,7 @@
|
||||||
<div id="hello">
|
<div id="hello">
|
||||||
<div class="fn__flex">
|
<div class="fn__flex">
|
||||||
<div class="fn__flex-1">
|
<div class="fn__flex-1">
|
||||||
<h2>[{opendCount}] Hello {name} v{ver}</h2>
|
<h2>Hello {name} v{ver}</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="fn__flex-1 b3-label__text __text-right">
|
<div class="fn__flex-1 b3-label__text __text-right">
|
||||||
{time_str}
|
{time_str}
|
||||||
|
|
16
src/index.ts
16
src/index.ts
|
@ -33,21 +33,22 @@ export default class SamplePlugin extends Plugin {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.customTab = this.addTab({
|
let div = document.createElement("div");
|
||||||
type: TAB_TYPE,
|
new HelloExample({
|
||||||
init() {
|
target: div,
|
||||||
this.tab = new HelloExample({
|
|
||||||
target: this.element,
|
|
||||||
props: {
|
props: {
|
||||||
name: this.i18n.name,
|
name: this.i18n.name,
|
||||||
opendCount: this.counter.hello,
|
|
||||||
i18n: this.i18n.hello
|
i18n: this.i18n.hello
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.customTab = this.addTab({
|
||||||
|
type: TAB_TYPE,
|
||||||
|
init() {
|
||||||
|
this.element.appendChild(div);
|
||||||
|
console.log(this.element);
|
||||||
},
|
},
|
||||||
destroy() {
|
destroy() {
|
||||||
console.log("destroy tab:", TAB_TYPE);
|
console.log("destroy tab:", TAB_TYPE);
|
||||||
this.tab.$destroy(); //Call svelte component destroy
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -192,7 +193,6 @@ export default class SamplePlugin extends Plugin {
|
||||||
target: dialog.element.querySelector("#helloPanel"),
|
target: dialog.element.querySelector("#helloPanel"),
|
||||||
props: {
|
props: {
|
||||||
name: this.i18n.name,
|
name: this.i18n.name,
|
||||||
opendCount: this.counter.hello,
|
|
||||||
i18n: this.i18n.hello
|
i18n: this.i18n.hello
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue