Skip to content

Commit 0b7002e

Browse files
committed
🎨 add fetch API
1 parent 7d55a5c commit 0b7002e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
getFrontend,
1010
getBackend,
1111
IModel,
12-
Setting
12+
Setting, fetchPost
1313
} from "siyuan";
1414
import "./index.scss";
1515

@@ -211,11 +211,15 @@ export default class PluginSample extends Plugin {
211211
}
212212

213213
private showDialog() {
214-
new Dialog({
214+
const dialog = new Dialog({
215215
title: "Info",
216-
content: '<div class="b3-dialog__content">This is a dialog</div>',
216+
content: '<div class="b3-dialog__content">System current time: <span id="time"></span></div>',
217217
width: this.isMobile ? "92vw" : "520px",
218218
});
219+
fetchPost("/api/system/currentTime", {}, (response) => {
220+
dialog.element.querySelector("#time").innerHTML = new Date(response.data).toString()
221+
222+
})
219223
}
220224

221225
private addMenu(rect?: DOMRect) {

0 commit comments

Comments
 (0)