add webview

This commit is contained in:
polv committed 2026-03-23 17:01:58 +07:00
1 parent b7090b6ed2
commit e3d06ebe9f
6 files changed
+803 -7

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
const { Webview } = require("webview-nodejs");
const { spawn } = require("child_process");
const PORT = 5173;
const p = spawn("pnpm", ["vitepress", "dev", "--port", String(PORT), "docs"], {
shell: true,
stdio: "inherit",
});
const w = new Webview();
w.title(require("./package.json").name);
w.size(1920, 1280);
w.init(/* js */ `
document.addEventListener('click', (ev) => {
if (ev.target.matches('a')) {
const href = ev.target.href || '';
if (href.startsWith('https://')) ev.preventDefault();
}
})
`);
w.navigate(`http://localhost:${PORT}`);
w.show();
console.log(p.kill("SIGINT"));
require("kill-port")(PORT);