Authored by 陈轩

save service

@@ -22,7 +22,7 @@ app.use(global.yoho.hbs({ @@ -22,7 +22,7 @@ app.use(global.yoho.hbs({
22 extname: '.hbs', 22 extname: '.hbs',
23 defaultLayout: 'layout', 23 defaultLayout: 'layout',
24 layoutsDir: doraemon, 24 layoutsDir: doraemon,
25 - partialsDir: path.join(__dirname, 'views/partial'), 25 + partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
26 views: path.join(__dirname, 'views/action'), 26 views: path.join(__dirname, 'views/action'),
27 helpers: global.yoho.helpers 27 helpers: global.yoho.helpers
28 })); 28 }));
  1 +exports.page = (req, res, next) => {
  2 + res.render('chat/index');
  3 +};
  1 +/**
  2 + * sub app service
  3 + * @author: xuan.chen@yoho.cn<xuan.chen@yoho.cn>
  4 + * @date: 2016/11/21
  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 service
  3 + * @author: xuan.chen@yoho.cn<xuan.chen@yoho.cn>
  4 + * @date: 2016/11/21
  5 + */
  6 +
  7 +'use strict';
  8 +
  9 +const router = require('express').Router(); //eslint-disable-line
  10 +const cRoot = './controllers';
  11 +
  12 +const chat = require(`${cRoot}/chat`);
  13 +
  14 +// Your controller here
  15 +router.get('/im/', chat.page);
  16 +
  17 +module.exports = router;
  1 +<header></header>
  2 +<div></div>
  3 +<footer></footer>
@@ -24,4 +24,7 @@ module.exports = app => { @@ -24,4 +24,7 @@ module.exports = app => {
24 24
25 // 第三方服务处理 25 // 第三方服务处理
26 app.use('/3party', require('./apps/3party')); 26 app.use('/3party', require('./apps/3party'));
  27 +
  28 + // 用户服务: 在线客服
  29 + app.use('/service', require('./apps/service'));
27 }; 30 };