diff --git a/resources/views/components/layouts/admin.blade.php b/resources/views/components/layouts/admin.blade.php index d3c4f797..485cffb4 100644 --- a/resources/views/components/layouts/admin.blade.php +++ b/resources/views/components/layouts/admin.blade.php @@ -1,5 +1,17 @@ + @php + // 钉钉工作台「财务系统」入口:只在店铺违规信息预警这一页隐藏全局菜单, + // 让这个入口点进去就只是一张页面;网页端登录(非钉钉容器)不受影响。 + // 也支持显式 ?focus=1,便于以后给别的入口做同样的单页模式。 + // 路由参数在部分上下文取不到时退回按路径段判断(与目录表同一套兼容写法)。 + $focusSection = (string) (request()->route('section') ?: request()->segment(3)); + $focusPage = (string) (request()->route('page') ?: request()->segment(4)); + $focusEntry = $focusSection === 'financial-risk-control' + && $focusPage === 'store-violation-alert' + && (request()->boolean('focus') || str_contains((string) request()->userAgent(), 'DingTalk')); + @endphp + @if (! empty($metaTitle)) @@ -20,11 +32,13 @@ @stack('body_start') - + @unless ($focusEntry) + + @endunless -
+
diff --git a/tests/Feature/Business/StoreViolationAlertPageTest.php b/tests/Feature/Business/StoreViolationAlertPageTest.php index 27e9a39e..a6e2bbf7 100644 --- a/tests/Feature/Business/StoreViolationAlertPageTest.php +++ b/tests/Feature/Business/StoreViolationAlertPageTest.php @@ -135,6 +135,31 @@ class StoreViolationAlertPageTest extends FeatureTestCase ->assertSee('data-platform-panel="jingxi"', false); } + public function test_dingtalk_entry_shows_only_this_page_without_the_global_menu(): void + { + $this->allowPage(); + + // 钉钉工作台入口:隐藏全局菜单,只留这一页。 + $this->loginAs() + ->withHeaders(['User-Agent' => 'Mozilla/5.0 (Macintosh) AppleWebKit/605.1.15 DingTalk(9.0.1-macOS-arm64) webDt/PC']) + ->get(route('business.pages.show', [ + 'section' => 'financial-risk-control', + 'page' => 'store-violation-alert', + ])) + ->assertOk() + ->assertDontSee('id="sidenav-main"', false) + ->assertSeeText('店铺违规信息预警'); + + // 网页端(非钉钉)照旧显示完整菜单。 + $this->withHeaders(['User-Agent' => 'Mozilla/5.0 (Macintosh) Safari/605.1.15']) + ->get(route('business.pages.show', [ + 'section' => 'financial-risk-control', + 'page' => 'store-violation-alert', + ])) + ->assertOk() + ->assertSee('id="sidenav-main"', false); + } + public function test_page_filters_by_keyword(): void { $this->allowPage();