Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/components/user/sidebar-user-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Image from "next/image"
import Link from "next/link"
import { useRouter } from "next/navigation"
import { usePathname, useRouter, useSearchParams } from "next/navigation"
import { CalendarDays, CheckCircle2, ChevronLeft, ChevronRight, Heart, Plus, RotateCcw, Settings, Star, Trophy, Users, Wallet, X } from "lucide-react"
import { useCallback, useEffect, useMemo, useRef, useState } from "react"

Expand Down Expand Up @@ -255,8 +255,13 @@ function CalendarPendingStatusIcon({

export function SidebarUserCard({ user, createPostHref = "/write", siteName = "知识型兴趣社区", siteDescription = "把时间浪费在你真正热爱的事情上。这里更适合持续浏览、慢慢讨论、围绕兴趣沉淀长期内容。", siteLogoPath, siteIconPath }: { user: SidebarUserCardData | null; createPostHref?: string; siteName?: string; siteDescription?: string; siteLogoPath?: string | null; siteIconPath?: string | null }) {
const router = useRouter()
const pathname = usePathname()
const searchParams = useSearchParams()
const { refresh: refreshCurrentUser } = useCurrentUser()
const currentUser = user
const currentSearch = searchParams.toString()
const currentPath = `${pathname}${currentSearch ? `?${currentSearch}` : ""}`
const loginHref = buildLoginHrefWithRedirect(currentPath)
const [checkInState, setCheckInState] = useState(() => ({
points: user?.points ?? 0,
checkedInToday: Boolean(user?.checkedInToday),
Expand Down Expand Up @@ -386,7 +391,7 @@ export function SidebarUserCard({ user, createPostHref = "/write", siteName = "
<div className="space-y-3 p-4">
<p className="text-sm leading-6 text-muted-foreground">{siteDescription}</p>
<div className="grid grid-cols-2 gap-2 border-t border-border/80 pt-3">
<Link href={buildLoginHrefWithRedirect("/")} className="block">
<Link href={loginHref} className="block">
<Button className="h-9 w-full rounded-lg">登录</Button>
</Link>
<Link href="/register" className="block">
Expand Down