新增聊天室成就系统与消息保留策略
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
{{--
|
||||
文件功能:我的成就页面
|
||||
按分类展示当前用户的固定成就解锁状态与进度。
|
||||
--}}
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('title', '我的成就 - 飘落流星')
|
||||
|
||||
@section('nav-icon', '🏅')
|
||||
@section('nav-title', '我的成就')
|
||||
|
||||
@section('content')
|
||||
<main class="p-4 sm:p-6 lg:p-8">
|
||||
<div class="max-w-7xl mx-auto flex flex-col gap-6">
|
||||
<section class="bg-white border border-gray-200 rounded-lg shadow-sm p-5">
|
||||
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
|
||||
<div>
|
||||
<h2 class="text-xl font-bold text-gray-900">{{ $user->username }} 的成就档案</h2>
|
||||
<p class="text-sm text-gray-500 mt-1">已解锁 {{ $unlocked_count }} / {{ $total_count }} 项</p>
|
||||
</div>
|
||||
<div class="w-full sm:w-64 bg-gray-100 rounded-full h-3 overflow-hidden">
|
||||
<div class="h-3 bg-amber-500"
|
||||
style="width: {{ $total_count > 0 ? min(100, floor($unlocked_count / $total_count * 100)) : 0 }}%">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<nav class="bg-white border border-gray-200 rounded-lg shadow-sm p-1 flex flex-col sm:flex-row gap-1"
|
||||
aria-label="成就筛选">
|
||||
@foreach ($achievement_tabs as $tabKey => $tab)
|
||||
<a href="{{ $tab['url'] }}"
|
||||
class="flex-1 inline-flex items-center justify-center gap-2 rounded-md px-4 py-2.5 text-sm font-semibold {{ $active_tab === $tabKey ? 'bg-gray-900 text-white shadow-sm' : 'text-gray-600 hover:bg-gray-100 hover:text-gray-900' }}"
|
||||
aria-current="{{ $active_tab === $tabKey ? 'page' : 'false' }}">
|
||||
<span>{{ $tab['label'] }}</span>
|
||||
<span
|
||||
class="text-xs px-2 py-0.5 rounded-full {{ $active_tab === $tabKey ? 'bg-white/15 text-white' : 'bg-gray-100 text-gray-500' }}">
|
||||
{{ $tab['count'] }}
|
||||
</span>
|
||||
</a>
|
||||
@endforeach
|
||||
</nav>
|
||||
|
||||
@foreach ($categories as $categoryKey => $categoryLabel)
|
||||
@php
|
||||
$items = $achievements->where('category', $categoryKey)->values();
|
||||
@endphp
|
||||
|
||||
@if ($items->isEmpty())
|
||||
@continue
|
||||
@endif
|
||||
|
||||
<section class="flex flex-col gap-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-lg font-bold text-gray-800">{{ $categoryLabel }}成就</h3>
|
||||
<span class="text-xs text-gray-500">
|
||||
{{ $items->where('unlocked', true)->count() }} / {{ $items->count() }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
|
||||
@foreach ($items as $achievement)
|
||||
<article
|
||||
class="bg-white border {{ $achievement['unlocked'] ? 'border-amber-200' : 'border-gray-200' }} rounded-lg p-4 shadow-sm flex gap-3">
|
||||
<div
|
||||
class="w-11 h-11 rounded-lg flex items-center justify-center text-2xl shrink-0 {{ $achievement['unlocked'] ? 'bg-amber-100' : 'bg-gray-100 grayscale' }}">
|
||||
{{ $achievement['icon'] }}
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<h4 class="font-bold text-gray-900 truncate">{{ $achievement['name'] }}</h4>
|
||||
<span
|
||||
class="text-xs px-2 py-0.5 rounded {{ $achievement['unlocked'] ? 'bg-emerald-100 text-emerald-700' : 'bg-gray-100 text-gray-500' }}">
|
||||
{{ $achievement['unlocked'] ? '已解锁' : '进行中' }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="text-sm text-gray-500 mt-1">{{ $achievement['description'] }}</p>
|
||||
<div class="mt-3 flex items-center gap-3">
|
||||
<div class="flex-1 h-2 bg-gray-100 rounded-full overflow-hidden">
|
||||
<div class="h-2 {{ $achievement['unlocked'] ? 'bg-emerald-500' : 'bg-indigo-500' }}"
|
||||
style="width: {{ $achievement['progress_percent'] }}%"></div>
|
||||
</div>
|
||||
<span class="text-xs text-gray-500 whitespace-nowrap">
|
||||
{{ number_format($achievement['progress_value']) }} /
|
||||
{{ number_format($achievement['threshold']) }}
|
||||
</span>
|
||||
</div>
|
||||
@if ($achievement['achieved_at'])
|
||||
<p class="text-xs text-amber-700 mt-2">
|
||||
解锁于 {{ $achievement['achieved_at']->format('Y-m-d H:i') }}
|
||||
</p>
|
||||
@endif
|
||||
</div>
|
||||
</article>
|
||||
@endforeach
|
||||
</div>
|
||||
</section>
|
||||
@endforeach
|
||||
|
||||
@if ($achievements->isEmpty())
|
||||
<section class="bg-white border border-gray-200 rounded-lg shadow-sm p-8 text-center">
|
||||
<h3 class="text-base font-bold text-gray-800">暂无对应成就</h3>
|
||||
<p class="text-sm text-gray-500 mt-2">切换其他筛选查看成就列表。</p>
|
||||
</section>
|
||||
@endif
|
||||
</div>
|
||||
</main>
|
||||
@endsection
|
||||
@@ -0,0 +1,118 @@
|
||||
{{--
|
||||
文件功能:后台成就记录页面
|
||||
提供固定成就目录、解锁统计与用户成就记录只读查询。
|
||||
--}}
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', '成就记录')
|
||||
|
||||
@section('content')
|
||||
<div class="space-y-6">
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-5 shadow-sm">
|
||||
<p class="text-sm text-slate-500">固定成就</p>
|
||||
<p class="mt-2 text-2xl font-bold text-slate-900">{{ number_format($summary['total_definitions']) }}</p>
|
||||
</div>
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-5 shadow-sm">
|
||||
<p class="text-sm text-slate-500">解锁记录</p>
|
||||
<p class="mt-2 text-2xl font-bold text-amber-600">{{ number_format($summary['unlocked_records']) }}</p>
|
||||
</div>
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-5 shadow-sm">
|
||||
<p class="text-sm text-slate-500">解锁用户</p>
|
||||
<p class="mt-2 text-2xl font-bold text-emerald-600">{{ number_format($summary['unlocked_users']) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 xl:grid-cols-3 gap-6">
|
||||
<section class="xl:col-span-2 rounded-lg border border-slate-200 bg-white shadow-sm">
|
||||
<div class="border-b border-slate-200 p-4">
|
||||
<form method="GET" class="flex flex-col md:flex-row gap-3">
|
||||
<input type="text" name="username" value="{{ request('username') }}" placeholder="用户名"
|
||||
class="w-full md:w-56 rounded-md border border-slate-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none">
|
||||
<select name="achievement_key"
|
||||
class="w-full md:w-64 rounded-md border border-slate-300 px-3 py-2 text-sm focus:border-indigo-500 focus:outline-none">
|
||||
<option value="">全部成就</option>
|
||||
@foreach ($definitions as $key => $definition)
|
||||
<option value="{{ $key }}" @selected(request('achievement_key') === $key)>
|
||||
{{ $definition['icon'] }} {{ $definition['name'] }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<button type="submit"
|
||||
class="rounded-md bg-indigo-600 px-4 py-2 text-sm font-bold text-white hover:bg-indigo-700">筛选</button>
|
||||
<a href="{{ route('admin.achievements.index') }}"
|
||||
class="rounded-md border border-slate-300 px-4 py-2 text-sm font-bold text-slate-600 hover:bg-slate-50">重置</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-slate-200 text-sm">
|
||||
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500">
|
||||
<tr>
|
||||
<th class="px-4 py-3">用户</th>
|
||||
<th class="px-4 py-3">成就</th>
|
||||
<th class="px-4 py-3">进度</th>
|
||||
<th class="px-4 py-3">解锁时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100">
|
||||
@forelse ($records as $record)
|
||||
@php
|
||||
$definition = $definitions[$record->achievement_key] ?? null;
|
||||
$threshold = (int) data_get($record->metadata, 'threshold', $definition['threshold'] ?? 0);
|
||||
@endphp
|
||||
<tr>
|
||||
<td class="px-4 py-3 font-semibold text-slate-900">
|
||||
{{ $record->user?->username ?? '未知用户' }}
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<div class="font-bold text-slate-800">
|
||||
{{ $definition['icon'] ?? '🏅' }} {{ $definition['name'] ?? $record->achievement_key }}
|
||||
</div>
|
||||
<div class="text-xs text-slate-500">{{ $definition['description'] ?? '' }}</div>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-slate-600">
|
||||
{{ number_format($record->progress_value) }} / {{ number_format($threshold) }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-slate-500">
|
||||
{{ $record->achieved_at?->format('Y-m-d H:i') }}
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="4" class="px-4 py-10 text-center text-slate-500">暂无解锁记录</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-slate-200 p-4">
|
||||
{{ $records->links() }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="rounded-lg border border-slate-200 bg-white p-5 shadow-sm">
|
||||
<h2 class="text-base font-bold text-slate-900">热门成就</h2>
|
||||
<div class="mt-4 space-y-3">
|
||||
@forelse ($topAchievements as $row)
|
||||
@php $definition = $definitions[$row->achievement_key] ?? null; @endphp
|
||||
<div class="flex items-center justify-between gap-3 rounded-md bg-slate-50 px-3 py-2">
|
||||
<div class="min-w-0">
|
||||
<p class="truncate font-semibold text-slate-800">
|
||||
{{ $definition['icon'] ?? '🏅' }} {{ $definition['name'] ?? $row->achievement_key }}
|
||||
</p>
|
||||
<p class="text-xs text-slate-500">{{ $definition['description'] ?? '' }}</p>
|
||||
</div>
|
||||
<span class="shrink-0 rounded bg-amber-100 px-2 py-1 text-xs font-bold text-amber-700">
|
||||
{{ number_format($row->unlocked_count) }}
|
||||
</span>
|
||||
</div>
|
||||
@empty
|
||||
<p class="text-sm text-slate-500">暂无热门成就。</p>
|
||||
@endforelse
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -68,6 +68,10 @@
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.currency-logs.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
{!! '💴 用户流水' !!}
|
||||
</a>
|
||||
<a href="{{ route('admin.achievements.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.achievements.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
🏅 成就记录
|
||||
</a>
|
||||
<a href="{{ route('admin.rooms.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.rooms.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
{!! '🏠 房间管理' !!}
|
||||
|
||||
@@ -188,7 +188,7 @@ $welcomeMessages = [
|
||||
<div style="font-size:10px;color:#4338ca;padding:0 2px 8px;">常用操作</div>
|
||||
<div style="display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;">
|
||||
<button type="button" data-chat-feature-local-clear
|
||||
style="font-size:11px;padding:6px 8px;background:#fff;color:#475569;border:1px solid #cbd5e1;border-radius:6px;cursor:pointer;">🧹 清屏</button>
|
||||
style="font-size:11px;padding:6px 8px;background:#fff;color:#475569;border:1px solid #cbd5e1;border-radius:6px;cursor:pointer;">🧹 本地清屏</button>
|
||||
<button type="button" data-chat-daily-status-open
|
||||
style="font-size:11px;padding:6px 8px;background:#fff;color:#4f46e5;border:1px solid #a5b4fc;border-radius:6px;cursor:pointer;">
|
||||
<span id="daily-status-shortcut-icon">{{ $activeDailyStatus['icon'] ?? '🙂' }}</span>
|
||||
|
||||
@@ -103,6 +103,10 @@
|
||||
class="text-green-400 hover:text-green-300 font-bold flex items-center transition hidden sm:flex">
|
||||
今日榜
|
||||
</a>
|
||||
<a href="{{ route('achievements.index') }}"
|
||||
class="text-amber-300 hover:text-amber-100 font-bold flex items-center transition hidden sm:flex {{ request()->routeIs('achievements.*') ? 'text-amber-100 underline underline-offset-4' : '' }}">
|
||||
成就
|
||||
</a>
|
||||
<a href="{{ route('duty-hall.index') }}"
|
||||
class="text-purple-300 hover:text-purple-100 font-bold flex items-center transition hidden sm:flex {{ request()->routeIs('duty-hall.*') ? 'text-purple-100 underline underline-offset-4' : '' }}">
|
||||
勤务台
|
||||
@@ -184,6 +188,10 @@
|
||||
class="px-4 py-2.5 text-green-300 hover:bg-indigo-700 hover:text-green-200 font-medium border-l-4 {{ request()->routeIs('leaderboard.today') ? 'border-green-400 bg-indigo-700/50' : 'border-transparent' }}">
|
||||
今日榜
|
||||
</a>
|
||||
<a href="{{ route('achievements.index') }}"
|
||||
class="px-4 py-2.5 text-amber-200 hover:bg-indigo-700 hover:text-amber-100 font-medium border-l-4 {{ request()->routeIs('achievements.*') ? 'border-amber-400 bg-indigo-700/50' : 'border-transparent' }}">
|
||||
成就
|
||||
</a>
|
||||
<a href="{{ route('duty-hall.index') }}"
|
||||
class="px-4 py-2.5 text-purple-200 hover:bg-indigo-700 hover:text-white font-medium border-l-4 {{ request()->routeIs('duty-hall.*') ? 'border-purple-400 bg-indigo-700/50' : 'border-transparent' }}">
|
||||
勤务台
|
||||
|
||||
Reference in New Issue
Block a user