Authored by 周少峰

optim

... ... @@ -50,22 +50,11 @@ const invoiceController = require(`${cRoot}/invoice`);
const meGiftController = require(`${cRoot}/me-gift`);
const checkLogin = (req, res, next) => {
if (req.user.uid) {
return next();
} else {
if (res.xhr) {
res.json({code: 401, message: '未登录!'});
} else {
res.redirect('/login.html');
}
}
};
// 首页
router.get(['/index', '/'], tabsMiddleware.getCommonHeaderNew, indexController.index);
router.get('/index/newsAvatar', checkLogin, indexController.newsAvatar);
router.get('/index/async', checkLogin, indexController.asyncData);
router.get('/index/newsAvatar', indexController.newsAvatar);
router.get('/index/async', indexController.asyncData);
// 查看二维码
router.get('/QRcode', tabsMiddleware.getCommonHeader, personalController.QRcode);
... ...
... ... @@ -58,7 +58,7 @@ module.exports = class extends global.yoho.BaseModel {
uid: uid
};
return this.get({data: param, param: {cache: true}});
return this.get({data: param});
}
};
... ...
... ... @@ -65,8 +65,8 @@ const cachePage = {
'/product/search/keyword/:id': 7 * DAY,
// 帮助
'/help/': 7 * DAY,
'/help/detail': 7 * DAY,
'/help/': 1 * DAY,
'/help/detail': 1 * DAY,
};
module.exports = cachePage;
... ...
... ... @@ -57,8 +57,7 @@
"uuid": "^2.0.2",
"yoho-express-session": "^2.0.0",
"yoho-node-lib": "=0.5.12",
"yoho-zookeeper": "^1.0.8",
"handlebars": "4.0.5"
"yoho-zookeeper": "^1.0.8"
},
"devDependencies": {
"autoprefixer": "^6.3.6",
... ...
function benchmark(fn, ctx) {
return function() {
let t = new Date();
let result = fn.apply(ctx, arguments).then(r => {
console.log('benchmark', fn.name, `[${ new Date() - t}]`);
return r;
});
return result;
};
}
module.exports = benchmark;