/
dimamir
/
undb
Обзор
Документация
Войти
/
dimamir
/
undb
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
apps/desktop/index.html
54 строки
2 KB
nichenqin
fix: update port
30 июл 2024, 08:54
30 июл 2024, 08:54
fb2ff00
Код
Авторство
О чём код?
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Sidecar</title> <style> .container { display: flex; } .container > div { flex: 1; } </style> </head> <body> <div class="container"> <div id="frontend"></div> <div id="backend"></div> </div> <script> function addMessage(div, message) { const p = document.createElement("p") p.innerText = message div.appendChild(p) } const backendDiv = document.getElementById("backend") const frontendDiv = document.getElementById("frontend") const { Command } = window.__TAURI__.shell const { listen } = window.__TAURI__.event const command = Command.sidecar("binaries/app", [], { NODE_ENV: "production" }) command.on("close", (data) => { addMessage(frontendDiv, `command finished with code ${data.code} and signal ${data.signal}`) }) command.on("error", (error) => addMessage(frontendDiv, `command error: "${error}"`)) command.stdout.on("data", (line) => addMessage(frontendDiv, `command stdout: "${line}"`)) command.stderr.on("data", (line) => addMessage(frontendDiv, `command stderr: "${line}"`)) command.spawn() listen("message", (event) => { addMessage(backendDiv, event.payload) }) setTimeout(() => { // TODO: dynamic globalThis.location.replace("http://localhost:4728") }, 5000) </script> </body> </html>