獲取cli安裝目錄
cml -v
[INFO] current running chameleon(安裝目錄)
修改安裝目錄/configs/config.js
增加一個(gè)獲取局域網(wǎng)ip地址的函數(shù)
function getLocalAddress() {
let localWlanHost = 'localhost';
try {
const ifaces = require('os').networkInterfaces();
for (let dev in ifaces) {
ifaces[dev].forEach((details, alias) => {
if (details.family === 'IPv4' && !details.internal && details.address.startsWith('192')) {
localWlanHost = details.address;
}
});
}
} catch (e) { }
return localWlanHost;
}
ip獲取方式修改為使用上面的函數(shù)
// ip: require('ip').address()
ip: getLocalAddress()