refactor(js): 复制成功toast文案收敛为toastCopied统一口径
This commit is contained in:
@@ -594,6 +594,20 @@
|
|||||||
return toast('error', text, 9000);
|
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 / 复制治理链接,避免两套口径漂移。
|
// 说明:用于复制 run_id / 复制治理链接,避免两套口径漂移。
|
||||||
function tempButtonFeedback(btn, ok, origAttr) {
|
function tempButtonFeedback(btn, ok, origAttr) {
|
||||||
@@ -638,7 +652,7 @@
|
|||||||
copyToClipboard(runId).then(function(){
|
copyToClipboard(runId).then(function(){
|
||||||
markCopiedRunId(true);
|
markCopiedRunId(true);
|
||||||
// 成功反馈优先 toast;若 toast 不可用也无需 alert(按钮已提供“已复制”短反馈)。
|
// 成功反馈优先 toast;若 toast 不可用也无需 alert(按钮已提供“已复制”短反馈)。
|
||||||
toastSuccess('已复制 run_id:' + runId);
|
toastCopied('run_id', runId);
|
||||||
}).catch(function(){
|
}).catch(function(){
|
||||||
markCopiedRunId(false);
|
markCopiedRunId(false);
|
||||||
if (toastError('复制失败,请手动复制 run_id:' + runId)) {
|
if (toastError('复制失败,请手动复制 run_id:' + runId)) {
|
||||||
@@ -679,7 +693,7 @@
|
|||||||
copyToClipboard(abs).then(function(){
|
copyToClipboard(abs).then(function(){
|
||||||
markCopied(btn, true);
|
markCopied(btn, true);
|
||||||
// 成功反馈优先 toast;若 toast 不可用也无需 alert(按钮已提供“已复制”短反馈)。
|
// 成功反馈优先 toast;若 toast 不可用也无需 alert(按钮已提供“已复制”短反馈)。
|
||||||
toastSuccess('已复制' + label + '链接');
|
toastCopied(label + '链接', '');
|
||||||
}).catch(function(){
|
}).catch(function(){
|
||||||
markCopied(btn, false);
|
markCopied(btn, false);
|
||||||
if (toastError('复制失败,请手动复制' + label + '链接')) {
|
if (toastError('复制失败,请手动复制' + label + '链接')) {
|
||||||
|
|||||||
20
tests/Feature/AdminJsToastCopiedHelperShouldExistTest.php
Normal file
20
tests/Feature/AdminJsToastCopiedHelperShouldExistTest.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminJsToastCopiedHelperShouldExistTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
public function test_admin_js_should_include_toast_copied_helper(): void
|
||||||
|
{
|
||||||
|
$js = file_get_contents(public_path('js/admin.js'));
|
||||||
|
$this->assertIsString($js);
|
||||||
|
|
||||||
|
$this->assertStringContainsString('function toastCopied', $js);
|
||||||
|
$this->assertStringContainsString("msg = '已复制'", $js);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user