Authored by htoooth

zookeeper

@@ -13,6 +13,8 @@ const bodyParser = require('body-parser'); @@ -13,6 +13,8 @@ const bodyParser = require('body-parser');
13 const cookieParser = require('cookie-parser'); 13 const cookieParser = require('cookie-parser');
14 const favicon = require('serve-favicon'); 14 const favicon = require('serve-favicon');
15 const session = require('yoho-express-session'); 15 const session = require('yoho-express-session');
  16 +const _ = require('lodash');
  17 +const fp = require('lodash/fp');
16 18
17 const memcached = require('connect-memcached'); 19 const memcached = require('connect-memcached');
18 const hbs = require('express-handlebars'); 20 const hbs = require('express-handlebars');
@@ -27,15 +29,24 @@ const MemcachedStore = memcached(session); @@ -27,15 +29,24 @@ const MemcachedStore = memcached(session);
27 // 全局注册library 29 // 全局注册library
28 yohoLib.global(config); 30 yohoLib.global(config);
29 31
  32 +const helpers = global.yoho.helpers;
  33 +
  34 +// NOTE: 这里修改了图片质量的参数
  35 +helpers.image = _.flow(helpers.image, fp.replace(/\/quality\/\d*$/, '/quality/90'));
  36 +helpers.json = JSON.stringify;
  37 +
30 global.middleware = path.resolve('./doraemon/middleware'); 38 global.middleware = path.resolve('./doraemon/middleware');
31 global.utils = path.resolve('./utils'); 39 global.utils = path.resolve('./utils');
32 40
33 // 向模板注入变量 41 // 向模板注入变量
34 app.locals.devEnv = app.get('env') === 'development'; 42 app.locals.devEnv = app.get('env') === 'development';
35 app.locals.version = pkg.version; 43 app.locals.version = pkg.version;
  44 +app.locals.__YOHO_CONFIG = {};
36 45
37 // zookeeper设置 46 // zookeeper设置
38 -require('yoho-zookeeper')(config.zookeeperServer, 'pc', app.locals); 47 +require('yoho-zookeeper')(config.zookeeperServer, 'pc', app.locals.__YOHO_CONFIG);
  48 +console.log(app.locals.__YOHO_CONFIG);
  49 +
39 50
40 app.set('subdomain offset', 2); 51 app.set('subdomain offset', 2);
41 app.set('view engine', '.hbs'); 52 app.set('view engine', '.hbs');
@@ -29,6 +29,12 @@ @@ -29,6 +29,12 @@
29 {{{body}}} 29 {{{body}}}
30 {{/if}} 30 {{/if}}
31 {{> footer}} 31 {{> footer}}
  32 +
  33 + <!--降级配置-->
  34 + <stript>
  35 + var __YOHO_CONFIG = {{{json __YOHO_CONFIG}}}
  36 + </stript>
  37 +
32 {{#if devEnv}} 38 {{#if devEnv}}
33 <script src="//localhost:5002/libs.js"></script> 39 <script src="//localhost:5002/libs.js"></script>
34 <script src="//localhost:5002/{{module}}.{{page}}.js"></script> 40 <script src="//localhost:5002/{{module}}.{{page}}.js"></script>
@@ -16,9 +16,6 @@ const itemFromBase = { @@ -16,9 +16,6 @@ const itemFromBase = {
16 saleSpecial: {domain: 'sale', module: 's'}// sale.yohobuy.com 16 saleSpecial: {domain: 'sale', module: 's'}// sale.yohobuy.com
17 }; 17 };
18 18
19 -// NOTE: 这里修改了图片质量的参数  
20 -helpers.image = _.flow(helpers.image, fp.replace(/\/quality\/\d*$/, '/quality/90'));  
21 -  
22 /** 19 /**
23 * 根据性别来决定 默认图片获取字段 如果是 2、3 20 * 根据性别来决定 默认图片获取字段 如果是 2、3
24 * 21 *