Skip to content

Commit 835a762

Browse files
committed
结构优化
1 parent 08a6f05 commit 835a762

File tree

8 files changed

+263
-276
lines changed

8 files changed

+263
-276
lines changed
File renamed without changes.

src/assets/js/index.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/assets/js/util.js

Lines changed: 0 additions & 236 deletions
This file was deleted.

src/main.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import Vue from 'vue'
22
import App from './App.vue'
33
import './plugins/element.js'
4-
import './assets/js';
4+
import Api from './api';
5+
import Util from './utils';
56
import '@/assets/css/base.css'
67
import "./components/base";
78
import store from "./store";
89
import router from './router'
910

11+
Vue.prototype.$api = Api;
12+
Vue.prototype.$util = Util;
13+
1014
Vue.config.productionTip = false
1115
Vue.prototype.BASE_URL = process.env.BASE_URL;
1216

1317
new Vue({
1418
router,
1519
store,
1620
render: h => h(App)
17-
}).$mount('#app')
21+
}).$mount('#app')
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@ const iv = utf8.parse("qwertyuiop123456");
77
const mode = CryptoJS.mode.CBC;
88
const padding = require("crypto-js/pad-pkcs7");
99

10-
const default_key = "junbokey12345678";
10+
const default_key = "yuikey0123456789";
1111

1212
export default {
1313
encrypt(data, key) {
14-
let real_key = utf8.parse(
15-
md5(key || default_key)
16-
.toString()
17-
.slice(0, 16)
18-
);
14+
if (typeof data !== "string") data = JSON.stringify(data);
15+
let real_key = utf8.parse(md5(key || default_key).toString().slice(0, 16));
1916
let bytes = AES.encrypt(data, real_key, {
2017
iv: iv,
2118
mode: mode,
@@ -24,12 +21,8 @@ export default {
2421
return bytes.toString();
2522
},
2623
decrypt(data, key) {
27-
if (!data) return null;
28-
let real_key = utf8.parse(
29-
md5(key || default_key)
30-
.toString()
31-
.slice(0, 16)
32-
);
24+
if (!data || typeof data !== "string") return '';
25+
let real_key = utf8.parse(md5(key || default_key).toString().slice(0, 16));
3326
let bytes = AES.decrypt(data, real_key, {
3427
iv: iv,
3528
mode: mode,

0 commit comments

Comments
 (0)