Authored by 周少峰

Merge branch 'gray'

... ... @@ -218,12 +218,19 @@ const getHeaderNavAsync = () => {
* @param {String} 频道类型
* @return {promise}
*/
let cacheHeaderHtml = {};
const cacheHeaderHtml = {
boys: [],
girls: [],
kids: [],
lifestyle: []
};
const THIRTY_MINUTES = 1000 * 60 * 10;
async function requestHeaderData(type) {
let resData = {};
if (_.isEmpty(cacheHeaderHtml[type])) {
if (_.isEmpty(cacheHeaderHtml[type][0]) || ((new Date() - cacheHeaderHtml[type][1]) > THIRTY_MINUTES)) {
let channelNum = (function() {
switch (type) {
case 'boys':
... ... @@ -270,17 +277,12 @@ async function requestHeaderData(type) {
cacheHeaderHtml[type] = resData;
}
} else {
resData = cacheHeaderHtml[type];
resData = cacheHeaderHtml[type][0];
}
return Promise.resolve({headerData: resData});
}
setInterval(function() {
cacheHeaderHtml = {};
}, 60 * 10 * 1000);
module.exports = {
requestHeaderData
};
... ...