From 22fb3e9da03b5c033402040d1cf4750ecbfffe9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Mon, 16 Mar 2026 11:03:11 +0800 Subject: [PATCH] refactor(platform-orders): dedupe show page back actions --- .../views/admin/platform_orders/show.blade.php | 4 +++- ...PlatformOrderShowIndexLinkKeepsContextTest.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php index 2889acf..ddd503b 100644 --- a/resources/views/admin/platform_orders/show.blade.php +++ b/resources/views/admin/platform_orders/show.blade.php @@ -72,7 +72,9 @@ 来源线索:#{{ $leadIdFromBack }} @endif - 返回平台订单列表(保留上下文) + @if($safeBackForLinks === '') + 返回平台订单列表(保留上下文) + @endif diff --git a/tests/Feature/AdminPlatformOrderShowIndexLinkKeepsContextTest.php b/tests/Feature/AdminPlatformOrderShowIndexLinkKeepsContextTest.php index 8d0269b..740da79 100644 --- a/tests/Feature/AdminPlatformOrderShowIndexLinkKeepsContextTest.php +++ b/tests/Feature/AdminPlatformOrderShowIndexLinkKeepsContextTest.php @@ -68,5 +68,20 @@ class AdminPlatformOrderShowIndexLinkKeepsContextTest extends TestCase $res->assertSee('返回平台订单列表(保留上下文)'); $res->assertSee($expectedIndexUrl, false); + + // 明确 back 为空时,也应显示该按钮(作为兜底返回列表入口) + $res2 = $this->get('/admin/platform-orders/' . $order->id . '?' . Arr::query([ + 'back' => '', + ])); + $res2->assertOk(); + $res2->assertSee('返回平台订单列表(保留上下文)'); + + // 当传入有效 back 时,应优先显示“返回上一页”并隐藏该兜底按钮(避免重复入口噪音) + $res3 = $this->get('/admin/platform-orders/' . $order->id . '?' . Arr::query([ + 'back' => '/admin', + ])); + $res3->assertOk(); + $res3->assertSee('← 返回上一页(保留上下文)'); + $res3->assertDontSee('返回平台订单列表(保留上下文)'); } }