Authored by 毕凯

MIP

'use strict';
const detail = (req, res) => {
res.render('guang/detail', {
canonical: req.path,
msg: 'mip'
});
};
module.exports = {
detail
};
... ...
/**
* sub app service
* @author: xuan.chen@yoho.cn<xuan.chen@yoho.cn>
* @date: 2016/11/21
*/
var express = require('express'),
path = require('path');
var app = express();
// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
app.on('mount', function(parent) {
delete parent.locals.settings; // 不继承父 App 的设置
Object.assign(app.locals, parent.locals);
});
app.use(global.yoho.hbs({
extname: '.hbs',
defaultLayout: 'mip',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial')],
views: path.join(__dirname, 'views/action'),
helpers: global.yoho.helpers
}));
app.locals.layout = 'mip';
// router
app.use(require('./router'));
module.exports = app;
... ...
/**
* router of sub app service
* @author: xuan.chen@yoho.cn<xuan.chen@yoho.cn>
* @date: 2016/11/21
*/
'use strict';
const router = require('express').Router(); //eslint-disable-line
const cRoot = './controllers';
const guang = require(`${cRoot}/guang`);
// Your controller here
router.get('/guang/info/:id.html', guang.detail);
module.exports = router;
... ...
... ... @@ -30,4 +30,7 @@ module.exports = app => {
// 用户服务: 在线客服
app.use('/service', require('./apps/service'));
// MIP
app.use('/mip', require('./apps/mip'));
};
... ...
<!DOCTYPE html>
<html mip>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<title>{{title}}</title>
<link rel="stylesheet" type="text/css" href="https://mipcache.bdstatic.com/static/v1/mip.css">
<link rel="canonical" href="{{canonical}}">
<style mip-custom>
/* 自定义样式 */
</style>
</head>
<body>
<!-- 正文 -->
{{{body}}}
<script src="https://mipcache.bdstatic.com/static/v1/mip.js"></script>
</body>
</html>
... ...
... ... @@ -52,7 +52,7 @@
"xml2js": "^0.4.17",
"yoho-express-session": "^2.0.0",
"yoho-md5": "^2.0.0",
"yoho-node-lib": "=0.2.25",
"yoho-node-lib": "=0.2.27",
"yoho-zookeeper": "^1.0.8"
},
"devDependencies": {
... ...