提交 4b8812e5 编写于 作者: yma16's avatar yma16

perf: 封装动态标签

上级 52f45789
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
> >
<div <div
v-bind:class="[ v-bind:class="[
{ li_active: index === challenge_loc }, { li_active: index === activeChallengeIndex },
li_errorClass, li_errorClass,
]" ]"
> >
...@@ -154,7 +154,7 @@ ...@@ -154,7 +154,7 @@
> >
<div <div
v-bind:class="[ v-bind:class="[
{ li_active: index === challenge_loc }, { li_active: index === activeChallengeIndex },
li_errorClass, li_errorClass,
]" ]"
> >
...@@ -332,7 +332,7 @@ export default { ...@@ -332,7 +332,7 @@ export default {
weather_low: [], weather_low: [],
toTopIsShow: false, toTopIsShow: false,
article_loc: 0, article_loc: 0,
challenge_loc: -1, activeChallengeIndex: -1,
topShow: false, topShow: false,
userImg: '', userImg: '',
username: '匿名', username: '匿名',
...@@ -490,7 +490,7 @@ export default { ...@@ -490,7 +490,7 @@ export default {
}, },
li_errorClass: function () {}, li_errorClass: function () {},
clickChallengeEvent: function (item, index) { clickChallengeEvent: function (item, index) {
this.challenge_loc = index this.activeChallengeIndex = index
if (item.isJumpPath) { if (item.isJumpPath) {
this.$router this.$router
.push({ .push({
......
import CryptoJS from 'crypto-js'
export default {
// 随机生成指定数量的16进制key
generatekey (num) {
let library = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
let key = ''
for (let i = 0; i < num; i++) {
let randomPoz = Math.floor(Math.random() * library.length)
key += library.substring(randomPoz, randomPoz + 1)
}
return key
},
// 加密
encrypt (word, keyStr) {
// 判断是否存在ksy,不存在就用定义好的key
keyStr = keyStr || 'abcdsxyzhkj12345'
const key = CryptoJS.enc.Utf8.parse(keyStr)
const srcs = CryptoJS.enc.Utf8.parse(word)
const encrypted = CryptoJS.AES.encrypt(srcs, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7})
return encrypted.toString()
},
// 解密
decrypt (word, keyStr) {
keyStr = keyStr || 'abcdsxyzhkj12345'
const key = CryptoJS.enc.Utf8.parse(keyStr)
const decrypt = CryptoJS.AES.decrypt(word, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7})
return CryptoJS.enc.Utf8.stringify(decrypt).toString()
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册