feat: Discourse-style reply-to indicator (↩ @username)
- replies table: add reply_to_username column - POST /api/replies: accept reply_to_username param - GET /api/replies: LEFT JOIN users to return reply_to_username - ReplyList: submit replyTo as reply_to_username on create - UI: each reply shows '↩ 正在回复 @username' indicator (clickable, scrolls to target reply) - data-username attribute on .reply-item for scroll targeting
This commit is contained in:
1 parent
7bf9e37036
commit
4d0d5edec3
5 files changed
+56
-20
No files matched your search
+12
-11
@@ -35,6 +35,7 @@ CREATE TABLE IF NOT EXISTS replies (
|
||||
post_id UUID NOT NULL REFERENCES posts(id) ON DELETE CASCADE,
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
content TEXT NOT NULL,
|
||||
reply_to_id UUID REFERENCES replies(id) ON DELETE SET NULL,
|
||||
created_at TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
@@ -227,14 +228,14 @@ CREATE TABLE IF NOT EXISTS recovery_codes (
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_recovery_codes_user ON recovery_codes(user_id);
|
||||
|
||||
|
||||
-- ============================================================
|
||||
-- 超级管理员自动设立(数据库兼容,幂等)
|
||||
-- 若没有任何 admin,将最早注册的用户提升为超级管理员。
|
||||
-- 不依赖自增 uid(users 主键是 UUID),任何现有数据库都可安全执行。
|
||||
-- ============================================================
|
||||
UPDATE users SET role = 'admin'
|
||||
WHERE role <> 'admin'
|
||||
AND NOT EXISTS (SELECT 1 FROM users WHERE role = 'admin')
|
||||
AND id = (SELECT id FROM users ORDER BY created_at ASC, id ASC LIMIT 1);
|
||||
|
||||
|
||||
-- ============================================================
|
||||
-- 超级管理员自动设立(数据库兼容,幂等)
|
||||
-- 若没有任何 admin,将最早注册的用户提升为超级管理员。
|
||||
-- 不依赖自增 uid(users 主键是 UUID),任何现有数据库都可安全执行。
|
||||
-- ============================================================
|
||||
UPDATE users SET role = 'admin'
|
||||
WHERE role <> 'admin'
|
||||
AND NOT EXISTS (SELECT 1 FROM users WHERE role = 'admin')
|
||||
AND id = (SELECT id FROM users ORDER BY created_at ASC, id ASC LIMIT 1);
|
||||
Reference in new issue
Block a user