feat(admin-js): auto open add payment receipt details when hash present

This commit is contained in:
萝卜
2026-03-16 15:33:09 +08:00
parent 9587f03edf
commit 7181cfbaf8
2 changed files with 34 additions and 0 deletions

View File

@@ -47,6 +47,22 @@
}
}
// 平台订单详情页:当从仪表盘/列表跳转到某个治理锚点(例如 #add-payment-receipt自动展开对应 <details>。
// 说明:避免“跳过去但面板是折叠的”,造成运营以为没跳到。
(function () {
if (!window.location || !window.location.hash) {
return;
}
var h = String(window.location.hash || '');
if (h === '#add-payment-receipt') {
var d = qs('details#add-payment-receipt');
if (d) {
d.open = true;
}
}
})();
// 通用:表单提交后禁用按钮,避免运营重复点击造成重复请求
// 用法form 标记 data-action="disable-on-submit"。
(function () {

View File

@@ -0,0 +1,18 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
class AdminJsShouldAutoOpenAddPaymentReceiptDetailsWhenHashPresentTest extends TestCase
{
public function test_admin_js_should_auto_open_add_payment_receipt_details_when_hash_present(): void
{
$js = (string) file_get_contents(public_path('js/admin.js'));
// 护栏:当 hash 为 #add-payment-receipt 时,应自动展开 details#add-payment-receipt。
$this->assertStringContainsString("h === '#add-payment-receipt'", $js);
$this->assertStringContainsString("qs('details#add-payment-receipt')", $js);
$this->assertStringContainsString('d.open = true', $js);
}
}