Merge branch 'master' of ssh://git.infini.ltd:64221/infini/logging-center

This commit is contained in:
medcl 2020-03-22 13:45:33 +08:00
commit 1e03bc9ada
2 changed files with 18 additions and 0 deletions

View File

@ -4,6 +4,9 @@ const Controller = require('egg').Controller;
class HomeController extends Controller {
async index() {
if(this.app.config.env == "local") {
this.app.config.assets.url = `http://${this.ctx.helper.getIPAddress()}:10000`;
}
await this.ctx.render('index.html');
}

15
app/extend/helper.js Normal file
View File

@ -0,0 +1,15 @@
const os = require('os');
module.exports = {
getIPAddress() {
var interfaces = os.networkInterfaces();
for (var devName in interfaces) {
var iface = interfaces[devName];
for (var i = 0; i < iface.length; i++) {
var alias = iface[i];
if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
return alias.address;
}
}
}
},
};