-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb-ui.js
More file actions
30 lines (27 loc) · 842 Bytes
/
web-ui.js
File metadata and controls
30 lines (27 loc) · 842 Bytes
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
const os = require('node:os');
const { startServer } = require('./web/server');
function listLocalIps() {
const nets = os.networkInterfaces();
const ips = [];
for (const name of Object.keys(nets)) {
const list = nets[name] || [];
for (const item of list) {
if (item.family === 'IPv4' && !item.internal) {
ips.push(item.address);
}
}
}
return [...new Set(ips)];
}
async function main() {
const started = await startServer({});
const ips = listLocalIps();
console.log(`[WebUI] 控制台已启动: http://127.0.0.1:${started.port}`);
for (const ip of ips) {
console.log(`[WebUI] 局域网访问: http://${ip}:${started.port}`);
}
}
main().catch((err) => {
console.error('[WebUI] 启动失败:', err);
process.exit(1);
});