...
|
...
|
@@ -229,12 +229,15 @@ const THIRTY_MINUTES = 1000 * 60 * 10; |
|
|
|
|
|
async function requestHeaderData(type) {
|
|
|
let resData = {};
|
|
|
let _html;
|
|
|
|
|
|
if (!cacheHeaderHtml[type]) {
|
|
|
type = 'boys';
|
|
|
}
|
|
|
|
|
|
if (_.isEmpty(cacheHeaderHtml[type][0]) || ((new Date() - cacheHeaderHtml[type][1]) > THIRTY_MINUTES)) {
|
|
|
let cacheData = cacheHeaderHtml[type];
|
|
|
|
|
|
if (_.isEmpty(cacheData[0]) || ((new Date() - cacheData[1]) > THIRTY_MINUTES)) {
|
|
|
let channelNum = (function() {
|
|
|
switch (type) {
|
|
|
case 'boys':
|
...
|
...
|
@@ -253,7 +256,6 @@ async function requestHeaderData(type) { |
|
|
let res = await Promise.all([
|
|
|
getHeaderNavAsync(),
|
|
|
getHotSearchAsync(channelNum)
|
|
|
|
|
|
]);
|
|
|
|
|
|
resData.headerData = {};
|
...
|
...
|
@@ -275,16 +277,17 @@ async function requestHeaderData(type) { |
|
|
});
|
|
|
}
|
|
|
|
|
|
resData = template(resData);
|
|
|
|
|
|
if (!_.isEmpty(res[0].data) && !_.isEmpty(res[1].data)) {
|
|
|
cacheHeaderHtml[type] = [resData, new Date()];
|
|
|
if (_.isEmpty(_.get(resData, 'headerData.navbars')) && cacheData[0]) {
|
|
|
_html = cacheData[0];
|
|
|
} else {
|
|
|
_html = template(resData);
|
|
|
cacheHeaderHtml[type] = [_html, new Date()];
|
|
|
}
|
|
|
} else {
|
|
|
resData = cacheHeaderHtml[type][0];
|
|
|
_html = cacheData[0];
|
|
|
}
|
|
|
|
|
|
return Promise.resolve({headerData: resData});
|
|
|
return Promise.resolve({headerData: _html});
|
|
|
}
|
|
|
|
|
|
module.exports = {
|
...
|
...
|
|