This commit is contained in:
luk.lu
2019-10-24 14:59:42 +08:00
parent 199b6c4acd
commit b073f3185f
3 changed files with 35 additions and 1 deletions

View File

@@ -13,14 +13,20 @@ try {
if (fs.existsSync(path.join(process.cwd(), './ConfigBasic.js'))) {
Config=require(path.join(process.cwd(), './ConfigBasic.js'))
console.info('ConfigBasic loaded')
}else {
console.info('Missing and omitting ConfigBasic')
}
if (fs.existsSync(path.join(process.cwd(), './ConfigCustom.js'))) { // 如果存在,覆盖掉 ConfigBasic 里的默认参数
Config=deepmerge(Config, require(path.join(process.cwd(), './ConfigCustom.js'))) // 注意objectMerge后产生了一个新的对象而不是在原来的Config里添加
console.info('ConfigCustom loaded')
}else {
console.info('Missing and omitting ConfigCustom')
}
if (fs.existsSync(path.join(process.cwd(), './ConfigSecret.js'))) { // 如果存在,覆盖掉 ConfigBasic 和 ConfigCustom 里的参数
Config=deepmerge(Config, require(path.join(process.cwd(), './ConfigSecret.js')))
console.info('ConfigSecret loaded')
}else {
console.info('Missing and omitting ConfigSecret')
}
}catch(err){
console.error('Loading config files failed: '+err.message)
@@ -82,7 +88,7 @@ async function init(){ /*** 设置全局对象 ***/
server.use(require('compression')())
/*** 路由 ***/
server.use(require('express').static(path.join(__dirname, 'dist'), {index: 'index.html'}))
server.use(require('express').static(path.join(process.cwd(), 'dist'), {index: 'index.html'}))
// server.use(require('serve-favicon')(path.join(__dirname, 'public', 'favicon.ico'))) // uncomment after placing your favicon in /public
let ipv4 = getMyIp()