From 9d8133cc732deeffd450898dc80da90b7ead3812 Mon Sep 17 00:00:00 2001 From: renshen <1005457301@qq.com> Date: Mon, 19 Oct 2026 10:42:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=90=8E=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=AF=BC=E8=88=AA=EF=BC=8C=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=89=93=E5=BC=80=E7=AC=AC=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增首页导航页:常用分组沿用侧边栏分组,下面是全部业务模块(可展开) - Pages@home 由跳转首个业务页改为渲染首页;侧边栏分组定义抽到 SidebarMenu 复用 - 侧边栏顶部标识可点回首页 - 更新钉钉登录落地断言,补充首页导航测试 --- app/Http/Controllers/Business/Pages.php | 22 +- app/Utilities/SidebarMenu.php | 139 ++++++++++ resources/views/business/pages/home.blade.php | 245 ++++++++++++++++++ .../components/layouts/admin/menu.blade.php | 70 +---- tests/Feature/Auth/DingTalkLoginTest.php | 9 +- tests/Feature/Business/PagesTest.php | 11 + 6 files changed, 419 insertions(+), 77 deletions(-) create mode 100644 app/Utilities/SidebarMenu.php create mode 100644 resources/views/business/pages/home.blade.php diff --git a/app/Http/Controllers/Business/Pages.php b/app/Http/Controllers/Business/Pages.php index 45925206..1a3a0482 100644 --- a/app/Http/Controllers/Business/Pages.php +++ b/app/Http/Controllers/Business/Pages.php @@ -664,24 +664,18 @@ class Pages extends Controller public function home() { - $section = collect(SidebarPermissions::navigationFor(user()))->first(); + $groups = \App\Utilities\SidebarMenu::groups(user()); + $sections = \App\Utilities\SidebarMenu::sections(user()); - if (empty($section)) { + if ($groups === [] && $sections === []) { return view('business.access-pending'); } - $page = collect($section['pages'] ?? [])->first(); - $parameters = ['section' => $section['slug']]; - - if ($page) { - $parameters['page'] = $page['slug']; - - if (! empty($page['tabs'])) { - $parameters['tab'] = $page['tabs'][0]['slug']; - } - } - - return redirect()->route('business.pages.show', $parameters); + // 登录后先落到首页导航,不再直接跳进第一个业务页面。 + return view('business.pages.home', [ + 'groups' => $groups, + 'sections' => $sections, + ]); } public function show(string $section, ?string $page = null, ?string $tab = null) diff --git a/app/Utilities/SidebarMenu.php b/app/Utilities/SidebarMenu.php new file mode 100644 index 00000000..31dbaa20 --- /dev/null +++ b/app/Utilities/SidebarMenu.php @@ -0,0 +1,139 @@ +}> + */ + public static function groups(?User $user = null): array + { + $user ??= user(); + + $groups = [ + ['title' => '工作台', 'items' => [ + ['workspace', 'overview', '经营总览', 'monitoring'], + ]], + ['title' => '经营报表', 'items' => [ + ['company-management', 'subject-operating-report', '主体维度经营报表', 'domain'], + ['company-management', 'company-cost-arrangement', '公司成本安排', 'account_balance_wallet'], + ['company-management', 'tax-forecast', '税金预测表', 'calculate'], + ['store-management', 'store-report', '店铺维度报表', 'storefront'], + ['store-management', 'internal-flow-report', '内部流转报表', 'swap_horiz'], + ['company-management', 'personnel-inventory', '人员盘点表', 'groups'], + ]], + ['title' => '基础资料', 'items' => [ + ['store-management', 'basic-information', '店铺基础信息', 'shopping_bag'], + ['store-management', 'store-accounts', '店铺账号密码', 'key'], + ['company-management', 'basic-information', '公司基础信息', 'badge'], + ['trademark-management', 'information', '商标基础信息', 'workspace_premium'], + ]], + ['title' => '规则信息', 'items' => [ + ['trademark-management', 'subject-trademark-rules', '主体商标规则', 'rule'], + ['trademark-management', 'store-change-rules', '店铺变更规则', 'rule'], + ['trademark-management', 'store-report-data-logic', '店铺维度报表逻辑配置', 'table_chart'], + ['trademark-management', 'tax-forecast-data-logic', '税金预测表逻辑配置', 'calculate'], + ]], + ['title' => '业务进度', 'items' => [ + ['company-management', 'company-progress', '公司进度表', 'timeline'], + ['store-management', 'change-progress', '店铺变更进度表', 'swap_horiz'], + ['trademark-management', 'trademark-progress', '商标进度表', 'format_list_bulleted'], + ['workspace', 'tasks', '待办事项', 'assignment_turned_in'], + ['workspace', 'warnings', '预警页面', 'warning_amber'], + ]], + ['title' => '财务报表', 'items' => [ + ['prototype-finance-reports', 'profit-report', '公司利润报表', 'request_quote'], + ['prototype-finance-reports', 'asset-report', '公司资产报表', 'account_balance'], + ]], + ]; + + $visiblePages = self::visiblePages($user); + + $groups = array_map(function (array $group) use ($visiblePages): array { + $items = []; + + foreach ($group['items'] as [$section, $page, $title, $icon]) { + $key = $section . '/' . $page; + + if (! isset($visiblePages[$key])) { + continue; + } + + $items[] = [ + 'section' => $section, + 'page' => $page, + 'title' => $visiblePages[$key], + 'icon' => $icon, + ]; + } + + $group['items'] = $items; + + return $group; + }, $groups); + + return array_values(array_filter($groups, static fn (array $group): bool => $group['items'] !== [])); + } + + /** + * 当前账号可访问的全部业务模块及页面,供首页做完整导航。 + * + * @return array}> + */ + public static function sections(?User $user = null): array + { + $user ??= user(); + + $sections = []; + + foreach (SidebarPermissions::navigationFor($user) as $section) { + $pages = []; + + foreach ($section['pages'] ?? [] as $page) { + $pages[] = ['slug' => $page['slug'], 'title' => $page['title']]; + + foreach ($page['children'] ?? [] as $child) { + $pages[] = ['slug' => $child['slug'], 'title' => $child['title']]; + } + } + + if ($pages === []) { + continue; + } + + $sections[] = [ + 'slug' => $section['slug'], + 'title' => $section['title'], + 'icon' => $section['icon'] ?? 'folder', + 'pages' => $pages, + ]; + } + + return $sections; + } + + /** + * @return array 「section/page」 => 页面标题 + */ + private static function visiblePages(User $user): array + { + $pages = []; + + foreach (SidebarPermissions::navigationFor($user) as $section) { + foreach ($section['pages'] ?? [] as $page) { + $pages[$section['slug'] . '/' . $page['slug']] = $page['title']; + + foreach ($page['children'] ?? [] as $child) { + $pages[$section['slug'] . '/' . $child['slug']] = $child['title']; + } + } + } + + return $pages; + } +} diff --git a/resources/views/business/pages/home.blade.php b/resources/views/business/pages/home.blade.php new file mode 100644 index 00000000..c0120b71 --- /dev/null +++ b/resources/views/business/pages/home.blade.php @@ -0,0 +1,245 @@ +@php + $pageTotal = collect($sections)->sum(static fn (array $section): int => count($section['pages'])); +@endphp + + + 首页 + + + + +
+
+

{{ user()->name }},欢迎回来

+

从下面的模块进入要处理的页面,也可以直接用左侧菜单搜索。

+
+ +
+ @foreach ($groups as $group) +
+

{{ $group['title'] }}

+ +
+ @endforeach +
+ + @if ($sections !== []) +
+

+ 全部业务模块 + {{ count($sections) }} 个模块 · {{ $pageTotal }} 个页面 +

+ @foreach ($sections as $section) +
+ + + {{ $section['title'] }} + {{ count($section['pages']) }} 个页面 + +
+ @foreach ($section['pages'] as $sectionPage) + {{ $sectionPage['title'] }} + @endforeach +
+
+ @endforeach +
+ @endif +
+
+
diff --git a/resources/views/components/layouts/admin/menu.blade.php b/resources/views/components/layouts/admin/menu.blade.php index 687c82cb..573b1a4f 100644 --- a/resources/views/components/layouts/admin/menu.blade.php +++ b/resources/views/components/layouts/admin/menu.blade.php @@ -126,7 +126,7 @@ @stack('main_menu_company_start') + @stack('main_menu_admin_start') @php - $prototypeGroups = [ - ['title' => '工作台', 'items' => [ - ['workspace', 'overview', '经营总览', 'monitoring'], - ]], - ['title' => '经营报表', 'items' => [ - ['company-management', 'subject-operating-report', '主体维度经营报表', 'domain'], - ['company-management', 'company-cost-arrangement', '公司成本安排', 'account_balance_wallet'], - ['company-management', 'tax-forecast', '税金预测表', 'calculate'], - ['store-management', 'store-report', '店铺维度报表', 'storefront'], - ['store-management', 'internal-flow-report', '内部流转报表', 'swap_horiz'], - ['company-management', 'personnel-inventory', '人员盘点表', 'groups'], - ]], - ['title' => '基础资料', 'items' => [ - ['store-management', 'basic-information', '店铺基础信息', 'shopping_bag'], - ['store-management', 'store-accounts', '店铺账号密码', 'key'], - ['company-management', 'basic-information', '公司基础信息', 'badge'], - ['trademark-management', 'information', '商标基础信息', 'workspace_premium'], - ]], - ['title' => '规则信息', 'items' => [ - ['trademark-management', 'subject-trademark-rules', '主体商标规则', 'rule'], - ['trademark-management', 'store-change-rules', '店铺变更规则', 'rule'], - ['trademark-management', 'store-report-data-logic', '店铺维度报表逻辑配置', 'table_chart'], - ['trademark-management', 'tax-forecast-data-logic', '税金预测表逻辑配置', 'calculate'], - ]], - ['title' => '业务进度', 'items' => [ - ['company-management', 'company-progress', '公司进度表', 'timeline'], - ['store-management', 'change-progress', '店铺变更进度表', 'swap_horiz'], - ['trademark-management', 'trademark-progress', '商标进度表', 'format_list_bulleted'], - ['workspace', 'tasks', '待办事项', 'assignment_turned_in'], - ['workspace', 'warnings', '预警页面', 'warning_amber'], - ]], - ['title' => '财务报表', 'items' => [ - ['prototype-finance-reports', 'profit-report', '公司利润报表', 'request_quote'], - ['prototype-finance-reports', 'asset-report', '公司资产报表', 'account_balance'], - ]], - ]; - $visiblePages = []; - foreach (\App\Utilities\SidebarPermissions::navigationFor(user()) as $visibleSection) { - foreach ($visibleSection['pages'] ?? [] as $visiblePage) { - $visiblePages[$visibleSection['slug'] . '/' . $visiblePage['slug']] = $visiblePage['title']; - foreach ($visiblePage['children'] ?? [] as $visibleChild) { - $visiblePages[$visibleSection['slug'] . '/' . $visibleChild['slug']] = $visibleChild['title']; - } - } - } - $prototypeGroups = array_values(array_filter(array_map(function ($group) use ($visiblePages) { - $group['items'] = array_values(array_filter($group['items'], fn ($item) => isset($visiblePages[$item[0] . '/' . $item[1]]))); - foreach ($group['items'] as &$item) { - $item[2] = $visiblePages[$item[0] . '/' . $item[1]]; - } - unset($item); - return $group; - }, $prototypeGroups), fn ($group) => $group['items'] !== [])); + $prototypeGroups = \App\Utilities\SidebarMenu::groups(user()); @endphp