Browse Source

Merge remote-tracking branch 'origin/master'

Wren 1 year ago
parent
commit
d9a19e79f2

+ 57 - 2
front/admin-front/src/views/address/index.vue

@@ -481,6 +481,8 @@ import {
 import Axios from "axios";
 import Loading from "@/components/Loading";
 import {saveAs} from 'file-saver';
+import Web3 from "web3";
+import CryptoJS from "crypto-js";
 
 export default {
   components: {Loading},
@@ -628,14 +630,67 @@ export default {
         this.error('密码不一致')
         return
       }
-      let params = this.batchAddressObj
+      // 要加密的数据
+      const dataToEncrypt = JSON.parse(JSON.stringify(this.batchAddressObj.password));
+      // console.log('输入的密码:', dataToEncrypt);
+      // 获取当前北京时间
+      const beijingDate = this.getCurrentBeijingTime();
+      // 生成keyByte
+      const keyByte = this.generateKeyByteArray(beijingDate);
+      // console.log('生成的toHex:', keyByte);
+      // 加密数据
+      const encryptedData = this.encryptData(dataToEncrypt, keyByte);
+      console.log('加密后的数据:', encryptedData);
+      let params = {
+        chainId : this.batchAddressObj.chainId,
+        groupName : this.batchAddressObj.groupName,
+        numWallet : this.batchAddressObj.numWallet,
+        password : encryptedData
+      }
       this.confirmLoading = true
       batchAddress(params).then(res=>{
         this.addressList = res
         this.completeGeneration = true
-        this.confirmLoading = true
+        this.confirmLoading = false
       })
     },
+    // 获取当前北京时间并格式化为 YYYYMMDD
+    getCurrentBeijingTime() {
+      const localDate = new Date();
+      const localTime = localDate.getTime(); // 获取当前本地时间的时间戳
+      const localOffset = localDate.getTimezoneOffset() * 60000; // 本地时区偏移的毫秒数
+      const utcTime = localTime + localOffset; // 转换为 UTC 时间
+      const beijingOffset = 8 * 60 * 60000; // 北京时区偏移的毫秒数
+      const beijingTime = utcTime + beijingOffset; // 加上北京时区偏移
+
+      const beijingDate = new Date(beijingTime);
+      const year = beijingDate.getFullYear();
+      const month = (beijingDate.getMonth() + 1).toString().padStart(2, '0');
+      const day = beijingDate.getDate().toString().padStart(2, '0');
+
+      return `${year}${month}${day}${year}${month}${day}`;
+    },
+    // 生成
+    generateKeyByteArray(content) {
+      let bytes = [];
+      let len, c;
+      len = content.length;
+      for (let i = 0; i < len; i++) {
+        c = content[i];
+        bytes.push(parseInt(c))
+      }
+      // console.log('当前北京时间的数组',bytes);
+      return Web3.utils.bytesToHex(bytes).substring(2);
+    },
+    // 加密函数
+    encryptData(word, keyStr) {
+      let key = CryptoJS.enc.Hex.parse(keyStr)
+      // console.log('CryptoJS生成的key',key);
+      let encrypted = CryptoJS.AES.encrypt(word, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7}) // 加密模式为ECB,补码方式为PKCS5Padding(也就是PKCS7)
+
+      return encrypted.toString()
+
+    },
     downloadAddress(el) {
       let groupName = this.table.walletNameGroup[this.table.walletNameGroupIndex]
       if(el){

+ 19 - 6
front/admin-front/src/views/autoplay/index.vue

@@ -819,7 +819,10 @@
           <el-input type="password" :show-password="true" v-model="password"
                     placeholder="输入钱包密码"></el-input>
           <div class="confirm" @click="batchExecutionTask">
-            <img src="../../assets/autoplay/check1.svg" alt="check1">
+            <img v-if="!confirmLoading" src="../../assets/autoplay/check1.svg" alt="check1">
+            <div v-if="confirmLoading" style="width: 20px;height: 20px;margin-top: -2px">
+              <Loading/>
+            </div>
             确认
           </div>
           <div class="tip">
@@ -920,8 +923,10 @@ import {getInteractionRecord, retryFailed} from "@/api/record";
 import {projectPage} from "@/api/project";
 import CryptoJS from "crypto-js";
 import Web3 from 'web3'
+import Loading from "@/components/Loading";
 
 export default {
+  components: {Loading},
   data() {
     return {
       missionData: [],
@@ -989,7 +994,8 @@ export default {
         projectName: '',
         taskCode: ''
       },
-      addTaskProjectData: []
+      addTaskProjectData: [],
+      confirmLoading:false
     }
   },
   mounted() {
@@ -1042,14 +1048,18 @@ export default {
       })
     },
     batchExecutionTask() {
+      if (this.confirmLoading){
+        return
+      }
+      this.confirmLoading = true
       // 要加密的数据
       const dataToEncrypt = this.password;
-      console.log('输入的密码:', dataToEncrypt);
+      // console.log('输入的密码:', dataToEncrypt);
       // 获取当前北京时间
       const beijingDate = this.getCurrentBeijingTime();
       // 生成keyByte
       const keyByte = this.generateKeyByteArray(beijingDate);
-      console.log('生成的toHex:', keyByte);
+      // console.log('生成的toHex:', keyByte);
       // 加密数据
       const encryptedData = this.encryptData(dataToEncrypt, keyByte);
       console.log('加密后的数据:', encryptedData);
@@ -1059,7 +1069,10 @@ export default {
       batchExecution(this.batchExecutionParams).then(() => {
         this.accountPassword = false
         this.drawerStrategy = false
+        this.confirmLoading = false
         this.getTaskList()
+      }).catch(()=>{
+        this.confirmLoading = false
       })
     },
     // 获取当前北京时间并格式化为 YYYYMMDD
@@ -1087,13 +1100,13 @@ export default {
         c = content[i];
         bytes.push(parseInt(c))
       }
-      console.log('当前北京时间的数组',bytes);
+      // console.log('当前北京时间的数组',bytes);
       return Web3.utils.bytesToHex(bytes).substring(2);
     },
     // 加密函数
     encryptData(word, keyStr) {
       let key = CryptoJS.enc.Hex.parse(keyStr)
-      console.log('CryptoJS生成的key',key);
+      // console.log('CryptoJS生成的key',key);
       let encrypted = CryptoJS.AES.encrypt(word, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7}) // 加密模式为ECB,补码方式为PKCS5Padding(也就是PKCS7)
 
       return encrypted.toString()

+ 1 - 1
src/main/java/com/ichaoj/ams/constant/AmsConstant.java

@@ -38,7 +38,7 @@ public class AmsConstant {
 //    }
 
     public static final String WALLET_FILE_PATH =
-            StrUtil.format("{}home{}ams{}wallet{}", File.separator, File.separator, File.separator, File.separator);
+            StrUtil.format("{}home{}pao{}ams{}wallet{}", File.separator, File.separator, File.separator, File.separator, File.separator);
 
     public enum TaskType {
         /**