Feat: 后台用户列表增加金币/魅力列,表头支持点击排序(等级/经验/金币/魅力)

This commit is contained in:
2026-02-27 15:31:29 +08:00
parent 6d73e50bff
commit b366c9888f
2 changed files with 50 additions and 6 deletions
+42 -2
View File
@@ -22,6 +22,22 @@
<!-- 用户表格 -->
<div class="overflow-x-auto">
@php
/**
* 生成排序链接:点击同一列切换方向,点击新列默认倒序
*/
$sortLink = function (string $col) use ($sortBy, $sortDir, $request): string {
$newDir = $sortBy === $col && $sortDir === 'desc' ? 'asc' : 'desc';
$qs = http_build_query(
array_merge($request->except(['sort_by', 'sort_dir', 'page']), [
'sort_by' => $col,
'sort_dir' => $newDir,
]),
);
return url('/admin/users?' . $qs);
};
$arrow = fn(string $col): string => $sortBy === $col ? ($sortDir === 'desc' ? ' ↓' : ' ↑') : '';
@endphp
<table class="w-full text-left border-collapse">
<thead>
<tr
@@ -29,8 +45,26 @@
<th class="p-4">ID</th>
<th class="p-4">注册名</th>
<th class="p-4">性别</th>
<th class="p-4">等级</th>
<th class="p-4">经验</th>
<th class="p-4">
<a href="{{ $sortLink('user_level') }}" class="hover:text-indigo-600 flex items-center gap-1">
等级<span class="text-indigo-500">{{ $arrow('user_level') }}</span>
</a>
</th>
<th class="p-4">
<a href="{{ $sortLink('exp_num') }}" class="hover:text-indigo-600 flex items-center gap-1">
经验<span class="text-indigo-500">{{ $arrow('exp_num') }}</span>
</a>
</th>
<th class="p-4">
<a href="{{ $sortLink('jjb') }}" class="hover:text-yellow-600 flex items-center gap-1">
金币<span class="text-yellow-500">{{ $arrow('jjb') }}</span>
</a>
</th>
<th class="p-4">
<a href="{{ $sortLink('meili') }}" class="hover:text-pink-600 flex items-center gap-1">
魅力<span class="text-pink-500">{{ $arrow('meili') }}</span>
</a>
</th>
<th class="p-4">注册时间</th>
<th class="p-4 text-right">管理操作</th>
</tr>
@@ -60,6 +94,12 @@
<td class="p-4 text-sm font-mono text-gray-600">
{{ number_format($user->exp_num ?? 0) }}
</td>
<td class="p-4 text-sm font-mono text-yellow-700">
{{ number_format($user->jjb ?? 0) }}
</td>
<td class="p-4 text-sm font-mono text-pink-600">
{{ number_format($user->meili ?? 0) }}
</td>
<td class="p-4 text-sm font-mono text-gray-500">{{ $user->created_at->format('Y/m/d H:i') }}
</td>
<td class="p-4 text-right space-x-2 relative" x-data>