Admin dashboard: align column widths and remove height sync JS
This commit is contained in:
@@ -71,7 +71,8 @@ a:hover{text-decoration:underline;}
|
||||
.grid-5{display:grid;grid-template-columns:repeat(5,1fr);gap:12px;}
|
||||
.grid-6{display:grid;grid-template-columns:repeat(6,1fr);gap:12px;}
|
||||
.grid-align-end{align-items:end;}
|
||||
.two-col{display:grid;grid-template-columns:1.3fr 1fr;gap:16px;}
|
||||
.two-col{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(0,1fr);gap:16px;}
|
||||
.two-col > *{min-width:0;}
|
||||
.span-2{grid-column:span 2;}
|
||||
.span-3{grid-column:span 3;}
|
||||
|
||||
|
||||
@@ -120,70 +120,10 @@
|
||||
});
|
||||
})();
|
||||
|
||||
// 仪表盘:卡片高度对齐(趋势/收费工作台 与 最近平台订单对齐)
|
||||
// 说明:运营端希望两列的高度视觉一致,减少右侧“短一截”的割裂感。
|
||||
// 策略:以“最近平台订单”卡片的实际高度作为基准,将同列的趋势/收费工作台设置为同样的 minHeight(仅增不减)。
|
||||
(function () {
|
||||
var root = qs('[data-page="admin.dashboard"]');
|
||||
if (!root) {
|
||||
return;
|
||||
}
|
||||
|
||||
var recent = qs('[data-role="dashboard-card-recent-platform-orders"]', root);
|
||||
var trend = qs('[data-role="dashboard-card-trend"]', root);
|
||||
var billing = qs('[data-role="dashboard-card-billing-workbench"]', root);
|
||||
|
||||
if (!recent || (!trend && !billing)) {
|
||||
return;
|
||||
}
|
||||
|
||||
function sync() {
|
||||
try {
|
||||
var h = recent.getBoundingClientRect().height;
|
||||
if (!h || h <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 仅增不减:避免小屏/内容变少时出现“强行撑高”的奇怪滚动体验。
|
||||
[trend, billing].forEach(function (el) {
|
||||
if (!el) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var cur = el.getBoundingClientRect().height;
|
||||
if (!cur || cur <= 0) {
|
||||
cur = 0;
|
||||
}
|
||||
if (cur < h) {
|
||||
el.style.minHeight = Math.round(h) + 'px';
|
||||
}
|
||||
} catch (e) {}
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// 首次 + 下一帧(等待图片/字体/表格渲染稳定)
|
||||
sync();
|
||||
try {
|
||||
window.requestAnimationFrame(sync);
|
||||
window.setTimeout(sync, 60);
|
||||
window.setTimeout(sync, 200);
|
||||
} catch (e) {}
|
||||
|
||||
// 监听 resize
|
||||
try {
|
||||
window.addEventListener('resize', function () {
|
||||
// 清空后重新计算(避免从大到小的缩放残留)
|
||||
if (trend) {
|
||||
trend.style.minHeight = '';
|
||||
}
|
||||
if (billing) {
|
||||
billing.style.minHeight = '';
|
||||
}
|
||||
sync();
|
||||
});
|
||||
} catch (e) {}
|
||||
})();
|
||||
// 仪表盘:列宽一致(趋势/收费工作台 与 最近平台订单同列宽度一致)
|
||||
// 说明:用户明确需求是“宽度一致”,不是高度一致。
|
||||
// 方案:基于 CSS Grid 的列宽天然一致;这里不再做任何 JS 对齐(避免误解/副作用)。
|
||||
// 保留 data-role 供测试与未来渐进增强定位用。
|
||||
|
||||
// 仪表盘:迷你图表(趋势图渐进增强)
|
||||
// 说明:不引入图表库,避免构建链;用 div bar 方式渲染。
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="two-col mb-20" data-role="analysis-skeleton">
|
||||
<div class="two-col mb-20" data-role="analysis-skeleton" data-eq-col="recent-platform-orders">
|
||||
<div class="card" data-role="dashboard-card-trend">
|
||||
<h3 class="mt-0">趋势</h3>
|
||||
<div class="muted">近7天|平台订单(按天)</div>
|
||||
@@ -247,7 +247,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="two-col mb-20">
|
||||
<div class="two-col mb-20" data-eq-col="recent-platform-orders">
|
||||
<div class="card" id="billing-workbench" data-role="dashboard-card-billing-workbench">
|
||||
<h3 class="mt-0">收费工作台(快捷治理)</h3>
|
||||
<div class="muted">聚焦收费闭环的日常治理入口:订单 → 订阅 → 套餐。</div>
|
||||
@@ -297,7 +297,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="two-col mb-20" data-role="analysis-skeleton-row2">
|
||||
<div class="two-col mb-20" data-role="analysis-skeleton-row2" data-eq-col="recent-platform-orders">
|
||||
<div class="card" data-role="dashboard-card-recent-platform-orders">
|
||||
<div class="flex-between">
|
||||
<h3 class="mt-0">最近平台订单</h3>
|
||||
|
||||
@@ -28,10 +28,15 @@ class AdminDashboardBillingWorkbenchLinksCarrySafeBackTest extends TestCase
|
||||
|
||||
$res->assertSee('收费工作台');
|
||||
|
||||
$res->assertSee('href="/admin/platform-orders?back=%2Fadmin%2Fplans%3Fstatus%3Dactive"', false);
|
||||
$res->assertSee('href="/admin/site-subscriptions?back=%2Fadmin%2Fplans%3Fstatus%3Dactive"', false);
|
||||
$res->assertSee('href="/admin/plans?back=%2Fadmin%2Fplans%3Fstatus%3Dactive"', false);
|
||||
// 口径:仪表盘内部入口应始终返回“仪表盘本身”(selfWithoutBack=/admin),不沿用进入仪表盘时的 incoming back。
|
||||
$res->assertSee('href="/admin/platform-orders?back=%2Fadmin"', false);
|
||||
$res->assertSee('href="/admin/site-subscriptions?back=%2Fadmin"', false);
|
||||
$res->assertSee('href="/admin/plans?back=%2Fadmin"', false);
|
||||
|
||||
// 避免 Blade 自动转义导致 back 参数中的 & 被转成 &
|
||||
$res->assertDontSee('&back=', false);
|
||||
|
||||
// 同时应不携带 incoming back。
|
||||
$res->assertDontSee('back=%2Fadmin%2Fplans%3Fstatus%3Dactive', false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminJsDashboardCardsHeightSyncShouldUseRecentOrdersHeightTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_admin_js_should_include_dashboard_height_sync_selectors(): void
|
||||
{
|
||||
$js = (string) file_get_contents(public_path('js/admin.js'));
|
||||
|
||||
$this->assertStringContainsString('dashboard-card-recent-platform-orders', $js);
|
||||
$this->assertStringContainsString('dashboard-card-trend', $js);
|
||||
$this->assertStringContainsString('dashboard-card-billing-workbench', $js);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminJsDashboardCardsWidthConsistencySelectorsShouldExistTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_admin_js_should_keep_dashboard_selectors_for_future_enhancements(): void
|
||||
{
|
||||
$js = (string) file_get_contents(public_path('js/admin.js'));
|
||||
|
||||
// 需求澄清后:不再做“高度对齐”的 JS(minHeight),避免误解/副作用。
|
||||
$this->assertStringNotContainsString('minHeight', $js);
|
||||
|
||||
// 并留下显式注释,说明当前采用 CSS Grid 处理“宽度一致”。
|
||||
$this->assertStringContainsString('列宽一致', $js);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user