diff --git a/src/app/(main)/character/[id]/ChatButton.tsx b/src/app/(main)/character/[id]/ChatButton.tsx index 0383863..5656c80 100644 --- a/src/app/(main)/character/[id]/ChatButton.tsx +++ b/src/app/(main)/character/[id]/ChatButton.tsx @@ -1,10 +1,14 @@ 'use client'; import { useRouter } from 'next/navigation'; import { Button } from '@/components/ui/button'; +import type React from 'react'; import { useAsyncFn } from '@/hooks/tools'; import { useStreamChatStore } from '@/app/(main)/chat/[id]/stream-chat'; -export default function ChatButton({ id }: { id: string }) { +export default function ChatButton({ + id, + ...props +}: { id: string } & React.ComponentProps<'button'>) { const router = useRouter(); const createChannel = useStreamChatStore((s) => s.createChannel); @@ -15,7 +19,7 @@ export default function ChatButton({ id }: { id: string }) { }); return ( - ); diff --git a/src/app/(main)/character/[id]/page.tsx b/src/app/(main)/character/[id]/page.tsx index 8a4afb4..1b3dc2d 100644 --- a/src/app/(main)/character/[id]/page.tsx +++ b/src/app/(main)/character/[id]/page.tsx @@ -2,23 +2,33 @@ import ChatButton from './ChatButton'; import { fetchCharacter } from './service'; import { Chip } from '@/components/ui/chip'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; +import { IconButton } from '@/components/ui/button'; +import Link from 'next/link'; export default async function Page({ params }: { params: Promise<{ id: string }> }) { const { id } = await params; const character = await fetchCharacter(id); return ( -
-
+
+ {/* header */} +
+ + + + +
+ {/* 内容区 */} +
-
+
{character?.name?.slice(0, 2)} -
+
{character?.name}
-
+
{character?.tags?.map((tag: any) => ( {tag.name} @@ -27,15 +37,39 @@ export default async function Page({ params }: { params: Promise<{ id: string }>
-
+
-
+
+
+
+ + 9.9k +
+
Liked
+
+
+
+ + 123456 +
+
Hot
+
+
+
Introduction
{character?.description}
+
+ +
); } diff --git a/src/app/(main)/chat/[id]/Input.tsx b/src/app/(main)/chat/[id]/Input.tsx index 2e7833e..bcaa178 100644 --- a/src/app/(main)/chat/[id]/Input.tsx +++ b/src/app/(main)/chat/[id]/Input.tsx @@ -97,7 +97,7 @@ export default function Input() { variant="ghost" size="small" iconfont="icon-voice_msg" - className="flex-shrink-0" + className="flex-shrink-0 hover:bg-surface-element-hover" /> null} - className={cn('bg-surface-element-hover flex-shrink-0')} + className={cn('hover:bg-surface-element-hover flex-shrink-0')} iconfont="icon-prompt" />
diff --git a/src/layout/Topbar.tsx b/src/layout/Topbar.tsx index e5c45c8..50a6192 100644 --- a/src/layout/Topbar.tsx +++ b/src/layout/Topbar.tsx @@ -11,7 +11,19 @@ import { useMedia } from '@/hooks/tools'; import Notice from './components/Notice'; import { items } from './BottomBar'; -const mobileHidenMenus = ['/profile/edit', '/profile/account']; +const mobileHidenMenus = ['/profile/edit', '/profile/account', '/character/:id']; + +// 将路由模式转换为正则表达式进行匹配 +function matchRoutePattern(pathname: string, patterns: string[]): boolean { + return patterns.some((pattern) => { + // 将路由模式中的 :param 转换为正则表达式 + const regexPattern = pattern + .replace(/:[^/]+/g, '[^/]+') // 将 :id, :userId 等替换为 [^/]+ + .replace(/\//g, '\\/'); // 转义斜杠 + const regex = new RegExp(`^${regexPattern}$`); + return regex.test(pathname); + }); +} function Topbar() { const [isBlur, setIsBlur] = useState(false); @@ -22,7 +34,7 @@ function Topbar() { const response = useMedia(); const searchParamsString = searchParams.toString(); const redirectURL = `${pathname}${searchParamsString ? `?${searchParamsString}` : ''}`; - // const loginHref = `/login?redirect=${encodeURIComponent(redirectURL)}`; + const loginHref = `/login?redirect=${encodeURIComponent(redirectURL)}`; useEffect(() => { function handleScroll(event: Event) { @@ -73,7 +85,7 @@ function Topbar() { const rightDomRender = () => { if (!user) return ( - + ); @@ -96,7 +108,7 @@ function Topbar() { ); }; - if (response && !response.sm && mobileHidenMenus.some((item) => item === pathname)) return null; + if (response && !response.sm && matchRoutePattern(pathname, mobileHidenMenus)) return null; return (