Files
chatroom/resources/views/guestbook/index.blade.php
T
lkddi ea06328885 功能:字体颜色持久化、等级体系升级至99级、钓鱼小游戏、补充系统参数
- 字体颜色:s_color 改为 varchar,发消息时保存颜色,进入聊天室自动恢复
- 等级体系:maxlevel 15→99,superlevel 16→100,99级经验阶梯(幂次曲线)
- 管理权限等级按比例调整:禁言50、踢人60、设公告60、封号80、封IP90
- 钓鱼小游戏:FishingController(抛竿扣金币+收竿随机结果+广播)
- 补充6个缺失的 sysparam 参数 + 4个钓鱼参数
- 用户列表点击用户名后自动聚焦输入框
- Pint 格式化
2026-02-26 21:10:34 +08:00

223 lines
12 KiB
PHP

{{--
文件功能:星光留言板页面(含公共留言、收件箱、发件箱三个分类)
支持公开留言和悄悄话私信功能
@extends layouts.app
--}}
@extends('layouts.app')
@section('title', '星光留言板 - 飘落流星')
@section('nav-icon', '✉️')
@section('nav-title', '星光留言板')
@section('nav-left')
<a href="{{ route('rooms.index') }}" class="text-indigo-200 hover:text-white transition flex items-center group">
<svg class="w-5 h-5 mr-1 transform group-hover:-translate-x-1 transition" fill="none" stroke="currentColor"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
</svg>
返回大厅
</a>
@endsection
@section('nav-right')
<button id="write-toggle-btn"
@click="showWriteForm = !showWriteForm; if(showWriteForm) setTimeout(() => $refs.textBody.focus(), 100)"
class="bg-indigo-500 hover:bg-indigo-400 text-white px-4 py-2 rounded-lg font-bold shadow-sm transition flex items-center">
<svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z">
</path>
</svg>
<span x-text="showWriteForm ? '取消留言' : '发布留言 / 写信'"></span>
</button>
@endsection
@section('body-class', 'flex flex-col h-screen overflow-hidden')
@section('body-data', "x-data=\"{ showWriteForm: false, towho: '{{ $defaultTo }}' }\"")
@section('content')
{{-- 验证错误信息 --}}
@if (isset($errors) && $errors->any())
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-4 mx-4 mt-4 shadow-sm">
<ul class="list-disc pl-5">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
{{-- 写信/留言表单区 (Alpine 控制显隐) --}}
<div x-show="showWriteForm" x-collapse class="bg-white border-b border-gray-200 shadow-inner">
<div class="max-w-4xl mx-auto p-6">
<form action="{{ route('guestbook.store') }}" method="POST" class="space-y-4">
@csrf
<div class="flex items-center space-x-4">
<div class="flex-1">
<label class="block text-sm font-medium text-gray-700 mb-1">接收人 (留空或填"大家"表示公共留言)</label>
<input type="text" name="towho" x-model="towho" placeholder="系统自动处理"
class="w-full border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
</div>
<div class="flex items-center h-full pt-6">
<label
class="flex items-center space-x-2 text-sm text-gray-700 cursor-pointer bg-pink-50 px-3 py-2 rounded-md hover:bg-pink-100 transition border border-pink-100">
<input type="checkbox" name="secret" value="1"
class="rounded text-pink-500 focus:ring-pink-500 w-4 h-4">
<span class="font-bold text-pink-700">🔒 悄悄话 (仅双方可见)</span>
</label>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">正文内容 <span
class="text-red-500">*</span></label>
<textarea name="text_body" x-ref="textBody" rows="3" required
class="w-full border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
placeholder="相逢何必曾相识,留下您的足迹吧..."></textarea>
</div>
<div class="flex justify-end">
<button type="submit"
class="bg-indigo-600 hover:bg-indigo-700 text-white py-2 px-6 rounded-md shadow flex items-center font-bold">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"></path>
</svg>
发送
</button>
</div>
</form>
</div>
</div>
{{-- 主体内容区 --}}
<div class="flex-1 flex overflow-hidden">
{{-- 左侧:分类导航 --}}
<div class="w-64 bg-white border-r border-gray-200 shrink-0 hidden md:block">
<div class="p-6">
<nav class="space-y-2">
<a href="{{ route('guestbook.index', ['tab' => 'public']) }}"
class="flex items-center px-4 py-3 rounded-lg font-medium transition-colors {{ $tab === 'public' ? 'bg-indigo-50 text-indigo-700' : 'text-gray-600 hover:bg-gray-50' }}">
<span class="mr-3 text-lg">🌍</span> 公共留言墙
</a>
<a href="{{ route('guestbook.index', ['tab' => 'inbox']) }}"
class="flex items-center px-4 py-3 rounded-lg font-medium transition-colors {{ $tab === 'inbox' ? 'bg-indigo-50 text-indigo-700' : 'text-gray-600 hover:bg-gray-50' }}">
<span class="mr-3 text-lg">📥</span> 我收件的
</a>
<a href="{{ route('guestbook.index', ['tab' => 'outbox']) }}"
class="flex items-center px-4 py-3 rounded-lg font-medium transition-colors {{ $tab === 'outbox' ? 'bg-indigo-50 text-indigo-700' : 'text-gray-600 hover:bg-gray-50' }}">
<span class="mr-3 text-lg">📤</span> 我发出的
</a>
</nav>
</div>
</div>
{{-- 右侧:留言流列表 --}}
<main class="flex-1 overflow-y-auto p-4 sm:p-6 lg:p-8 bg-gray-50">
<div class="max-w-4xl mx-auto space-y-4">
@forelse($messages as $msg)
@php
$isSecret = $msg->secret == 1;
$isToMe = Auth::check() && $msg->towho === Auth::user()->username;
$isFromMe = Auth::check() && $msg->who === Auth::user()->username;
@endphp
<div
class="bg-white rounded-xl shadow-sm border {{ $isSecret ? 'border-pink-200' : 'border-gray-200' }} p-5 relative group overflow-hidden">
@if ($isSecret)
<div
class="absolute top-0 right-0 bg-pink-100 text-pink-700 text-[10px] font-bold px-2 py-1 rounded-bl-lg">
🔒 私密信件
</div>
@endif
<div class="flex justify-between items-start mb-2">
<div class="flex items-center text-sm">
<span class="font-bold text-indigo-700">{{ $msg->who }}</span>
<span class="text-gray-400 mx-2"></span>
<span
class="font-bold {{ $msg->towho ? 'text-indigo-700' : 'text-gray-500' }}">{{ $msg->towho ?: '大家' }}</span>
<span class="text-gray-400 mx-2">留言:</span>
</div>
<div class="text-xs text-gray-400 flex items-center space-x-3">
<span>{{ \Carbon\Carbon::parse($msg->post_time)->diffForHumans() }}</span>
@if ($isFromMe || $isToMe || (Auth::check() && Auth::user()->user_level >= 15))
<form action="{{ route('guestbook.destroy', $msg->id) }}" method="POST"
onsubmit="return confirm('确定要抹除这条留言吗?');" class="inline">
@csrf
@method('DELETE')
<button type="submit"
class="text-red-400 hover:text-red-600 transition opacity-0 group-hover:opacity-100 bg-red-50 px-2 py-1 rounded">
删除
</button>
</form>
@endif
</div>
</div>
<div
class="text-gray-800 leading-relaxed text-sm whitespace-pre-wrap {{ $isSecret ? 'bg-pink-50 p-3 rounded-lg border border-pink-100' : 'bg-gray-50 p-3 rounded-lg border border-gray-100' }}">
{!! nl2br(e($msg->text_body)) !!}
</div>
@if (!Auth::check() || $msg->who !== Auth::user()->username)
<div class="mt-3 flex justify-end">
<button
@click="showWriteForm = true; towho = '{{ $msg->who }}'; setTimeout(() => $refs.textBody.focus(), 100); window.scrollTo({top:0, behavior:'smooth'})"
class="text-xs text-indigo-500 hover:text-indigo-700 font-medium flex items-center transition">
<svg class="w-3 h-3 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"></path>
</svg>
回复TA
</button>
</div>
@endif
</div>
@empty
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-12 text-center">
<span class="text-4xl">📭</span>
<h3 class="mt-4 text-lg font-medium text-gray-900">暂无信件</h3>
<p class="mt-2 text-sm text-gray-500">这里是空空如也的荒原。</p>
<button @click="showWriteForm = true; towho = ''; setTimeout(() => $refs.textBody.focus(), 100)"
class="mt-4 text-indigo-600 font-bold hover:underline">
来抢沙发留言吧!
</button>
</div>
@endforelse
{{-- 分页 --}}
<div class="mt-6">
{{ $messages->links() }}
</div>
</div>
</main>
</div>
{{-- 移动端底部分类栏 --}}
<div class="md:hidden bg-white border-t border-gray-200 flex justify-around p-2 shrink-0 relative z-20">
<a href="{{ route('guestbook.index', ['tab' => 'public']) }}"
class="flex flex-col items-center {{ $tab === 'public' ? 'text-indigo-600' : 'text-gray-500' }}">
<span class="text-xl">🌍</span>
<span class="text-xs mt-1">公共墙</span>
</a>
<a href="{{ route('guestbook.index', ['tab' => 'inbox']) }}"
class="flex flex-col items-center {{ $tab === 'inbox' ? 'text-indigo-600' : 'text-gray-500' }}">
<span class="text-xl">📥</span>
<span class="text-xs mt-1">收件箱</span>
</a>
<a href="{{ route('guestbook.index', ['tab' => 'outbox']) }}"
class="flex flex-col items-center {{ $tab === 'outbox' ? 'text-indigo-600' : 'text-gray-500' }}">
<span class="text-xl">📤</span>
<span class="text-xs mt-1">发件箱</span>
</a>
</div>
@endsection