From 291f715e9139633cc6324fd8723c09c0c9484a05 Mon Sep 17 00:00:00 2001 From: DearTanker <1122669+DearTanker@users.noreply.github.com> Date: Fri, 4 Jul 2025 09:43:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=B0=E5=BD=95=E5=80=BC?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E5=8A=9F=E8=83=BD=20(#266)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、修复无法复制包含双引号的 TXT 记录值 2、调整 MX 记录值的复制按钮到右侧,因为复制不需要复制优先级。 --- app/view/domain/record.html | 63 ++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/app/view/domain/record.html b/app/view/domain/record.html index 72a1ddf..763de3e 100644 --- a/app/view/domain/record.html +++ b/app/view/domain/record.html @@ -290,12 +290,16 @@ $(document).ready(function(){ field: 'Value', title: '记录值', formatter: function(value, row, index) { - var display = value; - if(row.Type == 'MX') display = value + ' | ' + row.MX; var copyId = 'copy-value-' + row.RecordId; - // 只允许安全字符,避免引号问题 - var safeValue = (value+'').replace(/'/g, "'").replace(/\\/g, "\\\\"); - return ''+display+''; + if(row.Type == 'MX') { + // 只复制 mx.yandex.net,按钮在其右侧,优先级单独显示 + return ''+value+'' + + '' + + ' | '+row.MX+''; + } else { + return ''+value+'' + + ''; + } } }, { @@ -728,23 +732,38 @@ function advanceSearch(){ } } function copyToClipboard(text, selector) { - var tempInput = document.createElement('input'); - tempInput.style.position = 'absolute'; - tempInput.style.left = '-9999px'; - tempInput.value = text; - document.body.appendChild(tempInput); - tempInput.select(); - document.execCommand('copy'); - document.body.removeChild(tempInput); - if(selector){ - var icon = document.querySelector(selector + ' + a i'); - if(icon){ - var oldClass = icon.className; - icon.className = 'fa fa-check'; - setTimeout(function(){ icon.className = oldClass; }, 1000); - } - } - layer.msg('已复制到剪贴板', {icon: 1, time: 600}); + if (!text && selector) { + var el = document.querySelector(selector); + if (el) { + text = el.getAttribute('data-value'); + } + } + var tempInput = document.createElement('input'); + tempInput.style.position = 'absolute'; + tempInput.style.left = '-9999px'; + tempInput.value = text; + document.body.appendChild(tempInput); + tempInput.select(); + document.execCommand('copy'); + document.body.removeChild(tempInput); + if(selector){ + var icon = document.querySelector(selector + ' + a i'); + if(icon){ + var oldClass = icon.className; + icon.className = 'fa fa-check'; + setTimeout(function(){ icon.className = oldClass; }, 1000); + } + } + layer.msg('已复制到剪贴板', {icon: 1, time: 600}); +} +// 工具函数:HTML转义,防止XSS +function htmlEscape(str) { + return String(str) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); } {/block} \ No newline at end of file