Authored by 沈志敏

个人主页

  1 +/**
  2 + * sub app home
  3 + * @author: shenzm<zhimin.shen@yoho.cn>
  4 + * @date: 2016/07/18
  5 + */
  6 +
  7 +var express = require('express'),
  8 + path = require('path'),
  9 + hbs = require('express-handlebars');
  10 +
  11 +var app = express();
  12 +
  13 +// set view engin
  14 +var doraemon = path.join(__dirname, '../../doraemon/views'); //parent view root
  15 +
  16 +app.on('mount', function(parent) {
  17 + delete parent.locals.settings; // 不继承父 App 的设置
  18 + Object.assign(app.locals, parent.locals);
  19 +});
  20 +
  21 +app.set('views', path.join(__dirname, 'views/action'));
  22 +app.engine('.hbs', hbs({
  23 + extname: '.hbs',
  24 + defaultLayout: 'layout',
  25 + layoutsDir: doraemon,
  26 + partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
  27 + helpers: global.yoho.helpers
  28 +}));
  29 +
  30 +// router
  31 +app.use(require('./router'));
  32 +
  33 +module.exports = app;
  1 +/**
  2 + * router of sub app home
  3 + * @author: shenzm<zhimin.shen@yoho.cn>
  4 + * @date: 2016/07/18
  5 + */
  6 +
  7 +'use strict';
  8 +
  9 +const router = require('express').Router();
  10 +const cRoot = './controllers';
  11 +
  12 +// Your controller here
  13 +
  14 +module.exports = router;