Showing
11 changed files
with
64 additions
and
14 deletions
@@ -27,6 +27,11 @@ const app = express(); | @@ -27,6 +27,11 @@ const app = express(); | ||
27 | app.locals.devEnv = app.get('env') === 'development'; | 27 | app.locals.devEnv = app.get('env') === 'development'; |
28 | app.locals.version = pkg.version; | 28 | app.locals.version = pkg.version; |
29 | 29 | ||
30 | +// zookeeper | ||
31 | +if (config.zookeeperServer) { | ||
32 | + require('yoho-zookeeper')(config.zookeeperServer, 'wap', app.locals.wap = {}); | ||
33 | +} | ||
34 | + | ||
30 | // 访问域名层级 | 35 | // 访问域名层级 |
31 | app.set('subdomain offset', 3); | 36 | app.set('subdomain offset', 3); |
32 | 37 |
@@ -27,6 +27,13 @@ app.use(global.yoho.hbs({ | @@ -27,6 +27,13 @@ app.use(global.yoho.hbs({ | ||
27 | helpers: Object.assign({}, global.yoho.helpers, helpers) | 27 | helpers: Object.assign({}, global.yoho.helpers, helpers) |
28 | })); | 28 | })); |
29 | 29 | ||
30 | +// for zookeeper, inject locals | ||
31 | +app.use((req, res, next) => { | ||
32 | + req.app.locals.wap = app.locals.wap; | ||
33 | + | ||
34 | + next(); | ||
35 | +}); | ||
36 | + | ||
30 | // router | 37 | // router |
31 | app.use(require('./router')); | 38 | app.use(require('./router')); |
32 | 39 |
@@ -15,6 +15,13 @@ app.on('mount', function(parent) { | @@ -15,6 +15,13 @@ app.on('mount', function(parent) { | ||
15 | Object.assign(app.locals, parent.locals); | 15 | Object.assign(app.locals, parent.locals); |
16 | }); | 16 | }); |
17 | 17 | ||
18 | +// for zookeeper, inject locals | ||
19 | +app.use((req, res, next) => { | ||
20 | + req.app.locals.wap = app.locals.wap; | ||
21 | + | ||
22 | + next(); | ||
23 | +}); | ||
24 | + | ||
18 | // router | 25 | // router |
19 | app.use(require('./router')); | 26 | app.use(require('./router')); |
20 | 27 |
@@ -4,27 +4,21 @@ | @@ -4,27 +4,21 @@ | ||
4 | * @date: 2016/05/09 | 4 | * @date: 2016/05/09 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | -var express = require('express'), | ||
8 | - path = require('path'); | 7 | +var express = require('express'); |
9 | 8 | ||
10 | var app = express(); | 9 | var app = express(); |
11 | 10 | ||
12 | -// set view engin | ||
13 | -var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root | ||
14 | - | ||
15 | app.on('mount', function(parent) { | 11 | app.on('mount', function(parent) { |
16 | delete parent.locals.settings; // 不继承父 App 的设置 | 12 | delete parent.locals.settings; // 不继承父 App 的设置 |
17 | Object.assign(app.locals, parent.locals); | 13 | Object.assign(app.locals, parent.locals); |
18 | }); | 14 | }); |
19 | 15 | ||
20 | -// app.use(global.yoho.hbs({ | ||
21 | -// extname: '.hbs', | ||
22 | -// defaultLayout: 'layout', | ||
23 | -// layoutsDir: doraemon, | ||
24 | -// partialsDir: path.join(__dirname, 'views/partial'), | ||
25 | -// views: path.join(__dirname, 'views/action'), | ||
26 | -// helpers: global.yoho.helpers | ||
27 | -// })); | 16 | +// for zookeeper, inject locals |
17 | +app.use((req, res, next) => { | ||
18 | + req.app.locals.wap = app.locals.wap; | ||
19 | + | ||
20 | + next(); | ||
21 | +}); | ||
28 | 22 | ||
29 | // router | 23 | // router |
30 | app.use(require('./router')); | 24 | app.use(require('./router')); |
@@ -26,6 +26,13 @@ app.use(global.yoho.hbs({ | @@ -26,6 +26,13 @@ app.use(global.yoho.hbs({ | ||
26 | helpers: global.yoho.helpers | 26 | helpers: global.yoho.helpers |
27 | })); | 27 | })); |
28 | 28 | ||
29 | +// for zookeeper, inject locals | ||
30 | +app.use((req, res, next) => { | ||
31 | + req.app.locals.wap = app.locals.wap; | ||
32 | + | ||
33 | + next(); | ||
34 | +}); | ||
35 | + | ||
29 | // router | 36 | // router |
30 | app.use(require('./router')); | 37 | app.use(require('./router')); |
31 | 38 |
@@ -26,6 +26,13 @@ app.use(global.yoho.hbs({ | @@ -26,6 +26,13 @@ app.use(global.yoho.hbs({ | ||
26 | helpers: global.yoho.helpers | 26 | helpers: global.yoho.helpers |
27 | })); | 27 | })); |
28 | 28 | ||
29 | +// for zookeeper, inject locals | ||
30 | +app.use((req, res, next) => { | ||
31 | + req.app.locals.wap = app.locals.wap; | ||
32 | + | ||
33 | + next(); | ||
34 | +}); | ||
35 | + | ||
29 | // router | 36 | // router |
30 | app.use(require('./router')); | 37 | app.use(require('./router')); |
31 | 38 |
@@ -26,6 +26,13 @@ app.use(global.yoho.hbs({ | @@ -26,6 +26,13 @@ app.use(global.yoho.hbs({ | ||
26 | helpers: global.yoho.helpers | 26 | helpers: global.yoho.helpers |
27 | })); | 27 | })); |
28 | 28 | ||
29 | +// for zookeeper, inject locals | ||
30 | +app.use((req, res, next) => { | ||
31 | + req.app.locals.wap = app.locals.wap; | ||
32 | + | ||
33 | + next(); | ||
34 | +}); | ||
35 | + | ||
29 | // router | 36 | // router |
30 | app.use(require('./router')); | 37 | app.use(require('./router')); |
31 | 38 |
@@ -28,6 +28,12 @@ app.use(global.yoho.hbs({ | @@ -28,6 +28,12 @@ app.use(global.yoho.hbs({ | ||
28 | helpers: global.yoho.helpers | 28 | helpers: global.yoho.helpers |
29 | })); | 29 | })); |
30 | 30 | ||
31 | +// for zookeeper, inject locals | ||
32 | +app.use((req, res, next) => { | ||
33 | + req.app.locals.wap = app.locals.wap; | ||
34 | + | ||
35 | + next(); | ||
36 | +}); | ||
31 | 37 | ||
32 | require('./auth'); | 38 | require('./auth'); |
33 | app.use(passport.initialize()); | 39 | app.use(passport.initialize()); |
@@ -27,6 +27,13 @@ app.use(global.yoho.hbs({ | @@ -27,6 +27,13 @@ app.use(global.yoho.hbs({ | ||
27 | helpers: global.yoho.helpers | 27 | helpers: global.yoho.helpers |
28 | })); | 28 | })); |
29 | 29 | ||
30 | +// for zookeeper, inject locals | ||
31 | +app.use((req, res, next) => { | ||
32 | + req.app.locals.wap = app.locals.wap; | ||
33 | + | ||
34 | + next(); | ||
35 | +}); | ||
36 | + | ||
30 | // router | 37 | // router |
31 | app.use(require('./router')); | 38 | app.use(require('./router')); |
32 | 39 |
@@ -2,5 +2,7 @@ | @@ -2,5 +2,7 @@ | ||
2 | <a href="{{@root.cartUrl}}"> | 2 | <a href="{{@root.cartUrl}}"> |
3 | <span class="iconfont"></span> | 3 | <span class="iconfont"></span> |
4 | </a> | 4 | </a> |
5 | + {{#unless @root.wap.common.removeCartCount}} | ||
5 | <span class="cart-count hide">0</span> | 6 | <span class="cart-count hide">0</span> |
7 | + {{/unless}} | ||
6 | </div> | 8 | </div> |
@@ -38,7 +38,8 @@ | @@ -38,7 +38,8 @@ | ||
38 | "request-promise": "^3.0.0", | 38 | "request-promise": "^3.0.0", |
39 | "serve-favicon": "^2.3.0", | 39 | "serve-favicon": "^2.3.0", |
40 | "uuid": "^2.0.3", | 40 | "uuid": "^2.0.3", |
41 | - "yoho-node-lib": "0.1.22" | 41 | + "yoho-node-lib": "0.1.22", |
42 | + "yoho-zookeeper": "^1.0.3" | ||
42 | }, | 43 | }, |
43 | "devDependencies": { | 44 | "devDependencies": { |
44 | "autoprefixer": "^6.3.7", | 45 | "autoprefixer": "^6.3.7", |
-
Please register or login to post a comment