diff --git a/app/api/users/[id]/route.js b/app/api/users/[id]/route.js index 826c157..848675d 100644 --- a/app/api/users/[id]/route.js +++ b/app/api/users/[id]/route.js @@ -1,6 +1,6 @@ // PUT /api/users/[id] (更新资料), PUT /api/users/[id]/role (改角色) import pool from '@/lib/db'; -import { getUser, requireAdmin } from '@/lib/auth'; +import { getUser, requireAdmin, isFirstUser } from '@/lib/auth'; export async function PUT(req, { params }) { const { id } = params; @@ -22,6 +22,10 @@ export async function PUT(req, { params }) { if (id === user.id) { return Response.json({ error: '不能修改自己的角色' }, { status: 400 }); } + // 超级管理员(第一个用户)不能被降级 + if (role !== 'admin' && await isFirstUser(id)) { + return Response.json({ error: '不能降级超级管理员' }, { status: 403 }); + } try { await pool.query('UPDATE users SET role = $1 WHERE id = $2', [role, id]); return Response.json({ success: true }); diff --git a/app/globals.css b/app/globals.css index 5b3109f..b2779e7 100644 --- a/app/globals.css +++ b/app/globals.css @@ -1179,6 +1179,17 @@ svg { width: 20px; height: 20px; } + /* 手机版帖子操作按钮紧凑排列,避免删除按钮越界 */ + .post-actions { + gap: 8px; + flex-wrap: wrap; + } + .post-actions button { + padding: 4px 4px; + } + #feed .post-content { + max-height: 4.25em; /* 手机屏约 2.5 行 */ + } } /* ============================================================ @@ -1907,15 +1918,24 @@ a.btn-secondary { ============================================================ */ #feed .post-content { - display: -webkit-box; - -webkit-line-clamp: 3; - -webkit-box-orient: vertical; + position: relative; + max-height: 5.1em; /* 约 3 行(line-height 1.7) */ overflow: hidden; - text-overflow: ellipsis; - max-height: none; line-height: 1.7; } +/* 长帖:底部渐变遮罩(提示还有更多内容) */ +#feed .post-content.has-fade::after { + content: ''; + position: absolute; + bottom: 0; + left: 0; + right: 0; + height: 2.2em; + background: linear-gradient(180deg, transparent 0%, var(--glass-bg) 100%); + pointer-events: none; +} + /* ===== 全屏加载页 ===== */ .loading-screen { position: fixed; @@ -2064,3 +2084,48 @@ a.btn-secondary { #adminContent td:nth-child(2) { white-space: normal !important; } + +/* ===== Toast 通知(右上角,替代 alert) ===== */ +.toast-container { + position: fixed; + top: 20px; + right: 20px; + z-index: 100000; + display: flex; + flex-direction: column; + gap: 10px; + pointer-events: none; +} + +.toast { + pointer-events: auto; + min-width: 200px; + max-width: 340px; + padding: 12px 18px; + border-radius: 10px; + font-size: 14px; + font-weight: 500; + color: #fff; + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2); + backdrop-filter: blur(12px); + -webkit-backdrop-filter: blur(12px); + cursor: pointer; + animation: toastIn 0.25s cubic-bezier(0.22, 1, 0.36, 1); +} + +.toast-success { + background: rgba(34, 197, 94, 0.92); +} + +.toast-error { + background: rgba(239, 68, 68, 0.92); +} + +.toast-info { + background: rgba(91, 155, 213, 0.92); +} + +@keyframes toastIn { + from { opacity: 0; transform: translateX(24px); } + to { opacity: 1; transform: translateX(0); } +} diff --git a/app/layout.js b/app/layout.js index ce8536f..43555e6 100644 --- a/app/layout.js +++ b/app/layout.js @@ -1,6 +1,7 @@ // 全局布局 import './globals.css'; import CustomCssLoader from '@/components/CustomCssLoader'; +import { ToastProvider } from '@/components/Toast'; export const metadata = { // 初始标题由客户端 AppProvider 接管(加载时轮换 Loading.,完成后显示论坛名) @@ -28,8 +29,10 @@ export default function RootLayout({ children }) { />
-