Authored by htoooth

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

@@ -5,4 +5,7 @@ export default { @@ -5,4 +5,7 @@ export default {
5 path: '/edit/:id.html', 5 path: '/edit/:id.html',
6 name: 'edit', 6 name: 'edit',
7 component: () => import(/* webpackChunkName: "product.edit" */'./edit'), 7 component: () => import(/* webpackChunkName: "product.edit" */'./edit'),
  8 + meta: {
  9 + pageName: '商品编辑',
  10 + }
8 }; 11 };
@@ -4,11 +4,11 @@ @@ -4,11 +4,11 @@
4 import _ from 'lodash'; 4 import _ from 'lodash';
5 import axios from 'axios'; 5 import axios from 'axios';
6 import UserService from 'services/user/user-service'; 6 import UserService from 'services/user/user-service';
7 -import Rsa from 'rsa'; 7 +import crypto from 'util/crypto';
8 8
9 export default { 9 export default {
10 updateUser(Vue, user, purviews) { 10 updateUser(Vue, user, purviews) {
11 - Vue.$store.set(Vue.$config.storeKeys.user, Rsa.encrypt(user)); 11 + Vue.$store.set(Vue.$config.storeKeys.user, crypto.aesEncrypt(user));
12 Vue.prop('user', user); 12 Vue.prop('user', user);
13 Vue.prop('isLogin', true); 13 Vue.prop('isLogin', true);
14 Vue.prop('purviews', purviews.deep); 14 Vue.prop('purviews', purviews.deep);
@@ -39,12 +39,16 @@ export default { @@ -39,12 +39,16 @@ export default {
39 let isLogin = Vue.$cookie.get('_isLogin'); 39 let isLogin = Vue.$cookie.get('_isLogin');
40 40
41 if (isLogin && user) { 41 if (isLogin && user) {
42 - user = Rsa.decrypt(user, Object); 42 + try {
  43 + user = crypto.aesDecrypt(user, Object);
43 return this.initPurview(Vue, user).then(() => { 44 return this.initPurview(Vue, user).then(() => {
44 next(); 45 next();
45 }, () => { 46 }, () => {
46 next(); 47 next();
47 }); 48 });
  49 + } catch (e) {
  50 + Vue.logout();
  51 + }
48 } 52 }
49 next(); 53 next();
50 }); 54 });
@@ -87,7 +91,7 @@ export default { @@ -87,7 +91,7 @@ export default {
87 } 91 }
88 }; 92 };
89 Vue.switchShop = shopsId => { 93 Vue.switchShop = shopsId => {
90 - Vue.$store.set(Vue.$config.storeKeys.user, Rsa.encrypt(Vue.$user)); 94 + Vue.$store.set(Vue.$config.storeKeys.user, crypto.aesEncrypt(Vue.$user));
91 Vue.$cookie.set('_sign', shopsId, { 95 Vue.$cookie.set('_sign', shopsId, {
92 path: '/' 96 path: '/'
93 }); 97 });
1 import axios from 'axios'; 1 import axios from 'axios';
2 import settle from 'axios/lib/core/settle'; 2 import settle from 'axios/lib/core/settle';
3 import cache from 'cache'; 3 import cache from 'cache';
4 -import md5 from 'yoho-md5'; 4 +import crypto from 'util/crypto';
5 5
6 export default { 6 export default {
7 defaultAdapter: axios.defaults.adapter, 7 defaultAdapter: axios.defaults.adapter,
8 install() { 8 install() {
9 axios.defaults.adapter = config => { 9 axios.defaults.adapter = config => {
10 if (config.cache) { 10 if (config.cache) {
11 - config.id = md5(`${config.url}|${JSON.stringify(config.params)}|${config.data}`); 11 + config.id = crypto.md5(`${config.url}|${JSON.stringify(config.params)}|${config.data}`);
12 let res = cache.get(config.id); 12 let res = cache.get(config.id);
13 13
14 if (res) { 14 if (res) {
  1 +import cryptoAES from 'crypto-js/aes';
  2 +import encUtf8 from 'crypto-js/enc-utf8';
  3 +import cryptoMd5 from 'crypto-js/md5';
  4 +
  5 +
  6 +let crypto = {
  7 + key: 'd7b7ac4b491fd2b1b9e27bc2ca9bf5d0',
  8 + aesEncrypt(plainText) {
  9 + if (typeof plainText === 'object') {
  10 + plainText = encodeURIComponent(JSON.stringify(plainText));
  11 + }
  12 + return cryptoAES.encrypt(plainText, this.key).toString();
  13 + },
  14 + aesDecrypt(cipherText, Type) {
  15 + let bytes = cryptoAES.decrypt(cipherText, this.key);
  16 + let plainText = bytes.toString(encUtf8);
  17 +
  18 + if (this.getType(Type) === 'Object') {
  19 + return JSON.parse(decodeURIComponent(plainText));
  20 + }
  21 + return plainText;
  22 + },
  23 + md5(plainText) {
  24 + return cryptoMd5(plainText).toString();
  25 + },
  26 + getType(fn) {
  27 + let match = fn && fn.toString().match(/^\s*function (\w+)/);
  28 +
  29 + return match && match[1];
  30 + }
  31 +};
  32 +
  33 +export default crypto;
1 -import cryptico from 'cryptico';  
2 -  
3 -class Rsa {  
4 - constructor() {  
5 - this.mattsRSAkey = cryptico.generateRSAKey('d7b7ac4b491fd2b1b9e27bc2ca9bf5d0', 1024);  
6 - this.mattsPublicKeyString = cryptico.publicKeyString(this.mattsRSAkey);  
7 - }  
8 - encrypt(plainText) {  
9 - if (typeof plainText === 'object') {  
10 - plainText = encodeURIComponent(JSON.stringify(plainText));  
11 - }  
12 - return cryptico.encrypt(plainText, this.mattsPublicKeyString).cipher;  
13 - }  
14 - decrypt(cipherText, Type) {  
15 - let plainText = cryptico.decrypt(cipherText, this.mattsRSAkey).plaintext;  
16 -  
17 - if (this.getType(Type) === 'Object') {  
18 - return JSON.parse(decodeURIComponent(plainText));  
19 - }  
20 - return plainText;  
21 - }  
22 - getType(fn) {  
23 - let match = fn && fn.toString().match(/^\s*function (\w+)/);  
24 -  
25 - return match && match[1];  
26 - }  
27 -}  
28 -  
29 -export default new Rsa();  
@@ -18,13 +18,9 @@ let vendors = [ @@ -18,13 +18,9 @@ let vendors = [
18 'yoho-store', 18 'yoho-store',
19 'yoho-cookie', 19 'yoho-cookie',
20 'moment', 20 'moment',
21 - 'buffer',  
22 - 'bn.js',  
23 - 'cryptico',  
24 'iview/dist/styles/iview.css' 21 'iview/dist/styles/iview.css'
25 ]; 22 ];
26 -  
27 -module.exports = { 23 +let webpackConfig = {
28 output: { 24 output: {
29 path: path.join(__dirname, '/dll'), 25 path: path.join(__dirname, '/dll'),
30 filename: '[name].[chunkhash:7].js', 26 filename: '[name].[chunkhash:7].js',
@@ -86,3 +82,10 @@ module.exports = { @@ -86,3 +82,10 @@ module.exports = {
86 }) 82 })
87 ], 83 ],
88 }; 84 };
  85 +
  86 +if (config.build.bundleAnalyzerReport) {
  87 + let BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
  88 + webpackConfig.plugins.push(new BundleAnalyzerPlugin())
  89 +}
  90 +
  91 +module.exports = webpackConfig;
@@ -52,6 +52,7 @@ @@ -52,6 +52,7 @@
52 "cookie-parser": "^1.4.3", 52 "cookie-parser": "^1.4.3",
53 "cookie-session": "^2.0.0-beta.1", 53 "cookie-session": "^2.0.0-beta.1",
54 "cryptico": "^1.0.2", 54 "cryptico": "^1.0.2",
  55 + "crypto-js": "^3.1.9-1",
55 "excel-export": "^0.5.1", 56 "excel-export": "^0.5.1",
56 "express": "^4.15.2", 57 "express": "^4.15.2",
57 "express-session": "^1.15.2", 58 "express-session": "^1.15.2",
@@ -132,7 +133,7 @@ @@ -132,7 +133,7 @@
132 "stylelint-webpack-plugin": "^0.7.0", 133 "stylelint-webpack-plugin": "^0.7.0",
133 "url-loader": "^0.5.7", 134 "url-loader": "^0.5.7",
134 "vue-loader": "^11.1.4", 135 "vue-loader": "^11.1.4",
135 - "vue-style-loader": "^2.0.0", 136 + "vue-style-loader": "^2.0.5",
136 "webpack": "^2.6.1", 137 "webpack": "^2.6.1",
137 "webpack-dev-middleware": "^1.10.2", 138 "webpack-dev-middleware": "^1.10.2",
138 "webpack-dev-server": "^2.4.2", 139 "webpack-dev-server": "^2.4.2",