From 7f59bb99856b70c0c3ca69457cc5615db7db0a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sun, 15 Mar 2026 19:16:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E4=BB=AA=E8=A1=A8=E7=9B=98?= =?UTF-8?q?=E6=9C=80=E8=BF=91=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E6=90=BA=E5=B8=A6=20back=20=E5=9B=9E=E8=B7=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/admin/dashboard.blade.php | 7 ++-- ...tPlatformOrderLinksShouldCarryBackTest.php | 33 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/Feature/AdminDashboardRecentPlatformOrderLinksShouldCarryBackTest.php diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index 99f82d7..b0f8e25 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -8,6 +8,9 @@ $incomingBack = (string) request()->query('back', ''); $safeBackForLinks = \App\Support\BackUrl::sanitizeForLinks($incomingBack); + // 用于构建“从仪表盘跳到其它治理页后可返回仪表盘”的 back + $selfWithoutBack = \App\Support\BackUrl::selfWithoutBack(); + $billingEntryLinks = [ 'platform_orders' => \App\Support\BackUrl::withBack('/admin/platform-orders', $safeBackForLinks), 'site_subscriptions' => \App\Support\BackUrl::withBack('/admin/site-subscriptions', $safeBackForLinks), @@ -130,10 +133,10 @@ @forelse(($recentPlatformOrders ?? []) as $po) @php - $poShowUrl = '/admin/platform-orders/' . $po->id; + $poShowUrl = \App\Support\BackUrl::withBack('/admin/platform-orders/' . $po->id, $selfWithoutBack); @endphp - {{ $po->order_no }} + {{ $po->order_no }} {{ $po->orderTypeLabel() }} ¥{{ number_format((float) $po->payable_amount, 2) }} {{ $po->payment_status }} diff --git a/tests/Feature/AdminDashboardRecentPlatformOrderLinksShouldCarryBackTest.php b/tests/Feature/AdminDashboardRecentPlatformOrderLinksShouldCarryBackTest.php new file mode 100644 index 0000000..a000fd6 --- /dev/null +++ b/tests/Feature/AdminDashboardRecentPlatformOrderLinksShouldCarryBackTest.php @@ -0,0 +1,33 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_dashboard_recent_platform_order_links_should_carry_back(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin'); + $res->assertOk(); + + // 从仪表盘点进订单详情后,应能通过 back 回到 /admin + $res->assertSee('href="/admin/platform-orders/1?back=%2Fadmin"', false); + $res->assertDontSee('&back=', false); + } +}