fix-offline-baidu-host-resolve-bug

This commit is contained in:
unknown
2025-05-14 11:13:36 +08:00
parent c250a1506f
commit 2a92fa385b

View File

@@ -1868,19 +1868,25 @@ var mixioServer = async function() {
if (globalWeather[req.query.dsc_code] && globalWeather[req.query.dsc_code].time && (new Date().getTime() - globalWeather[req.query.dsc_code].time) < 600000) { if (globalWeather[req.query.dsc_code] && globalWeather[req.query.dsc_code].time && (new Date().getTime() - globalWeather[req.query.dsc_code].time) < 600000) {
res.send(globalWeather[req.query.dsc_code].data) res.send(globalWeather[req.query.dsc_code].data)
} else { } else {
http.get('http://api.map.baidu.com/weather/v1/?district_id=' + req.query.dsc_code + '&data_type=now&ak=' + configs["BAIDU_MAP_SERVER_AK"], function(req2, res2) { try {
var html = '' http.get('http://api.map.baidu.com/weather/v1/?district_id=' + req.query.dsc_code + '&data_type=now&ak=' + configs["BAIDU_MAP_SERVER_AK"], function(req2, res2) {
req2.on('data', function(data) { var html = ''
html += data; req2.on('data', function(data) {
}); html += data;
req2.on('end', function() { });
globalWeather[req.query.dsc_code] = { req2.on('end', function() {
time: new Date().getTime(), globalWeather[req.query.dsc_code] = {
data: html time: new Date().getTime(),
} data: html
res.send(html) }
}); res.send(html)
}) });
}).on('error', function(e) {
res.send('-1')
})
} catch (e) {
res.send('-1')
}
} }
} else } else
res.send('-1') res.send('-1')
@@ -1891,19 +1897,25 @@ var mixioServer = async function() {
if (globalWeather[req.query.dsc_code] && globalWeather[req.query.dsc_code].time && (new Date().getTime() - globalWeather[req.query.dsc_code].time) < 600000) { if (globalWeather[req.query.dsc_code] && globalWeather[req.query.dsc_code].time && (new Date().getTime() - globalWeather[req.query.dsc_code].time) < 600000) {
res.send(globalWeather[req.query.dsc_code].data) res.send(globalWeather[req.query.dsc_code].data)
} else { } else {
http.get('http://api.map.baidu.com/weather/v1/?district_id=' + req.query.dsc_code + '&data_type=now&ak=' + configs["BAIDU_MAP_SERVER_AK"], function(req2, res2) { try {
var html = '' http.get('http://api.map.baidu.com/weather/v1/?district_id=' + req.query.dsc_code + '&data_type=now&ak=' + configs["BAIDU_MAP_SERVER_AK"], function(req2, res2) {
req2.on('data', function(data) { var html = ''
html += data; req2.on('data', function(data) {
}); html += data;
req2.on('end', function() { });
globalWeather[req.query.dsc_code] = { req2.on('end', function() {
time: new Date().getTime(), globalWeather[req.query.dsc_code] = {
data: html time: new Date().getTime(),
} data: html
res.send(html) }
}); res.send(html)
}) });
}).on('error', function(e) {
res.send('-1')
})
} catch (e) {
res.send('-1')
}
} }
} else } else
res.send('-1') res.send('-1')