diff --git a/public/js/admin.js b/public/js/admin.js index 33cc9bc..9ccaa19 100644 --- a/public/js/admin.js +++ b/public/js/admin.js @@ -594,6 +594,20 @@ return toast('error', text, 9000); } + // 复制反馈文案统一口径(更像后台系统的短反馈,不塞超长 URL) + function toastCopied(label, detail) { + var l = String(label || '').trim(); + var d = String(detail || '').trim(); + var msg = '已复制'; + if (l) { + msg += l; + } + if (d) { + msg += ':' + d; + } + return toastSuccess(msg); + } + // 通用:按钮短暂反馈(已复制/复制失败)并自动恢复 // 说明:用于复制 run_id / 复制治理链接,避免两套口径漂移。 function tempButtonFeedback(btn, ok, origAttr) { @@ -638,7 +652,7 @@ copyToClipboard(runId).then(function(){ markCopiedRunId(true); // 成功反馈优先 toast;若 toast 不可用也无需 alert(按钮已提供“已复制”短反馈)。 - toastSuccess('已复制 run_id:' + runId); + toastCopied('run_id', runId); }).catch(function(){ markCopiedRunId(false); if (toastError('复制失败,请手动复制 run_id:' + runId)) { @@ -679,7 +693,7 @@ copyToClipboard(abs).then(function(){ markCopied(btn, true); // 成功反馈优先 toast;若 toast 不可用也无需 alert(按钮已提供“已复制”短反馈)。 - toastSuccess('已复制' + label + '链接'); + toastCopied(label + '链接', ''); }).catch(function(){ markCopied(btn, false); if (toastError('复制失败,请手动复制' + label + '链接')) { diff --git a/tests/Feature/AdminJsToastCopiedHelperShouldExistTest.php b/tests/Feature/AdminJsToastCopiedHelperShouldExistTest.php new file mode 100644 index 0000000..2ec313e --- /dev/null +++ b/tests/Feature/AdminJsToastCopiedHelperShouldExistTest.php @@ -0,0 +1,20 @@ +assertIsString($js); + + $this->assertStringContainsString('function toastCopied', $js); + $this->assertStringContainsString("msg = '已复制'", $js); + } +}