INNER CODE UNIT · JavaScript
openUrl
wangshengithub/staticshield · encrypt.js:45
function openUrl(url) {
if (process.platform === 'win32') spawnSync('cmd', ['/c', 'start', '', url], { stdio: 'ignore' });
else if (process.platform === 'darwin') spawnSync('open', [url], { stdio: 'ignore' });
else spawnSync('xdg-open', [url], { stdio: 'ignore' });
}
async function startGui() {
const guiPath = path.join(__dirname, 'gui', 'index.html');
if (!fs.existsSync(guiPath)) { console.error('未找到 Web GUI(gui/index.html)。请先运行:node src/build-gui.js'); process.exit(1); }
const { startServer } = require('./src/server');
let info;
try { info = await startServer({ guiPath }); } catch (e) { console.error('启动本地服务失败:' + e.message); process.exit(1); }
const url = 'http://' + info.host + ':' + info.port + '/';
console.log('StaticShield GUI 已启动:' + url);
console.log('(多个客户端可同时访问该地址进行并行加密;按 Ctrl+C 停止服务)');
openUrl(url);
}