Authored by 郭成尧

Merge branch 'release/4.6' of git.yoho.cn:fe/yohobuy-node into release/4.6

... ... @@ -19,22 +19,19 @@ const cookieParser = require('cookie-parser');
const favicon = require('serve-favicon');
const session = require('yoho-express-session');
const memcached = require('yoho-connect-memcached');
const uuid = require('uuid');
const _ = require('lodash');
const pkg = require('./package.json');
const cookie = require('./library/cookie');
const app = express();
const MemcachedStore = memcached(session);
const seo = require('./doraemon/middleware/seo');
// 指定libray目录
global.library = path.resolve('./library');
global.middleware = path.resolve('./doraemon/middleware');
global.utils = path.resolve('./utils');
const seo = require(`${global.middleware}/seo`);
// 向模板注入变量
app.locals.devEnv = app.get('env') === 'development';
app.locals.version = pkg.version;
... ... @@ -47,23 +44,21 @@ app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieParser());
app.use(session({
proxy: true,
resave: false,
saveUninitialized: true,
unset: 'destroy',
secret: 'nothing', // 兼容 PHP SESSION,sessionID 不加密
name: 'PHPSESSID', // 兼容 PHP SESSION
genid: () => {
return uuid.v4(); // 兼容 PHP SESSION
},
secret: '82dd7e724f2c6870472c89dfa43cf48d',
name: 'yohobuy_session',
cookie: {
domain: 'yohobuy.com'
domain: 'yohobuy.com',
httpOnly: false
},
store: new MemcachedStore({
hosts: config.memcache.session,
prefix: 'qinsessionsession:', // 兼容 PHP SESSION
key: 'yohobuy_session' // 兼容 PHP SESSION
prefix: 'yohobuy_session:'
})
}));
... ... @@ -75,12 +70,15 @@ app.use((req, res, next) => {
req.user.uid = req.session._LOGIN_UID;
}
// session 没有读取到的时候,从 cookie 读取 UID
if (!req.user.uid && req.cookies._UID) {
req.user.uid = cookie.getUid(req);
}
next();
});
app.use(seo());
// dispatcher
require('./dispatch')(app);
... ...
... ... @@ -59,9 +59,9 @@ if (isProduction) {
service: 'http://service.yoho.yohoops.org/'
},
memcache: {
master: ['172.31.22.1:12111', '172.31.20.56:12111', '172.31.31.146:12111'],
slave: ['172.31.22.1:12112', '172.31.20.56:12112', '172.31.31.146:12112'],
session: ['172.31.22.1:12111', '172.31.20.56:12111', '172.31.31.146:12111'],
master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'],
slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112', 'memcache3.yohoops.org:12112'],
session: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'],
timeout: 3000
},
useOneapm: true,
... ...
... ... @@ -3,6 +3,9 @@
* @param {[object]} req
* @return {[string]}
*/
'use strict';
const sign = require('./sign');
exports.getUid = (req) => {
const cookie = req.cookies._UID;
let _uid = 0;
... ... @@ -19,5 +22,14 @@ exports.getUid = (req) => {
}
}
// 校验 cookie 的 uid 有没有被修改
if (req.cookies._TOKEN !== sign.makeToken(_uid)) {
_uid = 0;
}
return _uid;
};
exports.getShoppingKey = (req) => {
return req.cookies['_SPK'] ? req.cookies['_SPK'] : ''; // eslint-disable-line
};
... ...
No preview for this file type
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -25,7 +25,7 @@ const env = {
const config = require('../package.json');
const ftpConfig = {
host: '218.94.75.50',
host: '218.94.75.58',
user: 'php',
pass: 'yoho9646'
};
... ... @@ -189,6 +189,7 @@ gulp.task('webpack', () => {
var proConfig = Object.assign({}, webpackConfig);
proConfig.output.path = dist.js;
proConfig.plugins = [new webpack.optimize.UglifyJsPlugin()];
webpack(proConfig, (err, stats) => {
if (err) {
throw new gutil.PluginError('webpack', err);
... ...
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
... ... @@ -15,7 +15,6 @@ var homePage = $('.home-page').data('page'),
require('../common');
require('../plugins/slider');
require('../plugins/slider2');
require('../plugins/logo-brand');
require('../plugins/accordion');
... ...
... ... @@ -558,7 +558,7 @@
line-height: 40px;
padding-right: 46px;
box-sizing: border-box;
margin-right: 38px;
margin-right: 36px;
display: inline-block;
}
... ...
/**
* 登录判断
* @author: xuqi<qi.xu@yoho.cn>
* 图片处理
* @author: 梁校松
* @date: 2016/4/25
*/
... ...