forked from mirror/MCSManager
删除 - 去除新闻请求时的输出
This commit is contained in:
parent
e286467f93
commit
e78d01aefa
@ -1,14 +1,13 @@
|
||||
const fs = require('fs');
|
||||
const http = require('http');
|
||||
|
||||
|
||||
//最新动态信息获取模块,如果你不需要这个功能,你可以将这里的全部代码删除!
|
||||
|
||||
//地址 与 备用地址
|
||||
let newsUrl1 = 'http://www.suwings.top/mcserver/?_=' + Date.parse(new Date());
|
||||
let newsUrl2 = 'http://mcservermanager.oss-cn-beijing.aliyuncs.com/news.json?_= ' + Date.parse(new Date());
|
||||
|
||||
let requestNewsUrl = newsUrl1;
|
||||
|
||||
let requestNewsCount = 1;
|
||||
|
||||
function requestNewsError() {
|
||||
@ -16,47 +15,31 @@ function requestNewsError() {
|
||||
//尝试第二次链接
|
||||
requestNewsUrl = newsUrl2;
|
||||
requestNewsCount++;
|
||||
requestNews()
|
||||
MCSERVER.infoLog('Exception'.red, '第一次发起请求失败,启动备用服务器链接', true);
|
||||
requestNews();
|
||||
return;
|
||||
}
|
||||
MCSERVER.infoLog('Exception'.red, '读取最新动态失败', true);
|
||||
}
|
||||
|
||||
|
||||
//get 请求外网
|
||||
function requestNews() {
|
||||
|
||||
|
||||
let req = http.get(requestNewsUrl, function(req, res) {
|
||||
MCSERVER.log('版本管理机制准备');
|
||||
let req = http.get(requestNewsUrl, function (req, res) {
|
||||
var html = '';
|
||||
|
||||
req.on('data', (data) => html += data);
|
||||
req.on('end', () => {
|
||||
MCSERVER.log('正在获取版本动态...');
|
||||
//判断是否是正确的
|
||||
try {
|
||||
JSON.parse(html);
|
||||
fs.writeFile('./public/news.json', html, function(err) {
|
||||
fs.writeFile('./public/news.json', html, function (err) {
|
||||
if (err) {
|
||||
console.error('更新最新资讯写入失败');
|
||||
return;
|
||||
}
|
||||
MCSERVER.log('保存最新版本动态完成')
|
||||
MCSERVER.infoLog('Done','Module 集合与 AppListen 已全部执行')
|
||||
});
|
||||
} catch (err) {
|
||||
// MCSERVER.log('')
|
||||
console.error(err)
|
||||
requestNewsError();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
req.on("error", function(err) {
|
||||
console.error(err)
|
||||
req.on("error", function (err) {
|
||||
requestNewsError();
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user