From 4b8812e54b93d693a5ced52a0b90a0f20f33ca83 Mon Sep 17 00:00:00 2001
From: yma16 <17685043634@163.com>
Date: Wed, 15 Feb 2023 02:12:31 +0800
Subject: [PATCH] =?UTF-8?q?perf:=20=E5=B0=81=E8=A3=85=E5=8A=A8=E6=80=81?=
=?UTF-8?q?=E6=A0=87=E7=AD=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Article.vue | 8 ++++----
src/style/special.css | 1 +
src/utils/aesEncode.js | 31 +++++++++++++++++++++++++++++++
3 files changed, 36 insertions(+), 4 deletions(-)
create mode 100644 src/style/special.css
create mode 100644 src/utils/aesEncode.js
diff --git a/src/components/Article.vue b/src/components/Article.vue
index fbd2528..e341dc6 100644
--- a/src/components/Article.vue
+++ b/src/components/Article.vue
@@ -68,7 +68,7 @@
>
@@ -154,7 +154,7 @@
>
@@ -332,7 +332,7 @@ export default {
weather_low: [],
toTopIsShow: false,
article_loc: 0,
- challenge_loc: -1,
+ activeChallengeIndex: -1,
topShow: false,
userImg: '',
username: '匿名',
@@ -490,7 +490,7 @@ export default {
},
li_errorClass: function () {},
clickChallengeEvent: function (item, index) {
- this.challenge_loc = index
+ this.activeChallengeIndex = index
if (item.isJumpPath) {
this.$router
.push({
diff --git a/src/style/special.css b/src/style/special.css
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src/style/special.css
@@ -0,0 +1 @@
+
diff --git a/src/utils/aesEncode.js b/src/utils/aesEncode.js
new file mode 100644
index 0000000..d29c491
--- /dev/null
+++ b/src/utils/aesEncode.js
@@ -0,0 +1,31 @@
+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()
+ }
+}
--
GitLab