feat(js): #filters锚点跳转自动展开平台订单筛选面板
This commit is contained in:
@@ -68,6 +68,33 @@
|
||||
}
|
||||
})();
|
||||
|
||||
// 平台订单列表页:当从批次页等入口带 #filters 跳转过来时,自动展开筛选面板并定位。
|
||||
// 说明:筛选面板会记忆折叠状态(localStorage);若运营之前手动收起,再跳转回来可能看不到筛选条件。
|
||||
(function () {
|
||||
if (!window.location || String(window.location.hash || '') !== '#filters') {
|
||||
return;
|
||||
}
|
||||
|
||||
var d = qs('#filters');
|
||||
if (!d) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 若是 <details>,确保展开
|
||||
if (String(d.tagName || '').toLowerCase() === 'details') {
|
||||
d.open = true;
|
||||
}
|
||||
|
||||
// 轻量定位(不强依赖 smooth)
|
||||
try {
|
||||
d.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
} catch (e) {
|
||||
try {
|
||||
d.scrollIntoView();
|
||||
} catch (e2) {}
|
||||
}
|
||||
})();
|
||||
|
||||
// 通用:表单提交后禁用按钮,避免运营重复点击造成重复请求
|
||||
// 用法:form 标记 data-action="disable-on-submit"。
|
||||
(function () {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminJsShouldIncludeAutoOpenPlatformOrderFiltersOnAnchorTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_admin_js_should_include_auto_open_filters_logic(): void
|
||||
{
|
||||
$js = file_get_contents(public_path('js/admin.js'));
|
||||
|
||||
$this->assertIsString($js);
|
||||
|
||||
// 关键口径:hash=#filters 时,自动展开 #filters(details)
|
||||
$this->assertStringContainsString("#filters", $js);
|
||||
$this->assertStringContainsString("location.hash", $js);
|
||||
$this->assertStringContainsString("d.open = true", $js);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user