diff --git a/backend/app/routers/pages.py b/backend/app/routers/pages.py index c8d6080..3c3d680 100644 --- a/backend/app/routers/pages.py +++ b/backend/app/routers/pages.py @@ -326,7 +326,8 @@ async def get_page(slug: str, ctx: PageAccess = Depends(page_dep("read"))): user = ctx.user permission = ctx.permission rows = await db.execute_fetchall( - """SELECT p.*, CASE WHEN u.display_name IS NOT NULL AND u.display_name != '' THEN u.display_name ELSE u.username END AS author_name + """SELECT p.*, u.username AS author_username, + CASE WHEN u.display_name IS NOT NULL AND u.display_name != '' THEN u.display_name ELSE u.username END AS author_name FROM pages p LEFT JOIN users u ON u.id = p.created_by WHERE p.id = ?""", diff --git a/backend/app/routers/trash.py b/backend/app/routers/trash.py index c81ee26..1e7091c 100644 --- a/backend/app/routers/trash.py +++ b/backend/app/routers/trash.py @@ -25,6 +25,7 @@ async def list_trash(user=Depends(get_current_user)): base_sql = """ SELECT p.id, p.slug, p.title, p.content_md, p.parent_id, p.version, p.view_count, p.created_by, p.deleted_at, p.updated_at, + u.username AS author_username, CASE WHEN u.display_name IS NOT NULL AND u.display_name != '' THEN u.display_name ELSE u.username END AS author_name FROM pages p diff --git a/backend/app/schemas.py b/backend/app/schemas.py index e93de87..2aabf6c 100644 --- a/backend/app/schemas.py +++ b/backend/app/schemas.py @@ -70,6 +70,7 @@ class PageResponse(BaseModel): mindmap_layout: MindmapLayout | None = None created_by: int | None = None author_name: str | None = None + author_username: str | None = None created_at: str | None = None updated_at: str | None = None effective_permission: str | None = None diff --git a/frontend/src/components/Comments.jsx b/frontend/src/components/Comments.jsx index e83067b..4e5ed73 100644 --- a/frontend/src/components/Comments.jsx +++ b/frontend/src/components/Comments.jsx @@ -1,4 +1,5 @@ import { useState, useEffect } from 'react' +import { Link } from 'react-router-dom' import { useTranslation } from 'react-i18next' import DOMPurify from 'dompurify' import useAuth from '../store/useAuth' @@ -26,7 +27,16 @@ function CommentItem({ comment, currentUser, onDelete, onUpdate, pageSlug }) {
- {comment.display_name || comment.username} + {comment.username ? ( + + {comment.display_name || comment.username} + + ) : ( + {comment.display_name || '?'} + )} {new Date(comment.created_at).toLocaleString()} {comment.updated_at !== comment.created_at && ( {t('comments.edited')} diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 10bd6da..5672d9c 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -533,7 +533,8 @@ "title": "Account Info", "username": "Username", "role": "Role", - "created": "Created" + "created": "Created", + "viewPublic": "View public profile" }, "edit": { "title": "Edit Profile", diff --git a/frontend/src/locales/ja.json b/frontend/src/locales/ja.json index 8546ffb..6dcec2e 100644 --- a/frontend/src/locales/ja.json +++ b/frontend/src/locales/ja.json @@ -533,7 +533,8 @@ "title": "アカウント情報", "username": "ユーザー名", "role": "ロール", - "created": "作成日" + "created": "作成日", + "viewPublic": "公開プロフィールを見る" }, "edit": { "title": "プロフィールを編集", diff --git a/frontend/src/locales/ko.json b/frontend/src/locales/ko.json index 364e03b..ae5904f 100644 --- a/frontend/src/locales/ko.json +++ b/frontend/src/locales/ko.json @@ -533,7 +533,8 @@ "title": "계정 정보", "username": "사용자명", "role": "역할", - "created": "생성일" + "created": "생성일", + "viewPublic": "공개 프로필 보기" }, "edit": { "title": "프로필 편집", diff --git a/frontend/src/locales/zh-TW.json b/frontend/src/locales/zh-TW.json index 6c5fdfe..9551e91 100644 --- a/frontend/src/locales/zh-TW.json +++ b/frontend/src/locales/zh-TW.json @@ -533,7 +533,8 @@ "title": "帳號資訊", "username": "使用者名稱", "role": "角色", - "created": "建立時間" + "created": "建立時間", + "viewPublic": "檢視公開頁面" }, "edit": { "title": "編輯個人檔案", diff --git a/frontend/src/pages/Activity.jsx b/frontend/src/pages/Activity.jsx index 74c2658..5e70e2b 100644 --- a/frontend/src/pages/Activity.jsx +++ b/frontend/src/pages/Activity.jsx @@ -89,7 +89,16 @@ export default function Activity() { {text}
- {a.display_name || a.username || t('activity.system')} + {a.username ? ( + + {a.display_name || a.username} + + ) : ( + {t('activity.system')} + )} {' '}{text}{' '} {meta.slug && a.action !== 'deleted' ? ( diff --git a/frontend/src/pages/Admin.jsx b/frontend/src/pages/Admin.jsx index d561b25..43d7d5d 100644 --- a/frontend/src/pages/Admin.jsx +++ b/frontend/src/pages/Admin.jsx @@ -462,7 +462,14 @@ function UsersSection() { {users.map((u) => ( - {u.username} + + + {u.username} + +