feat: init blog repo

This commit is contained in:
YGC
2026-06-29 19:30:20 +08:00
commit 97d29e1135
188 changed files with 26664 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { connection } from "next/server";
import { getPublicConfig } from "@/api/config";
import AboutPageClient from "@/components/about/AboutPageClient";
import { aboutProfile } from "@/mock/about";
export async function generateMetadata(): Promise<Metadata> {
let title = "春风不解别离意,今日方知我是春。";
try {
const response = await getPublicConfig();
const configs = response.data?.data;
if (Array.isArray(configs)) {
const titleConfig = configs.find(
(item: { configKey?: string; configValue?: string }) =>
item.configKey === "site.title.about"
);
if (titleConfig?.configValue) {
title = titleConfig.configValue;
}
}
} catch (error) {
console.warn("Failed to generate About page metadata:", error);
}
return {
title,
description: "我在代码、文字和生活的缝隙里,慢慢搭建一个属于自己的小宇宙。关于 RRTiamo,此间主人。",
};
}
async function isAboutPageEnabled() {
try {
const response = await getPublicConfig();
const configs = response.data?.data;
if (!Array.isArray(configs)) return true;
const aboutConfig = configs.find(
(item: { configKey?: string; configValue?: string }) =>
item.configKey === "page.about.enable"
);
return aboutConfig?.configValue !== "false";
} catch (error) {
console.warn("About page: public config unavailable, keeping page enabled.", error);
return true;
}
}
export default async function AboutPage() {
await connection();
const enabled = await isAboutPageEnabled();
if (!enabled) notFound();
let profile = aboutProfile;
try {
const response = await getPublicConfig();
const configs = response.data?.data;
if (Array.isArray(configs)) {
const profileConfig = configs.find(
(item: { configKey?: string; configValue?: string }) =>
item.configKey === "page.about.profile"
);
if (profileConfig?.configValue) {
profile = JSON.parse(profileConfig.configValue);
}
}
} catch (error) {
console.warn("Failed to load dynamic about profile, using default fallback.", error);
}
return <AboutPageClient profile={profile} />;
}
+71
View File
@@ -0,0 +1,71 @@
import React from "react";
import AchievementsPageClient from "@/components/achievements/AchievementsPageClient";
import { Achievement } from "@/components/achievements/CertificateCard";
import { getAchievementsList, getAchievementMetasList } from "@/api/achievements";
import { getPublicConfig } from "@/api/config";
export interface AchievementMeta {
id: number;
type: string; // category or level
name: string;
code: string;
icon?: string;
}
async function getAchievements(): Promise<Achievement[]> {
try {
const res = await getAchievementsList();
const data = res.data;
if (data && data.code === 200 && Array.isArray(data.data)) {
return data.data;
}
} catch (err) {
console.warn("Achievements Page SSR: API offline, falling back to client-side initialization.", err);
}
return [];
}
async function getAchievementMetas(): Promise<AchievementMeta[]> {
try {
const res = await getAchievementMetasList();
const data = res.data;
if (data && data.code === 200 && Array.isArray(data.data)) {
return data.data;
}
} catch (err) {
console.warn("Achievements Page SSR metas: API offline, using empty meta.", err);
}
return [];
}
async function getPublicConfigs(): Promise<Record<string, string>> {
try {
const res = await getPublicConfig();
const data = res.data;
if (data && data.code === 200 && Array.isArray(data.data)) {
const configMap: Record<string, string> = {};
data.data.forEach((item: any) => {
configMap[item.configKey] = item.configValue;
});
return configMap;
}
} catch (err) {
console.warn("Achievements Page SSR configs: API offline, using empty configuration.", err);
}
return {};
}
export default async function AchievementsPage() {
const achievements = await getAchievements();
const metas = await getAchievementMetas();
const configs = await getPublicConfigs();
return (
<AchievementsPageClient
initialItems={achievements}
initialMetas={metas}
configs={configs}
/>
);
}
+913
View File
@@ -0,0 +1,913 @@
"use client";
import React, { useState, useEffect, useRef } from "react";
import Link from "next/link";
import Image from "next/image";
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import {
BookOpen,
Heart,
Camera,
Lock,
EyeSlash,
MapPin,
Smiley,
Funnel,
CalendarBlank
} from "@phosphor-icons/react";
import { writingData } from "@/data/writing";
import { mockLoveNotes } from "@/mock/love";
import { galleryData } from "@/data/gallery";
import { useArticles } from "@/hooks/useArticles";
import { useLove } from "@/hooks/useLove";
import { useGallery } from "@/hooks/useGallery";
import { useSysConfig } from "@/hooks/useSysConfig";
if (typeof window !== "undefined") {
gsap.registerPlugin(ScrollTrigger);
}
interface ArchiveItem {
key: string;
title: string;
date: string;
type: "Writing" | "Love Note" | "Photo";
visibility: "public" | "hidden" | "private";
link: string;
category?: string;
mood?: string;
description?: string;
cover?: string;
location?: string;
content?: string;
camera?: string;
lens?: string;
filmStock?: string;
settings?: string;
photoType?: "image" | "video";
}
// 情绪翻译
const translateMood = (mood: string) => {
const map: { [key: string]: string } = {
quiet: "安静",
thoughtful: "沉思",
observant: "观察",
inspired: "灵感",
happy: "愉悦",
joyful: "欣喜",
energetic: "活力",
romantic: "浪漫",
playful: "淘气",
peaceful: "宁静",
};
return map[mood] || mood;
};
// 权限标签组件
const VisibilityBadge = ({ visibility, isLove = false }: { visibility: "public" | "hidden" | "private"; isLove?: boolean }) => {
if (visibility === "private") {
return (
<span className="inline-flex items-center text-[9px] font-semibold text-amber-900 bg-amber-50/80 dark:text-amber-300 dark:bg-amber-950/40 px-1.5 py-0.5 rounded border border-amber-200/50 dark:border-amber-900/30 whitespace-nowrap">
<Lock className="w-2.5 h-2.5 mr-0.5" /> 密码锁定
</span>
);
}
if (visibility === "hidden") {
return (
<span className="inline-flex items-center text-[9px] font-semibold text-charcoal/60 bg-charcoal/5 dark:text-white/60 dark:bg-white/5 px-1.5 py-0.5 rounded border border-charcoal/10 dark:border-white/10 whitespace-nowrap">
<EyeSlash className="w-2.5 h-2.5 mr-0.5" /> 隐秘链接
</span>
);
}
return (
<span className={`text-[8px] font-mono font-semibold tracking-wider uppercase px-1.5 py-0.5 rounded ${
isLove
? "text-red-800 bg-red-50 dark:text-red-300 dark:bg-red-950/20"
: "text-charcoal/30 bg-charcoal/5 dark:text-white/30 dark:bg-white/5"
}`}>
PUBLIC
</span>
);
};
// 单张归档卡片组件 - 结合高级 GSAP 3D Hover Tilt 物理摇摆
const ArchiveCard = ({ item }: { item: ArchiveItem }) => {
const cardRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const el = cardRef.current;
if (!el) return;
let onMouseMove: (e: MouseEvent) => void;
let onMouseLeave: () => void;
const ctx = gsap.context(() => {
// 创建高频物理磁吸过渡
const xTo = gsap.quickTo(el, "rotationY", { duration: 0.5, ease: "power2.out" });
const yTo = gsap.quickTo(el, "rotationX", { duration: 0.5, ease: "power2.out" });
onMouseMove = (e: MouseEvent) => {
const rect = el.getBoundingClientRect();
const mouseX = e.clientX - rect.left - rect.width / 2;
const mouseY = e.clientY - rect.top - rect.height / 2;
// 限制倾斜角度在 3.5 度以内,保持低调奢华
const rotateY = (mouseX / (rect.width / 2)) * 3.5;
const rotateX = -(mouseY / (rect.height / 2)) * 3.5;
xTo(rotateY);
yTo(rotateX);
};
onMouseLeave = () => {
xTo(0);
yTo(0);
};
el.addEventListener("mousemove", onMouseMove);
el.addEventListener("mouseleave", onMouseLeave);
}, cardRef);
return () => {
if (onMouseMove && onMouseLeave) {
el.removeEventListener("mousemove", onMouseMove);
el.removeEventListener("mouseleave", onMouseLeave);
}
ctx.revert();
};
}, []);
if (item.type === "Writing") {
return (
<div
ref={cardRef}
style={{ transformStyle: "preserve-3d", perspective: 1000 }}
className="group relative bg-[#F9F9F6] dark:bg-[#1E2521] border border-charcoal/10 dark:border-white/10 rounded-2xl p-6 shadow-[0_4px_12px_rgba(0,0,0,0.02)] hover:shadow-[0_12px_32px_rgba(0,0,0,0.08)] transition-shadow duration-500 flex flex-col justify-between min-h-[220px] overflow-hidden"
>
{/* 曲别针效果 */}
<div className="absolute top-0 left-6 w-8 h-4 bg-zinc-300/40 dark:bg-zinc-800/60 rounded-b-md border-x border-b border-charcoal/5 dark:border-white/5 shadow-inner" />
<div className="space-y-4">
<div className="flex justify-between items-center text-[10px] font-mono text-charcoal/40 dark:text-white/40 uppercase tracking-wider">
<span className="flex items-center gap-1">
<BookOpen className="w-3.5 h-3.5 text-gold" /> {item.category || "Essay"}
</span>
<span className="flex items-center gap-1">
<CalendarBlank className="w-3.5 h-3.5" /> {item.date}
</span>
</div>
<div className="space-y-2 relative">
<h3 className="font-serif text-lg md:text-xl font-medium text-charcoal dark:text-white group-hover:text-gold transition-colors duration-300 leading-snug">
<Link href={item.link} className="after:absolute after:inset-0">
{item.title}
</Link>
</h3>
<p className="font-sans text-xs text-charcoal/60 dark:text-white/60 line-clamp-3 leading-relaxed">
{item.description}
</p>
</div>
</div>
<div className="mt-6 pt-4 border-t border-charcoal/5 dark:border-white/5 flex justify-between items-center text-[10px] font-mono text-charcoal/40 dark:text-white/40">
<span className="flex items-center gap-1">
<Smiley className="w-3.5 h-3.5 text-gold" /> Mood: {item.mood ? translateMood(item.mood) : "未知"}
</span>
<VisibilityBadge visibility={item.visibility} />
</div>
</div>
);
}
if (item.type === "Love Note") {
return (
<div
ref={cardRef}
style={{ transformStyle: "preserve-3d", perspective: 1000 }}
className="group relative bg-[#FCF5F2] dark:bg-[#25201E] border border-red-900/10 dark:border-red-900/20 rounded-2xl p-6 shadow-[0_4px_12px_rgba(0,0,0,0.02)] hover:shadow-[0_12px_32px_rgba(244,63,94,0.08)] transition-shadow duration-500 flex flex-col justify-between min-h-[220px] overflow-hidden"
>
{/* 心形火漆印记 */}
<div className="absolute -top-3 -right-3 w-12 h-12 rounded-full bg-red-800/10 dark:bg-red-800/20 border border-red-800/15 flex items-center justify-center rotate-12 group-hover:rotate-45 transition-transform duration-500">
<Heart className="w-5 h-5 text-red-800 dark:text-red-600 fill-red-800/20" />
</div>
<div className="space-y-4">
<div className="flex justify-between items-center text-[10px] font-mono text-red-800/50 dark:text-red-400/50 uppercase tracking-wider">
<span className="flex items-center gap-1 font-semibold">
<Heart className="w-3.5 h-3.5" /> Love Memory
</span>
<span className="flex items-center gap-1">
<CalendarBlank className="w-3.5 h-3.5" /> {item.date}
</span>
</div>
<div className="space-y-2 relative">
<h3 className="font-serif text-lg md:text-xl font-medium text-red-950 dark:text-red-100 group-hover:text-gold transition-colors duration-300 leading-snug">
<Link href={item.link} className="after:absolute after:inset-0">
{item.title}
</Link>
</h3>
<p className="font-sans text-xs text-red-950/60 dark:text-red-100/60 line-clamp-3 leading-relaxed">
{item.content}
</p>
</div>
</div>
<div className="mt-6 pt-4 border-t border-red-900/5 dark:border-red-900/10 flex justify-between items-center text-[10px] font-mono text-red-800/50 dark:text-red-400/50">
<span className="flex items-center gap-1">
<MapPin className="w-3.5 h-3.5 text-red-800" /> {item.location || "我们的窝"}
</span>
<VisibilityBadge visibility={item.visibility} isLove />
</div>
</div>
);
}
// Photo / Polaroid 相片卡片
return (
<div
ref={cardRef}
style={{ transformStyle: "preserve-3d", perspective: 1000 }}
className="group relative bg-[#FCFAF2] dark:bg-[#25241E] border border-charcoal/10 dark:border-white/10 rounded-2xl p-4 pb-5 shadow-[0_4px_12px_rgba(0,0,0,0.02)] hover:shadow-[0_12px_32px_rgba(0,0,0,0.08)] transition-shadow duration-500 flex flex-col justify-between min-h-[300px] overflow-hidden"
>
{/* 拍立得相框区 */}
<div className="relative aspect-square w-full rounded-lg overflow-hidden bg-zinc-100 dark:bg-zinc-950 border border-charcoal/5 dark:border-white/5">
{item.visibility === "public" ? (
<>
{item.photoType === "video" ? (
<video
src={item.cover}
className="w-full h-full object-cover brightness-[0.98] group-hover:brightness-100 group-hover:scale-[1.03] transition-all duration-500"
muted
loop
playsInline
onMouseOver={(e) => (e.target as HTMLVideoElement).play()}
onMouseOut={(e) => (e.target as HTMLVideoElement).pause()}
/>
) : (
<Image
src={item.cover || ""}
alt={item.title}
fill
sizes="(max-width: 768px) 100vw, (max-width: 1024px) 50vw, 33vw"
className="object-cover brightness-[0.98] group-hover:brightness-100 group-hover:scale-[1.03] transition-all duration-500"
/>
)}
<div className="absolute bottom-2 right-2 bg-black/40 backdrop-blur-[2px] text-[8px] font-mono text-white/80 px-1.5 py-0.5 rounded-sm pointer-events-none uppercase">
{item.camera ? item.camera.split(" ")[0] : "SNAP"}
</div>
</>
) : (
/* 私密硫酸纸盖印效果 */
<div className="w-full h-full bg-gradient-to-br from-amber-900/15 to-zinc-900/40 backdrop-blur-md flex flex-col items-center justify-center p-6 text-center select-none relative">
<div className="absolute inset-0 bg-cream/10 dark:bg-black/10 mix-blend-overlay" />
<div className="space-y-2 z-10">
<div className="w-10 h-10 rounded-full bg-red-950/20 dark:bg-red-900/30 border border-red-950/20 dark:border-red-900/30 flex items-center justify-center mx-auto shadow-inner">
<Lock className="w-4 h-4 text-red-800 dark:text-red-500 fill-red-800/10" />
</div>
<div>
<div className="text-xs font-serif font-medium text-red-950 dark:text-red-100">
{item.visibility === "private" ? "私密归档" : "隐藏档案"}
</div>
<div className="text-[9px] font-mono text-charcoal/50 dark:text-white/40 uppercase tracking-widest mt-0.5">
{item.visibility === "private" ? "Passcode Secured" : "Direct Link Only"}
</div>
</div>
</div>
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 -rotate-12 bg-red-800/90 dark:bg-red-700/90 text-white text-[9px] font-mono font-semibold tracking-[0.2em] px-4 py-1 shadow-md border border-red-700 pointer-events-none uppercase whitespace-nowrap">
{item.visibility === "private" ? "CONFIDENTIAL" : "RESTRICTED"}
</div>
</div>
)}
</div>
{/* 拍立得白边底座手写区 */}
<div className="mt-4 space-y-3 px-1">
<div className="space-y-1">
<h3 className="font-ma-shan-zheng text-xl text-charcoal dark:text-zinc-100 group-hover:text-gold transition-colors duration-300 leading-snug">
<Link href={item.link} className="after:absolute after:inset-0">
{item.title}
</Link>
</h3>
{item.visibility === "public" && (
<p className="font-sans text-[10px] text-charcoal/50 dark:text-white/40 line-clamp-1">
{item.description}
</p>
)}
</div>
<div className="pt-2 border-t border-charcoal/5 dark:border-white/5 flex justify-between items-end">
<div className="text-[8px] font-mono text-charcoal/40 dark:text-white/40 leading-normal">
{item.visibility === "public" && item.camera ? (
<>
<div className="line-clamp-1">{item.camera} · {item.lens}</div>
<div className="text-gold/70 dark:text-gold-light/60 font-semibold uppercase">{item.filmStock} · {item.settings}</div>
</>
) : (
<div>SYSTEM INDEX: PHOTO-{item.key.toUpperCase()}</div>
)}
</div>
<VisibilityBadge visibility={item.visibility} />
</div>
</div>
</div>
);
};
// 预先静态化提取初始年份以供延迟加载状态
const getInitialYears = () => {
const dates = [
...writingData.map((post) => post.date),
...mockLoveNotes.map((entry) => entry.date),
...galleryData.map((photo) => photo.date),
];
dates.sort((a, b) => new Date(b).getTime() - new Date(a).getTime());
const years = dates.map(d => d.split("-")[0]);
return Array.from(new Set(years)).sort((a, b) => b.localeCompare(a));
};
export default function ArchivePage() {
const { isPageEnabled } = useSysConfig();
const loveEnabled = isPageEnabled("page.love.enable", true);
const { posts: dynamicPosts } = useArticles();
const { loveNotes: dynamicLove } = useLove();
const { photos: dynamicGallery } = useGallery();
const [activeTab, setActiveTab] = useState<"all" | "Writing" | "Love Note" | "Photo">("all");
const [activeYear, setActiveYear] = useState<string>(() => {
const initialYears = getInitialYears();
return initialYears.length > 0 ? initialYears[0] : "";
});
const pageRef = useRef<HTMLDivElement>(null);
// 动态年份同步更新
useEffect(() => {
const allItems = [
...dynamicPosts.map((post) => post.date),
...dynamicLove.map((entry) => entry.date),
...dynamicGallery.map((photo) => photo.date),
];
if (allItems.length > 0) {
allItems.sort((a, b) => new Date(b).getTime() - new Date(a).getTime());
const years = Array.from(new Set(allItems.map(d => d.split("-")[0]))).sort((a, b) => b.localeCompare(a));
if (years.length > 0 && !years.includes(activeYear)) {
setActiveYear(years[0]);
}
}
}, [dynamicPosts, dynamicLove, dynamicGallery]);
const noteRef = useRef<HTMLDivElement>(null);
// 独立控制黄便签的高级 3D 悬挂物理摇摆与交互
useEffect(() => {
const el = noteRef.current;
if (!el) return;
let onMouseEnter: () => void;
let onMouseMove: (e: MouseEvent) => void;
let onMouseLeave: () => void;
const ctx = gsap.context(() => {
const xTo = gsap.quickTo(el, "rotationY", { duration: 0.6, ease: "power2.out" });
const yTo = gsap.quickTo(el, "rotationX", { duration: 0.6, ease: "power2.out" });
const rTo = gsap.quickTo(el, "rotation", { duration: 0.6, ease: "power2.out" });
onMouseEnter = () => {
gsap.to(el, {
y: -6,
boxShadow: "0 15px 30px rgba(0,0,0,0.06)",
duration: 0.4,
ease: "power2.out"
});
};
onMouseMove = (e: MouseEvent) => {
const rect = el.getBoundingClientRect();
const mouseX = e.clientX - rect.left - rect.width / 2;
const mouseY = e.clientY - rect.top - rect.height / 2;
const rotateY = (mouseX / (rect.width / 2)) * 6;
const rotateX = -(mouseY / (rect.height / 2)) * 6;
const rot = -2.5 + (mouseX / (rect.width / 2)) * 4;
xTo(rotateY);
yTo(rotateX);
rTo(rot);
};
onMouseLeave = () => {
xTo(0);
yTo(0);
rTo(-2.5);
gsap.to(el, {
y: 0,
boxShadow: "5px 5px 15px rgba(0,0,0,0.03)",
duration: 0.8,
ease: "elastic.out(1.2, 0.5)" // 回弹时产生微微颤动的阻尼效果
});
};
el.addEventListener("mouseenter", onMouseEnter);
el.addEventListener("mousemove", onMouseMove);
el.addEventListener("mouseleave", onMouseLeave);
}, noteRef);
return () => {
if (onMouseEnter && onMouseMove && onMouseLeave) {
el.removeEventListener("mouseenter", onMouseEnter);
el.removeEventListener("mousemove", onMouseMove);
el.removeEventListener("mouseleave", onMouseLeave);
}
ctx.revert();
};
}, []);
// 合载所有的静态/动态数据并按时间自新到旧排序
const archives: ArchiveItem[] = [
...dynamicPosts.map((post) => ({
key: post.slug,
title: post.title,
date: post.date,
type: "Writing" as const,
visibility: post.visibility,
link: `/writing/${post.slug}`,
category: post.category,
mood: post.mood,
cover: post.cover,
description: post.description,
content: post.content,
})),
...(loveEnabled ? dynamicLove.map((entry) => ({
key: entry.id,
title: entry.title,
date: entry.date,
type: "Love Note" as const,
visibility: entry.visibility,
link: `/love`,
location: entry.location,
mood: entry.mood,
cover: entry.cover,
content: entry.content,
})) : []),
...dynamicGallery.map((photo) => {
// 模拟一些私密/隐藏影像切片,增加物理档案馆的仪式感
let vis: "public" | "hidden" | "private" = "public";
if (photo.id === "anime-boy") vis = "private";
if (photo.id === "flower-wall") vis = "hidden";
return {
key: photo.id,
title: photo.title,
date: photo.date,
type: "Photo" as const,
visibility: vis,
link: `/gallery`,
cover: photo.src,
description: photo.description,
camera: photo.camera,
lens: photo.lens,
filmStock: photo.filmStock,
settings: photo.settings,
location: photo.location,
photoType: photo.type,
};
}),
];
archives.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
// 数量统计
const writingCount = archives.filter(i => i.type === "Writing").length;
const loveCount = archives.filter(i => i.type === "Love Note").length;
const photoCount = archives.filter(i => i.type === "Photo").length;
// 过滤后的数据
const filteredArchives = archives.filter(
(item) => activeTab === "all" || item.type === activeTab
);
// 年份分组
const groups: { [key: string]: ArchiveItem[] } = {};
filteredArchives.forEach((item) => {
const year = item.date.split("-")[0];
if (!groups[year]) {
groups[year] = [];
}
groups[year].push(item);
});
const years = Object.keys(groups).sort((a, b) => b.localeCompare(a));
// 高端洗牌-发牌过滤动画逻辑 (通过 GSAP 物理动画接管 Tab 切换卡片排布)
const changeTab = (tab: "all" | "Writing" | "Love Note" | "Photo") => {
if (tab === activeTab) return;
// 提前在 pageRef 范围内获取所有卡片,如果不存在则不执行 GSAP 动画以防止报错
const cards = pageRef.current?.querySelectorAll(".archive-card-anim");
if (!cards || cards.length === 0) {
setActiveTab(tab);
return;
}
// 1. 发起“洗牌合拢淡出”动效
gsap.to(cards, {
opacity: 0,
y: 25,
scale: 0.95,
rotation: 0,
duration: 0.35,
stagger: 0.015,
ease: "power2.in",
onComplete: () => {
// 2. 动效完成后同步状态
setActiveTab(tab);
const filtered = archives.filter(item => tab === "all" || item.type === tab);
const tempGroups: { [key: string]: boolean } = {};
filtered.forEach((item) => {
const yr = item.date.split("-")[0];
tempGroups[yr] = true;
});
const tempYears = Object.keys(tempGroups).sort((a, b) => b.localeCompare(a));
if (tempYears.length > 0) {
setActiveYear(tempYears[0]);
} else {
setActiveYear("");
}
// 3. 在下一渲染帧中,完美发起 staggered“散开物理发牌”动效
setTimeout(() => {
const newCards = pageRef.current?.querySelectorAll(".archive-card-anim");
if (newCards && newCards.length > 0) {
gsap.fromTo(newCards,
{
opacity: 0,
y: 45,
scale: 0.96,
rotation: () => (Math.random() - 0.5) * 2.5,
},
{
opacity: 1,
y: 0,
scale: 1,
rotation: () => (Math.random() - 0.5) * 1.5,
duration: 0.9,
stagger: 0.04,
ease: "power4.out" // 完美的减速物理阻尼曲线
}
);
}
}, 30);
}
});
};
// GSAP 首次加载动画及 ScrollTrigger 物理联动
useEffect(() => {
const ctx = gsap.context(() => {
// 1. 顶部索引卡与便签滑入 (优雅的弹性入场)
gsap.from(".archive-index-card", {
opacity: 0,
y: 40,
duration: 1.0,
ease: "power3.out"
});
// 2. 黄便签的“飘落悬挂物理摇摆”进场动效
gsap.fromTo(".archive-sticky-note",
{
opacity: 0,
y: -80,
rotation: -18,
scale: 0.9
},
{
opacity: 1,
y: 0,
scale: 1,
rotation: -2.5,
duration: 1.6,
delay: 0.2,
ease: "elastic.out(1.1, 0.45)"
}
);
// 2. 过滤栏滑入
gsap.from(".archive-filter-bar", {
opacity: 0,
y: 25,
duration: 1.0,
delay: 0.15,
ease: "power3.out"
});
// 3. 侧边栏时间轴滑入
gsap.from(".archive-timeline-sidebar", {
opacity: 0,
x: -30,
duration: 1.0,
delay: 0.25,
ease: "power3.out"
});
// 4. 首次加载卡片 Stagger 物理发牌滑入
const firstCards = pageRef.current?.querySelectorAll(".archive-card-anim");
if (firstCards && firstCards.length > 0) {
gsap.from(firstCards, {
opacity: 0,
y: 45,
rotation: () => (Math.random() - 0.5) * 2.5,
duration: 0.9,
stagger: 0.05,
delay: 0.35,
ease: "power4.out"
});
}
// 5. 年份标题横线 ScrollTrigger 动态横向拉伸生长
years.forEach((year) => {
gsap.fromTo(`#divider-${year}`,
{ scaleX: 0, opacity: 0 },
{
scaleX: 1,
opacity: 1,
ease: "power2.out",
duration: 1.2,
scrollTrigger: {
trigger: `#year-${year}`,
start: "top 85%", // 进入屏幕下方 85% 位置时触发
once: true
}
}
);
});
// 6. 滚动联动高亮左侧年份刻度
years.forEach((year) => {
ScrollTrigger.create({
trigger: `#year-${year}`,
start: "top 35%",
end: "bottom 35%",
onToggle: (self) => {
if (self.isActive) {
setActiveYear(year);
}
}
});
});
// 7. 时光轴流逝线滚动比例拉伸 (只在桌面端 sticky sidebar 启用,避免移动端计算报错)
if (window.innerWidth >= 1024) {
gsap.to(".timeline-progress-fill", {
scaleY: 1,
ease: "none",
scrollTrigger: {
trigger: ".archive-timeline-sidebar",
start: "top 32%",
end: "bottom 70%",
endTrigger: ".archive-cards-list-container", // 跟踪右侧网格底端
scrub: true
}
});
}
}, pageRef);
return () => ctx.revert();
}, [years, activeTab]); // 过滤引起 years 变动时,安全重建 ScrollTrigger 保证坐标绝对精准
// 锚点滚动
const scrollToYear = (year: string) => {
const lenis = (window as unknown as { lenis: { scrollTo: (target: string, options: { offset: number }) => void } }).lenis;
if (lenis) {
lenis.scrollTo(`#year-${year}`, { offset: -120 });
} else {
document.getElementById(`year-${year}`)?.scrollIntoView({ behavior: "smooth" });
}
};
const categories = [
{ id: "all" as const, name: "全部归档", icon: null },
{ id: "Writing" as const, name: "随笔散文", icon: <BookOpen className="w-3.5 h-3.5" /> },
...(loveEnabled ? [{ id: "Love Note" as const, name: "恋爱纪实", icon: <Heart className="w-3.5 h-3.5" /> }] : []),
{ id: "Photo" as const, name: "影像切片", icon: <Camera className="w-3.5 h-3.5" /> },
];
return (
<div ref={pageRef} className="max-w-6xl mx-auto w-full px-4 md:px-8 py-24 md:py-32">
{/* 1. 档案馆索书卡(数字索引卡) */}
<div className="archive-index-card bg-white/60 dark:bg-zinc-900/60 backdrop-blur-md border border-charcoal/10 dark:border-white/10 rounded-3xl p-6 md:p-10 shadow-[0_12px_40px_-12px_rgba(0,0,0,0.08)] relative overflow-hidden mb-10">
<div className="absolute -top-12 -right-12 w-48 h-48 bg-gold/5 dark:bg-gold/10 rounded-full blur-3xl pointer-events-none" />
<div className="flex flex-col md:flex-row md:items-start md:justify-between gap-8 relative z-10">
<div className="space-y-4 max-w-2xl">
<div className="flex items-center space-x-3">
<span className="text-[9px] font-mono tracking-[0.2em] text-gold bg-gold/10 px-2.5 py-1 rounded-md uppercase font-semibold">
NO. ATLAS-260624-MYHOUSE
</span>
<span className="flex h-2 w-2 relative">
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>
<span className="relative inline-flex rounded-full h-2 w-2 bg-emerald-500"></span>
</span>
<span className="text-[9px] font-mono text-charcoal/40 dark:text-white/40 uppercase">
ONLINE INDEX
</span>
</div>
<h1 className="font-serif text-4xl md:text-5xl font-light text-charcoal dark:text-white">
Archive / 编目归档
</h1>
<p className="font-sans text-xs md:text-sm text-charcoal/60 dark:text-white/60 leading-relaxed">
档案馆内所有收录文章、恋爱纪实与影像切片的索引总汇。
我们用文字与胶片,在易逝的时间河流中,为日常编目,留存那些闪闪发光的细碎回忆。
</p>
</div>
{/* 手写黄便签 */}
<div
ref={noteRef}
style={{ transformStyle: "preserve-3d", perspective: 1000 }}
className="archive-sticky-note self-start md:self-center bg-[#FDF6E2] dark:bg-[#2C2921] border border-[#EBE3CD] dark:border-[#423C2F] p-4 rounded-xl shadow-[5px_5px_15px_rgba(0,0,0,0.03)] max-w-xs relative flex-shrink-0"
>
<div className="absolute -top-2 left-1/2 -translate-x-1/2 w-12 h-3 bg-white/40 dark:bg-black/20 backdrop-blur-[1px] rotate-1 pointer-events-none" />
<p className="font-ma-shan-zheng text-lg text-amber-900/80 dark:text-amber-200/80 leading-relaxed pt-1.5 select-none">
“时间的针脚密密麻麻,有些落在了纸上,有些藏在了心里。”
</p>
<div className="text-right mt-1.5 select-none font-sans text-[9px] text-amber-900/40 dark:text-amber-200/40">
— 馆长编目印
</div>
</div>
</div>
{/* 统计指标卡 */}
<div className="grid grid-cols-3 gap-4 mt-8 pt-8 border-t border-charcoal/10 dark:border-white/10">
<div className="bg-cream/40 dark:bg-charcoal/30 p-4 rounded-2xl border border-charcoal/5 dark:border-white/5 flex flex-col justify-between">
<span className="text-[11px] text-charcoal/50 dark:text-white/50 flex items-center gap-1.5 font-medium">
<BookOpen className="w-4 h-4 text-gold" /> 随笔散文
</span>
<div className="mt-2 flex items-baseline gap-1">
<span className="font-serif text-2xl md:text-3xl font-light text-charcoal dark:text-white">{writingCount}</span>
<span className="text-[9px] text-charcoal/40 dark:text-white/40 font-mono">DOCS</span>
</div>
</div>
<div className="bg-cream/40 dark:bg-charcoal/30 p-4 rounded-2xl border border-charcoal/5 dark:border-white/5 flex flex-col justify-between">
<span className="text-[11px] text-charcoal/50 dark:text-white/50 flex items-center gap-1.5 font-medium">
<Heart className="w-4 h-4 text-red-500" /> 恋爱纪实
</span>
<div className="mt-2 flex items-baseline gap-1">
<span className="font-serif text-2xl md:text-3xl font-light text-charcoal dark:text-white">{loveCount}</span>
<span className="text-[9px] text-charcoal/40 dark:text-white/40 font-mono">NOTES</span>
</div>
</div>
<div className="bg-cream/40 dark:bg-charcoal/30 p-4 rounded-2xl border border-charcoal/5 dark:border-white/5 flex flex-col justify-between">
<span className="text-[11px] text-charcoal/50 dark:text-white/50 flex items-center gap-1.5 font-medium">
<Camera className="w-4 h-4 text-blue-500" /> 影像切片
</span>
<div className="mt-2 flex items-baseline gap-1">
<span className="font-serif text-2xl md:text-3xl font-light text-charcoal dark:text-white">{photoCount}</span>
<span className="text-[9px] text-charcoal/40 dark:text-white/40 font-mono">PHOTOS</span>
</div>
</div>
</div>
</div>
{/* 2. 分类页签过滤器 */}
<div className="archive-filter-bar flex flex-wrap items-center gap-3 mb-10 pb-4 border-b border-charcoal/5 dark:border-white/5">
<span className="text-xs text-charcoal/40 dark:text-white/40 flex items-center gap-1 mr-2 font-mono">
<Funnel className="w-3.5 h-3.5" /> FILTER / 检索 :
</span>
<div className="flex bg-cream/80 dark:bg-charcoal/50 p-1 rounded-full border border-charcoal/10 dark:border-white/10 relative">
{categories.map((cat) => {
const isActive = activeTab === cat.id;
return (
<button
key={cat.id}
onClick={() => changeTab(cat.id)}
className={`px-3.5 py-1.5 rounded-full text-xs font-sans transition-all duration-300 relative z-10 flex items-center gap-1.5 ${
isActive
? "text-white dark:text-charcoal bg-gold dark:bg-gold shadow-[0_2px_8px_rgba(217,134,95,0.25)] font-medium"
: "text-charcoal/60 dark:text-white/60 hover:text-charcoal dark:hover:text-white"
}`}
>
{cat.icon}
<span>{cat.name}</span>
</button>
);
})}
</div>
</div>
{/* 3. 两栏式主体:时光刻度轴 + 归档网格 */}
<div className="flex flex-col lg:flex-row gap-8 items-start">
{/* 3.A 侧边年份刻度轴 (在大屏幕下粘性固定,在小屏幕下水平滑动) */}
<div className="archive-timeline-sidebar w-full lg:w-1/4 lg:sticky lg:top-32 self-start space-y-6">
{/* 桌面端时间线 */}
<div className="hidden lg:block space-y-4 pr-6">
<div className="text-[10px] font-mono tracking-widest text-charcoal/40 dark:text-white/40 uppercase">
TIMELINE / 时光轴
</div>
<div className="relative pl-4 space-y-6">
{/* 时间轴轨道(灰色底) */}
<div className="absolute left-[4px] top-2 bottom-2 w-[1px] bg-charcoal/10 dark:bg-white/10" />
{/* 时光流逝金色填充进度条 */}
<div className="absolute left-[4px] top-2 bottom-2 w-[1px] bg-gold origin-top scale-y-0 timeline-progress-fill" />
{years.map((year) => {
const count = groups[year]?.length || 0;
const isActive = activeYear === year;
return (
<button
key={year}
onClick={() => scrollToYear(year)}
className="group block text-left relative focus:outline-none py-1"
>
{/* 时光轴节点 */}
<div className={`absolute -left-[21px] top-1/2 -translate-y-1/2 w-2.5 h-2.5 rounded-full bg-cream dark:bg-charcoal border-2 transition-all duration-300 ${
isActive
? "border-gold bg-gold scale-125 shadow-[0_0_8px_rgba(217,134,95,0.6)]"
: "border-charcoal/30 dark:border-white/30 group-hover:border-gold"
}`} />
<div className={`font-serif text-3xl font-light transition-all duration-300 flex items-baseline gap-1.5 ${
isActive
? "text-gold translate-x-1"
: "text-charcoal/40 dark:text-white/40 group-hover:text-gold"
}`}>
{year}
<span className={`text-[10px] font-sans font-normal transition-all duration-300 ${
isActive ? "text-gold/60" : "text-charcoal/30 dark:text-white/30"
}`}>({count})</span>
</div>
</button>
);
})}
</div>
</div>
{/* 移动端年份快捷导航 */}
<div className="lg:hidden flex items-center gap-2 overflow-x-auto pb-4 scrollbar-none w-full border-b border-charcoal/5 dark:border-white/5">
{years.map((year) => {
const count = groups[year]?.length || 0;
const isActive = activeYear === year;
return (
<button
key={year}
onClick={() => scrollToYear(year)}
className={`flex-shrink-0 px-3.5 py-1.5 rounded-lg border text-xs font-serif transition-all duration-300 ${
isActive
? "text-gold border-gold bg-gold/5 font-medium"
: "bg-cream/80 dark:bg-charcoal/50 border-charcoal/10 dark:border-white/10 text-charcoal/70 dark:text-white/70"
}`}
>
{year} 年 <span className={`font-sans text-[9px] ${isActive ? "text-gold/60" : "text-charcoal/40 dark:text-white/40"}`}>({count})</span>
</button>
);
})}
</div>
</div>
{/* 3.B 归档卡片网格列表 */}
<div className="archive-cards-list-container w-full lg:w-3/4 space-y-16">
{years.length === 0 ? (
<div className="py-20 text-center space-y-3 bg-white/40 dark:bg-zinc-900/40 rounded-3xl border border-charcoal/5 dark:border-white/5">
<span className="text-3xl">📭</span>
<p className="font-serif text-lg text-charcoal/40 dark:text-white/40">此分类下暂无已归档内容</p>
</div>
) : (
years.map((year) => (
<div key={year} id={`year-${year}`} className="space-y-6 scroll-mt-28">
{/* 年份标题刻度线 */}
<div className="flex items-center gap-4 border-b border-charcoal/10 dark:border-white/10 pb-3">
<h2 className="font-serif text-4xl font-light text-charcoal dark:text-white tracking-wide">
{year}
</h2>
<span className="text-xs font-sans text-charcoal/40 dark:text-white/40 font-normal uppercase tracking-widest bg-cream/80 dark:bg-charcoal/60 px-2.5 py-0.5 rounded border border-charcoal/5 dark:border-white/5">
{groups[year].length} 档案
</span>
{/* origin-left 用于横线拉伸生长 */}
<div
id={`divider-${year}`}
className="grow h-px bg-gradient-to-r from-charcoal/15 dark:from-white/15 to-transparent origin-left"
/>
</div>
{/* 卡片网格 */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8">
{groups[year].map((item) => (
<div
key={item.key}
className="archive-card-anim"
>
<ArchiveCard item={item} />
</div>
))}
</div>
</div>
))
)}
</div>
</div>
</div>
);
}
+222
View File
@@ -0,0 +1,222 @@
import FootprintsPageClient from "@/components/footprints/FootprintsPageClient";
import { getPublicConfig } from "@/api/config";
import { getGalleryList, getFootprintCategoryList } from "@/api/gallery";
import { getLoveList } from "@/api/love";
interface PublicConfig {
configKey: string;
configValue: string;
}
// 1. 获取公开系统配置以取得高德地图密钥
async function getMapConfig() {
try {
const res = await getPublicConfig();
const payload = res.data;
if (payload?.code === 200 && Array.isArray(payload.data)) {
const data = payload.data as PublicConfig[];
const keyCfg = data.find((c) => c.configKey === "page.footprint.amap.key");
const codeCfg = data.find((c) => c.configKey === "page.footprint.amap.securityJsCode");
return {
key: keyCfg?.configValue || "",
code: codeCfg?.configValue || "",
};
}
} catch (error) {
console.warn("Footprints: API public configs unavailable, fallback to env keys.", error);
}
return { key: "", code: "" };
}
// 2. 拉取照片墙列表
async function getGalleryFootprints(): Promise<any[]> {
try {
const res = await getGalleryList();
const payload = res.data;
if (payload?.code === 200 && Array.isArray(payload.data)) {
return payload.data
.filter((item: any) => item.longitude && item.latitude) // 只要带坐标的
.map((item: any) => ({
id: `photo-${item.id}`,
type: (item.footprintType || "photo") as "photo" | "love",
slug: item.slug || `photo-${item.id}`,
title: item.title,
date: item.date ? item.date.split("T")[0] : new Date().toISOString().split("T")[0],
location: item.location || "未知",
longitude: Number(item.longitude),
latitude: Number(item.latitude),
cover: item.src || "/assets/writing-camera.png",
content: item.description || "",
camera: item.camera || "",
lens: item.lens || "",
filmStock: item.filmStock || "",
settings: item.settings || "",
mediaType: item.type || "image",
}));
}
} catch (error) {
console.warn("Footprints page: Gallery API offline, falling back to static photo data.", error);
}
return [];
}
// 3. 拉取恋爱日记列表
async function getLoveFootprints(): Promise<any[]> {
try {
const res = await getLoveList();
const payload = res.data;
if (payload?.code === 200 && Array.isArray(payload.data)) {
return payload.data
.filter((item: any) => item.longitude && item.latitude) // 只要带坐标的
.map((item: any) => ({
id: `love-${item.id}`,
type: (item.footprintType || "love") as "photo" | "love",
slug: item.slug || `love-${item.id}`,
title: item.title,
date: item.date ? item.date.split("T")[0] : new Date().toISOString().split("T")[0],
location: item.location || "未知",
longitude: Number(item.longitude),
latitude: Number(item.latitude),
cover: item.cover || "/assets/love-anniversary.png",
content: item.content || "",
mood: item.mood || "",
mediaType: "image",
}));
}
} catch (error) {
console.warn("Footprints page: Love API offline, falling back to static love data.", error);
}
return [];
}
// 4. 拉取足迹类别列表
async function getFootprintCategories(): Promise<any[]> {
try {
const res = await getFootprintCategoryList();
const payload = res.data;
if (payload?.code === 200 && Array.isArray(payload.data)) {
return payload.data;
}
} catch (error) {
console.warn("Footprints page: Categories API offline, falling back to static categories.", error);
}
return [
{ id: 1, name: "光影影像", code: "photo", icon: "Camera" },
{ id: 2, name: "甜蜜瞬间", code: "love", icon: "Heart" },
];
}
export default async function FootprintsPage() {
const mapConfig = await getMapConfig();
const galleryItems = await getGalleryFootprints();
const loveItems = await getLoveFootprints();
const categories = await getFootprintCategories();
// 拼接与去重
let combinedItems = [...galleryItems, ...loveItems];
// 4. 静态本地 fallback 兜底数据(在接口完全离线时保证前台完美可看)
if (combinedItems.length === 0) {
combinedItems = [
{
id: "static-photo-1",
type: "photo",
slug: "sidewalk-night",
title: "深夜霓虹下的人行道",
date: "2026-06-18",
location: "上海 · 南京东路",
longitude: 121.4883,
latitude: 31.2369,
cover: "/assets/【哲风壁纸】人行道-城市-夜晚.png",
content: "城市的霓虹反射在微湿的人行道上。路灯把行人的影子拉得很长。深邃的蓝色调中透着都市的孤独感。胶片特有的银盐颗粒在暗部特别明显,配合 Zeiss 镜头的大光圈,散发出迷人的光圈散景。",
camera: "Contax T2",
lens: "Sonnar 38mm f/2.8",
filmStock: "Fujifilm Superia 400",
settings: "f/2.8, 1/30s",
},
{
id: "static-photo-2",
type: "photo",
slug: "mountain-pavilion",
title: "孤山亭子与破晓薄雾",
date: "2026-03-05",
location: "南京 · 紫金山巅",
longitude: 118.8443,
latitude: 32.0621,
cover: "/assets/【哲风壁纸】亭子-励志文案-山石.png",
content: "立于山巅乱石之中的古典凉亭,旁侧印刻着励志文字。朝霞初生,破晓的薄雾在树干之间弥漫,这是一场逃离都市的山野探索。在清晨五点爬上山顶,寒风料峭中按下这枚快门,定格物理意义上的光线碰撞。",
camera: "Canon F-1",
lens: "FD 50mm f/1.4",
filmStock: "Kodak Portra 160",
settings: "f/5.6, 1/125s",
},
{
id: "static-photo-3",
type: "photo",
slug: "rabbit-sunset",
title: "公路旁日落时分的小兔",
date: "2026-02-14",
location: "杭州 · 龙井山道",
longitude: 120.1551,
latitude: 30.2741,
cover: "/assets/【哲风壁纸】兔子-公路-日落.png",
content: "夕阳将公路渲染成温暖的金黄色,一只小兔在路边草丛里探出头。金色的逆光将兔毛边缘照亮成光晕。在落日前的最后十分钟,使用 Leica M6 的黄斑快速对焦,这是一张极其难得的生活切片。",
camera: "Leica M6",
lens: "Elmarit 90mm f/2.8",
filmStock: "Kodak Gold 200",
settings: "f/4.0, 1/250s",
},
{
id: "static-love-1",
type: "love",
slug: "anniversary-3years",
title: "三周年:从日落到星空",
date: "2026-05-20",
location: "秦皇岛 · 阿那亚孤独图书馆",
longitude: 119.866068,
latitude: 39.734289,
cover: "/assets/love-anniversary.png",
content: "海浪冲刷着沙滩,我们在阿那亚的孤独图书馆旁坐了很久。从天色微红一直坐到繁星点点,风很大,但因为你靠在身旁,一切都显得无比安详。谢谢你陪我走过的第三个四季。希望下一个三年、十年,我们依然能在世界各个海角仰望同一片星空。",
mood: "romantic",
},
{
id: "static-love-2",
type: "love",
slug: "first-cooking-disaster",
title: "厨房里的“灾难”与大笑",
date: "2026-02-14",
location: "上海 · 卢湾旧租屋",
longitude: 121.4737,
latitude: 31.2304,
cover: "/assets/love-cooking.png",
content: "本来计划做一顿法式红酒炖牛肉,结果因为聊天太投入,红酒收汁过头,牛肉有些焦糊,烟雾报警器还响了起来。我们手忙脚乱地挥动抹布散热,最后只能叫了外卖披萨。但那晚我们开了一瓶好酒,坐在地板上笑了整整一个通宵。其实幸福并不是多么精致的晚宴,而是我们面对灾难时能一起大笑的默契。",
mood: "playful",
},
{
id: "static-love-3",
type: "love",
slug: "rainy-day-museum",
title: "美术馆的无声漫步",
date: "2025-11-18",
location: "上海 · 徐汇西岸美术馆",
longitude: 121.45524,
latitude: 31.18123,
cover: "/assets/love-museum.png",
content: "窗外是阴冷潮湿的上海秋雨,展厅内是巨大而沉静的抽象画作。我们没有太多言语,只是安静地并肩走过一个又一个展厅。有时候,爱情不需要轰轰烈烈的对白,只要在沉默的艺术品前,余光里全是你,就足够温暖。",
mood: "peaceful",
},
];
}
// 按照日期倒序排列,让最新的足迹先展示在顶部
combinedItems.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
return (
<FootprintsPageClient
initialItems={combinedItems}
apiMapKey={mapConfig.key}
apiMapCode={mapConfig.code}
categories={categories}
/>
);
}
+200
View File
@@ -0,0 +1,200 @@
"use client";
import { useState, useEffect, useRef } from "react";
import { motion, AnimatePresence } from "framer-motion";
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import { galleryData, GalleryPhoto } from "@/data/gallery";
import { useGallery } from "@/hooks/useGallery";
import Lightbox from "@/components/gallery/Lightbox";
import GalleryCard from "@/components/gallery/GalleryCard";
if (typeof window !== "undefined") {
gsap.registerPlugin(ScrollTrigger);
}
export default function GalleryPage() {
const { photos, loading } = useGallery();
const [selectedPhoto, setSelectedPhoto] = useState<GalleryPhoto | null>(null);
const [columnsCount, setColumnsCount] = useState(3);
const [mounted, setMounted] = useState(false);
const gridRef = useRef<HTMLDivElement>(null);
const leftColRef = useRef<HTMLDivElement>(null);
const rightColRef = useRef<HTMLDivElement>(null);
// 1. 客户端响应式自适应列数计算
useEffect(() => {
requestAnimationFrame(() => {
setMounted(true);
});
const handleResize = () => {
const width = window.innerWidth;
if (width < 768) {
setColumnsCount(1);
} else if (width < 1024) {
setColumnsCount(2);
} else {
setColumnsCount(3);
}
};
handleResize();
window.addEventListener("resize", handleResize);
return () => window.removeEventListener("resize", handleResize);
}, []);
// 2. GSAP 左右列视差漂移动效 (仅在三列大屏下生效,防移动端重排)
useEffect(() => {
if (!mounted || columnsCount < 3) return;
const ctx = gsap.context(() => {
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
if (reduceMotion) return;
// 左列视差滚动偏慢 (向上滑移偏少)
if (leftColRef.current) {
gsap.fromTo(
leftColRef.current,
{ y: 0 },
{
y: -40,
ease: "none",
scrollTrigger: {
trigger: gridRef.current,
start: "top bottom",
end: "bottom top",
scrub: 0.5,
invalidateOnRefresh: true,
},
}
);
}
// 右列视差滚动偏快 (向上滑移偏多)
if (rightColRef.current) {
gsap.fromTo(
rightColRef.current,
{ y: 0 },
{
y: 40,
ease: "none",
scrollTrigger: {
trigger: gridRef.current,
start: "top bottom",
end: "bottom top",
scrub: 0.5,
invalidateOnRefresh: true,
},
}
);
}
}, gridRef);
// 页面高度更新时刷新缓存
const refreshTimer = setTimeout(() => ScrollTrigger.refresh(), 250);
return () => {
ctx.revert();
clearTimeout(refreshTimer);
};
}, [mounted, columnsCount]);
// 将数据按照列数分发给对应的子数组
const getColumnsData = () => {
const columns: GalleryPhoto[][] = Array.from({ length: columnsCount }, () => []);
photos.forEach((photo, idx) => {
columns[idx % columnsCount].push(photo);
});
return columns;
};
const columns = getColumnsData();
return (
<div className="max-w-7xl mx-auto w-full px-6 md:px-12 py-16 md:py-24">
{/* 栏目头部 */}
<div className="border-b border-charcoal/10 dark:border-white/10 pb-12 mb-20">
<span className="text-[10px] font-sans font-semibold tracking-widest text-charcoal/40 dark:text-white/40 uppercase">
05 / Gallery
</span>
<h1 className="font-serif text-4xl md:text-5xl font-light text-charcoal dark:text-cream mt-2">
Gallery / 影像档案
</h1>
<p className="font-sans text-xs text-charcoal/50 dark:text-white/50 tracking-wider mt-2">
用镜头与感光胶片物理定格的光影。已升级为极简无界艺术杂志排版,左右侧列辅以不对称顶部偏置与 GSAP 视差,实现顺畅呼吸的观看体验。
</p>
</div>
{/* 瀑布流网格 */}
<div ref={gridRef} className="relative z-10 w-full overflow-visible">
{/* 未挂载骨架屏 */}
{!mounted || loading ? (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-12">
{(photos.length > 0 ? photos : galleryData).map((photo) => (
<div
key={photo.id}
className="bg-stone-100 dark:bg-zinc-950 border border-charcoal/5 dark:border-white/5 h-96 rounded-none animate-pulse"
/>
))}
</div>
) : (
<div className="flex gap-12 items-start w-full">
{columns.map((columnItems, colIdx) => {
// 决定分配视差 Ref 绑定
let colRef = undefined;
if (columnsCount === 3) {
if (colIdx === 0) colRef = leftColRef;
if (colIdx === 2) colRef = rightColRef;
}
// 决定不对称顶部偏置,增加版面韵律感 (仅在多列且挂载后应用)
let colOffsetClass = "";
if (columnsCount === 3) {
if (colIdx === 1) colOffsetClass = "pt-20";
if (colIdx === 2) colOffsetClass = "pt-10";
} else if (columnsCount === 2) {
if (colIdx === 1) colOffsetClass = "pt-12";
}
return (
<div
key={colIdx}
ref={colRef}
className={`flex-1 flex flex-col gap-12 will-change-transform ${colOffsetClass}`}
>
<AnimatePresence mode="popLayout">
{columnItems.map((photo) => {
const globalIdx = photos.indexOf(photo);
return (
<motion.div
key={photo.id}
initial={{ opacity: 0, y: 35 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, amount: 0.15 }}
transition={{
duration: 0.7,
ease: [0.16, 1, 0.3, 1], // easeOutQuart
}}
>
<GalleryCard
photo={photo}
index={globalIdx}
onClick={() => setSelectedPhoto(photo)}
/>
</motion.div>
);
})}
</AnimatePresence>
</div>
);
})}
</div>
)}
</div>
{/* 大图查看灯箱 */}
<Lightbox photo={selectedPhoto} onClose={() => setSelectedPhoto(null)} />
</div>
);
}
+583
View File
@@ -0,0 +1,583 @@
@import "tailwindcss";
:root {
--bg-color: #F7F8F1;
--bg-dark-color: #EAF0E5;
--fg-color: #223326;
--border-line-color: rgba(34, 51, 38, 0.1);
--font-heading: var(--font-jost);
--font-body: var(--font-inter);
--accent-color: #D9865F;
--accent-light-color: #F1B894;
/* Section-specific font variables (Personal archive defaults) */
--font-hero-heading: var(--font-jost);
--font-hero-body: var(--font-inter);
--font-writing-heading: var(--font-jost);
--font-writing-body: var(--font-inter);
--font-bento-heading: var(--font-space-grotesk);
--font-bento-body: var(--font-inter);
--font-gallery-heading: var(--font-jost);
--font-gallery-body: var(--font-inter);
--font-quote-heading: var(--font-jost);
/* Font fallback mapping values (Sans-first personal blog system) */
--font-hero-h-val: var(--font-hero-heading), var(--font-noto-serif-sc), system-ui, sans-serif;
--font-hero-b-val: var(--font-hero-body), var(--font-body), sans-serif;
--font-writing-h-val: var(--font-writing-heading), var(--font-noto-serif-sc), system-ui, sans-serif;
--font-writing-b-val: var(--font-writing-body), var(--font-body), sans-serif;
--font-bento-h-val: var(--font-bento-heading), var(--font-body), sans-serif;
--font-bento-b-val: var(--font-bento-body), var(--font-body), sans-serif;
--font-gallery-h-val: var(--font-gallery-heading), var(--font-noto-serif-sc), system-ui, sans-serif;
--font-gallery-b-val: var(--font-gallery-body), var(--font-body), sans-serif;
--font-quote-h-val: var(--font-quote-heading), var(--font-noto-serif-sc), system-ui, sans-serif;
}
/* 暗黑模式变量配置 */
.dark {
--bg-color: #17211B;
--bg-dark-color: #203027;
--fg-color: #F1F4EA;
--border-line-color: rgba(241, 244, 234, 0.12);
--font-heading: var(--font-jost);
--font-body: var(--font-inter);
--accent-color: #F1A77C;
--accent-light-color: #F5C6A8;
}
@theme {
--color-cream: var(--bg-color);
--color-cream-dark: var(--bg-dark-color);
--color-charcoal: var(--fg-color);
--color-gold: var(--accent-color);
--color-gold-light: var(--accent-light-color);
--color-border-line: var(--border-line-color);
--font-sans: var(--font-body), system-ui, sans-serif;
--font-serif: var(--font-heading), var(--font-noto-serif-sc), Georgia, serif;
/* Module specific font theme mappings using fallback variables */
--font-hero-h: var(--font-hero-h-val);
--font-hero-b: var(--font-hero-b-val);
--font-writing-h: var(--font-writing-h-val);
--font-writing-b: var(--font-writing-b-val);
--font-bento-h: var(--font-bento-h-val);
--font-bento-b: var(--font-bento-b-val);
--font-gallery-h: var(--font-gallery-h-val);
--font-gallery-b: var(--font-gallery-b-val);
--font-quote-h: var(--font-quote-h-val);
}
/* ==========================================================================
UI/UX Pro Max 风格系统定义
========================================================================== */
@import "./styles/themes/life.css";
@import "./styles/themes/swiss.css";
@import "./styles/themes/minimalist.css";
@import "./styles/themes/glass.css";
@import "./styles/themes/brutalist.css";
body {
background-color: var(--bg-color);
color: var(--fg-color);
font-family: var(--font-sans);
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
transition: background-color 0.6s cubic-bezier(0.25, 1, 0.5, 1), color 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}
html {
scrollbar-color:
color-mix(in srgb, var(--accent-color) 72%, var(--fg-color) 28%)
color-mix(in srgb, var(--bg-dark-color) 82%, transparent);
scrollbar-width: thin;
}
html::-webkit-scrollbar {
width: 12px;
}
html::-webkit-scrollbar-track {
background:
linear-gradient(
180deg,
color-mix(in srgb, var(--bg-color) 86%, white 14%),
color-mix(in srgb, var(--bg-dark-color) 88%, var(--accent-light-color) 12%)
);
border-left: 1px solid color-mix(in srgb, var(--fg-color) 10%, transparent);
}
html::-webkit-scrollbar-thumb {
border: 3px solid color-mix(in srgb, var(--bg-color) 88%, white 12%);
border-radius: 999px;
background:
linear-gradient(
180deg,
color-mix(in srgb, var(--accent-light-color) 82%, white 18%),
color-mix(in srgb, var(--accent-color) 76%, var(--fg-color) 24%)
);
box-shadow:
inset 0 1px 0 rgb(255 255 255 / 0.45),
0 0 0 1px color-mix(in srgb, var(--fg-color) 8%, transparent);
}
html::-webkit-scrollbar-thumb:hover {
background:
linear-gradient(
180deg,
color-mix(in srgb, var(--accent-light-color) 72%, white 28%),
color-mix(in srgb, var(--accent-color) 88%, var(--fg-color) 12%)
);
}
/* 全局应用渐变过渡以配合明暗主题切换(限制选择器以避免通配符导致的性能崩溃) */
body, header, footer, main, button, input, textarea, a,
.writing-card, .bg-cream, .bg-charcoal, .border, .text-charcoal, .text-cream {
transition: background-color 0.6s cubic-bezier(0.25, 1, 0.5, 1),
border-color 0.6s cubic-bezier(0.25, 1, 0.5, 1),
color 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}
/* 胶片颗粒感遮罩层 (使用高效静态 Base64 平铺 PNG 代替 CPU 密集型 SVG 动态噪点滤镜) */
.film-grain {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAA5u7F8AAAADFBMVEUAAAAAAAAAAAAAAAA17ypIAAAABHRSTlMAr6+vp0hMSgAAAElJREFUeNqVzckNADAMwzD33/Q610uDQDwgCSpq7F2t965Gey2j5Y6WG8peKOcCOV/A+QPOD3B+gPMDnB/g/ADnBzg/wPkBzg/4/wA8xQEVO2D2OAAAAABJRU5ErkJggg==");
background-repeat: repeat;
opacity: 0.035;
pointer-events: none;
z-index: 9999;
}
.dark .film-grain {
opacity: 0.02; /* 暗模式下略微减弱噪点强度 */
}
/* 动态背景视频过渡 */
.bg-video {
transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}
/* 自定义文字选择 */
::selection {
background-color: var(--color-gold-light);
color: #1A1A1A;
}
/* 隐藏 Lenis 滚动条默认样式以配合高级排版 */
html.lenis, html.lenis body {
height: auto;
}
.lenis-smooth {
scroll-behavior: auto !important;
}
.lenis-smooth [data-lenis-prevent] {
overscroll-behavior: contain;
}
.lenis-stopped {
overflow: hidden;
}
.lenis-scrolling iframe {
pointer-events: none;
}
/* 细线条风格 */
.divider-h {
width: 100%;
height: 1px;
background-color: var(--color-border-line);
}
.divider-v {
width: 1px;
height: 100%;
background-color: var(--color-border-line);
}
/* 双边框细线样式 */
.border-double-line {
border-bottom: 3px double var(--color-border-line);
}
/* 文字遮罩显示效果基础 */
.char-mask {
overflow: hidden;
display: inline-block;
vertical-align: bottom;
}
.char-inner {
display: inline-block;
transform: translateY(100%);
}
/* ==========================================================================
背景图片及卡片可读性优化(防止背景图片亮度过高遮挡文字)
========================================================================== */
.bg-image-layer {
opacity: 0.1 !important;
transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}
.dark .bg-image-layer {
opacity: 0.05 !important;
}
.style-glass .bg-image-layer {
opacity: 0.22 !important;
}
.style-minimalist .bg-image-layer {
opacity: 0.04 !important;
}
.style-brutalist .bg-image-layer {
opacity: 0 !important;
}
/* 实色卡片高对比度类,用于防止卡片内容在强背景下看不清 */
.high-contrast-card {
background-color: var(--bg-color) !important;
border: 1px solid var(--border-line-color) !important;
}
.style-glass .high-contrast-card {
background-color: rgba(255, 255, 255, 0.08) !important;
backdrop-filter: blur(20px) saturate(120%) !important;
-webkit-backdrop-filter: blur(20px) saturate(120%) !important;
border: 1px solid rgba(255, 255, 255, 0.15) !important;
}
.dark.style-glass .high-contrast-card {
background-color: rgba(15, 12, 28, 0.5) !important;
border: 1px solid rgba(255, 255, 255, 0.12) !important;
}
.style-minimalist .high-contrast-card {
background-color: var(--bg-dark-color) !important;
border-color: transparent !important;
box-shadow: none !important;
}
.style-brutalist .high-contrast-card {
background-color: var(--bg-color) !important;
border: 2px solid var(--border-line-color) !important;
box-shadow: 4px 4px 0px var(--border-line-color) !important;
}
/* 隐藏默认横向滚动条 */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
.no-scrollbar,
.scrollbar-none {
-ms-overflow-style: none;
scrollbar-width: none;
}
.scrollbar-none::-webkit-scrollbar {
display: none;
}
/* 硬件加速以调优横滚流畅度 */
.gpu-accelerated-track {
will-change: transform;
transform: translate3d(0, 0, 0);
}
/* 自动跑马灯滑道双端半透明羽化遮罩 */
.mask-image-horizontal {
mask-image: linear-gradient(to right, transparent, white 15%, white 85%, transparent);
-webkit-mask-image: linear-gradient(to right, transparent, white 15%, white 85%, transparent);
}
/* 首页开屏底部的低矮动态波浪 */
.home-hero-wave {
height: clamp(5rem, 10vw, 8.5rem);
transform: translateY(1px);
}
.waves {
position: relative;
display: block;
width: 100%;
height: 100%;
margin-bottom: -7px;
}
.wave-parallax > use {
animation: atlas-wave-drift 25s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite;
will-change: transform;
}
.wave-layer-1 {
fill: color-mix(in srgb, var(--bg-color) 70%, var(--accent-light-color) 30%);
opacity: 0.7;
animation-delay: -2s;
animation-duration: 7s;
}
.wave-layer-2 {
fill: color-mix(in srgb, var(--bg-color) 82%, var(--accent-light-color) 18%);
opacity: 0.55;
animation-delay: -3s;
animation-duration: 10s;
}
.wave-layer-3 {
fill: color-mix(in srgb, var(--bg-color) 90%, var(--accent-light-color) 10%);
opacity: 0.4;
animation-delay: -4s;
animation-duration: 13s;
}
.wave-layer-4 {
fill: var(--bg-color);
animation-delay: -5s;
animation-duration: 20s;
}
@keyframes atlas-wave-drift {
0% {
transform: translate3d(-90px, 0, 0);
}
100% {
transform: translate3d(85px, 0, 0);
}
}
/* Footer window decoration, shown only when the document bottom is reached */
.footer-peekers {
position: absolute;
inset-inline: 0;
top: 0;
z-index: 2;
pointer-events: none;
transform: translateY(calc(-100% + 8px));
opacity: 0;
visibility: hidden;
}
.footer-peekers-image {
position: relative;
z-index: 1;
width: min(48rem, 74vw);
filter: drop-shadow(0 16px 24px color-mix(in srgb, var(--fg-color) 12%, transparent));
}
.footer-peekers-image img {
display: block;
width: 100%;
height: auto;
}
.footer-peekers-floating {
position: fixed;
inset-inline: 0;
bottom: 0;
z-index: 30;
pointer-events: none;
opacity: 1;
transform: translateY(8px);
/* Visibility / fade is driven by GSAP (see FloatingFooterPeekers); no CSS
transition here so the scroll-scrubbed cross-dissolve is not double-eased. */
}
.footer-peekers-floating-image {
position: relative;
z-index: 1;
width: min(48rem, 74vw);
filter: drop-shadow(0 16px 24px color-mix(in srgb, var(--fg-color) 12%, transparent));
}
.footer-peekers-floating-image img {
display: block;
width: 100%;
height: auto;
}
@media (max-width: 1023px) {
.footer-peekers-image,
.footer-peekers-floating-image {
width: min(44rem, 86vw);
}
}
@media (max-width: 640px) {
.footer-peekers-image,
.footer-peekers-floating-image {
width: 104vw;
}
}
@media (prefers-reduced-motion: reduce) {
.wave-parallax > use {
animation: none;
transform: translate3d(0, 0, 0);
}
.ecg-flow-left,
.ecg-flow-right,
.outer-dashed-ring {
animation: none;
}
}
/* Alternating slanted clip paths for writing cards */
.clip-even-img {
clip-path: polygon(0 0, 100% 0, 100% 88%, 0 100%);
}
.clip-odd-img {
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 88%);
}
@media (min-width: 768px) {
.clip-even-img {
clip-path: polygon(0 0, 45% 0, 37% 100%, 0 100%);
}
.clip-odd-img {
clip-path: polygon(55% 0, 100% 0, 100% 100%, 63% 100%);
}
}
/* ==========================================================================
性能与硬件加速渲染优化系统
========================================================================== */
/* 1. 硬件加速弹幕节点:将弹幕隔离为独立的 GPU 合成层,避免滚动或位移时与高清视频背景混合重绘 */
.love-danmaku-node {
will-change: transform;
backface-visibility: hidden;
}
@keyframes ecgFlowLeft {
0% {
stroke-dashoffset: 80;
}
100% {
stroke-dashoffset: 0;
}
}
@keyframes ecgFlowRight {
0% {
stroke-dashoffset: -80;
}
100% {
stroke-dashoffset: 0;
}
}
.ecg-flow-left {
stroke-dasharray: 20 60;
animation: ecgFlowLeft 3.5s linear infinite;
}
.ecg-flow-right {
stroke-dasharray: 20 60;
animation: ecgFlowRight 3.5s linear infinite;
}
.outer-dashed-ring {
animation: rotateRing 15s linear infinite;
}
@keyframes rotateRing {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.perspective {
perspective: 1000px;
}
.transform-style-3d {
transform-style: preserve-3d;
}
.backface-hidden {
backface-visibility: hidden;
}
.rotate-y-180 {
transform: rotateY(180deg);
}
/* 2. 硬件加速大半径高斯模糊背景层:避免在滚动时造成全屏重排与掉帧 */
.glass-glows {
will-change: transform;
backface-visibility: hidden;
}
/* 3. 硬件加速胶片噪点层:将其固定到 GPU 合成图层上,避免与滚动层发生图层拉扯 */
.film-grain {
will-change: transform;
backface-visibility: hidden;
}
/* ==========================================================================
ListeningCard 音乐频谱跳动动画 (自定义)
========================================================================== */
@keyframes bar-jump-1 {
0%, 100% { transform: scaleY(0.3); }
50% { transform: scaleY(1); }
}
@keyframes bar-jump-2 {
0%, 100% { transform: scaleY(0.4); }
50% { transform: scaleY(1.2); }
}
@keyframes bar-jump-3 {
0%, 100% { transform: scaleY(0.25); }
50% { transform: scaleY(0.85); }
}
@keyframes bar-jump-4 {
0%, 100% { transform: scaleY(0.5); }
50% { transform: scaleY(1.1); }
}
@keyframes bar-jump-5 {
0%, 100% { transform: scaleY(0.35); }
50% { transform: scaleY(0.95); }
}
.animate-bar-jump-1 {
animation: bar-jump-1 1.2s ease-in-out infinite;
transform-origin: bottom;
}
.animate-bar-jump-2 {
animation: bar-jump-2 0.9s ease-in-out infinite;
transform-origin: bottom;
}
.animate-bar-jump-3 {
animation: bar-jump-3 1.4s ease-in-out infinite;
transform-origin: bottom;
}
.animate-bar-jump-4 {
animation: bar-jump-4 1.1s ease-in-out infinite;
transform-origin: bottom;
}
.animate-bar-jump-5 {
animation: bar-jump-5 1.3s ease-in-out infinite;
transform-origin: bottom;
}
/* ==========================================================================
GalleryCard 暗角纹理 (自定义)
========================================================================== */
.bg-radial-vignette {
background: radial-gradient(circle, transparent 40%, rgba(0, 0, 0, 0.75) 100%);
}
/* 隐藏 Next.js 本地开发状态指示器 */
nextjs-portal, #__next-prerender-indicator {
display: none !important;
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 362 KiB

+148
View File
@@ -0,0 +1,148 @@
import type { Metadata } from "next";
import { Inter, Cormorant_Garamond, Playfair_Display, Space_Grotesk, Space_Mono, Jost, Noto_Serif_SC, Ma_Shan_Zheng } from "next/font/google";
import "./globals.css";
import Navbar from "@/components/Navbar";
import Footer from "@/components/Footer";
import FloatingFooterPeekers from "@/components/ui/FloatingFooterPeekers";
import SmoothScroll from "@/components/ui/SmoothScroll";
import StyleConsole from "@/components/ui/StyleConsole";
import BackToTop from "@/components/ui/BackToTop";
import TapeStation from "@/components/ui/TapeStation";
import ThemeApplier from "@/components/ui/ThemeApplier";
const inter = Inter({
variable: "--font-inter",
subsets: ["latin"],
});
const cormorant = Cormorant_Garamond({
variable: "--font-cormorant",
subsets: ["latin"],
weight: ["300", "400", "500", "600", "700"],
style: ["normal", "italic"],
});
const playfair = Playfair_Display({
variable: "--font-playfair",
subsets: ["latin"],
weight: ["400", "500", "600", "700"],
style: ["normal", "italic"],
});
const spaceGrotesk = Space_Grotesk({
variable: "--font-space-grotesk",
subsets: ["latin"],
weight: ["300", "400", "500", "600", "700"],
});
const spaceMono = Space_Mono({
variable: "--font-space-mono",
subsets: ["latin"],
weight: ["400", "700"],
});
const jost = Jost({
variable: "--font-jost",
subsets: ["latin"],
weight: ["300", "400", "500", "600", "700"],
});
const notoSerifSC = Noto_Serif_SC({
variable: "--font-noto-serif-sc",
preload: false,
weight: ["300", "400", "500", "600", "700"],
display: "swap",
});
const maShanZheng = Ma_Shan_Zheng({
variable: "--font-ma-shan-zheng",
weight: "400",
subsets: ["latin"],
preload: false,
});
export async function generateMetadata(): Promise<Metadata> {
let title = "春风不解别离 | 个人生活档案馆";
let faviconUrl = "/icon.png";
try {
const res = await fetch("http://localhost:8080/api/config/public", { next: { revalidate: 10 } });
if (res.ok) {
const data = await res.json();
if (data.code === 200 && Array.isArray(data.data)) {
const titleItem = data.data.find((c: any) => c.configKey === "site.title.default");
if (titleItem?.configValue) {
title = titleItem.configValue;
}
const favItem = data.data.find((c: any) => c.configKey === "site.favicon.url");
if (favItem?.configValue) {
faviconUrl = favItem.configValue;
}
}
}
} catch (e) {
console.warn("Failed to fetch root metadata:", e);
}
return {
title,
description: "春风得意马蹄疾,不信人间有别离。承载思想随笔、时间胶囊、恋爱纪实与日常影像的私人电子展厅。",
icons: {
icon: faviconUrl,
}
};
}
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html
lang="zh"
className={`${inter.variable} ${cormorant.variable} ${playfair.variable} ${spaceGrotesk.variable} ${spaceMono.variable} ${jost.variable} ${notoSerifSC.variable} ${maShanZheng.variable} h-full antialiased`}
>
<body className="min-h-full flex flex-col text-charcoal bg-transparent">
<ThemeApplier />
{/* 1. 全局底色层 (z-0) */}
<div className="fixed inset-0 z-0 bg-cream pointer-events-none" />
{/* 2. 静态高定背景图片层 (z-1) */}
<div
className="fixed inset-0 z-1 pointer-events-none bg-cover bg-center bg-image-layer"
style={{ backgroundImage: "url('/bg-image.png')" }}
/>
{/* 2.5 霓虹发光灯效层 (仅在 Glassmorphic 风格下可见) */}
<div className="fixed inset-0 z-[2] opacity-0 pointer-events-none transition-opacity duration-1000 glass-glows overflow-hidden">
<div className="absolute top-[10%] left-[5%] w-[45vw] h-[45vw] rounded-full bg-pink-500/10 dark:bg-pink-500/15 blur-[120px]" />
<div className="absolute bottom-[15%] right-[5%] w-[50vw] h-[50vw] rounded-full bg-blue-500/15 dark:bg-blue-500/20 blur-[150px]" />
</div>
{/* 3. 电影胶片质感颗粒图层 (z-50, 保证极弱噪点铺在最上层) */}
<div className="film-grain" />
{/* 4. 网页主内容容器 (z-10),拥有显式正值 z-index,保证所有文字、按钮绝对不被背景或视频遮挡 */}
<div className="relative z-10 min-h-full flex flex-col">
<SmoothScroll>
<Navbar />
<main className="grow flex flex-col">{children}</main>
<Footer />
</SmoothScroll>
</div>
{/* 5. 全站底部趴窗装饰,接近 footer 时停靠到 footer 顶部 */}
<FloatingFooterPeekers />
{/* 6. 悬浮的视觉控制中心 */}
<StyleConsole />
{/* 7. 全局回到顶部按钮 */}
<BackToTop />
{/* 8. 治愈系磁带播放器 */}
<TapeStation />
</body>
</html>
);
}
+119
View File
@@ -0,0 +1,119 @@
"use client";
import { useState, useEffect } from "react";
import { notFound } from "next/navigation";
import { useSysConfig } from "@/hooks/useSysConfig";
import EnvelopeCard from "@/components/letter/EnvelopeCard";
import LetterModal from "@/components/letter/LetterModal";
import { getTimeLetterList } from "@/api/letter";
interface CapsuleLetter {
id: string;
title: string;
targetDate: string; // ISO 日期
bypassCode: string; // 绕过密码
prompt: string; // 胶囊预告
content: string; // 信件内容
images?: string;
}
export default function LetterPage() {
const { isPageEnabled, loading } = useSysConfig();
const [letters, setLetters] = useState<CapsuleLetter[]>([]);
const [activeLetter, setActiveLetter] = useState<CapsuleLetter | null>(null);
const [unlockedIds, setUnlockedIds] = useState<string[]>([]);
useEffect(() => {
const fetchLetters = async () => {
try {
const res = await getTimeLetterList();
if (res.data?.code === 200) {
const list = (res.data.data || []).map((item: any) => ({
id: String(item.id),
title: item.title,
targetDate: item.targetDate,
bypassCode: item.bypassCode || "",
prompt: item.prompt || "",
content: item.content || "",
images: item.images || ""
}));
console.log("[岁月信箱] 动态加载的未来信札列表:", list);
setLetters(list);
}
} catch (err) {
console.error("Failed to fetch letters", err);
}
};
fetchLetters();
}, []);
if (!loading && !isPageEnabled("page.letter.enable", true)) {
notFound();
return null;
}
const handleOpenLetter = (letter: CapsuleLetter) => {
setActiveLetter(letter);
};
const handleUnlockSuccess = (id: string) => {
setUnlockedIds([...unlockedIds, id]);
};
return (
<div className="max-w-6xl mx-auto w-full px-4 md:px-8 py-24 md:py-32 relative">
{/* 3D 书桌皮质/木质档案垫板容器 */}
<div className="relative bg-cream border border-charcoal/10 rounded-3xl p-8 md:p-12 shadow-[0_20px_50px_-20px_rgba(23,33,27,0.3)] overflow-hidden">
{/* 精致拟真黄铜回形针 (Paper Clip) - 别在信笺的左上角 */}
<div className="absolute top-8 left-8 w-6 h-14 border-2 border-[#D4AF37]/50 rounded-full pointer-events-none rotate-[25deg] z-20 shadow-[2px_4px_6px_rgba(0,0,0,0.15)] flex justify-center">
{/* 回形针内折叠金属环 */}
<div className="absolute top-2 w-3.5 h-10 border border-[#D4AF37]/60 rounded-full" />
{/* 回形针最内层回环 */}
<div className="absolute top-4 w-2 h-7 border border-[#D4AF37]/50 rounded-full" />
</div>
{/* 右上角精致信箱标签印花 */}
<div className="absolute top-8 right-8 font-mono text-[8px] tracking-widest text-[#B5A891]/40 dark:text-white/20 uppercase pointer-events-none select-none text-right hidden sm:block">
<span>SPRING TIME-BOX</span>
<br />
<span>EST. 2026.06</span>
</div>
{/* 栏目头部 */}
<div className="border-b border-charcoal/10 dark:border-white/10 pb-10 mb-12 relative pl-8">
<span className="text-[10px] font-sans font-semibold tracking-widest text-charcoal/40 uppercase">
08 / Time Capsule
</span>
<h1 className="font-serif text-4xl md:text-5xl font-light text-charcoal dark:text-cream mt-2 tracking-wide">
Letter / 岁月信箱
</h1>
<p className="font-sans text-xs text-charcoal/50 tracking-wider mt-2.5 max-w-[60ch] leading-relaxed">
投递给未来自己的时光胶囊。它们静静沉睡于「春风不解别离」逻辑舱中,将在倒计时归零时解封开启,亦可输入对应的时空秘钥提前唤醒阅读。
</p>
</div>
{/* 实体信卡列表 - 采用符合网格的 2 列排列 */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 md:gap-12 relative z-10 px-2">
{letters.map((letter) => (
<EnvelopeCard
key={letter.id}
letter={letter}
unlockedIds={unlockedIds}
onClick={() => handleOpenLetter(letter)}
/>
))}
</div>
</div>
{/* 模块化信件查看弹窗 */}
<LetterModal
letter={activeLetter}
onClose={() => setActiveLetter(null)}
unlockedIds={unlockedIds}
onUnlockSuccess={handleUnlockSuccess}
/>
</div>
);
}
+36
View File
@@ -0,0 +1,36 @@
import { notFound } from "next/navigation";
import LovePageClient from "@/components/love/LovePageClient";
import { getPublicConfig } from "@/api/config";
interface PublicConfig {
configKey: string;
configValue: string;
}
async function getPublicConfigs(): Promise<Record<string, string>> {
try {
const response = await getPublicConfig();
const payload = response.data;
if (payload?.code === 200 && Array.isArray(payload.data)) {
const configMap: Record<string, string> = {};
payload.data.forEach((item: any) => {
configMap[item.configKey] = item.configValue;
});
return configMap;
}
} catch (error) {
console.warn("Love page config unavailable, using empty fallback.", error);
}
return {};
}
export default async function LovePage() {
const configs = await getPublicConfigs();
const enabled = configs["page.love.enable"] !== "false";
if (!enabled) {
notFound();
}
return <LovePageClient configs={configs} />;
}
+856
View File
@@ -0,0 +1,856 @@
"use client";
import React, { useState, useEffect, useRef, useMemo } from "react";
import { getNotesList, createNote } from "@/api/notes";
import { motion, AnimatePresence } from "framer-motion";
import gsap from "gsap";
import {
Notebook,
Clock,
Funnel,
Sparkle,
PaperPlaneRight,
Database,
TextAlignLeft
} from "@phosphor-icons/react";
interface Note {
id: number;
date?: string;
time?: string;
content: string;
mood?: string;
createTime?: string;
}
// 情绪相关的辅助函数
const getMoodEmoji = (m?: string) => {
switch (m) {
case 'happy': return '😊';
case 'calm': return '🌿';
case 'tired': return '🥱';
case 'love': return '💓';
case 'blue': return '🍂';
default: return '📝';
}
};
const translateMood = (m?: string) => {
switch (m) {
case 'happy': return '喜悦';
case 'calm': return '平静';
case 'tired': return '疲惫';
case 'love': return '心动';
case 'blue': return '忧郁';
default: return '随笔';
}
};
const getMoodStyle = (m?: string) => {
switch (m) {
case 'happy': return 'bg-orange-500/10 text-orange-600 dark:text-orange-400 border-orange-500/15';
case 'calm': return 'bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/15';
case 'tired': return 'bg-zinc-500/10 text-zinc-600 dark:text-zinc-400 border-zinc-500/15';
case 'love': return 'bg-red-500/10 text-red-600 dark:text-red-400 border-red-500/15';
case 'blue': return 'bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/15';
default: return 'bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/15';
}
};
// 拟真便签卡片组件,集成了 GSAP 3D Hover Tilt 倾斜和颤动回弹动效
const NoteCard = ({ note }: { note: Note }) => {
const cardRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const el = cardRef.current;
if (!el) return;
// 创建高频物理磁吸偏转过渡
const xTo = gsap.quickTo(el, "rotationY", { duration: 0.5, ease: "power2.out" });
const yTo = gsap.quickTo(el, "rotationX", { duration: 0.5, ease: "power2.out" });
const onMouseMove = (e: MouseEvent) => {
const rect = el.getBoundingClientRect();
const mouseX = e.clientX - rect.left - rect.width / 2;
const mouseY = e.clientY - rect.top - rect.height / 2;
// 倾斜角度控制在 3.5 度以内,保持优雅低调的物理空间感
const rotateY = (mouseX / (rect.width / 2)) * 3.5;
const rotateX = -(mouseY / (rect.height / 2)) * 3.5;
xTo(rotateY);
yTo(rotateX);
};
const onMouseLeave = () => {
xTo(0);
yTo(0);
// 回弹时产生微微震颤的阻尼效果
gsap.to(el, {
y: 0,
scale: 1,
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.01)",
duration: 0.8,
ease: "elastic.out(1.2, 0.5)"
});
};
const onMouseEnter = () => {
gsap.to(el, {
y: -4,
scale: 1.01,
boxShadow: "0 12px 30px rgba(0, 0, 0, 0.05)",
duration: 0.3,
ease: "power2.out"
});
};
el.addEventListener("mousemove", onMouseMove);
el.addEventListener("mouseleave", onMouseLeave);
el.addEventListener("mouseenter", onMouseEnter);
return () => {
el.removeEventListener("mousemove", onMouseMove);
el.removeEventListener("mouseleave", onMouseLeave);
el.removeEventListener("mouseenter", onMouseEnter);
};
}, []);
const noteDate = useMemo(() => {
if (note.createTime) {
return note.createTime.split("T")[0];
}
return note.date || "";
}, [note]);
const noteTime = useMemo(() => {
if (note.createTime) {
const t = note.createTime.split("T")[1];
return t ? t.slice(0, 5) : "";
}
return note.time || "";
}, [note]);
return (
<div
ref={cardRef}
style={{ transformStyle: "preserve-3d", perspective: 1000 }}
className="note-card-anim group relative bg-[#FDFBF7] dark:bg-[#1E2521] border border-charcoal/10 dark:border-white/10 rounded-2xl p-6 shadow-[0_4px_20px_rgba(0,0,0,0.01)] flex flex-col justify-between min-h-[160px] overflow-hidden transition-shadow duration-500"
>
{/* 顶部手写便利贴半透明胶带纸效果 */}
<div className="absolute -top-3 left-1/2 -translate-x-1/2 w-16 h-4 bg-yellow-100/25 dark:bg-yellow-950/10 border-x border-dashed border-yellow-400/20 backdrop-blur-[0.5px] rotate-1 z-20 pointer-events-none" />
{/* 正文区域 */}
<div className="space-y-4">
{/* 情绪微型标签 */}
{note.mood && (
<div className="flex">
<span className={`inline-flex items-center gap-1 px-2 py-0.5 rounded-full border text-[10px] font-semibold tracking-wide ${getMoodStyle(note.mood)}`}>
<span>{getMoodEmoji(note.mood)}</span>
<span>{translateMood(note.mood)}</span>
</span>
</div>
)}
<p className="font-serif text-base md:text-lg leading-relaxed text-charcoal/80 dark:text-cream/80 font-light tracking-wide break-words whitespace-pre-wrap">
{note.content}
</p>
</div>
{/* 底部时间与操作栏 */}
<div className="mt-6 pt-4 border-t border-charcoal/5 dark:border-white/5 flex justify-between items-center text-[10px] font-mono text-charcoal/40 dark:text-white/40">
<span className="flex items-center gap-1.5">
<Clock className="w-3.5 h-3.5 text-gold/80" />
{noteDate.replace(/-/g, ".")} {"//"} {noteTime}
</span>
</div>
</div>
);
};
export default function NotesPage() {
const [notes, setNotes] = useState<Note[]>([]);
const [input, setInput] = useState("");
const [mood, setMood] = useState("calm");
const [currentPage, setCurrentPage] = useState(1);
const [searchQuery, setSearchQuery] = useState("");
const pageRef = useRef<HTMLDivElement>(null);
const inputCardRef = useRef<HTMLDivElement>(null);
// 从后端及 localStorage 加载便签
useEffect(() => {
const savedNotes = localStorage.getItem("atlas_notes");
let initialNotes: Note[] = [];
if (savedNotes) {
try {
initialNotes = JSON.parse(savedNotes) as Note[];
} catch (e) {
console.warn("Parse saved notes failed", e);
}
}
const fetchNotes = async () => {
try {
const response = await getNotesList();
const json = response.data;
if (json && json.code === 200 && json.data) {
setNotes(json.data);
return;
}
} catch (e) {
console.warn("Server offline, loading notes from localstorage fallback", e);
}
// 离线回退
if (initialNotes.length > 0) {
setNotes(initialNotes);
} else {
const seeds = [
{
id: 1,
date: "2026-06-21",
time: "23:45",
content: "代码和胶片是一样的。胶片是通过化学反应固定光线,代码是通过编译运行固化逻辑。它们都是把当下的心境与思考变成物理实体的尝试。",
mood: "calm"
},
{
id: 2,
date: "2026-05-14",
time: "08:30",
content: "今早的咖啡偏酸。读书读到这一句:‘人们说时间流逝,但时间什么也没做,流逝的是我们自己。’ 突然很有共鸣。",
mood: "blue"
},
{
id: 3,
date: "2026-04-20",
time: "19:15",
content: "写了一个平滑滚动的动效,调试了很久阻尼系数。看着网页顺滑地跟随滚轮移动,那种舒适感很难向不写前端的人解释。",
mood: "happy"
},
{
id: 4,
date: "2026-03-08",
time: "14:10",
content: "在老式相机里塞进了一卷过期十年的 Kodak Gold 200。很期待冲洗出来的颗粒感。时间在感光乳剂上的老化,本身就是一种天然的滤镜。",
mood: "love"
}
];
setNotes(seeds);
localStorage.setItem("atlas_notes", JSON.stringify(seeds));
}
};
fetchNotes();
}, []);
// 主导心情计算:以列表中最新一条随笔的心情为底色
const dominantMood = useMemo(() => {
if (notes.length === 0) return "calm";
return notes[0].mood || "calm";
}, [notes]);
// 情绪流体背景 GSAP 缓动逻辑
useEffect(() => {
// 浅色模式色彩配置
const moodColors: Record<string, { c1: string; c2: string; c3: string }> = {
happy: { c1: "hsla(28, 90%, 88%, 0.75)", c2: "hsla(45, 90%, 88%, 0.75)", c3: "hsla(15, 80%, 90%, 0.55)" }, // 暖沙橘黄
calm: { c1: "hsla(140, 45%, 88%, 0.75)", c2: "hsla(170, 40%, 88%, 0.75)", c3: "hsla(90, 35%, 90%, 0.55)" }, // 抹茶薄荷
tired: { c1: "hsla(35, 20%, 88%, 0.75)", c2: "hsla(0, 5%, 88%, 0.75)", c3: "hsla(210, 10%, 90%, 0.55)" }, // 麦芽褐灰
love: { c1: "hsla(350, 75%, 90%, 0.75)", c2: "hsla(320, 60%, 90%, 0.75)", c3: "hsla(15, 80%, 90%, 0.55)" }, // 樱粉烟紫
blue: { c1: "hsla(200, 60%, 88%, 0.75)", c2: "hsla(220, 50%, 88%, 0.75)", c3: "hsla(170, 35%, 90%, 0.55)" } // 湖蓝灰绿
};
// 深色模式色彩配置
const moodColorsDark: Record<string, { c1: string; c2: string; c3: string }> = {
happy: { c1: "hsla(28, 55%, 11%, 0.75)", c2: "hsla(45, 45%, 10%, 0.75)", c3: "hsla(15, 40%, 11%, 0.55)" },
calm: { c1: "hsla(140, 25%, 8%, 0.75)", c2: "hsla(170, 20%, 8%, 0.75)", c3: "hsla(90, 18%, 9%, 0.55)" },
tired: { c1: "hsla(35, 12%, 9%, 0.75)", c2: "hsla(0, 5%, 8%, 0.75)", c3: "hsla(210, 8%, 10%, 0.55)" },
love: { c1: "hsla(350, 40%, 11%, 0.75)", c2: "hsla(320, 30%, 11%, 0.75)", c3: "hsla(15, 35%, 11%, 0.55)" },
blue: { c1: "hsla(200, 35%, 9%, 0.75)", c2: "hsla(220, 30%, 10%, 0.75)", c3: "hsla(170, 20%, 9%, 0.55)" }
};
const isDark = document.documentElement.classList.contains("dark");
const palette = isDark ? moodColorsDark : moodColors;
const colors = palette[dominantMood] || palette.calm;
const ctx = gsap.context(() => {
// 1. 心情颜色平缓变化
gsap.to("#fluid-blob-1", {
backgroundColor: colors.c1,
duration: 3,
ease: "power2.out"
});
gsap.to("#fluid-blob-2", {
backgroundColor: colors.c2,
duration: 3,
ease: "power2.out"
});
gsap.to("#fluid-blob-3", {
backgroundColor: colors.c3,
duration: 3,
ease: "power2.out"
});
// 2. 持续位置漂移与呼吸起伏动画
gsap.to("#fluid-blob-1", {
x: "random(-50, 50)",
y: "random(-50, 50)",
scale: "random(0.9, 1.15)",
duration: "random(8, 12)",
repeat: -1,
yoyo: true,
ease: "sine.inOut"
});
gsap.to("#fluid-blob-2", {
x: "random(-60, 60)",
y: "random(-60, 60)",
scale: "random(0.85, 1.1)",
duration: "random(9, 14)",
repeat: -1,
yoyo: true,
ease: "sine.inOut"
});
gsap.to("#fluid-blob-3", {
x: "random(-45, 45)",
y: "random(-45, 45)",
scale: "random(0.9, 1.15)",
duration: "random(7, 11)",
repeat: -1,
yoyo: true,
ease: "sine.inOut"
});
});
return () => ctx.revert();
}, [dominantMood]);
// 输入便签的 GSAP 微交互:聚焦时轻轻抬起
useEffect(() => {
const el = inputCardRef.current;
if (!el) return;
// 表单轻微倾斜,呈现手写本随性放置感
gsap.set(el, { rotation: 1 });
const handleFocus = () => {
gsap.to(el, {
y: -5,
rotation: 0,
boxShadow: "0 10px 25px rgba(0, 0, 0, 0.04)",
duration: 0.4,
ease: "power2.out"
});
};
const handleBlur = () => {
gsap.to(el, {
y: 0,
rotation: 1,
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.02)",
duration: 0.6,
ease: "elastic.out(1.2, 0.6)"
});
};
const textarea = el.querySelector("textarea");
textarea?.addEventListener("focus", handleFocus);
textarea?.addEventListener("blur", handleBlur);
return () => {
textarea?.removeEventListener("focus", handleFocus);
textarea?.removeEventListener("blur", handleBlur);
};
}, []);
// 搜索过滤
const filteredNotes = useMemo(() => {
return notes.filter((note) => {
return note.content.toLowerCase().includes(searchQuery.toLowerCase());
});
}, [notes, searchQuery]);
// 分页计算:每页展示 6 条笔记
const itemsPerPage = 6;
const totalNotes = filteredNotes.length;
const totalPages = Math.ceil(totalNotes / itemsPerPage) || 1;
const activePage = Math.min(Math.max(1, currentPage), totalPages);
const currentPageNotes = useMemo(() => {
return filteredNotes.slice((activePage - 1) * itemsPerPage, activePage * itemsPerPage);
}, [filteredNotes, activePage]);
// 录入动作
const handleAdd = async (e: React.FormEvent) => {
e.preventDefault();
if (!input.trim()) return;
let success = false;
try {
const response = await createNote({ content: input.trim(), mood });
const json = response.data;
if (json && json.code === 200 && json.data) {
setNotes((prev) => [json.data, ...prev]);
success = true;
}
} catch (e) {
console.warn("Create note on server failed, fallback to localstorage", e);
}
if (!success) {
const now = new Date();
const newNote: Note = {
id: Date.now(),
date: now.toISOString().split("T")[0],
time: now.toTimeString().split(" ")[0].slice(0, 5),
content: input.trim(),
mood,
};
const updatedNotes = [newNote, ...notes];
setNotes(updatedNotes);
localStorage.setItem("atlas_notes", JSON.stringify(updatedNotes));
}
setInput("");
setMood("calm");
// 新增便签后自动切回第 1 页
setCurrentPage(1);
// 录入完成时,将输入框卡片轻微抖动,表达物理写下的确认反馈
if (inputCardRef.current) {
gsap.fromTo(inputCardRef.current,
{ scale: 0.97, y: 2 },
{ scale: 1, y: 0, duration: 0.5, ease: "elastic.out(1.5, 0.4)" }
);
}
};
// GSAP 首次加载动效 (静态部分)
useEffect(() => {
const ctx = gsap.context(() => {
gsap.from(".notes-index-card", {
opacity: 0,
y: 40,
duration: 1.0,
ease: "power3.out"
});
gsap.from(".notes-sticky-input", {
opacity: 0,
y: 30,
rotation: -4,
duration: 1.2,
delay: 0.2,
ease: "elastic.out(1.1, 0.55)"
});
gsap.from(".notes-filter-bar", {
opacity: 0,
y: 20,
duration: 0.8,
delay: 0.15,
ease: "power3.out"
});
}, pageRef);
return () => ctx.revert();
}, []);
// 翻页与检索过滤触发 Stagger 发牌动画
useEffect(() => {
if (currentPageNotes.length === 0) return;
const ctx = gsap.context(() => {
gsap.fromTo(".note-card-anim",
{
opacity: 0,
y: 35,
rotation: () => (Math.random() - 0.5) * 2.5,
},
{
opacity: 1,
y: 0,
rotation: () => (Math.random() - 0.5) * 1.5,
duration: 0.8,
stagger: 0.04,
ease: "power3.out"
}
);
}, pageRef);
return () => ctx.revert();
}, [activePage, currentPageNotes.length]);
// 统计指标
const noteCount = notes.length;
const wordCount = useMemo(() => {
return notes.reduce((sum, n) => sum + n.content.length, 0);
}, [notes]);
const lastUpdate = useMemo(() => {
if (notes.length === 0) return "—";
const target = notes[0];
const rawDate = target.createTime ? target.createTime.split("T")[0] : (target.date || "");
return rawDate.replace(/-/g, ".");
}, [notes]);
return (
<div ref={pageRef} className="max-w-6xl mx-auto w-full px-4 md:px-8 py-24 md:py-32 space-y-10 relative">
{/* 情绪流体背景与毛玻璃容器 */}
<div className="fixed inset-0 -z-10 overflow-hidden pointer-events-none opacity-60 dark:opacity-40">
<div
id="fluid-blob-1"
className="absolute -top-20 -left-20 w-[550px] h-[550px] rounded-full blur-[110px] transition-all mix-blend-multiply dark:mix-blend-screen"
style={{ transitionDuration: '3s' }}
/>
<div
id="fluid-blob-2"
className="absolute -bottom-30 -right-30 w-[650px] h-[650px] rounded-full blur-[130px] transition-all mix-blend-multiply dark:mix-blend-screen"
style={{ transitionDuration: '3s' }}
/>
<div
id="fluid-blob-3"
className="absolute top-1/3 left-1/4 w-[480px] h-[480px] rounded-full blur-[100px] transition-all mix-blend-multiply dark:mix-blend-screen"
style={{ transitionDuration: '3s' }}
/>
<div className="absolute inset-0 bg-[#F5F2EB]/15 dark:bg-[#121513]/10 backdrop-blur-[80px]" />
</div>
{/* 1. 档案馆数字索引卡 Header 与 录入区 */}
<div className="notes-index-card bg-white/60 dark:bg-zinc-900/60 backdrop-blur-md border border-charcoal/10 dark:border-white/10 rounded-3xl p-6 md:p-10 shadow-[0_12px_40px_-12px_rgba(0,0,0,0.08)] relative overflow-hidden">
<div className="absolute -top-12 -right-12 w-48 h-48 bg-gold/5 dark:bg-gold/10 rounded-full blur-3xl pointer-events-none" />
<div className="flex flex-col lg:flex-row lg:items-start lg:justify-between gap-8 relative z-10">
{/* 左侧说明 & 数据指标 */}
<div className="space-y-6 max-w-2xl grow">
<div className="flex items-center space-x-3">
<span className="text-[9px] font-mono tracking-[0.2em] text-gold bg-gold/10 px-2.5 py-1 rounded-md uppercase font-semibold">
NO. ATLAS-NOTES-LOCAL
</span>
<span className="flex h-2 w-2 relative">
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>
<span className="relative inline-flex rounded-full h-2 w-2 bg-emerald-500"></span>
</span>
<span className="text-[9px] font-mono text-charcoal/40 dark:text-white/40 uppercase">
ACTIVE WRITER
</span>
</div>
<div className="space-y-3">
<h1 className="font-serif text-4xl md:text-5xl font-light text-charcoal dark:text-white flex items-center gap-2">
Notes / 闪念随笔
</h1>
<p className="font-sans text-xs md:text-sm text-charcoal/60 dark:text-white/60 leading-relaxed max-w-lg">
随性记下微小而无声消逝的瞬间与思考。
这里不谈体系,不求工整,只有碎片。文字是一块块在暗室里等待冲印的底片,静止并留存下当下的感官阻尼。
</p>
</div>
{/* 统计指标卡 */}
<div className="grid grid-cols-3 gap-4 pt-4 border-t border-charcoal/10 dark:border-white/10">
<div className="bg-cream/40 dark:bg-charcoal/30 p-3.5 rounded-2xl border border-charcoal/5 dark:border-white/5 flex flex-col justify-between">
<span className="text-[10px] text-charcoal/50 dark:text-white/50 flex items-center gap-1.5 font-medium">
<Notebook className="w-3.5 h-3.5 text-gold" /> 已载随笔
</span>
<div className="mt-1.5 flex items-baseline gap-1">
<span className="font-serif text-xl md:text-2xl font-light text-charcoal dark:text-white">{noteCount}</span>
<span className="text-[8px] text-charcoal/40 dark:text-white/40 font-mono">ITEMS</span>
</div>
</div>
<div className="bg-cream/40 dark:bg-charcoal/30 p-3.5 rounded-2xl border border-charcoal/5 dark:border-white/5 flex flex-col justify-between">
<span className="text-[10px] text-charcoal/50 dark:text-white/50 flex items-center gap-1.5 font-medium">
<TextAlignLeft className="w-3.5 h-3.5 text-gold" /> 笔录字数
</span>
<div className="mt-1.5 flex items-baseline gap-1">
<span className="font-serif text-xl md:text-2xl font-light text-charcoal dark:text-white">{wordCount}</span>
<span className="text-[8px] text-charcoal/40 dark:text-white/40 font-mono">CHARS</span>
</div>
</div>
<div className="bg-cream/40 dark:bg-charcoal/30 p-3.5 rounded-2xl border border-charcoal/5 dark:border-white/5 flex flex-col justify-between">
<span className="text-[10px] text-charcoal/50 dark:text-white/50 flex items-center gap-1.5 font-medium">
<Database className="w-3.5 h-3.5 text-gold" /> 最近记录
</span>
<div className="mt-1.5 flex items-baseline gap-1">
<span className="font-serif text-sm md:text-base font-light text-charcoal dark:text-white truncate max-w-full leading-normal">{lastUpdate}</span>
</div>
</div>
</div>
{/* 情绪晴雨表 */}
<div className="pt-4 border-t border-charcoal/10 dark:border-white/10 space-y-3">
<span className="text-[10px] text-charcoal/50 dark:text-white/50 flex items-center gap-1.5 font-medium tracking-wider uppercase font-mono">
<Sparkle className="w-3.5 h-3.5 text-gold animate-spin" style={{ animationDuration: '8s' }} /> Mood Tracker / 情绪晴雨表
</span>
{notes.length === 0 ? (
<div className="text-[10px] text-charcoal/40 dark:text-white/40 italic">暂无情绪记录...</div>
) : (
<div className="space-y-2.5">
{/* 情绪渐变分布条 */}
<div className="h-2 rounded-full overflow-hidden flex bg-charcoal/5 dark:bg-white/5 border border-charcoal/5 dark:border-white/5">
{(() => {
const stats = { happy: 0, calm: 0, tired: 0, love: 0, blue: 0, other: 0 };
notes.forEach((n) => {
const m = n.mood || "calm";
if (m in stats) {
stats[m as keyof typeof stats]++;
} else {
stats.other++;
}
});
const total = notes.length;
return [
{ key: "happy", color: "bg-orange-400 dark:bg-orange-500", label: "喜悦" },
{ key: "calm", color: "bg-emerald-400 dark:bg-emerald-500", label: "平静" },
{ key: "tired", color: "bg-zinc-400 dark:bg-zinc-500", label: "疲惫" },
{ key: "love", color: "bg-red-400 dark:bg-red-500", label: "心动" },
{ key: "blue", color: "bg-blue-400 dark:bg-blue-500", label: "忧郁" },
{ key: "other", color: "bg-amber-400 dark:bg-amber-500", label: "其他" }
].map((item) => {
const count = stats[item.key as keyof typeof stats] || 0;
if (count === 0) return null;
const pct = (count / total) * 100;
return (
<div
key={item.key}
className={`${item.color} h-full transition-all duration-500`}
style={{ width: `${pct}%` }}
title={`${item.label}: ${count}条 (${pct.toFixed(1)}%)`}
/>
);
});
})()}
</div>
{/* 情绪文字比重比例 */}
<div className="flex flex-wrap gap-x-4 gap-y-1.5 text-[10px] text-charcoal/50 dark:text-white/50 font-sans select-none">
{(() => {
const stats = { happy: 0, calm: 0, tired: 0, love: 0, blue: 0 };
notes.forEach((n) => {
const m = n.mood || "calm";
if (m in stats) {
stats[m as keyof typeof stats]++;
}
});
return [
{ key: "happy", emoji: "😊", label: "喜悦", colorClass: "text-orange-500 dark:text-orange-400" },
{ key: "calm", emoji: "🌿", label: "平静", colorClass: "text-emerald-500 dark:text-emerald-400" },
{ key: "tired", emoji: "🥱", label: "疲惫", colorClass: "text-zinc-500/70 dark:text-zinc-400/80" },
{ key: "love", emoji: "💓", label: "心动", colorClass: "text-red-500 dark:text-red-400" },
{ key: "blue", emoji: "🍂", label: "忧郁", colorClass: "text-blue-500 dark:text-blue-400" }
].map((item) => {
const count = stats[item.key as keyof typeof stats] || 0;
if (count === 0) return null;
const pct = (count / notes.length) * 100;
return (
<span key={item.key} className="flex items-center gap-1 font-mono">
<span className={item.colorClass}>{item.emoji}</span>
<span>{item.label}</span>
<span className="font-semibold text-charcoal/80 dark:text-white/80">{pct.toFixed(0)}%</span>
</span>
);
});
})()}
</div>
</div>
)}
</div>
</div>
{/* 右侧:手撕纸信笺拟真录入区 */}
<div ref={inputCardRef} className="notes-sticky-input self-stretch lg:self-start bg-[#FCF6E5] dark:bg-[#2C2921] border border-[#EBE3CD] dark:border-[#423C2F] p-5 rounded-2xl shadow-[5px_5px_15px_rgba(0,0,0,0.03)] w-full lg:max-w-md relative flex-shrink-0 flex flex-col justify-between">
{/* 曲别针效果 */}
<div className="absolute -top-1 left-8 w-3.5 h-8 bg-zinc-300/40 dark:bg-zinc-800/60 rounded-b-md border-x border-b border-charcoal/5 dark:border-white/5 shadow-inner" />
<form onSubmit={handleAdd} className="space-y-4">
<div className="text-[9px] font-mono tracking-wider text-amber-900/50 dark:text-amber-200/50 uppercase pl-9 font-semibold flex items-center gap-1">
<Sparkle className="w-3 h-3 text-gold" /> Write a flash...
</div>
<div className="relative border border-amber-900/10 dark:border-amber-200/10 bg-white/20 dark:bg-black/10 focus-within:bg-white/60 dark:focus-within:bg-black/30 rounded-xl p-4 transition-all duration-300">
<textarea
placeholder="记下此刻的一闪之念..."
value={input}
onChange={(e) => setInput(e.target.value)}
className="w-full h-24 bg-transparent text-sm leading-relaxed border-none focus:outline-none placeholder:text-amber-900/35 dark:placeholder:text-amber-200/35 font-sans text-amber-950 dark:text-amber-100 resize-none font-light"
/>
</div>
{/* 心情选择器 */}
<div className="flex flex-col gap-1.5 px-1 select-none">
<span className="text-[10px] text-amber-900/60 dark:text-amber-200/60 font-semibold tracking-wide flex items-center gap-1">
当下心情 / Current Mood:
</span>
<div className="flex flex-wrap items-center gap-1.5">
{[
{ value: "happy", emoji: "😊", label: "喜悦" },
{ value: "calm", emoji: "🌿", label: "平静" },
{ value: "tired", emoji: "🥱", label: "疲惫" },
{ value: "love", emoji: "💓", label: "心动" },
{ value: "blue", emoji: "🍂", label: "忧郁" }
].map((item) => {
const isSelected = mood === item.value;
return (
<button
key={item.value}
type="button"
onClick={() => setMood(item.value)}
className={`flex items-center gap-1 px-2.5 py-1 rounded-full text-[10px] font-sans transition-all duration-350 border cursor-pointer ${
isSelected
? "bg-amber-900/90 text-[#FCF6E5] border-amber-900/90 dark:bg-amber-100 dark:text-amber-950 dark:border-amber-100 font-semibold scale-105 shadow-sm"
: "bg-white/20 border-amber-900/10 text-amber-950/70 hover:bg-white/40 dark:bg-black/10 dark:border-amber-200/10 dark:text-amber-100/70 dark:hover:bg-black/20"
}`}
>
<span>{item.emoji}</span>
<span>{item.label}</span>
</button>
);
})}
</div>
</div>
<div className="flex justify-between items-center text-[10px] font-sans px-1">
<span className="text-amber-900/50 dark:text-amber-200/50 font-mono">
{input.trim().length} chars
</span>
<button
type="submit"
disabled={!input.trim()}
className="inline-flex items-center justify-center gap-1.5 text-[10px] tracking-widest uppercase bg-charcoal text-cream dark:bg-cream dark:text-charcoal hover:bg-gold hover:text-white dark:hover:bg-gold dark:hover:text-cream px-5 py-2 transition-all duration-300 font-sans cursor-pointer rounded-full font-semibold shadow-sm hover:-translate-y-[1px] active:translate-y-0 disabled:opacity-20 disabled:cursor-not-allowed disabled:hover:bg-charcoal disabled:hover:text-cream disabled:hover:translate-y-0"
>
<PaperPlaneRight className="w-3 h-3" /> Record / 写下
</button>
</div>
</form>
</div>
</div>
</div>
{/* 2. 检索过滤栏 */}
<div className="notes-filter-bar flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-4 pb-4 border-b border-charcoal/5 dark:border-white/5 relative z-10">
<div className="flex items-center gap-3">
<span className="text-xs text-charcoal/40 dark:text-white/40 flex items-center gap-1 font-mono">
<Funnel className="w-3.5 h-3.5" /> SEARCH / 检索 :
</span>
<div className="relative">
<input
type="text"
placeholder="搜索随笔正文..."
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="bg-cream/80 dark:bg-charcoal/50 px-4 py-1.5 pr-8 rounded-full border border-charcoal/10 dark:border-white/10 text-xs text-charcoal dark:text-white placeholder:text-charcoal/40 dark:placeholder:text-white/40 focus:outline-none focus:border-gold dark:focus:border-gold w-48 transition-all"
/>
{searchQuery && (
<button
onClick={() => setSearchQuery("")}
className="absolute right-2.5 top-1/2 -translate-y-1/2 text-charcoal/40 dark:text-white/40 hover:text-charcoal dark:hover:text-white text-[10px] font-sans"
>
×
</button>
)}
</div>
</div>
{searchQuery && (
<span className="text-[10px] font-mono text-charcoal/50 dark:text-white/50 bg-cream/50 dark:bg-charcoal/40 px-3 py-1 rounded-full border border-charcoal/5 dark:border-white/5">
找到 {filteredNotes.length} 条符合要求的闪念
</span>
)}
</div>
{/* 空状态显示 */}
{notes.length === 0 && (
<div className="py-24 text-center border-2 border-dashed border-charcoal/10 dark:border-white/10 rounded-3xl max-w-md mx-auto relative z-10">
<Notebook className="w-10 h-10 text-charcoal/20 dark:text-white/20 mx-auto mb-4" />
<p className="text-xs font-sans text-charcoal/40 dark:text-white/40 uppercase tracking-widest">
No notes recorded / 本卷暂无闪念记录
</p>
</div>
)}
{notes.length > 0 && filteredNotes.length === 0 && (
<div className="py-24 text-center border border-dashed border-charcoal/10 dark:border-white/10 rounded-3xl max-w-md mx-auto relative z-10">
<p className="text-xs font-sans text-charcoal/40 dark:text-white/40 uppercase tracking-widest">
No matching results / 未搜索到匹配随笔
</p>
</div>
)}
{/* 3. 随笔卡片网格 - 2 列排布 (每页最多 6 条) */}
{filteredNotes.length > 0 && (
<div className="space-y-10 relative z-10">
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 min-h-[380px] content-start">
<AnimatePresence mode="popLayout" initial={false}>
{currentPageNotes.map((note) => (
<motion.div
key={note.id}
layout
initial={{ opacity: 0, scale: 0.96 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.95 }}
transition={{ duration: 0.25 }}
className="h-full"
>
<NoteCard note={note} />
</motion.div>
))}
</AnimatePresence>
</div>
{/* 4. 精致卡槽式数字页码分页器 */}
{totalPages > 1 && (
<div className="flex items-center justify-between text-[11px] font-sans tracking-widest pt-8 border-t border-charcoal/5 dark:border-white/5 select-none">
<button
type="button"
onClick={() => setCurrentPage((prev) => Math.max(prev - 1, 1))}
disabled={activePage === 1}
className="text-charcoal/70 dark:text-cream/70 hover:text-gold dark:hover:text-gold-light disabled:opacity-20 disabled:hover:text-charcoal/30 cursor-pointer disabled:cursor-not-allowed uppercase transition-colors font-medium"
>
← Older / 更早
</button>
<div className="flex items-center space-x-1.5">
{Array.from({ length: totalPages }).map((_, idx) => {
const pNum = idx + 1;
const isCurrent = activePage === pNum;
return (
<button
key={pNum}
type="button"
onClick={() => setCurrentPage(pNum)}
className={`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-mono transition-all cursor-pointer ${
isCurrent
? "bg-gold text-white font-semibold shadow-sm"
: "text-charcoal/50 dark:text-cream/50 hover:text-gold dark:hover:text-gold-light"
}`}
>
{pNum}
</button>
);
})}
</div>
<button
type="button"
onClick={() => setCurrentPage((prev) => Math.min(prev + 1, totalPages))}
disabled={activePage === totalPages}
className="text-charcoal/70 dark:text-cream/70 hover:text-gold dark:hover:text-gold-light disabled:opacity-20 disabled:hover:text-charcoal/30 cursor-pointer disabled:cursor-not-allowed uppercase transition-colors font-medium"
>
Newer / 更晚 →
</button>
</div>
)}
</div>
)}
</div>
);
}
+88
View File
@@ -0,0 +1,88 @@
"use client";
import LocationCard from "@/components/now/LocationCard";
import FocusCard from "@/components/now/FocusCard";
import ReadingCard from "@/components/now/ReadingCard";
import ListeningCard from "@/components/now/ListeningCard";
import MoodCard from "@/components/now/MoodCard";
import SetupCard from "@/components/now/SetupCard";
import { notFound } from "next/navigation";
import { useSysConfig } from "@/hooks/useSysConfig";
export default function NowPage() {
const { isPageEnabled, configs, loading } = useSysConfig();
if (!loading && !isPageEnabled("page.now.enable", true)) {
notFound();
return null;
}
// 尝试反序列化此时此刻内容数据
let nowData: any = null;
const nowConfig = configs.find((c) => c.configKey === "now.content.json");
if (nowConfig && nowConfig.configValue) {
try {
nowData = JSON.parse(nowConfig.configValue);
} catch (e) {
console.warn("Failed to parse now.content.json", e);
}
}
return (
<div className="max-w-6xl mx-auto w-full px-4 md:px-8 py-24 md:py-32">
<div className="bg-cream/90 border border-charcoal/10 rounded-3xl p-8 md:p-12 shadow-[0_12px_40px_-12px_rgba(0,0,0,0.15)]">
{/* 栏目头部 */}
<div className="border-b border-charcoal/10 dark:border-white/10 pb-10 mb-12">
<span className="text-[10px] font-sans font-semibold tracking-widest text-charcoal/40 dark:text-white/40 uppercase">
07 / Live Status
</span>
<h1 className="font-serif text-4xl md:text-5xl font-light text-charcoal dark:text-cream mt-2">
Now / 此时此刻
</h1>
<p className="font-sans text-xs text-charcoal/50 dark:text-white/50 tracking-wider mt-2">
这是根据 nownownow.com 理念建立的现状版,定期同步我当前生活的关注点。最近更新时间:2026年06月24日。
</p>
</div>
{/* 主面板布局 */}
<div className="grid grid-cols-1 lg:grid-cols-12 gap-12 items-start">
{/* 左侧超大号 Serif NOW 排版 */}
<div className="lg:col-span-4 lg:sticky lg:top-24 space-y-4">
<div className="font-serif text-8xl md:text-9xl font-light tracking-tighter text-charcoal/10 dark:text-white/5 select-none">
NOW.
</div>
<div className="border-l-2 border-gold/40 pl-4 py-1 space-y-2">
<p className="text-xs uppercase font-semibold font-sans tracking-widest text-charcoal dark:text-cream">
Focusing on Less / 专注当下
</p>
<p className="text-xs font-sans font-light leading-relaxed text-charcoal/50 dark:text-white/50 tracking-wider">
“不盲从,不浮躁。在一行代码与一格快门里,寻回自我的稳定叙事。”
</p>
</div>
</div>
{/* 右侧 Bento 卡片网格 */}
<div className="lg:col-span-8 grid grid-cols-1 md:grid-cols-2 gap-8">
{/* 地点 (横跨两栏) */}
<LocationCard data={nowData?.location} />
{/* 正在研究 */}
<FocusCard data={nowData?.focus} />
{/* 正在阅读 */}
<ReadingCard data={nowData?.reading} />
{/* 正在循环 */}
<ListeningCard data={nowData?.listening} />
{/* 精神状态 */}
<MoodCard data={nowData?.mood} />
{/* 工具设备 (横跨两栏) */}
<SetupCard data={nowData?.setup} />
</div>
</div>
</div>
</div>
);
}
+85
View File
@@ -0,0 +1,85 @@
import HomePageClient from "@/components/home/HomePageClient";
import { galleryData } from "@/data/gallery";
import { writingData, Post } from "@/data/writing";
import { getBlogsList } from "@/api/blogs";
import { getGalleryList } from "@/api/gallery";
import { getPublicConfig } from "@/api/config";
async function getFeaturedPosts(): Promise<Post[]> {
try {
const res = await getBlogsList();
const data = res.data;
if (data && data.code === 200) {
return data.data.map((item: any) => ({
slug: item.slug || `post-${item.id}`,
title: item.title,
date: item.createTime ? item.createTime.split("T")[0] : new Date().toISOString().split("T")[0],
category: item.category || "Thoughts",
mood: item.mood || "quiet",
visibility: (item.visibility as any) || "public",
cover: item.cover || "/assets/writing-camera.png",
description: item.summary || "",
content: item.content || ""
})).slice(0, 3);
}
} catch (err) {
console.warn("Home page: API unavailable, using local writingData static fallback.", err);
}
return writingData.slice(0, 3);
}
async function getFeaturedPhotos(): Promise<any[]> {
try {
const res = await getGalleryList();
const data = res.data;
if (data && data.code === 200) {
return data.data.map((item: any) => ({
id: item.slug || `photo-${item.id}`,
title: item.title,
date: item.date ? item.date.split("T")[0] : new Date().toISOString().split("T")[0],
camera: item.camera || "",
lens: item.lens || "",
filmStock: item.filmStock || "",
settings: item.settings || "",
location: item.location || "",
src: item.src || "",
description: item.description || "",
type: item.type || "image"
})).slice(0, 4);
}
} catch (err) {
console.warn("Home page gallery: API unavailable, using local galleryData static fallback.", err);
}
return galleryData.slice(0, 4);
}
async function getPublicConfigs(): Promise<Record<string, string>> {
try {
const res = await getPublicConfig();
const data = res.data;
if (data && data.code === 200 && Array.isArray(data.data)) {
const configMap: Record<string, string> = {};
data.data.forEach((item: any) => {
configMap[item.configKey] = item.configValue;
});
return configMap;
}
} catch (err) {
console.warn("Home page configs: API unavailable, using empty config fallback.", err);
}
return {};
}
export default async function HomePage() {
const featuredPosts = await getFeaturedPosts();
const featuredPhotos = await getFeaturedPhotos();
const configs = await getPublicConfigs();
return (
<HomePageClient
featuredPosts={featuredPosts}
homeGallerySlices={featuredPhotos}
configs={configs}
/>
);
}
File diff suppressed because it is too large Load Diff
+100
View File
@@ -0,0 +1,100 @@
/* 4. 工业黑客粗野主义 (Industrial Brutalism) */
.style-brutalist {
--font-heading: var(--font-space-mono);
--font-body: var(--font-space-mono);
--accent-color: #FF3E3E;
--accent-light-color: #FFAAAA;
--bg-color: #ECECEC;
--bg-dark-color: #DFDFDF;
--fg-color: #000000;
--border-line-color: #000000;
/* Brutalist raw pairings (Space Mono) */
--font-hero-heading: var(--font-space-mono);
--font-hero-body: var(--font-space-mono);
--font-writing-heading: var(--font-space-mono);
--font-writing-body: var(--font-space-mono);
--font-bento-heading: var(--font-space-mono);
--font-bento-body: var(--font-space-mono);
--font-gallery-heading: var(--font-space-mono);
--font-gallery-body: var(--font-space-mono);
--font-quote-heading: var(--font-space-mono);
/* Fallback overrides for Brutalist (console Monospace) */
--font-hero-h-val: var(--font-hero-heading), ui-monospace, SFMono-Regular, monospace;
--font-hero-b-val: var(--font-hero-body), ui-monospace, SFMono-Regular, monospace;
--font-writing-h-val: var(--font-writing-heading), ui-monospace, SFMono-Regular, monospace;
--font-writing-b-val: var(--font-writing-body), ui-monospace, SFMono-Regular, monospace;
--font-bento-h-val: var(--font-bento-heading), ui-monospace, SFMono-Regular, monospace;
--font-bento-b-val: var(--font-bento-body), ui-monospace, SFMono-Regular, monospace;
--font-gallery-h-val: var(--font-gallery-heading), ui-monospace, SFMono-Regular, monospace;
--font-gallery-b-val: var(--font-gallery-body), ui-monospace, SFMono-Regular, monospace;
--font-quote-h-val: var(--font-quote-heading), ui-monospace, SFMono-Regular, monospace;
}
.dark.style-brutalist {
--bg-color: #0A0A0A;
--bg-dark-color: #121212;
--fg-color: #00FF55; /* 黑客终端绿 */
--border-line-color: #00FF55;
--accent-color: #00FF55;
--accent-light-color: #00AA33;
}
/* 工业粗野背景点阵图 */
.style-brutalist body {
background-color: var(--bg-color) !important;
background-image: radial-gradient(var(--border-line-color) 1.5px, transparent 1.5px) !important;
background-size: 20px 20px !important;
}
.style-brutalist .fixed.inset-0.z-1 { /* 隐藏视频背景 */
opacity: 0 !important;
}
/* 所有边框强制加粗、变黑且使用实线 */
.style-brutalist .border {
border-width: 2px !important;
border-color: var(--border-line-color) !important;
border-style: solid !important;
}
.style-brutalist .border-t {
border-top-width: 2px !important;
border-color: var(--border-line-color) !important;
border-top-style: solid !important;
}
.style-brutalist .border-b {
border-bottom-width: 2px !important;
border-color: var(--border-line-color) !important;
border-bottom-style: solid !important;
}
.style-brutalist .border-l {
border-left-width: 2px !important;
border-color: var(--border-line-color) !important;
border-left-style: solid !important;
}
.style-brutalist .border-r {
border-right-width: 2px !important;
border-color: var(--border-line-color) !important;
border-right-style: solid !important;
}
/* 粗野主义直角消除 */
.style-brutalist .rounded-3xl,
.style-brutalist .rounded-2xl,
.style-brutalist .rounded-xl,
.style-brutalist .rounded-lg,
.style-brutalist .rounded-md,
.style-brutalist .rounded {
border-radius: 0px !important;
}
/* 粗野主义硬边缘阴影 */
.style-brutalist .shadow-sm,
.style-brutalist .shadow,
.style-brutalist .shadow-md,
.style-brutalist .shadow-lg,
.style-brutalist .shadow-xl,
.style-brutalist .shadow-2xl,
.style-brutalist .shadow-\[0_12px_40px_-12px_rgba\(0\2c 0\2c 0\2c 0\.15\)\] {
box-shadow: 4px 4px 0px 0px var(--border-line-color) !important;
transition: transform 0.2s, box-shadow 0.2s !important;
}
.style-brutalist .group:hover {
transform: translate(-3px, -3px) !important;
box-shadow: 7px 7px 0px 0px var(--border-line-color) !important;
}
+80
View File
@@ -0,0 +1,80 @@
/* 3. 赛博拟玻毛玻璃 (Glassmorphism Cyber) */
.style-glass {
--font-heading: var(--font-inter);
--font-body: var(--font-inter);
--accent-color: #EC4899;
--accent-light-color: #F472B6;
--bg-color: #0E0C15;
--bg-dark-color: #151324;
--fg-color: #F8F9FA;
--border-line-color: rgba(255, 255, 255, 0.12);
/* Cyber Glassmorphism pairings (high contrast modern) */
--font-hero-heading: var(--font-space-grotesk);
--font-hero-body: var(--font-inter);
--font-writing-heading: var(--font-space-grotesk);
--font-writing-body: var(--font-inter);
--font-bento-heading: var(--font-space-mono);
--font-bento-body: var(--font-space-mono);
--font-gallery-heading: var(--font-space-grotesk);
--font-gallery-body: var(--font-inter);
--font-quote-heading: var(--font-space-grotesk);
/* Fallback overrides for Glassmorphism (futuristic Sans-serif) */
--font-hero-h-val: var(--font-hero-heading), system-ui, -apple-system, sans-serif;
--font-hero-b-val: var(--font-hero-body), system-ui, -apple-system, sans-serif;
--font-writing-h-val: var(--font-writing-heading), system-ui, -apple-system, sans-serif;
--font-writing-b-val: var(--font-writing-body), system-ui, -apple-system, sans-serif;
--font-bento-h-val: var(--font-bento-heading), system-ui, -apple-system, sans-serif;
--font-bento-b-val: var(--font-bento-body), monospace;
--font-gallery-h-val: var(--font-gallery-heading), system-ui, -apple-system, sans-serif;
--font-gallery-b-val: var(--font-gallery-body), system-ui, -apple-system, sans-serif;
--font-quote-h-val: var(--font-quote-heading), system-ui, -apple-system, sans-serif;
}
.dark.style-glass {
--bg-color: #09070F;
--bg-dark-color: #110E1C;
--fg-color: #F8F9FA;
--border-line-color: rgba(255, 255, 255, 0.15);
}
/* 强行应用毛玻璃背景 */
.style-glass body {
background-color: var(--bg-color) !important;
}
.style-glass .bg-white\/40,
.style-glass .bg-white\/20,
.style-glass .bg-white,
.style-glass .bg-cream\/90,
.style-glass .bg-cream\/85 {
background-color: rgba(255, 255, 255, 0.07) !important;
backdrop-filter: blur(18px) saturate(130%) !important;
-webkit-backdrop-filter: blur(18px) saturate(130%) !important;
border-color: rgba(255, 255, 255, 0.1) !important;
}
.dark.style-glass .bg-white\/40,
.dark.style-glass .bg-white\/20,
.dark.style-glass .bg-white,
.dark.style-glass .bg-charcoal\/90,
.dark.style-glass .bg-charcoal\/85 {
background-color: rgba(15, 12, 28, 0.45) !important;
backdrop-filter: blur(18px) saturate(130%) !important;
-webkit-backdrop-filter: blur(18px) saturate(130%) !important;
border-color: rgba(255, 255, 255, 0.15) !important;
}
.style-glass .rounded-3xl {
border-radius: 28px !important;
}
.style-glass .rounded-2xl {
border-radius: 20px !important;
}
.style-glass .rounded-xl {
border-radius: 12px !important;
}
.style-glass .shadow-sm,
.style-glass .shadow,
.style-glass .shadow-md,
.style-glass .shadow-lg,
.style-glass .shadow-xl,
.style-glass .shadow-2xl {
box-shadow: 0 10px 30px -10px rgba(236, 72, 153, 0.15) !important;
}
+43
View File
@@ -0,0 +1,43 @@
/* 0. 生活档案馆 (Personal Life Archive) */
.style-life {
--font-heading: var(--font-jost);
--font-body: var(--font-inter);
--accent-color: #D9865F;
--accent-light-color: #F1B894;
--bg-color: #F7F8F1;
--bg-dark-color: #EAF0E5;
--fg-color: #223326;
--border-line-color: rgba(34, 51, 38, 0.1);
--font-hero-heading: var(--font-jost);
--font-hero-body: var(--font-inter);
--font-writing-heading: var(--font-jost);
--font-writing-body: var(--font-inter);
--font-bento-heading: var(--font-space-grotesk);
--font-bento-body: var(--font-inter);
--font-gallery-heading: var(--font-jost);
--font-gallery-body: var(--font-inter);
--font-quote-heading: var(--font-jost);
--font-hero-h-val: var(--font-hero-heading), var(--font-noto-serif-sc), system-ui, sans-serif;
--font-hero-b-val: var(--font-hero-body), var(--font-body), sans-serif;
--font-writing-h-val: var(--font-writing-heading), var(--font-noto-serif-sc), system-ui, sans-serif;
--font-writing-b-val: var(--font-writing-body), var(--font-body), sans-serif;
--font-bento-h-val: var(--font-bento-heading), var(--font-body), sans-serif;
--font-bento-b-val: var(--font-bento-body), var(--font-body), sans-serif;
--font-gallery-h-val: var(--font-gallery-heading), var(--font-noto-serif-sc), system-ui, sans-serif;
--font-gallery-b-val: var(--font-gallery-body), var(--font-body), sans-serif;
--font-quote-h-val: var(--font-quote-heading), var(--font-noto-serif-sc), system-ui, sans-serif;
}
.dark.style-life {
--bg-color: #17211B;
--bg-dark-color: #203027;
--fg-color: #F1F4EA;
--border-line-color: rgba(241, 244, 234, 0.12);
--accent-color: #F1A77C;
--accent-light-color: #F5C6A8;
}
.style-life .high-contrast-card {
background-color: color-mix(in srgb, var(--bg-color) 92%, white 8%) !important;
border-color: var(--border-line-color) !important;
}
+67
View File
@@ -0,0 +1,67 @@
/* 2. 极致极简无界卡片 (Minimalist Bento) */
.style-minimalist {
--font-heading: var(--font-inter);
--font-body: var(--font-inter);
--accent-color: #64748B;
--accent-light-color: #94A3B8;
--bg-color: #FCFCFC;
--bg-dark-color: #F5F5F5;
--fg-color: #1E293B;
--border-line-color: transparent;
/* Minimalist font pairing overrides */
--font-hero-heading: var(--font-jost);
--font-hero-body: var(--font-inter);
--font-writing-heading: var(--font-jost);
--font-writing-body: var(--font-inter);
--font-bento-heading: var(--font-inter);
--font-bento-body: var(--font-inter);
--font-gallery-heading: var(--font-jost);
--font-gallery-body: var(--font-inter);
--font-quote-heading: var(--font-jost);
/* Fallback overrides for Minimalist (pure modern Sans-serif) */
--font-hero-h-val: var(--font-hero-heading), system-ui, -apple-system, sans-serif;
--font-hero-b-val: var(--font-hero-body), system-ui, -apple-system, sans-serif;
--font-writing-h-val: var(--font-writing-heading), system-ui, -apple-system, sans-serif;
--font-writing-b-val: var(--font-writing-body), system-ui, -apple-system, sans-serif;
--font-bento-h-val: var(--font-bento-heading), system-ui, -apple-system, sans-serif;
--font-bento-b-val: var(--font-bento-body), system-ui, -apple-system, sans-serif;
--font-gallery-h-val: var(--font-gallery-heading), system-ui, -apple-system, sans-serif;
--font-gallery-b-val: var(--font-gallery-body), system-ui, -apple-system, sans-serif;
--font-quote-h-val: var(--font-quote-heading), system-ui, -apple-system, sans-serif;
}
.dark.style-minimalist {
--bg-color: #0F172A;
--bg-dark-color: #1E293B;
--fg-color: #F1F5F9;
--border-line-color: transparent;
}
/* 极简模式下消除多余边框、将卡片扁平化 */
.style-minimalist .border,
.style-minimalist .border-t,
.style-minimalist .border-b,
.style-minimalist .border-l,
.style-minimalist .border-r {
border-color: transparent !important;
}
.style-minimalist .rounded-3xl,
.style-minimalist .rounded-2xl {
border-radius: 12px !important;
}
.style-minimalist .rounded-xl,
.style-minimalist .rounded-lg {
border-radius: 8px !important;
}
.style-minimalist .bg-white\/40,
.style-minimalist .bg-white\/20,
.style-minimalist .bg-white {
background-color: var(--bg-dark-color) !important;
box-shadow: none !important;
}
.style-minimalist .fixed.inset-0.z-1 { /* 隐藏视频背景 */
opacity: 0 !important;
}
.style-minimalist .film-grain { /* 隐藏颗粒感 */
display: none !important;
}
+28
View File
@@ -0,0 +1,28 @@
/* 1. 瑞士现代杂志排版 (Swiss Modernism 2.0) */
.style-swiss {
--font-heading: var(--font-cormorant);
--font-body: var(--font-inter);
--accent-color: #C5A880;
--accent-light-color: #DFCEB4;
--font-hero-heading: var(--font-cormorant);
--font-hero-body: var(--font-inter);
--font-writing-heading: var(--font-playfair);
--font-writing-body: var(--font-inter);
--font-bento-heading: var(--font-space-grotesk);
--font-bento-body: var(--font-space-mono);
--font-gallery-heading: var(--font-jost);
--font-gallery-body: var(--font-inter);
--font-quote-heading: var(--font-cormorant);
/* Fallback overrides for Swiss Editorial (Serif headings, Sans-serif body) */
--font-hero-h-val: var(--font-hero-heading), var(--font-noto-serif-sc), var(--font-heading), Georgia, serif;
--font-hero-b-val: var(--font-hero-body), var(--font-body), sans-serif;
--font-writing-h-val: var(--font-writing-heading), var(--font-noto-serif-sc), var(--font-heading), Georgia, serif;
--font-writing-b-val: var(--font-writing-body), var(--font-body), sans-serif;
--font-bento-h-val: var(--font-bento-heading), var(--font-body), sans-serif;
--font-bento-b-val: var(--font-bento-body), monospace;
--font-gallery-h-val: var(--font-gallery-heading), var(--font-noto-serif-sc), var(--font-heading), Georgia, serif;
--font-gallery-b-val: var(--font-gallery-body), var(--font-body), sans-serif;
--font-quote-h-val: var(--font-quote-heading), var(--font-noto-serif-sc), var(--font-heading), Georgia, serif;
}
+339
View File
@@ -0,0 +1,339 @@
"use client";
import { useState, useEffect } from "react";
import { useParams } from "next/navigation";
import Link from "next/link";
import Image from "next/image";
import { ArrowLeft, Lock, Calendar, Tag, Smile, AlignLeft, Compass } from "lucide-react";
import { writingData, Post } from "@/data/writing";
import { getBlogDetailBySlug } from "@/api/blogs";
import ParallaxImage from "@/components/ui/ParallaxImage";
import PasscodeGate from "@/components/ui/PasscodeGate";
import Markdown from "@/components/ui/Markdown";
export default function PostPage() {
const params = useParams();
const slug = params.slug as string;
const [post, setPost] = useState<Post | null>(null);
const [loading, setLoading] = useState(true);
const [unlocked, setUnlocked] = useState(false);
const [toc, setToc] = useState<{ id: string; text: string; level: number }[]>([]);
const [activeId, setActiveId] = useState<string>("");
const [recommendations, setRecommendations] = useState<Post[]>([]);
useEffect(() => {
const fetchPost = async () => {
try {
const response = await getBlogDetailBySlug(slug);
const res = response.data;
if (res && res.code === 200) {
const item = res.data;
const formatted: Post = {
slug: item.slug || `post-${item.id}`,
title: item.title,
date: item.createTime ? item.createTime.split("T")[0] : new Date().toISOString().split("T")[0],
category: item.category || "Thoughts",
mood: item.mood || "quiet",
visibility: (item.visibility as any) || "public",
cover: item.cover || "/assets/writing-camera.png",
description: item.summary || "",
content: item.content || ""
};
setPost(formatted);
} else {
throw new Error("Post not found in API");
}
} catch (err) {
console.warn("Detail page: API unavailable, using local writingData static fallback.", err);
const local = writingData.find((p) => p.slug === slug);
setPost(local || null);
} finally {
setLoading(false);
}
};
fetchPost();
}, [slug]);
// 解析并生成大纲 (TOC)
useEffect(() => {
if (!post || (post.visibility === "private" && !unlocked)) return;
const timer = setTimeout(() => {
const headings = document.querySelectorAll("article h1, article h2, article h3, article h4");
const items: { id: string; text: string; level: number }[] = [];
headings.forEach((heading) => {
const id = heading.id;
if (id && id.startsWith("heading-")) {
const text = heading.textContent || "";
const level = parseInt(heading.tagName.substring(1), 10);
items.push({ id, text, level });
}
});
setToc(items);
}, 200);
return () => clearTimeout(timer);
}, [post, unlocked]);
// 监听滚动更新 active 大纲项
useEffect(() => {
if (toc.length === 0) return;
const handleScroll = () => {
const headingElements = toc
.map((item) => document.getElementById(item.id))
.filter(Boolean) as HTMLElement[];
let currentActiveId = "";
// 头部 Navbar 120px + 间距 40px 的总偏移量
const scrollPosition = window.scrollY + 160;
for (const el of headingElements) {
if (el.offsetTop <= scrollPosition) {
currentActiveId = el.id;
} else {
break;
}
}
setActiveId(currentActiveId || toc[0].id);
};
window.addEventListener("scroll", handleScroll);
handleScroll();
return () => window.removeEventListener("scroll", handleScroll);
}, [toc]);
// 挑选当前文章之外的 3 篇推荐文章
useEffect(() => {
if (!post) return;
const filtered = writingData.filter((p) => p.slug !== slug);
setRecommendations(filtered.slice(0, 3));
}, [post, slug]);
if (loading) {
return (
<div className="max-w-xl mx-auto py-32 px-6 text-center space-y-4">
<div className="w-6 h-6 border-2 border-gold border-t-transparent rounded-full animate-spin mx-auto"></div>
<p className="text-xs text-charcoal/50 dark:text-cream/50 font-sans tracking-widest uppercase mt-4">
Loading archive / 正在读取小站随笔档案...
</p>
</div>
);
}
if (!post) {
return (
<div className="max-w-xl mx-auto py-24 px-6 text-center space-y-4">
<h1 className="font-serif text-2xl font-light text-charcoal dark:text-cream">
404 / 档案不存在
</h1>
<p className="text-xs text-charcoal/50 dark:text-cream/50 font-sans tracking-widest uppercase">
The requested record could not be found in the archive.
</p>
<Link
href="/writing"
className="inline-flex items-center text-xs tracking-widest uppercase text-charcoal border-b border-charcoal/20 hover:border-charcoal pb-1 transition-colors font-sans mt-4 cursor-pointer"
>
<ArrowLeft className="w-3.5 h-3.5 mr-2 stroke-[1.5]" /> 返回目录
</Link>
</div>
);
}
const isPrivate = post.visibility === "private";
if (isPrivate && !unlocked) {
return (
<PasscodeGate
onUnlock={() => setUnlocked(true)}
title={`解锁加密档案:《${post.title}》`}
description="此随笔包含隐私片段。请输入访问口令(默认:2026)解锁查看全站加密内容。"
/>
);
}
return (
<div className="max-w-7xl mx-auto w-full px-4 md:px-8 py-24 md:py-32">
<div className="grid grid-cols-1 xl:grid-cols-[320px_1fr] gap-8 items-start">
{/* 左侧侧边栏:大纲与推荐文章 */}
<aside className="hidden xl:block sticky top-28 w-[320px] space-y-6 shrink-0 pointer-events-auto select-none">
{/* 板块一:大纲目录 */}
{toc.length > 0 && (
<div className="bg-cream/85 dark:bg-charcoal/85 backdrop-blur-md border border-charcoal/15 dark:border-white/15 rounded-3xl p-6 shadow-[0_8px_30px_rgb(0,0,0,0.04)] dark:shadow-[0_8px_30px_rgba(0,0,0,0.25)]">
<h3 className="flex items-center gap-2 text-xs font-sans font-bold uppercase tracking-wider text-charcoal/70 dark:text-cream/80 border-b border-charcoal/10 dark:border-white/10 pb-3 mb-4">
<AlignLeft className="w-4 h-4 text-gold stroke-[1.8]" />
<span>大纲目录</span>
<span className="text-[10px] text-charcoal/40 dark:text-cream/40 font-normal normal-case ml-auto">Outline</span>
</h3>
<nav data-lenis-prevent className="relative space-y-1 max-h-[320px] overflow-y-auto pr-1 scrollbar-thin">
{toc.map((item) => {
const isActive = activeId === item.id;
const indentClass =
item.level === 2 ? "pl-4" :
item.level === 3 ? "pl-8" :
item.level === 4 ? "pl-12" : "pl-4";
return (
<a
key={item.id}
href={`#${item.id}`}
onClick={(e) => {
e.preventDefault();
const el = document.getElementById(item.id);
if (el) {
window.scrollTo({
top: el.offsetTop - 120,
behavior: "smooth",
});
}
}}
className={`relative block text-sm leading-relaxed font-serif py-1.5 transition-all duration-300 hover:text-gold ${indentClass} ${
isActive
? "text-gold font-medium translate-x-1"
: "text-charcoal/65 dark:text-cream/65 hover:translate-x-0.5"
}`}
>
{isActive && (
<span className="absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-4 bg-gold rounded-full shadow-[0_0_8px_rgba(212,175,55,0.7)]" />
)}
{item.text}
</a>
);
})}
</nav>
</div>
)}
{/* 板块二:推荐随笔 */}
{recommendations.length > 0 && (
<div className="bg-cream/85 dark:bg-charcoal/85 backdrop-blur-md border border-charcoal/15 dark:border-white/15 rounded-3xl p-6 shadow-[0_8px_30px_rgb(0,0,0,0.04)] dark:shadow-[0_8px_30px_rgba(0,0,0,0.25)]">
<h3 className="flex items-center gap-2 text-xs font-sans font-bold uppercase tracking-wider text-charcoal/70 dark:text-cream/80 border-b border-charcoal/10 dark:border-white/10 pb-3 mb-4">
<Compass className="w-4 h-4 text-gold stroke-[1.8]" />
<span>推荐随笔</span>
<span className="text-[10px] text-charcoal/40 dark:text-cream/40 font-normal normal-case ml-auto">Recommended</span>
</h3>
<div className="space-y-4">
{recommendations.map((rec) => (
<Link
key={rec.slug}
href={`/writing/${rec.slug}`}
className="flex items-start gap-3.5 p-2.5 rounded-2xl border border-charcoal/5 dark:border-white/5 bg-cream/30 dark:bg-charcoal/30 hover:border-gold/30 dark:hover:border-gold/30 hover:bg-cream/70 dark:hover:bg-charcoal/70 hover:-translate-y-0.5 shadow-sm hover:shadow-md transition-all duration-300 group cursor-pointer"
>
<div className="relative w-20 h-14 overflow-hidden rounded-lg border border-gold/10 shrink-0 bg-charcoal/5">
<Image
src={rec.cover}
alt={rec.title}
fill
sizes="80px"
className="object-cover group-hover:scale-105 transition-transform duration-500"
/>
</div>
<div className="min-w-0 flex-1 py-0.5">
<h4 className="text-xs font-serif font-medium text-charcoal dark:text-cream line-clamp-2 leading-snug group-hover:text-gold transition-colors">
{rec.title}
</h4>
<p className="text-[9px] font-sans text-charcoal/40 dark:text-cream/40 mt-1.5 flex items-center gap-1">
<Calendar className="w-2.5 h-2.5 text-gold/60" />
{rec.date}
</p>
</div>
</Link>
))}
</div>
</div>
)}
</aside>
{/* 右侧主文章 */}
<article className="bg-cream/90 dark:bg-charcoal/90 backdrop-blur-md border border-charcoal/10 dark:border-white/10 rounded-[2.5rem] p-6 md:p-12 shadow-[0_12px_40px_-12px_rgba(0,0,0,0.12)] max-w-4xl w-full mx-auto">
{/* 返回目录导航 */}
<div className="mb-10">
<Link
href="/writing"
className="inline-flex items-center gap-1.5 text-xs tracking-widest uppercase text-charcoal/50 hover:text-charcoal dark:text-cream/50 dark:hover:text-cream transition-colors font-sans cursor-pointer"
>
<ArrowLeft className="w-4 h-4 stroke-[1.8]" /> Catalog / 返回随笔目录
</Link>
</div>
{/* 元信息、标题与导言 */}
<div className="space-y-6 mb-10">
<div className="flex flex-wrap items-center gap-3 text-[10px] uppercase tracking-widest text-charcoal/45 dark:text-cream/45 font-sans">
<span className="flex items-center gap-1">
<Calendar className="w-3.5 h-3.5 text-gold/80" />
{post.date}
</span>
<span>•</span>
<span className="flex items-center gap-1 text-gold font-medium">
<Tag className="w-3.5 h-3.5 text-gold/80" />
{post.category}
</span>
<span>•</span>
<span className="flex items-center gap-1">
<Smile className="w-3.5 h-3.5 text-gold/80" />
{post.mood}
</span>
{isPrivate && (
<span className="inline-flex items-center text-amber-800 bg-amber-50 dark:bg-amber-950/20 dark:text-amber-300 px-2 py-0.5 border border-amber-200/50 dark:border-amber-900/50 rounded">
<Lock className="w-2.5 h-2.5 mr-1 stroke-[1.5]" /> DECRYPTED / 已解密
</span>
)}
</div>
<h1 className="font-serif text-3xl md:text-5xl font-light text-charcoal dark:text-cream leading-tight tracking-wide">
{post.title}
</h1>
{/* 导言引用样式 */}
<p className="font-serif italic text-base text-charcoal/60 dark:text-cream/60 leading-relaxed max-w-2xl pl-4.5 border-l border-gold/45 py-1">
{post.description}
</p>
{/* 作者卡片 */}
<div className="flex items-center gap-3 border-y border-charcoal/5 dark:border-white/5 py-4">
<div className="relative w-10 h-10 overflow-hidden rounded-full border border-gold/15">
<Image
src="/assets/avtor-boy.jpg"
alt="Rrtiamo"
fill
sizes="40px"
className="object-cover"
/>
</div>
<div className="space-y-0.5">
<p className="text-xs font-semibold text-charcoal dark:text-cream">Rrtiamo</p>
<p className="text-[10px] text-charcoal/40 dark:text-cream/40 font-sans tracking-wide">
Archivist & Author
</p>
</div>
</div>
</div>
{/* 滚动视差封面大图 */}
<div className="mb-12 overflow-hidden rounded-[1.8rem] border border-charcoal/5 dark:border-white/5 shadow-md">
<ParallaxImage
src={post.cover}
alt={post.title}
aspectRatio="aspect-[16/10]"
speed={0.65}
tone="warm"
/>
</div>
{/* 正文排版区域 */}
<div className="font-serif text-base md:text-lg text-charcoal/80 dark:text-cream/80 leading-loose space-y-8 tracking-wide">
<Markdown content={post.content} />
</div>
{/* 结束装饰点 */}
<div className="flex justify-center mt-20">
<div className="w-1.5 h-1.5 rounded-full bg-gold/50 animate-pulse" />
</div>
</article>
</div>
</div>
);
}
+349
View File
@@ -0,0 +1,349 @@
"use client";
import { useState, useEffect, useRef } from "react";
import { Search, Lock, ArrowRight, ArrowLeft, Calendar, Tag, Smile } from "lucide-react";
import Link from "next/link";
import { writingData } from "@/data/writing";
import { useArticles } from "@/hooks/useArticles";
import Image from "next/image";
import gsap from "gsap";
export default function WritingPage() {
const { posts: dynamicPosts, loading } = useArticles();
const [searchInput, setSearchInput] = useState("");
const [searchQuery, setSearchQuery] = useState("");
const [activeCategory, setActiveCategory] = useState("All");
const [currentPage, setCurrentPage] = useState(1);
const listContainerRef = useRef<HTMLDivElement>(null);
const categories = ["All", ...Array.from(new Set(dynamicPosts.map((post) => post.category)))];
// 统一的重置页码过滤处理器
const handleCategoryChange = (cat: string) => {
setActiveCategory(cat);
setCurrentPage(1);
};
const handleSearchChange = (val: string) => {
setSearchInput(val);
};
// 防抖处理搜索输入,降低高频渲染与图片解码造成的内存占用
useEffect(() => {
const timer = setTimeout(() => {
setSearchQuery(searchInput);
setCurrentPage(1);
}, 250);
return () => clearTimeout(timer);
}, [searchInput]);
// 过滤条件:排除 visibility: "hidden" 除非有搜索匹配,过滤分类,匹配搜索词
const filteredPosts = dynamicPosts.filter((post) => {
if (post.visibility === "hidden" && !searchQuery) {
return false;
}
const matchesSearch =
post.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
post.description.toLowerCase().includes(searchQuery.toLowerCase());
const matchesCategory = activeCategory === "All" || post.category === activeCategory;
return matchesSearch && matchesCategory;
});
// 分页计算
const itemsPerPage = 5;
const totalPages = Math.ceil(filteredPosts.length / itemsPerPage);
// 确保页码不越界
const activePage = Math.min(Math.max(1, currentPage), totalPages || 1);
const paginatedPosts = filteredPosts.slice((activePage - 1) * itemsPerPage, activePage * itemsPerPage);
// GSAP 列表交替进场与视差进入动画
useEffect(() => {
if (loading || !listContainerRef.current) return;
// 检查是否渲染了卡片元素,防止 GSAP 控制台打出 Target not found 警告
const cards = listContainerRef.current.querySelectorAll(".writing-card");
if (cards.length === 0) return;
const prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const ctx = gsap.context(() => {
if (prefersReducedMotion) {
// 低动效模式下:仅使用极速淡入
gsap.fromTo(
".writing-card",
{ opacity: 0 },
{
opacity: 1,
duration: 0.4,
stagger: 0.05,
ease: "none",
overwrite: "auto",
}
);
} else {
// 1. 卡片外框淡入并上移
gsap.fromTo(
".writing-card",
{ opacity: 0, y: 35 },
{
opacity: 1,
y: 0,
duration: 0.7,
stagger: 0.1,
ease: "power3.out",
overwrite: "auto",
}
);
// 2. 图片缩放淡入
gsap.fromTo(
".writing-card-img-wrapper",
{ opacity: 0, scale: 1.06 },
{
opacity: 1,
scale: 1,
duration: 0.9,
stagger: 0.1,
ease: "power2.out",
delay: 0.1,
overwrite: "auto",
}
);
// 3. 文本内容自适应左右滑入
gsap.fromTo(
".writing-card-text-even",
{ opacity: 0, x: 20 },
{
opacity: 1,
x: 0,
duration: 0.8,
stagger: 0.1,
ease: "power2.out",
delay: 0.15,
overwrite: "auto",
}
);
gsap.fromTo(
".writing-card-text-odd",
{ opacity: 0, x: -20 },
{
opacity: 1,
x: 0,
duration: 0.8,
stagger: 0.1,
ease: "power2.out",
delay: 0.15,
overwrite: "auto",
}
);
}
}, listContainerRef);
return () => ctx.revert();
}, [activeCategory, activePage, loading]);
return (
<div className="max-w-6xl mx-auto w-full px-4 md:px-8 py-24 md:py-32">
<div className="bg-cream/90 dark:bg-charcoal/90 backdrop-blur-md border border-charcoal/10 dark:border-white/10 rounded-[2.5rem] p-6 md:p-12 shadow-[0_12px_40px_-12px_rgba(0,0,0,0.12)]">
{/* 头部标题与检索栏 */}
<div className="border-b border-charcoal/8 dark:border-white/8 pb-8 mb-10 flex flex-col lg:flex-row lg:items-end justify-between gap-6">
<div className="space-y-3">
<span className="text-[10px] font-sans font-semibold tracking-widest text-gold uppercase bg-gold/10 px-2.5 py-1 rounded">
02 / Catalog
</span>
<h1 className="font-serif text-4xl md:text-5xl font-light text-charcoal dark:text-cream mt-2">
Writing / 随笔与文章
</h1>
<p className="font-sans text-xs text-charcoal/50 dark:text-cream/50 tracking-wider">
关于前端视觉、摄影银盐、阅读碎片与日常琐碎的私人电子编目。
</p>
</div>
{/* 玻璃拟态搜索条 */}
<div className="relative w-full lg:max-w-xs border border-charcoal/10 dark:border-white/10 bg-white/40 dark:bg-white/5 rounded-2xl px-4 py-2.5 flex items-center focus-within:border-gold/50 transition-colors shadow-sm">
<Search className="w-4 h-4 text-charcoal/40 dark:text-cream/40 mr-2.5 stroke-[1.8]" />
<input
type="text"
placeholder="SEARCH / 检索档案..."
value={searchInput}
onChange={(e) => handleSearchChange(e.target.value)}
className="bg-transparent border-none w-full text-xs tracking-wider focus:outline-none placeholder:text-charcoal/30 dark:placeholder:text-cream/30 font-sans text-charcoal dark:text-cream"
/>
</div>
</div>
{/* 分类选项卡 */}
<div className="flex flex-wrap gap-2.5 border-b border-charcoal/5 dark:border-white/5 pb-6 mb-10 select-none">
{categories.map((cat) => (
<button
key={cat}
onClick={() => handleCategoryChange(cat)}
className={`text-[9px] font-sans uppercase tracking-widest px-4.5 py-2.5 rounded-full border transition-all duration-300 cursor-pointer ${
activeCategory === cat
? "bg-gold text-white border-gold shadow-sm font-semibold"
: "border-charcoal/10 dark:border-white/10 text-charcoal/60 dark:text-cream/60 hover:border-gold/50 hover:text-gold"
}`}
>
{cat === "All" ? "ALL / 全部" : cat}
</button>
))}
</div>
{/* 文章列表 */}
<div ref={listContainerRef} className="space-y-6">
{paginatedPosts.length > 0 ? (
paginatedPosts.map((post, idx) => {
const isEven = idx % 2 === 0;
return (
<div
key={post.slug}
className="writing-card group relative overflow-hidden rounded-[2.5rem] border border-charcoal/8 bg-white/55 dark:bg-white/[0.03] shadow-sm backdrop-blur-sm transition-all duration-500 hover:-translate-y-1 hover:bg-white/72 dark:hover:bg-white/8 hover:shadow-[0_20px_50px_-32px_rgba(217,134,95,0.22)] dark:border-white/10 flex flex-col md:flex-row items-stretch min-h-[420px] md:min-h-0 md:h-[250px]"
>
{/* 封面图容器 - 绝对定位以支持无缝斜切分割 */}
<div className="writing-card-img-wrapper w-full h-48 relative shrink-0 md:absolute md:inset-y-0 md:left-0 md:w-full md:h-full md:z-10 pointer-events-none overflow-hidden rounded-[2.5rem]">
{/* 斜角切割裁剪层 - 增加 isolation 与 backface-visibility 强制规避硬件加速层穿透 bug */}
<div
className={`w-full h-full overflow-hidden ${
isEven ? "clip-even-img" : "clip-odd-img"
}`}
style={{
isolation: "isolate",
backfaceVisibility: "hidden",
WebkitBackfaceVisibility: "hidden",
transform: "translateZ(0)",
}}
>
<div className="relative w-full h-full">
<div className="absolute inset-0 bg-charcoal/5 pointer-events-none z-10" />
<Image
src={post.cover}
alt={post.title}
fill
sizes="(min-width: 768px) 35vw, 100vw"
className="object-cover transition-transform duration-1000 ease-out group-hover:scale-108 saturate-[1.12] contrast-[1.02] brightness-[1.02] pointer-events-auto"
priority={idx < 2}
/>
</div>
</div>
</div>
{/* 右侧文章摘要 - 视交替左右进行内边距位移 */}
<div
className={`writing-card-text-${
isEven ? "even" : "odd"
} flex-1 p-6 md:p-0 md:absolute md:inset-0 md:z-20 md:flex md:flex-col md:justify-between md:py-6 md:px-8 ${
isEven ? "md:pl-[47%]" : "md:pr-[47%]"
}`}
>
<div className="space-y-3">
{/* 元数据标签 */}
<div className="flex flex-wrap items-center gap-3 text-[10px] uppercase tracking-widest text-charcoal/45 dark:text-cream/45 font-sans">
<span className="flex items-center gap-1">
<Calendar className="w-3.5 h-3.5 text-gold/80" />
{post.date}
</span>
<span>•</span>
<span className="flex items-center gap-1 text-gold font-medium">
<Tag className="w-3.5 h-3.5 text-gold/80" />
{post.category}
</span>
<span>•</span>
<span className="flex items-center gap-1">
<Smile className="w-3.5 h-3.5 text-gold/80" />
{post.mood}
</span>
{post.visibility === "private" && (
<span className="inline-flex items-center text-amber-800 bg-amber-50 dark:bg-amber-950/20 dark:text-amber-300 px-2 py-0.5 border border-amber-200/50 dark:border-amber-900/50 rounded text-[9px]">
<Lock className="w-2.5 h-2.5 mr-1 stroke-[1.5]" /> PRIVATE / 已加密
</span>
)}
</div>
<Link href={`/writing/${post.slug}`} className="block">
<h3 className="font-serif text-xl md:text-2xl font-light text-charcoal dark:text-cream group-hover:text-gold dark:group-hover:text-gold-light transition-colors duration-300 leading-tight">
{post.title}
</h3>
</Link>
<p className="text-xs md:text-sm text-charcoal/60 dark:text-cream/60 leading-relaxed font-light tracking-wide max-w-2xl line-clamp-3">
{post.description}
</p>
</div>
{/* 阅读全文按钮 */}
<div className="pt-2">
<Link
href={`/writing/${post.slug}`}
className="inline-flex items-center gap-1.5 text-[10px] tracking-widest uppercase border border-charcoal/10 dark:border-white/10 hover:border-gold hover:bg-gold hover:text-white px-5 py-2.5 transition-all font-sans cursor-pointer rounded-full"
>
READ / 阅读全文
<ArrowRight className="w-3.5 h-3.5 transition-transform duration-300 group-hover:translate-x-1" />
</Link>
</div>
</div>
</div>
);
})
) : (
<div className="py-20 text-center border border-dashed border-charcoal/10 dark:border-white/10 rounded-2xl">
<p className="text-xs font-sans text-charcoal/40 dark:text-cream/40 uppercase tracking-widest">
No matching records found / 暂无匹配的数字档案
</p>
</div>
)}
</div>
{/* 分页控制器 */}
{totalPages > 1 && (
<div className="flex items-center justify-center gap-3 pt-8 border-t border-charcoal/10 dark:border-white/10 mt-12">
<button
onClick={() => setCurrentPage((prev) => Math.max(prev - 1, 1))}
disabled={activePage === 1}
className="p-2.5 rounded-full border border-charcoal/10 dark:border-white/10 text-charcoal/60 dark:text-cream/60 disabled:opacity-30 disabled:hover:border-charcoal/10 disabled:hover:text-charcoal/60 hover:border-gold hover:text-gold dark:hover:border-gold-light dark:hover:text-gold-light transition-all duration-300 cursor-pointer disabled:cursor-not-allowed bg-white/20 dark:bg-white/5 flex items-center justify-center"
aria-label="Previous Page"
>
<ArrowLeft className="w-4 h-4" />
</button>
<div className="flex items-center gap-2">
{Array.from({ length: totalPages }).map((_, i) => {
const pageNum = i + 1;
const isCurrent = activePage === pageNum;
return (
<button
key={pageNum}
onClick={() => setCurrentPage(pageNum)}
className={`w-9 h-9 rounded-full text-xs font-sans tracking-wider transition-all duration-300 cursor-pointer flex items-center justify-center border ${
isCurrent
? "bg-gold text-white border-gold shadow-sm font-semibold dark:bg-gold dark:border-gold"
: "border-charcoal/10 dark:border-white/10 text-charcoal/60 dark:text-cream/60 hover:border-gold/50 hover:text-gold dark:hover:text-gold-light bg-white/20 dark:bg-white/5"
}`}
>
{pageNum}
</button>
);
})}
</div>
<button
onClick={() => setCurrentPage((prev) => Math.min(prev + 1, totalPages))}
disabled={activePage === totalPages}
className="p-2.5 rounded-full border border-charcoal/10 dark:border-white/10 text-charcoal/60 dark:text-cream/60 disabled:opacity-30 disabled:hover:border-charcoal/10 disabled:hover:text-charcoal/60 hover:border-gold hover:text-gold dark:hover:border-gold-light dark:hover:text-gold-light transition-all duration-300 cursor-pointer disabled:cursor-not-allowed bg-white/20 dark:bg-white/5 flex items-center justify-center"
aria-label="Next Page"
>
<ArrowRight className="w-4 h-4" />
</button>
</div>
)}
</div>
</div>
);
}