ソースを参照

AES加解密复制功能逻辑修复

cfort 1 年間 前
コミット
2fe530b80d

+ 0 - 4
src/views/platform/examination/exam/detail.vue

@@ -255,10 +255,6 @@ export default {
         examId: {
         examId: {
             type: String,
             type: String,
             default: ''
             default: ''
-        },
-        id: {
-            type: String,
-            default: ''
         }
         }
     },
     },
     data () {
     data () {

+ 20 - 12
src/views/platform/system/tools/convertByAes.vue

@@ -112,18 +112,26 @@ export default {
             if (!this.plaintext) {
             if (!this.plaintext) {
                 return this.$message.warning('明文为空!')
                 return this.$message.warning('明文为空!')
             }
             }
-            const temp = JSON.parse(this.plaintext)
-            const hasSql = temp.hasOwnProperty('sql')
-            // if (!temp.sql) {
-            //     return this.$message.warning('明文中不含SQL!')
-            // }
-            navigator.clipboard.writeText(temp.sql || this.plaintext).then(() => {
-                const msg = hasSql ? '明文SQL已复制到剪贴板!' : '明文中不含SQL,已复制所有内容到剪贴板!'
-                this.$message.success(msg)
-            }).catch(error => {
-                this.$message.success('复制失败!')
-                console.log(error)
-            })
+            try {
+                const temp = JSON.parse(this.plaintext)
+                const hasSql = temp.hasOwnProperty('sql')
+                // 明文是 JSON 格式
+                navigator.clipboard.writeText(temp.sql || this.plaintext).then(() => {
+                    const msg = hasSql ? '明文SQL已复制到剪贴板!' : '明文中不含SQL,已复制所有内容到剪贴板!'
+                    this.$message.success(msg)
+                }).catch(error => {
+                    this.$message.error('复制失败!')
+                    console.log(error)
+                })
+            } catch (e) {
+                // 明文不是 JSON 格式
+                navigator.clipboard.writeText(this.plaintext).then(() => {
+                    this.$message.success('明文内容已复制到剪贴板!')
+                }).catch(error => {
+                    this.$message.error('复制失败!')
+                    console.log(error)
+                })
+            }
         },
         },
         closeDialog () {
         closeDialog () {
             this.$emit('close', false)
             this.$emit('close', false)