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";
|
||||
export let name: string;
|
||||
export let i18n: any;
|
||||
export let opendCount: number;
|
||||
|
||||
let time;
|
||||
let ver;
|
||||
|
@ -17,14 +16,6 @@
|
|||
time = new Date();
|
||||
}, 1000);
|
||||
|
||||
let intv2 = setInterval(async () => {
|
||||
ver = await version();
|
||||
showMessage(
|
||||
`[${opendCount}] Hello ${name} v${ver}`,
|
||||
5000
|
||||
);
|
||||
}, 10000);
|
||||
|
||||
onMount(async () => {
|
||||
time = new Date();
|
||||
ver = await version();
|
||||
|
@ -36,7 +27,6 @@
|
|||
onDestroy(() => {
|
||||
showMessage("Hello panel closed");
|
||||
clearInterval(intv1);
|
||||
clearInterval(intv2);
|
||||
});
|
||||
|
||||
$: time_str = new Date(time).toLocaleTimeString();
|
||||
|
@ -46,7 +36,7 @@
|
|||
<div id="hello">
|
||||
<div class="fn__flex">
|
||||
<div class="fn__flex-1">
|
||||
<h2>[{opendCount}] Hello {name} v{ver}</h2>
|
||||
<h2>Hello {name} v{ver}</h2>
|
||||
</div>
|
||||
<div class="fn__flex-1 b3-label__text __text-right">
|
||||
{time_str}
|
||||
|
|
20
src/index.ts
20
src/index.ts
|
@ -33,21 +33,22 @@ export default class SamplePlugin extends Plugin {
|
|||
}
|
||||
});
|
||||
|
||||
let div = document.createElement("div");
|
||||
new HelloExample({
|
||||
target: div,
|
||||
props: {
|
||||
name: this.i18n.name,
|
||||
i18n: this.i18n.hello
|
||||
}
|
||||
});
|
||||
this.customTab = this.addTab({
|
||||
type: TAB_TYPE,
|
||||
init() {
|
||||
this.tab = new HelloExample({
|
||||
target: this.element,
|
||||
props: {
|
||||
name: this.i18n.name,
|
||||
opendCount: this.counter.hello,
|
||||
i18n: this.i18n.hello
|
||||
}
|
||||
});
|
||||
this.element.appendChild(div);
|
||||
console.log(this.element);
|
||||
},
|
||||
destroy() {
|
||||
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"),
|
||||
props: {
|
||||
name: this.i18n.name,
|
||||
opendCount: this.counter.hello,
|
||||
i18n: this.i18n.hello
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue