From c3cbe225433dac48ae5059e9b68a6d0c99b5b09b Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Wed, 2 Jul 2025 23:23:51 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E5=A4=8D=E5=88=B6=E5=A4=B1=E8=B4=A5;?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E8=A1=A8=E6=97=A0=E6=B3=95=E5=AE=8C=E6=88=90?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/src/components/AppGeneratorPage.js | 47 ++++++++----------- src/main/resources/templates/database.html | 2 +- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/main/resources/static/src/components/AppGeneratorPage.js b/src/main/resources/static/src/components/AppGeneratorPage.js index eac08ed..b4304a9 100644 --- a/src/main/resources/static/src/components/AppGeneratorPage.js +++ b/src/main/resources/static/src/components/AppGeneratorPage.js @@ -94,40 +94,31 @@ const AppGeneratorPage = defineComponent({ * 点击复制图表 * 几秒后恢复原状 */ - onCopyToClipboard(code) { - const textarea = document.createElement('textarea'); - textarea.value = code; - // 避免滚动到页面底部 - textarea.style.position = 'fixed'; - document.body.appendChild(textarea); - textarea.select(); - + async onCopyToClipboard(code) { try { - const successful = document.execCommand('copy'); - if (successful) { - this.copied = true; - antd.notification.open({ - type: 'success', - message: '复制成功', - description: '已将内容复制至剪切板', - duration: 3, - }); - - // 几秒后恢复原状 - setTimeout(() => { - this.copied = false; - }, 2000); - } - } catch (err) { + await navigator.clipboard.writeText(code); antd.notification.open({ type: 'success', - message: '复制失败', - description: err.message, + message: '复制成功', + description: '已将内容复制至剪切板', duration: 3, }); + } catch (err) { + antd.notification.open({ + type: 'error', + message: '复制失败', + description: err.message``, + duration: 3, + }); + console.error('复制失败:', err); + // 回退到传统方法 + const textarea = document.createElement('textarea'); + textarea.value = code; + document.body.appendChild(textarea); + textarea.select(); + document.execCommand('copy'); + document.body.removeChild(textarea); } - - document.body.removeChild(textarea); }, /* 下载全部文件 */ diff --git a/src/main/resources/templates/database.html b/src/main/resources/templates/database.html index 551c6f5..0d12bb3 100644 --- a/src/main/resources/templates/database.html +++ b/src/main/resources/templates/database.html @@ -180,7 +180,7 @@ handler(val) { this.tableList = this.rawTableList; // 根据表名进行过滤筛选或者根据注释内容进行筛选 - this.tableList = this.tableList.filter(table => table.tableName.includes(val) || table.tablePrefixes.includes(val)); + this.tableList = this.tableList.filter(table => table.tableName.includes(val) || table.comment.includes(val)); } }, },