From c48c4e7470536119c56226ff410507453e8258ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Tue, 17 Mar 2026 17:25:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(js):=20=E5=A4=8D=E5=88=B6=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E4=BC=98=E5=85=88toastError=E5=8F=8D=E9=A6=88(alert?= =?UTF-8?q?=E9=99=8D=E7=BA=A7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/admin.js | 6 ++++++ ...pyFailuresShouldUseToastErrorFirstTest.php | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/Feature/AdminJsCopyFailuresShouldUseToastErrorFirstTest.php diff --git a/public/js/admin.js b/public/js/admin.js index a135e4a..27909b3 100644 --- a/public/js/admin.js +++ b/public/js/admin.js @@ -643,6 +643,9 @@ try { window.alert('已复制 run_id:' + runId); } catch (e) {} }).catch(function(){ markCopiedRunId(false); + if (toastError('复制失败,请手动复制 run_id:' + runId)) { + return; + } try { window.alert('复制失败,请手动复制 run_id:' + runId); } catch (e) {} }); }); @@ -684,6 +687,9 @@ try { window.alert('已复制' + label + '链接'); } catch (e) {} }).catch(function(){ markCopied(btn, false); + if (toastError('复制失败,请手动复制' + label + '链接')) { + return; + } try { window.alert('复制失败,请手动复制' + label + '链接'); } catch (e) {} }); }); diff --git a/tests/Feature/AdminJsCopyFailuresShouldUseToastErrorFirstTest.php b/tests/Feature/AdminJsCopyFailuresShouldUseToastErrorFirstTest.php new file mode 100644 index 0000000..6a13389 --- /dev/null +++ b/tests/Feature/AdminJsCopyFailuresShouldUseToastErrorFirstTest.php @@ -0,0 +1,20 @@ +assertIsString($js); + + // 复制失败时应优先 toastError(alert 作为降级) + $this->assertStringContainsString("toastError('复制失败", $js); + } +}