-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
95 lines (82 loc) · 2.33 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Windows-mqtt</title>
<script>
const lines = [];
function log(message) {
console.log(message);
window.electronAPI.log(message);
}
async function start() {
window.electronAPI.sendMessage({type: 'getEnabledModules'});
window.electronAPI.onLine((message, logLevel) => {
// lines.push(`[${logLevel}] ${message}`);
lines.push(message);
lines.slice(0, 500);
console.log('log to lines');
const logDiv = document.getElementById('log');
logDiv.innerHTML = lines.map(line => `<div>${line}</div>`).join('\n');
});
window.electronAPI.onMessage((message, logLevel) => {
// log(`Main process message: ${JSON.stringify(message)}`);
// getEnabledModulesResponse
if (message.type === 'getEnabledModulesResponse') {
const enabledModules = message.data;
const modulesList = document.getElementById('enabled-modules');
modulesList.innerHTML = enabledModules.map(mod => `<span class="module">${mod}</span>`).join(', ');
}
//
/*ipcMain.on('log', (event, arg) => {
log(`frontend: ${arg}`);
mainWindow.webContents.send('log-message', arg); // Pe3d6
});*/
});
}
start();
</script>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
#body {
padding: 20px;
}
h1 {
font-size: 24px;
margin-bottom: 10px;
}
ul {
list-style-type: none;
padding: 0;
}
li {
padding: 5px 0;
}
#log {
margin-top: 20px;
padding: 10px;
border: 1px solid #ccc;
background-color: #f9f9f9;
white-space: nowrap;
max-height: 80vh;
overflow-y: auto;
font-family: monospace;
}
</style>
</head>
<body>
<div id="body">
<div>
<b>Enabled Modules:</b>
<span id="enabled-modules"></span>
</div>
<div id="log">
</div>
</div>
</body>
</html>