修复:排行榜/留言板缺失布局、退出登录跳转、WebSocket 配置与部署文档

- 修复 LeaderboardController 查询不存在的 sign 字段导致 500 错误
- 修复 leaderboard/index 和 guestbook/index 引用不存在的 layouts.app 布局
- 将排行榜和留言板改为独立 HTML 页面结构(含 Tailwind CDN)
- 修复退出登录返回 JSON 而非重定向的问题,现在会正确跳转回登录页
- 将 REDIS_CLIENT 从 phpredis 改为 predis(兼容无扩展环境)
- 新增 RoomSeeder 自动创建默认公共大厅房间
- 新增 Nginx 生产环境配置示例(含 WebSocket 反向代理)
- 重写 README.md 为完整的中文部署指南
- 修复 rooms/index 和 chat/frame 中 Alpine.js 语法错误
- 将 chat.js 加入 Vite 构建配置
- 新增验证码配置文件
This commit is contained in:
2026-02-26 14:57:24 +08:00
parent 50fc804402
commit d884853968
19 changed files with 1083 additions and 458 deletions
+19 -10
View File
@@ -1,8 +1,15 @@
@extends('layouts.app')
<!DOCTYPE html>
<html lang="zh-CN">
@section('title', '星光留言板')
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>星光留言板 - 飘落流星</title>
<script src="https://cdn.tailwindcss.com"></script>
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
</head>
@section('content')
<body class="bg-gray-50 flex h-screen overflow-hidden text-sm">
<div class="h-screen w-full flex flex-col bg-gray-50 overflow-hidden font-sans" x-data="{ showWriteForm: false, towho: '{{ $defaultTo }}' }">
<!-- 顶部导航条 -->
@@ -53,7 +60,7 @@
<p>{{ session('error') }}</p>
</div>
@endif
@if ($errors->any())
@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)
@@ -137,8 +144,8 @@
@php
// 判断是否属于自己发或收的悄悄话,用于高亮
$isSecret = $msg->secret == 1;
$isToMe = $msg->towho === Auth::user()->username;
$isFromMe = $msg->who === Auth::user()->username;
$isToMe = Auth::check() && $msg->towho === Auth::user()->username;
$isFromMe = Auth::check() && $msg->who === Auth::user()->username;
@endphp
<div
@@ -164,7 +171,7 @@
<span>{{ \Carbon\Carbon::parse($msg->post_time)->diffForHumans() }}</span>
<!-- 删除按钮 (只有发件人、收件人、超管可见) -->
@if ($isFromMe || $isToMe || Auth::user()->user_level >= 15)
@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
@@ -184,7 +191,7 @@
</div>
<!-- 快捷回复按钮 -->
@if ($msg->who !== Auth::user()->username)
@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'})"
@@ -223,7 +230,7 @@
</div>
<!-- 移动端底部分类栏 -->
<div class="md:hidden bg-white border-t border-gray-200 flex justify-around p-2 shrink-0">
<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>
@@ -241,4 +248,6 @@
</a>
</div>
@endsection
</body>
</html>