feat(js): 复制成功不再alert(仅toast+按钮短反馈)
This commit is contained in:
@@ -637,10 +637,8 @@
|
||||
var runId = btn.getAttribute('data-run-id') || '';
|
||||
copyToClipboard(runId).then(function(){
|
||||
markCopiedRunId(true);
|
||||
if (toastSuccess('已复制 run_id:' + runId)) {
|
||||
return;
|
||||
}
|
||||
try { window.alert('已复制 run_id:' + runId); } catch (e) {}
|
||||
// 成功反馈优先 toast;若 toast 不可用也无需 alert(按钮已提供“已复制”短反馈)。
|
||||
toastSuccess('已复制 run_id:' + runId);
|
||||
}).catch(function(){
|
||||
markCopiedRunId(false);
|
||||
if (toastError('复制失败,请手动复制 run_id:' + runId)) {
|
||||
@@ -680,11 +678,8 @@
|
||||
var abs = absoluteUrl(href);
|
||||
copyToClipboard(abs).then(function(){
|
||||
markCopied(btn, true);
|
||||
|
||||
if (toastSuccess('已复制' + label + '链接')) {
|
||||
return;
|
||||
}
|
||||
try { window.alert('已复制' + label + '链接'); } catch (e) {}
|
||||
// 成功反馈优先 toast;若 toast 不可用也无需 alert(按钮已提供“已复制”短反馈)。
|
||||
toastSuccess('已复制' + label + '链接');
|
||||
}).catch(function(){
|
||||
markCopied(btn, false);
|
||||
if (toastError('复制失败,请手动复制' + label + '链接')) {
|
||||
|
||||
20
tests/Feature/AdminJsCopySuccessShouldNotUseAlertTest.php
Normal file
20
tests/Feature/AdminJsCopySuccessShouldNotUseAlertTest.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminJsCopySuccessShouldNotUseAlertTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_copy_success_should_not_use_alert(): void
|
||||
{
|
||||
$js = file_get_contents(public_path('js/admin.js'));
|
||||
$this->assertIsString($js);
|
||||
|
||||
// 成功路径不应再依赖 alert(用 toast + 按钮短反馈即可)
|
||||
$this->assertStringNotContainsString("window.alert('已复制", $js);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user