Showing
6 changed files
with
38 additions
and
6 deletions
1 | 'use strict'; | 1 | 'use strict'; |
2 | +const css = require('../css'); | ||
2 | 3 | ||
3 | const detail = (req, res) => { | 4 | const detail = (req, res) => { |
4 | res.render('guang/detail', { | 5 | res.render('guang/detail', { |
5 | - canonical: req.path, | ||
6 | - msg: 'mip' | 6 | + css: css('guang/detail.css'), |
7 | + msg: 'xxxxxxx' | ||
7 | }); | 8 | }); |
8 | }; | 9 | }; |
9 | 10 | ||
10 | - | ||
11 | module.exports = { | 11 | module.exports = { |
12 | detail | 12 | detail |
13 | }; | 13 | }; |
apps/mip/css.js
0 → 100644
1 | +const fs = require('fs'); | ||
2 | +const path = require('path'); | ||
3 | + | ||
4 | +const css = {}; | ||
5 | + | ||
6 | +module.exports = (file) => { | ||
7 | + if (css[file]) { | ||
8 | + return css[file]; | ||
9 | + } | ||
10 | + | ||
11 | + const cssPath = path.join(__dirname, 'css', file); | ||
12 | + const cssfile = fs.readFileSync(cssPath).toString(); | ||
13 | + | ||
14 | + css[file] = cssfile; | ||
15 | + | ||
16 | + return css[file]; | ||
17 | +}; |
apps/mip/css/guang/detail.css
0 → 100644
@@ -9,9 +9,10 @@ | @@ -9,9 +9,10 @@ | ||
9 | const router = require('express').Router(); //eslint-disable-line | 9 | const router = require('express').Router(); //eslint-disable-line |
10 | const cRoot = './controllers'; | 10 | const cRoot = './controllers'; |
11 | 11 | ||
12 | +const mip = require('../../doraemon/middleware/mip'); | ||
12 | const guang = require(`${cRoot}/guang`); | 13 | const guang = require(`${cRoot}/guang`); |
13 | 14 | ||
14 | -// Your controller here | 15 | +router.use(mip()); |
15 | 16 | ||
16 | router.get('/guang/info/:id.html', guang.detail); | 17 | router.get('/guang/info/:id.html', guang.detail); |
17 | 18 |
doraemon/middleware/mip.js
0 → 100644
@@ -7,11 +7,10 @@ | @@ -7,11 +7,10 @@ | ||
7 | <link rel="stylesheet" type="text/css" href="https://mipcache.bdstatic.com/static/v1/mip.css"> | 7 | <link rel="stylesheet" type="text/css" href="https://mipcache.bdstatic.com/static/v1/mip.css"> |
8 | <link rel="canonical" href="{{canonical}}"> | 8 | <link rel="canonical" href="{{canonical}}"> |
9 | <style mip-custom> | 9 | <style mip-custom> |
10 | - /* 自定义样式 */ | 10 | + {{css}} |
11 | </style> | 11 | </style> |
12 | </head> | 12 | </head> |
13 | <body> | 13 | <body> |
14 | -<!-- 正文 --> | ||
15 | {{{body}}} | 14 | {{{body}}} |
16 | <script src="https://mipcache.bdstatic.com/static/v1/mip.js"></script> | 15 | <script src="https://mipcache.bdstatic.com/static/v1/mip.js"></script> |
17 | </body> | 16 | </body> |
-
Please register or login to post a comment