Files
gitlab-instance-0a899031_no…/app/community/components/MemoExplorer.tsx
2026-03-15 04:25:45 -05:00

93 lines
3.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import Link from "next/link";
import type { MouseEvent } from "react";
import styles from "./memos.module.css";
type MemoExplorerProps = {
userId: string | null;
isVip: boolean;
pathname: string;
onVipRequired?: () => void;
};
const ROUTES = {
HOME: "/community",
EXPLORE: "/community/explore",
ARCHIVED: "/community/archived",
ATTACHMENTS: "/community/attachments",
} as const;
export function MemoExplorer({ userId, isVip, pathname, onVipRequired }: MemoExplorerProps) {
const navItems = [
{ href: ROUTES.HOME, label: "星球首页", icon: "主" },
{ href: ROUTES.EXPLORE, label: "发现话题", icon: "搜" },
{ href: ROUTES.ARCHIVED, label: "归档内容", icon: "档" },
{ href: ROUTES.ATTACHMENTS, label: "附件资料", icon: "图" },
];
const handleNavClick = (event: MouseEvent, href: string) => {
if (!isVip && href !== ROUTES.HOME) {
event.preventDefault();
onVipRequired?.();
}
};
return (
<nav className={styles.explorer}>
<div className={styles.explorerBrand}>
<Link href="/" className={styles.brandBackLink}>
</Link>
<h2 className={styles.explorerBrandTitle}></h2>
<p className={styles.explorerBrandDesc}></p>
</div>
<div className={styles.explorerSection}>
<h3 className={styles.explorerTitle}></h3>
<ul className={styles.explorerList}>
{navItems.map((item) => {
const isActive =
pathname === item.href || (item.href !== ROUTES.HOME && pathname.startsWith(item.href));
return (
<li key={item.href}>
<Link
href={item.href}
className={`${styles.explorerLink} ${isActive ? styles.explorerLinkActive : ""}`}
onClick={(event) => handleNavClick(event, item.href)}
>
<span className={styles.explorerIcon}>{item.icon}</span>
<span>{item.label}</span>
</Link>
</li>
);
})}
</ul>
</div>
<div className={styles.explorerSection}>
<h3 className={styles.explorerTitle}></h3>
<div className={styles.explorerRules}>
<span></span>
<span>便</span>
<span></span>
</div>
</div>
{userId ? (
<div className={styles.explorerUser}>
<span className={styles.userLabel}></span>
<span className={styles.userId}>{userId}</span>
<span className={styles.userState}>{isVip ? "VIP 已解锁完整社群" : "当前仅可预览社群结构"}</span>
</div>
) : (
<div className={styles.explorerUser}>
<span className={styles.userLabel}></span>
<span className={styles.userId}></span>
<span className={styles.userState}></span>
</div>
)}
</nav>
);
}