feat(admin): 仪表盘最近平台订单链接携带 back 回跳

This commit is contained in:
萝卜
2026-03-15 19:16:51 +08:00
parent 52a889712a
commit 7f59bb9985
2 changed files with 38 additions and 2 deletions

View File

@@ -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 @@
<tbody>
@forelse(($recentPlatformOrders ?? []) as $po)
@php
$poShowUrl = '/admin/platform-orders/' . $po->id;
$poShowUrl = \App\Support\BackUrl::withBack('/admin/platform-orders/' . $po->id, $selfWithoutBack);
@endphp
<tr>
<td><a class="link" href="{{ $poShowUrl }}">{{ $po->order_no }}</a></td>
<td><a class="link" href="{!! $poShowUrl !!}">{{ $po->order_no }}</a></td>
<td>{{ $po->orderTypeLabel() }}</td>
<td>¥{{ number_format((float) $po->payable_amount, 2) }}</td>
<td>{{ $po->payment_status }}</td>

View File

@@ -0,0 +1,33 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminDashboardRecentPlatformOrderLinksShouldCarryBackTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->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('&amp;back=', false);
}
}