renderEx.js 1008 B

123456789101112131415161718192021222324252627282930313233343536
  1. const { MENU, AUTH, host } = require('../config');
  2. // 分页修改中间件
  3. module.exports = () => {
  4. return (req, res, next) => {
  5. res.renderEx = (view, option) => {
  6. !option.keywords && (option.keywords = '');
  7. !option.description && (option.description = '');
  8. res.render(view, {
  9. ...option,
  10. menuData: MENU,
  11. signStatus: req.uid,
  12. // user: req.user,
  13. auth: req.uid
  14. ? [
  15. {
  16. url: 'https://www.fuxicarbon.com/userCenter/basic',
  17. value: '用户中心',
  18. },
  19. {
  20. url: 'https://www.fuxicarbon.com/sellCenter/basic',
  21. value: '商家中心',
  22. },
  23. {
  24. url: `https://www.fuxicarbon.com/logout?redirect=${encodeURIComponent(
  25. host + req.originalUrl
  26. )}`,
  27. value: '退出登录',
  28. },
  29. ]
  30. : null,
  31. });
  32. };
  33. next();
  34. };
  35. };