feat(js): 复制失败优先toastError反馈(alert降级)

This commit is contained in:
萝卜
2026-03-17 17:25:14 +08:00
parent b34236b32f
commit c48c4e7470
2 changed files with 26 additions and 0 deletions

View File

@@ -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) {}
});
});

View File

@@ -0,0 +1,20 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminJsCopyFailuresShouldUseToastErrorFirstTest extends TestCase
{
use RefreshDatabase;
public function test_copy_failures_should_use_toast_error_first(): void
{
$js = file_get_contents(public_path('js/admin.js'));
$this->assertIsString($js);
// 复制失败时应优先 toastErroralert 作为降级)
$this->assertStringContainsString("toastError('复制失败", $js);
}
}