renderEx.js 981 B

1234567891011121314151617181920212223242526272829303132333435
  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. auth: req.uid
  13. ? [
  14. {
  15. url: 'https://www.fuxicarbon.com/userCenter/basic',
  16. value: '用户中心',
  17. },
  18. {
  19. url: 'https://www.fuxicarbon.com/sellCenter/basic',
  20. value: '商家中心',
  21. },
  22. {
  23. url: `https://www.fuxicarbon.com/logout?redirect=${encodeURIComponent(
  24. host + req.originalUrl
  25. )}`,
  26. value: '退出登录',
  27. },
  28. ]
  29. : null,
  30. });
  31. };
  32. next();
  33. };
  34. };