From 8063200f0b53b9c09b73d84b2882ef62c28316e2 Mon Sep 17 00:00:00 2001 From: lkddi Date: Fri, 27 Feb 2026 01:46:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E7=95=99=E8=A8=80?= =?UTF-8?q?=E6=9D=BF=E6=96=B0=E5=BB=BA=E6=8C=89=E9=92=AE=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E7=9A=84=20AlpineJS=20x-data=20=E4=BD=9C=E7=94=A8=E5=9F=9F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原因:按钮元素被移除了原先包裹它的 body-data 组件树中。 解决:将留言板的所有内容(包括表单和按钮)都包裹在一个顶级 x-data=showWriteForm... 容器内。 --- resources/views/guestbook/index.blade.php | 399 +++++++++++----------- 1 file changed, 200 insertions(+), 199 deletions(-) diff --git a/resources/views/guestbook/index.blade.php b/resources/views/guestbook/index.blade.php index b8794bf..a7faeea 100644 --- a/resources/views/guestbook/index.blade.php +++ b/resources/views/guestbook/index.blade.php @@ -24,215 +24,216 @@ -@section('body-data', "x-data=\"{ showWriteForm: false, towho: '{{ $defaultTo }}' }\"") - @section('content') - {{-- 验证错误信息 --}} - @if (isset($errors) && $errors->any()) -
- -
- @endif - - {{-- 写信/留言表单区 (Alpine 控制显隐) --}} -
-
-
- @csrf -
-
- - -
-
- -
-
- -
- - -
- -
- -
-
-
-
- - {{-- 主体内容区 --}} -
- - {{-- 左侧:分类导航 --}} - - {{-- 移动端悬浮写留言按钮 --}} - + {{-- 主体内容区 --}} +
- {{-- 移动端底部分类栏 --}} -
- - 🌍 - 公共墙 - - - 📥 - 收件箱 - - - 📤 - 发件箱 - + {{-- 左侧:分类导航 --}} + + + {{-- 右侧:留言流列表 --}} +
+
+ + @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 + +
+ + @if ($isSecret) +
+ 🔒 私密信件 +
+ @endif + +
+
+ {{ $msg->who }} + + {{ $msg->towho ?: '大家' }} + 留言: +
+
+ {{ \Carbon\Carbon::parse($msg->post_time)->diffForHumans() }} + + @if ($isFromMe || $isToMe || (Auth::check() && Auth::user()->user_level >= 15)) +
+ @csrf + @method('DELETE') + +
+ @endif +
+
+ +
+ {!! nl2br(e($msg->text_body)) !!} +
+ + @if (!Auth::check() || $msg->who !== Auth::user()->username) +
+ +
+ @endif +
+ @empty +
+ 📭 +

暂无信件

+

这里是空空如也的荒原。

+ +
+ @endforelse + + {{-- 分页 --}} +
+ {{ $messages->links() }} +
+ +
+
+
+ + {{-- 移动端悬浮写留言按钮 --}} + + + {{-- 移动端底部分类栏 --}} +
@endsection