From 13810236d401f9d8ad7fcdea62c2b37010312610 Mon Sep 17 00:00:00 2001 From: javayhu Date: Sat, 8 Mar 2025 18:31:35 +0800 Subject: [PATCH] feat: add logout translations and update mobile/desktop navbar components - Add "logout" translation key to English and Chinese locale files - Update `UserButton` component to use translated logout text - Modify mobile and desktop navbar to conditionally render user button based on session - Adjust styling for blog category list mobile and navbar components - Improve internationalization and user authentication UI --- messages/en.json | 3 ++- messages/zh.json | 3 ++- src/components/blog/blog-category-list-mobile.tsx | 8 ++------ src/components/layout/navbar-mobile.tsx | 9 +++++++-- src/components/layout/navbar.tsx | 7 +++---- src/components/layout/user-button.tsx | 9 +++++---- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/messages/en.json b/messages/en.json index 86de1f6..c485c97 100644 --- a/messages/en.json +++ b/messages/en.json @@ -1,7 +1,8 @@ { "Common": { "login": "Log in", - "signUp": "Sign up" + "logout": "Log out", + "signUp": "Sign up" }, "HomePage": { "title": "next-intl example" diff --git a/messages/zh.json b/messages/zh.json index 362bb15..6de5f6b 100644 --- a/messages/zh.json +++ b/messages/zh.json @@ -1,6 +1,7 @@ { "Common": { "login": "登录", + "logout": "退出", "signUp": "注册" }, "HomePage": { @@ -105,7 +106,7 @@ } }, "pages": { - "title": "页面", + "title": "演示页面", "items": { "about": { "title": "关于我们", diff --git a/src/components/blog/blog-category-list-mobile.tsx b/src/components/blog/blog-category-list-mobile.tsx index 5da9aa8..5c97ee3 100644 --- a/src/components/blog/blog-category-list-mobile.tsx +++ b/src/components/blog/blog-category-list-mobile.tsx @@ -37,7 +37,7 @@ export function BlogCategoryListMobile({ setOpen(true)} - className="flex items-center w-full p-3 border-y text-foreground/90" + className="flex items-center w-full p-4 border-y text-foreground/90" >
@@ -53,11 +53,7 @@ export function BlogCategoryListMobile({ {t("categories")} -
-
-
- -
    +
      ) { const [open, setOpen] = React.useState(false); const pathname = usePathname(); + const { data: session, error } = authClient.useSession(); + const user = session?.user; React.useEffect(() => { const handleRouteChangeStart = () => { @@ -71,7 +74,9 @@ export function NavbarMobile({ {/* navbar right shows menu icon */}
      - + {/* show user button if user is logged in */} + {user ? : null} +
    @@ -154,7 +156,6 @@ export function UserButton() { {avatarLinks.map((item) => ( { if (item.href) { @@ -180,7 +181,7 @@ export function UserButton() { >
    -

    Log out

    +

    {commonTranslations("logout")}