Kaynağa Gözat

feat:修改加密时间戳

st 2 ay önce
ebeveyn
işleme
6e2dc7fdd9
1 değiştirilmiş dosya ile 9 ekleme ve 6 silme
  1. 9 6
      src/utils/crypto.ts

+ 9 - 6
src/utils/crypto.ts

@@ -4,6 +4,7 @@ import CryptoJS from 'crypto-js'
 export class SmCrypto {
   private readonly privateKey: string
   private readonly publicKey: string
+
   constructor(privateKey: string, publicKey: string) {
     this.privateKey = privateKey
     this.publicKey = publicKey
@@ -42,13 +43,15 @@ export class SmCrypto {
   }
 
   getNowFormatDate() {
+    // const date = new Date()
+    // const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
+    // const strDate = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
+    // const hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
+    // const minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
+    // const seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
+    // return `${date.getFullYear()}${month}${strDate}${hours}${minutes}${seconds}`
     const date = new Date()
-    const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
-    const strDate = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
-    const hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
-    const minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
-    const seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
-    return `${date.getFullYear()}${month}${strDate}${hours}${minutes}${seconds}`
+    return date.getTime() // 获取时间戳(毫秒)
   }
 
   uuid(len, radix) {