Authored by htoooth

Merge remote-tracking branch 'origin/release/2.0' into release/2.0

... ... @@ -5,4 +5,7 @@ export default {
path: '/edit/:id.html',
name: 'edit',
component: () => import(/* webpackChunkName: "product.edit" */'./edit'),
meta: {
pageName: '商品编辑',
}
};
... ...
... ... @@ -4,11 +4,11 @@
import _ from 'lodash';
import axios from 'axios';
import UserService from 'services/user/user-service';
import Rsa from 'rsa';
import crypto from 'util/crypto';
export default {
updateUser(Vue, user, purviews) {
Vue.$store.set(Vue.$config.storeKeys.user, Rsa.encrypt(user));
Vue.$store.set(Vue.$config.storeKeys.user, crypto.aesEncrypt(user));
Vue.prop('user', user);
Vue.prop('isLogin', true);
Vue.prop('purviews', purviews.deep);
... ... @@ -39,12 +39,16 @@ export default {
let isLogin = Vue.$cookie.get('_isLogin');
if (isLogin && user) {
user = Rsa.decrypt(user, Object);
return this.initPurview(Vue, user).then(() => {
next();
}, () => {
next();
});
try {
user = crypto.aesDecrypt(user, Object);
return this.initPurview(Vue, user).then(() => {
next();
}, () => {
next();
});
} catch (e) {
Vue.logout();
}
}
next();
});
... ... @@ -87,7 +91,7 @@ export default {
}
};
Vue.switchShop = shopsId => {
Vue.$store.set(Vue.$config.storeKeys.user, Rsa.encrypt(Vue.$user));
Vue.$store.set(Vue.$config.storeKeys.user, crypto.aesEncrypt(Vue.$user));
Vue.$cookie.set('_sign', shopsId, {
path: '/'
});
... ...
import axios from 'axios';
import settle from 'axios/lib/core/settle';
import cache from 'cache';
import md5 from 'yoho-md5';
import crypto from 'util/crypto';
export default {
defaultAdapter: axios.defaults.adapter,
install() {
axios.defaults.adapter = config => {
if (config.cache) {
config.id = md5(`${config.url}|${JSON.stringify(config.params)}|${config.data}`);
config.id = crypto.md5(`${config.url}|${JSON.stringify(config.params)}|${config.data}`);
let res = cache.get(config.id);
if (res) {
... ...
import cryptoAES from 'crypto-js/aes';
import encUtf8 from 'crypto-js/enc-utf8';
import cryptoMd5 from 'crypto-js/md5';
let crypto = {
key: 'd7b7ac4b491fd2b1b9e27bc2ca9bf5d0',
aesEncrypt(plainText) {
if (typeof plainText === 'object') {
plainText = encodeURIComponent(JSON.stringify(plainText));
}
return cryptoAES.encrypt(plainText, this.key).toString();
},
aesDecrypt(cipherText, Type) {
let bytes = cryptoAES.decrypt(cipherText, this.key);
let plainText = bytes.toString(encUtf8);
if (this.getType(Type) === 'Object') {
return JSON.parse(decodeURIComponent(plainText));
}
return plainText;
},
md5(plainText) {
return cryptoMd5(plainText).toString();
},
getType(fn) {
let match = fn && fn.toString().match(/^\s*function (\w+)/);
return match && match[1];
}
};
export default crypto;
... ...
import cryptico from 'cryptico';
class Rsa {
constructor() {
this.mattsRSAkey = cryptico.generateRSAKey('d7b7ac4b491fd2b1b9e27bc2ca9bf5d0', 1024);
this.mattsPublicKeyString = cryptico.publicKeyString(this.mattsRSAkey);
}
encrypt(plainText) {
if (typeof plainText === 'object') {
plainText = encodeURIComponent(JSON.stringify(plainText));
}
return cryptico.encrypt(plainText, this.mattsPublicKeyString).cipher;
}
decrypt(cipherText, Type) {
let plainText = cryptico.decrypt(cipherText, this.mattsRSAkey).plaintext;
if (this.getType(Type) === 'Object') {
return JSON.parse(decodeURIComponent(plainText));
}
return plainText;
}
getType(fn) {
let match = fn && fn.toString().match(/^\s*function (\w+)/);
return match && match[1];
}
}
export default new Rsa();
... ... @@ -18,13 +18,9 @@ let vendors = [
'yoho-store',
'yoho-cookie',
'moment',
'buffer',
'bn.js',
'cryptico',
'iview/dist/styles/iview.css'
];
module.exports = {
let webpackConfig = {
output: {
path: path.join(__dirname, '/dll'),
filename: '[name].[chunkhash:7].js',
... ... @@ -85,4 +81,11 @@ module.exports = {
filename: '[name].[contenthash:7].css'
})
],
};
\ No newline at end of file
};
if (config.build.bundleAnalyzerReport) {
let BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = webpackConfig;
\ No newline at end of file
... ...
... ... @@ -52,6 +52,7 @@
"cookie-parser": "^1.4.3",
"cookie-session": "^2.0.0-beta.1",
"cryptico": "^1.0.2",
"crypto-js": "^3.1.9-1",
"excel-export": "^0.5.1",
"express": "^4.15.2",
"express-session": "^1.15.2",
... ... @@ -132,7 +133,7 @@
"stylelint-webpack-plugin": "^0.7.0",
"url-loader": "^0.5.7",
"vue-loader": "^11.1.4",
"vue-style-loader": "^2.0.0",
"vue-style-loader": "^2.0.5",
"webpack": "^2.6.1",
"webpack-dev-middleware": "^1.10.2",
"webpack-dev-server": "^2.4.2",
... ...