base_controller.js 731 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * 控制器基类
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/6/29
  6. * @version
  7. */
  8. class BaseController {
  9. /**
  10. * 页面title
  11. *
  12. * @var string
  13. */
  14. title = '';
  15. /**
  16. * 构造函数
  17. *
  18. * @return {void}
  19. */
  20. constructor() {
  21. if (new.target === BaseController) {
  22. throw new Error('BaseController不能实例化,只能继承使用。');
  23. }
  24. }
  25. /**
  26. * 初始化函数
  27. *
  28. * @param {object} request
  29. * @param {object} response
  30. * @param {function} next
  31. * @return {void}
  32. */
  33. init(request, response, next) {
  34. // 页面标题
  35. response.locals.title = 'test';
  36. next();
  37. }
  38. }
  39. export default BaseController;