From ce26dd04547726f94ccffec85bb216058d076a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Mon, 16 Mar 2026 14:22:16 +0800 Subject: [PATCH] style(admin): scope row-warn styles for dashboard and keep platform orders guards --- public/css/admin-components.css | 12 +++++++---- ...vernanceBlocksShouldUseThemeTokensTest.php | 5 +++-- ...ashboardRowWarnStyleShouldBeScopedTest.php | 21 +++++++++++++++++++ ...OrderIndexRowWarnPrefixStyleScopedTest.php | 3 ++- ...atformOrderIndexRowWarnStyleScopedTest.php | 3 ++- 5 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 tests/Feature/AdminDashboardRowWarnStyleShouldBeScopedTest.php diff --git a/public/css/admin-components.css b/public/css/admin-components.css index 945b322..fb0e202 100644 --- a/public/css/admin-components.css +++ b/public/css/admin-components.css @@ -672,7 +672,8 @@ } /* 平台订单列表:行内治理提示(精简视图主要入口) */ -.platform-orders-table .row-warn{ +.platform-orders-table .row-warn, +[data-page="admin.dashboard"] .row-warn{ margin-top:4px; padding:4px 6px; border-left:3px solid var(--adm-error, #ef4444); @@ -680,16 +681,19 @@ border-radius:4px; } -.platform-orders-table .row-warn a.link{ +.platform-orders-table .row-warn a.link, +[data-page="admin.dashboard"] .row-warn a.link{ color:var(--adm-error, #ef4444); text-decoration:underline; } -.platform-orders-table .row-warn a.link:hover{ +.platform-orders-table .row-warn a.link:hover, +[data-page="admin.dashboard"] .row-warn a.link:hover{ text-decoration:none; } -.platform-orders-table .row-warn-prefix{ +.platform-orders-table .row-warn-prefix, +[data-page="admin.dashboard"] .row-warn-prefix{ font-weight:600; display:inline-block; padding:1px 6px; diff --git a/tests/Feature/AdminComponentsCssGovernanceBlocksShouldUseThemeTokensTest.php b/tests/Feature/AdminComponentsCssGovernanceBlocksShouldUseThemeTokensTest.php index 1790562..ccb162b 100644 --- a/tests/Feature/AdminComponentsCssGovernanceBlocksShouldUseThemeTokensTest.php +++ b/tests/Feature/AdminComponentsCssGovernanceBlocksShouldUseThemeTokensTest.php @@ -32,9 +32,10 @@ class AdminComponentsCssGovernanceBlocksShouldUseThemeTokensTest extends TestCas $this->assertStringContainsString('background:var(--adm-error-bg', $css); // 列表行内治理提示(row-warn)也必须用 token。 - $this->assertStringContainsString('.platform-orders-table .row-warn{', $css); + // row-warn/row-warn-prefix 允许复用到仪表盘(按页面 scope),但平台订单列表的 scope 仍必须存在。 + $this->assertStringContainsString('.platform-orders-table .row-warn', $css); $this->assertStringContainsString('border-left:3px solid var(--adm-error', $css); - $this->assertStringContainsString('.platform-orders-table .row-warn-prefix{', $css); + $this->assertStringContainsString('.platform-orders-table .row-warn-prefix', $css); $this->assertStringContainsString('background:var(--adm-error-tint', $css); } } diff --git a/tests/Feature/AdminDashboardRowWarnStyleShouldBeScopedTest.php b/tests/Feature/AdminDashboardRowWarnStyleShouldBeScopedTest.php new file mode 100644 index 0000000..e354f01 --- /dev/null +++ b/tests/Feature/AdminDashboardRowWarnStyleShouldBeScopedTest.php @@ -0,0 +1,21 @@ +assertStringContainsString('[data-page="admin.dashboard"] .row-warn{', $css); + $this->assertStringContainsString('[data-page="admin.dashboard"] .row-warn-prefix{', $css); + + // 保持治理:禁止出现全局 .row-warn{...} 或 .row-warn-prefix{...},避免污染其它页面。 + $this->assertStringNotContainsString("\n.row-warn{", $css); + $this->assertStringNotContainsString("\n.row-warn-prefix{", $css); + } +} diff --git a/tests/Feature/AdminPlatformOrderIndexRowWarnPrefixStyleScopedTest.php b/tests/Feature/AdminPlatformOrderIndexRowWarnPrefixStyleScopedTest.php index 8cb058f..09e4ee5 100644 --- a/tests/Feature/AdminPlatformOrderIndexRowWarnPrefixStyleScopedTest.php +++ b/tests/Feature/AdminPlatformOrderIndexRowWarnPrefixStyleScopedTest.php @@ -26,7 +26,8 @@ class AdminPlatformOrderIndexRowWarnPrefixStyleScopedTest extends TestCase $css = file_get_contents(public_path('css/admin-components.css')); $this->assertIsString($css); - $this->assertStringContainsString('.platform-orders-table .row-warn-prefix{', $css); + // 允许同一套样式同时覆盖仪表盘最近订单(通过 [data-page="admin.dashboard"] 范围),但平台订单列表的 scope 仍必须存在。 + $this->assertStringContainsString('.platform-orders-table .row-warn-prefix', $css); // 避免全局污染 $this->assertStringNotContainsString("\n.row-warn-prefix{", $css); diff --git a/tests/Feature/AdminPlatformOrderIndexRowWarnStyleScopedTest.php b/tests/Feature/AdminPlatformOrderIndexRowWarnStyleScopedTest.php index 3d45951..9ef348d 100644 --- a/tests/Feature/AdminPlatformOrderIndexRowWarnStyleScopedTest.php +++ b/tests/Feature/AdminPlatformOrderIndexRowWarnStyleScopedTest.php @@ -27,7 +27,8 @@ class AdminPlatformOrderIndexRowWarnStyleScopedTest extends TestCase $css = file_get_contents(public_path('css/admin-components.css')); $this->assertIsString($css); - $this->assertStringContainsString('.platform-orders-table .row-warn{', $css); + // 允许同一套样式同时覆盖仪表盘最近订单(通过 [data-page="admin.dashboard"] 范围),但平台订单列表的 scope 仍必须存在。 + $this->assertStringContainsString('.platform-orders-table .row-warn', $css); // 仅避免“全局 .row-warn{...}”这种写法(会污染其它页面)。 $this->assertStringNotContainsString("\n.row-warn{", $css);