This commit is contained in:
eric
2026-03-15 04:25:45 -05:00
parent df12c7af4a
commit bbaa38b3b3
32 changed files with 4312 additions and 152 deletions

View File

@@ -0,0 +1,102 @@
"use client";
import Link from "next/link";
import { useEffect, useMemo, useState } from "react";
import { CommunityTimeline } from "../components/CommunityTimeline";
import { CommunityPageHero } from "../components/CommunityPageHero";
import styles from "../components/memos.module.css";
function getStorage(key: string): string | null {
if (typeof window === "undefined") {
return null;
}
return localStorage.getItem(key);
}
export default function ExplorePage() {
const [userId, setUserId] = useState<string | null>(null);
const [isVip, setIsVip] = useState(false);
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
const [query, setQuery] = useState("");
useEffect(() => {
const uid = getStorage("userId") || getStorage("memosAccount");
const type = getStorage("paidType");
setUserId(uid || null);
setIsVip(type === "vip");
}, []);
useEffect(() => {
if (typeof window === "undefined") {
return;
}
const tag = new URLSearchParams(window.location.search).get("tag");
if (tag) {
setQuery(`#${tag}`);
}
}, []);
const normalizedQuery = useMemo(() => query.trim(), [query]);
return (
<div className={styles.pageStack}>
<CommunityPageHero
eyebrow="Explore Topics"
title="发现高频问题与热门标签"
description="按关键词或标签搜索整个社群,把分散动态重新整理成可浏览的话题页。"
chips={["标签聚合", "关键词检索", "按时间流浏览"]}
actions={[{ href: "/community", label: "返回首页", secondary: true }]}
/>
<section className={styles.filterPanel}>
<div className={styles.searchField}>
<label htmlFor="community-search" className={styles.searchLabel}>
</label>
<input
id="community-search"
className={styles.searchInput}
value={query}
onChange={(event) => setQuery(event.target.value)}
placeholder="例如AI 工具、远程工作、自动化"
/>
</div>
<div className={styles.filterHint}>
`#标签`
</div>
</section>
{showLoginPrompt ? (
<section className={styles.vipBanner}>
<p></p>
<Link href="/" className={styles.ctaLink}>
</Link>
</section>
) : null}
{isVip && userId ? (
<CommunityTimeline
userId={userId}
onVipRequired={() => setShowLoginPrompt(true)}
state="NORMAL"
query={normalizedQuery}
emptyText="没有匹配当前关键词的动态,换个标签试试。"
/>
) : (
<section className={styles.lockedPanel}>
<div className={styles.lockedPanelCopy}>
<span className={styles.lockedPanelEyebrow}>Members Only</span>
<h2 className={styles.lockedPanelTitle}></h2>
<p className={styles.lockedPanelDesc}></p>
</div>
<div className={styles.lockedPanelActions}>
<Link href="/" className={styles.heroPrimaryAction}>
</Link>
</div>
</section>
)}
</div>
);
}