diff --git a/resources/views/admin/components/metric_explain.blade.php b/resources/views/admin/components/metric_explain.blade.php index 5df2875..9fb0ae3 100644 --- a/resources/views/admin/components/metric_explain.blade.php +++ b/resources/views/admin/components/metric_explain.blade.php @@ -1,13 +1,25 @@ @php $items = $items ?? []; $title = $title ?? '口径说明'; + $collapsible = (bool) ($collapsible ?? true); @endphp @if(is_array($items) && count($items) > 0) -
- {{ $title }}: - @foreach($items as $i => $text) - {{ $text }}@if($i < count($items) - 1);@endif - @endforeach -
+ @if($collapsible) +
+ {{ $title }}:(点击展开) +
+ @foreach($items as $i => $text) + {{ $text }}@if($i < count($items) - 1);@endif + @endforeach +
+
+ @else +
+ {{ $title }}: + @foreach($items as $i => $text) + {{ $text }}@if($i < count($items) - 1);@endif + @endforeach +
+ @endif @endif diff --git a/tests/Feature/AdminMetricExplainComponentShouldUseDetailsByDefaultTest.php b/tests/Feature/AdminMetricExplainComponentShouldUseDetailsByDefaultTest.php new file mode 100644 index 0000000..2f80b5f --- /dev/null +++ b/tests/Feature/AdminMetricExplainComponentShouldUseDetailsByDefaultTest.php @@ -0,0 +1,34 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_dashboard_should_render_metric_explain_as_details(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin'); + + $res->assertOk(); + // 组件默认应使用 details 折叠,避免口径说明撑满页面。 + $res->assertSee('data-role="metric-explain"', false); + $res->assertSee('assertSee('点击展开'); + } +}