钉钉工作台入口:店铺违规信息预警整页展示(隐藏全局菜单)

钉钉工作台里点进来的这个入口,现在只显示这一张页面:不再渲染全局侧边栏,
内容区占满宽度,其余页面和网页端登录完全不受影响。

判断依据:当前页面是 financial-risk-control/store-violation-alert,且请求来自
钉钉容器(UA 含 DingTalk)或显式带 ?focus=1;路由参数取不到时按路径段兜底。
This commit is contained in:
renshen 2026-10-13 13:28:49 +08:00
parent 57f2dccfac
commit 7a5f04287c
2 changed files with 41 additions and 2 deletions

View File

@ -1,5 +1,17 @@
<!DOCTYPE html>
<html dir="{{ language()->direction() }}" lang="{{ app()->getLocale() }}">
@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
<x-layouts.admin.head>
@if (! empty($metaTitle))
<x-slot name="metaTitle">
@ -20,11 +32,13 @@
@stack('body_start')
@unless ($focusEntry)
<x-layouts.admin.menu />
@endunless
<!-- loading component will add this line -->
<div class="main-content xl:ltr:ml-64 xl:rtl:mr-64 transition-all ease-in-out" id="panel">
<div class="main-content {{ $focusEntry ? '' : 'xl:ltr:ml-64 xl:rtl:mr-64' }} transition-all ease-in-out" id="panel">
<div id="main-body">
<div class="container">
<x-layouts.admin.header>

View File

@ -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();