refactor: 播放器与 Love 页重构(无限 Marquee、统一章节标题、时间轴手动翻页)

This commit is contained in:
2026-09-26 04:00:32 +08:00
parent a57b66189c
commit 80f562b489
56 changed files with 2456 additions and 1459 deletions
+6
View File
@@ -3,3 +3,9 @@ NEXT_PUBLIC_API_BASE_URL=/api
# Used by Server Components and the development rewrite target.
SERVER_API_BASE_URL=http://localhost:8080/api
# --- 自建网易云增强 API(可选,留空 = 关闭)---
# 本地开发时若本机未运行自建 API,保持注释即可。
# NCM_API_URL=http://127.0.0.1:3000
# NCM_API_COOKIE_FILE=/www/wwwroot/ncm-api/.netease_cookie
# NCM_API_COOKIE=...
+8
View File
@@ -3,3 +3,11 @@ NEXT_PUBLIC_API_BASE_URL=/api
# Internal address used only by the Next.js server on the production host.
SERVER_API_BASE_URL=http://127.0.0.1:8080/api
# --- 自建网易云增强 API(可选,留空 = 关闭,网易云走 gdstudio 原通道)---
# 博客迁到宝塔服务器后启用即可享受会员音质/解灰;本机未部署时请保持注释。
# NCM_API_URL=http://127.0.0.1:3000
# 会员 cookie 存服务器文件(推荐,cookie 不进仓库):
# NCM_API_COOKIE_FILE=/www/wwwroot/ncm-api/.netease_cookie
# 或直接写入环境变量(二选一):
# NCM_API_COOKIE=...
+1 -1
View File
@@ -1,6 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/types/routes.d.ts";
import "./.next/dev/types/routes.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
+26
View File
@@ -14,6 +14,7 @@
"framer-motion": "^12.40.0",
"gsap": "^3.15.0",
"highlight.js": "^11.11.1",
"katex": "^0.18.9",
"leaflet": "^1.9.4",
"lenis": "^1.3.23",
"lucide-react": "^1.21.0",
@@ -2882,6 +2883,15 @@
"node": ">= 0.8"
}
},
"node_modules/commander": {
"version": "15.0.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-15.0.0.tgz",
"integrity": "sha512-z67u4ZhzCL/Tydu1lJARtEZYWbWaN7oYLHbsuzocr6y4N6WZAagG3RQ4FW61V1/0+jImpj293XfrcYnd1qxtPg==",
"license": "MIT",
"engines": {
"node": ">=22.12.0"
}
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmmirror.com/concat-map/-/concat-map-0.0.1.tgz",
@@ -4887,6 +4897,22 @@
"node": ">=4.0"
}
},
"node_modules/katex": {
"version": "0.18.9",
"resolved": "https://registry.npmjs.org/katex/-/katex-0.18.9.tgz",
"integrity": "sha512-8ad9RyoKsb/g8/yLFE+KAlP+DhbCTRUNi/V9XGsxn0R+trJJltNwzcDNo0q/DEkOy5fQUQTAQyCXCYSE+OakTQ==",
"funding": [
"https://opencollective.com/katex",
"https://github.com/sponsors/katex"
],
"license": "MIT",
"dependencies": {
"commander": "^15.0.0"
},
"bin": {
"katex": "cli.js"
}
},
"node_modules/keyv": {
"version": "4.5.4",
"resolved": "https://registry.npmmirror.com/keyv/-/keyv-4.5.4.tgz",
+1
View File
@@ -15,6 +15,7 @@
"framer-motion": "^12.40.0",
"gsap": "^3.15.0",
"highlight.js": "^11.11.1",
"katex": "^0.18.9",
"leaflet": "^1.9.4",
"lenis": "^1.3.23",
"lucide-react": "^1.21.0",
+126 -4
View File
@@ -6,13 +6,124 @@ export interface PublicConfigItem {
configValue: string
}
export function getPublicConfig() {
return request.get('/config/public')
/** 主题强类型字段 → page.theme.* 后缀(与 theme_config 表列一一对应) */
const THEME_KEYS = [
'accentColor',
'accentSoftColor',
'bgColor',
'bgSoftColor',
'darkAccentColor',
'darkAccentSoftColor',
'darkBgColor',
'darkBgSoftColor',
'grainOpacity',
'glowsEnabled',
'bgImageUrl',
'bgImageStyle',
'bgImageBlur',
'bgImageOpacity',
'darkBgImageOpacity',
'customCss'
] as const
/** site_access 强类型字段 → page.*.enable 遗留键 */
const PAGE_KEYS: Array<[string, string]> = [
['love', 'page.love.enable'],
['letter', 'page.letter.enable'],
['now', 'page.now.enable'],
['about', 'page.about.enable'],
['footprints', 'page.footprints.enable'],
['pond', 'page.pond.enable']
]
/** 统一转字符串:null/undefined → '',布尔 → 'true'/'false',其余 String() */
function toText(value: unknown): string {
if (value === null || value === undefined) return ''
if (typeof value === 'boolean') return value ? 'true' : 'false'
return String(value)
}
/** JSON 型键:内容为空时输出空串,复现“配置缺失”语义以触发前端兜底 */
function toJson(value: unknown, isEmpty: (parsed: any) => boolean): string {
if (!isEmpty(value)) return JSON.stringify(value)
return ''
}
/** 把 /config/bootstrap 的强类型聚合摊平为遗留 {configKey, configValue} 字符串数组 */
function flattenBootstrap(payload: any): PublicConfigItem[] {
const data = payload?.data ?? {}
const site = data.site ?? {}
const beian = site.beian ?? {}
const amap = site.amap ?? {}
const theme = data.theme ?? {}
const pages = data.pages ?? {}
const love = data.love ?? {}
const couple = love.couple ?? {}
const stats = love.stats ?? {}
const items: PublicConfigItem[] = []
const push = (configKey: string, configValue: unknown) => {
items.push({ configKey, configValue: toText(configValue) })
}
// 站点品牌与全局文案
push('site.logo.url', site.logoUrl)
push('site.logo.text', site.logoText)
push('site.favicon.url', site.faviconUrl)
push('site.title.default', site.titleDefault)
push('site.title.about', site.titleAbout)
push('page.home.welcomeText', site.welcomeText)
push('page.home.welcomeSubtitle', site.welcomeSubtitle)
push('page.home.heroTitle', site.heroTitle)
push('page.home.eyebrowTag', site.eyebrowTag)
push('page.home.heroDescription', site.heroDescription)
push('page.home.heroBgUrl', site.heroBgUrl)
push('site.beian.icp', beian.icp)
push('site.beian.icpUrl', beian.icpUrl)
push('site.beian.police', beian.police)
push('site.beian.policeUrl', beian.policeUrl)
push('page.footprint.amap.key', amap.key)
push('page.footprint.amap.securityJsCode', amap.securityJsCode)
// 外观主题
push('page.theme.enabled', theme.enabled)
THEME_KEYS.forEach((key) => push(`page.theme.${key}`, theme[key]))
// 页面可见性(口令不回传:由后端 /config/verify-passcode 单独校验,避免泄露)
PAGE_KEYS.forEach(([field, configKey]) => push(configKey, pages[field]))
// 关于作者 / 此时此刻(由关系表实时拼装,保持 JSON 字符串形态)
push('page.about.profile', toJson(data.about, (v) => !v || Object.keys(v).length === 0))
push('now.content.json', toJson(data.now, (v) => !v || Object.keys(v).length === 0))
// 恋爱域(伴侣信息未配置时输出空串,前端按空态渲染,不做兜底)
push('love.couple.info', toJson(couple, (v) => !v.name && !v.avatar))
push('love.stats.startDate', stats.startDate)
push('love.stats.citiesCount', stats.citiesCount)
push('love.stats.flightDistance', stats.flightDistance)
push('love.stats.movieCount', stats.movieCount)
push('love.stats.mealCount', stats.mealCount)
push('page.love.heroBgUrl', love.heroBgUrl)
push('page.love.atmospheres', toJson(love.atmospheres, (v) => !Array.isArray(v) || v.length === 0))
return items
}
export async function getPublicConfig() {
const response = await request.get('/config/bootstrap')
return {
...response,
data: {
code: response.data?.code,
msg: response.data?.msg,
data: flattenBootstrap(response.data)
}
}
}
export async function fetchPublicConfigForServer(init?: Parameters<typeof fetch>[1]) {
try {
const response = await fetch(getServerApiURL('/config/public'), {
const response = await fetch(getServerApiURL('/config/bootstrap'), {
...init,
// 容错超时防刷屏
signal: AbortSignal.timeout(3000)
@@ -20,7 +131,8 @@ export async function fetchPublicConfigForServer(init?: Parameters<typeof fetch>
if (!response.ok) {
return { code: response.status, data: [] }
}
return await response.json()
const payload = await response.json()
return { ...payload, data: flattenBootstrap(payload) }
} catch {
// 静默兜底,避免打印庞大的 Socket 异常日志
return { code: 500, data: [] }
@@ -36,3 +148,13 @@ export const getPublicConfigSnapshot = cache(async (): Promise<PublicConfigItem[
return typeof candidate.configKey === 'string' && typeof candidate.configValue === 'string'
})
})
/** 校验全站私密口令(服务端只校验、不回传口令,避免泄露) */
export async function verifyPasscode(code: string): Promise<{ code: number; msg?: string }> {
try {
const response = await request.post('/config/verify-passcode', { code })
return response.data ?? { code: 500 }
} catch {
return { code: 500, msg: '口令校验服务暂不可用' }
}
}
+16
View File
@@ -270,3 +270,19 @@ export async function fetchPlaylist(
throw normalizeMusicError(error);
}
}
/** 网易云热歌榜歌单 ID(默认播放列表数据源) */
const NETEASE_HOT_PLAYLIST_ID = "3778678";
/**
* 拉取网易云热歌榜作为默认播放列表。
* 复用现有歌单导入接口(music.163.com 直连,不依赖 gdstudio),失败返回空数组由调用方兜底。
*/
export async function fetchHotPlaylist(count = 20): Promise<TrackDetail[]> {
try {
const items = await fetchPlaylist(NETEASE_HOT_PLAYLIST_ID, "netease");
return items.slice(0, count);
} catch {
return [];
}
}
+15 -1
View File
@@ -7,6 +7,7 @@ import { aboutProfile } from "@/mock/about";
export async function generateMetadata(): Promise<Metadata> {
let title = "春风不解别离意,今日方知我是春。";
let authorName = "RRTiamo";
try {
const response = await getPublicConfig();
const configs = response.data?.data;
@@ -18,6 +19,19 @@ export async function generateMetadata(): Promise<Metadata> {
if (titleConfig?.configValue) {
title = titleConfig.configValue;
}
// 作者名取自身份档案聚合键(about_* 关系表拼装),缺失时回退默认值
const profileConfig = configs.find(
(item: { configKey?: string; configValue?: string }) =>
item.configKey === "page.about.profile"
);
if (profileConfig?.configValue) {
try {
const profile = JSON.parse(profileConfig.configValue);
if (profile?.name) authorName = profile.name;
} catch {
// blob 解析失败时保持默认名
}
}
}
} catch (error) {
console.warn("Failed to generate About page metadata:", error);
@@ -25,7 +39,7 @@ export async function generateMetadata(): Promise<Metadata> {
return {
title,
description: "我在代码、文字和生活的缝隙里,慢慢搭建一个属于自己的小宇宙。关于 RRTiamo,此间主人。",
description: `我在代码、文字和生活的缝隙里,慢慢搭建一个属于自己的小宇宙。关于 ${authorName},此间主人。`,
};
}
+185 -1
View File
@@ -1,8 +1,16 @@
import { readFileSync } from 'node:fs';
import { isIP } from 'node:net';
import { NextResponse } from 'next/server';
import type { MusicApiErrorCode, MusicSource } from '@/interface/music';
import type { ApiSearchResult, MusicApiErrorCode, MusicSource } from '@/interface/music';
const MUSIC_API_URL = 'https://music-api.gdstudio.xyz/api.php';
/**
* 自建网易云增强 API(NeteaseCloudMusicApi Enhanced)
* 配置 NCM_API_URL 后,网易云源将优先走自建服务(携带会员 cookie,支持 VIP 音质与解灰),失败自动回退 gdstudio。
* 留空 = 关闭,网易云走原有 gdstudio 通道。
*/
const NCM_API_URL = (process.env.NCM_API_URL || '').replace(/\/+$/, '');
const ALLOWED_SOURCES = new Set<MusicSource>(['netease', 'tencent', 'kugou', 'kuwo', 'bilibili', 'joox']);
const ALLOWED_TYPES = new Set(['search', 'url', 'pic', 'lyric', 'stream', 'playlist']);
@@ -188,6 +196,146 @@ async function resolveLyricWithFallback(source: MusicSource, id: string, name?:
return { lyric: '', tlyric: '', from: 'music.gdstudio.xyz' };
}
/* ==================== 自建网易云增强 API(NCM_API_URL) ==================== */
let ncmCookieCache: { value: string; time: number } | null = null;
/** 解析自建 API 所需的会员 cookie:优先环境变量,其次读取服务器上的 cookie 文件(缓存 60s) */
function getNcmCookie(): string {
if (process.env.NCM_API_COOKIE) return process.env.NCM_API_COOKIE;
const file = process.env.NCM_API_COOKIE_FILE;
if (!file) return '';
const now = Date.now();
if (ncmCookieCache && now - ncmCookieCache.time < 60_000) return ncmCookieCache.value;
try {
const value = readFileSync(file, 'utf-8').trim();
ncmCookieCache = { value, time: now };
return value;
} catch {
return '';
}
}
function ncmCookieParam(): string {
const ck = getNcmCookie();
return ck ? `cookie=${encodeURIComponent(ck)}` : '';
}
/** 请求自建 API 并解析 JSON,失败抛错(交由上层回退 gdstudio) */
async function ncmFetch(path: string): Promise<Record<string, unknown>> {
if (!NCM_API_URL) throw new Error('NCM_API_URL 未配置');
const response = await fetch(`${NCM_API_URL}${path}`, {
headers: {
Accept: 'application/json, text/plain, */*',
'Accept-Language': 'zh-CN,zh;q=0.9',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
},
signal: AbortSignal.timeout(8_000),
});
if (!response.ok) throw new Error(`自建网易云接口响应失败 (${response.status})`);
const text = await response.text();
if (!text.trim()) throw new Error('自建网易云接口返回无内容');
const data = JSON.parse(text) as Record<string, unknown>;
if (typeof data.code === 'number' && data.code !== 200 && data.code !== 0) {
throw new Error(String(data.message || data.msg || data.code));
}
return data;
}
/** 码率 -> 音质等级(增强 API 参数) */
function ncmLevel(br: number): string {
if (br >= 900000) return 'lossless';
if (br >= 320000) return 'exhigh';
if (br >= 192000) return 'high';
return 'standard';
}
/** 网易云搜索(返回与 gdstudio 一致的结构,前端零改动) */
async function ncmSearch(name: string, count: number): Promise<ApiSearchResult[]> {
const data = await ncmFetch(
`/search?keywords=${encodeURIComponent(name)}&limit=${count}&type=1&${ncmCookieParam()}`,
);
const songs = (data.result as { songs?: unknown[] } | undefined)?.songs;
if (!Array.isArray(songs)) return [];
const ids = songs
.map((raw) => String((raw as { id?: number | string }).id ?? ''))
.filter(Boolean);
// 批量拉取封面 URL,避免依赖 gdstudio 的 types=pic 通道(gdstudio 挂了封面也不裂)
let picMap = new Map<string, string>();
if (ids.length > 0) {
try {
picMap = await ncmSongDetailPicUrls(ids);
} catch {
// 拿不到封面则回退到数字 pic_id,由前端走 gdstudio 兜底
}
}
return songs.map((raw) => {
const s = raw as {
id?: number | string;
name?: string;
artists?: { name?: string }[];
album?: { name?: string; picUrl?: string; pic_str?: string; picId?: number | string };
};
const artistList = Array.isArray(s.artists)
? s.artists.map((a) => a.name ?? '').filter(Boolean)
: [];
const album = s.album?.name || '单曲';
const pic =
picMap.get(String(s.id ?? '')) ||
s.album?.picUrl ||
s.album?.pic_str ||
s.album?.picId ||
String(s.id ?? '');
return {
id: String(s.id ?? ''),
name: s.name || '未知曲目',
artist: artistList.length > 0 ? artistList : '未知歌手',
album,
pic_id: String(pic),
url_id: String(s.id ?? ''),
lyric_id: String(s.id ?? ''),
source: 'netease' as MusicSource,
};
});
}
/** 批量获取歌曲封面 URL(/song/detail 一次查询多首),返回 id -> 完整封面 URL */
async function ncmSongDetailPicUrls(ids: string[]): Promise<Map<string, string>> {
const map = new Map<string, string>();
const data = await ncmFetch(
`/song/detail?ids=${encodeURIComponent(ids.join(','))}&${ncmCookieParam()}`,
);
const songs = data.songs as
| Array<{ id?: number | string; al?: { picUrl?: string; pic_str?: string } }>
| undefined;
if (Array.isArray(songs)) {
for (const s of songs) {
if (s?.id == null) continue;
const pic = s.al?.picUrl || s.al?.pic_str;
if (pic) map.set(String(s.id), pic);
}
}
return map;
}
/** 网易云播放地址(VIP 音质,支持解灰:unblock=true) */
async function ncmSongUrl(id: string, br: number): Promise<string> {
const data = await ncmFetch(
`/song/url/v1?id=${encodeURIComponent(id)}&level=${ncmLevel(br)}&unblock=true&${ncmCookieParam()}`,
);
const item = (data.data as { url?: string }[] | undefined)?.[0];
return item?.url && isSafeStreamUrl(item.url) ? item.url : '';
}
/** 网易云歌词(含翻译) */
async function ncmLyric(id: string): Promise<{ lyric: string; tlyric: string }> {
const data = await ncmFetch(`/lyric?id=${encodeURIComponent(id)}&${ncmCookieParam()}`);
return {
lyric: toSimplifiedChinese((data.lrc as { lyric?: string } | undefined)?.lyric || ''),
tlyric: toSimplifiedChinese((data.tlyric as { lyric?: string } | undefined)?.lyric || ''),
};
}
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const requestType = searchParams.get('types') || 'search';
@@ -208,6 +356,15 @@ export async function GET(request: Request) {
try {
if (requestType === 'search') {
// 网易云优先走自建增强 API(会员搜索),失败回退 gdstudio
if (source === 'netease' && NCM_API_URL) {
try {
const ncmItems = await ncmSearch(name, Number(count) || 12);
if (ncmItems.length > 0) return NextResponse.json(ncmItems);
} catch {
// 回退到 gdstudio
}
}
let data = await requestMusicApi('search', params);
if (Array.isArray(data) && data.length === 0) {
const fallbackSource: MusicSource = source === 'netease' ? 'kuwo' : 'netease';
@@ -217,11 +374,29 @@ export async function GET(request: Request) {
}
if (requestType === 'lyric') {
if (source === 'netease' && NCM_API_URL) {
try {
const ncmL = await ncmLyric(id);
if (ncmL.lyric) {
return NextResponse.json({ ...ncmL, from: 'ncm-api.self-hosted' });
}
} catch {
// 回退到 gdstudio
}
}
const lyricData = await resolveLyricWithFallback(source, id, name);
return NextResponse.json(lyricData);
}
if (requestType === 'stream') {
if (source === 'netease' && NCM_API_URL) {
try {
const ncmAudio = await ncmSongUrl(id, Number(br) || 320000);
if (ncmAudio) return NextResponse.redirect(ncmAudio, { status: 302 });
} catch {
// 回退到 gdstudio
}
}
const audioUrl = await resolveAudioUrlWithFallback(source, id, name, br);
if (!audioUrl) {
return errorResponse('TRACK_UNAVAILABLE', '全网暂无可用的音频播放路径', 404);
@@ -377,6 +552,15 @@ export async function GET(request: Request) {
return NextResponse.json(Array.isArray(data) ? data : []);
}
if (requestType === 'url' && source === 'netease' && NCM_API_URL) {
try {
const ncmUrl = await ncmSongUrl(id, Number(br) || 320000);
if (ncmUrl) return NextResponse.json({ url: ncmUrl });
} catch {
// 回退到 gdstudio
}
}
const data = await requestMusicApi(requestType, params);
if (requestType === 'url' && !(data as { url?: string })?.url) {
const audioUrl = await resolveAudioUrlWithFallback(source, id, name, br);
+114 -40
View File
@@ -6,15 +6,15 @@ import Image from "next/image";
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import {
BookOpen,
Heart,
Camera,
Lock,
EyeSlash,
MapPin,
Smiley,
Funnel,
CalendarBlank
BookOpenIcon as BookOpen,
HeartIcon as Heart,
CameraIcon as Camera,
LockIcon as Lock,
EyeSlashIcon as EyeSlash,
MapPinIcon as MapPin,
SmileyIcon as Smiley,
FunnelIcon as Funnel,
CalendarBlankIcon as CalendarBlank
} from "@phosphor-icons/react";
import { writingData } from "@/data/writing";
@@ -320,6 +320,37 @@ const ArchiveCard = ({ item }: { item: ArchiveItem }) => {
);
};
// 归档分类元信息:用于“全部归档”视图中按类别分区展示,避免不同类型卡片相互挤压
const CATEGORY_META: {
type: ArchiveItem["type"];
label: string;
en: string;
icon: React.ReactNode;
badgeClass: string;
}[] = [
{
type: "Writing",
label: "随笔散文",
en: "WRITING",
icon: <BookOpen className="w-3 h-3 text-gold" />,
badgeClass: "text-charcoal/50 bg-charcoal/5 dark:text-white/50 dark:bg-white/5 border border-charcoal/10 dark:border-white/10",
},
{
type: "Love Note",
label: "恋爱纪实",
en: "LOVE",
icon: <Heart className="w-3 h-3 text-red-500" />,
badgeClass: "text-red-800/80 bg-red-50 dark:text-red-300 dark:bg-red-950/30 border border-red-900/10 dark:border-red-900/20",
},
{
type: "Photo",
label: "影像切片",
en: "PHOTO",
icon: <Camera className="w-3 h-3 text-blue-500" />,
badgeClass: "text-sky-700/80 bg-sky-50 dark:text-sky-300 dark:bg-sky-950/30 border border-sky-900/10 dark:border-sky-900/20",
},
];
// 预先静态化提取初始年份以供延迟加载状态
const getInitialYears = () => {
const dates = [
@@ -566,7 +597,11 @@ export default function ArchivePage() {
});
};
// GSAP 首次加载动画及 ScrollTrigger 物理联动
// 年份列表稳定标识:years 是每次渲染都新生成的数组引用,
// 直接作为 effect 依赖会导致 ScrollTrigger 与入场动画在每个渲染周期反复重建/重播(表现为页面疯狂闪烁刷新)
const yearsKey = years.join("|");
// GSAP 入场动画:仅挂载时执行一次,避免后续渲染(如数据陆续返回、切换分类)反复重播造成页面闪烁
useEffect(() => {
const ctx = gsap.context(() => {
// 1. 顶部索引卡与便签滑入 (优雅的弹性入场)
@@ -595,7 +630,7 @@ export default function ArchivePage() {
ease: "elastic.out(1.1, 0.45)"
}
);
// 2. 过滤栏滑入
// 3. 过滤栏滑入
gsap.from(".archive-filter-bar", {
opacity: 0,
y: 25,
@@ -603,7 +638,7 @@ export default function ArchivePage() {
delay: 0.15,
ease: "power3.out"
});
// 3. 侧边栏时间轴滑入
// 4. 侧边栏时间轴滑入
gsap.from(".archive-timeline-sidebar", {
opacity: 0,
x: -30,
@@ -611,22 +646,33 @@ export default function ArchivePage() {
delay: 0.25,
ease: "power3.out"
});
}, pageRef);
// 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"
});
}
return () => ctx.revert();
}, []);
// 5. 年份标题横线 ScrollTrigger 动态横向拉伸生长
// 卡片网格首次数据到达后播放一次 Stagger 物理发牌入场(后续分类切换交给 changeTab 处理动画)
const hasRunCardEntranceRef = useRef(false);
useEffect(() => {
if (hasRunCardEntranceRef.current) return;
const cards = pageRef.current?.querySelectorAll(".archive-card-anim");
if (!cards || cards.length === 0) return;
hasRunCardEntranceRef.current = true;
gsap.from(cards, {
opacity: 0,
y: 45,
rotation: () => (Math.random() - 0.5) * 2.5,
duration: 0.9,
stagger: 0.05,
delay: 0.35,
ease: "power4.out"
});
}, [yearsKey]);
// ScrollTrigger 物理联动:仅在年份列表内容或分类页签真正变化时安全重建,保证坐标绝对精准
useEffect(() => {
const ctx = gsap.context(() => {
// 1. 年份标题横线 ScrollTrigger 动态横向拉伸生长
years.forEach((year) => {
gsap.fromTo(`#divider-${year}`,
{ scaleX: 0, opacity: 0 },
@@ -644,7 +690,7 @@ export default function ArchivePage() {
);
});
// 6. 滚动联动高亮左侧年份刻度
// 2. 滚动联动高亮左侧年份刻度
years.forEach((year) => {
ScrollTrigger.create({
trigger: `#year-${year}`,
@@ -658,7 +704,7 @@ export default function ArchivePage() {
});
});
// 7. 时光轴流逝线滚动比例拉伸 (只在桌面端 sticky sidebar 启用,避免移动端计算报错)
// 3. 时光轴流逝线滚动比例拉伸 (只在桌面端 sticky sidebar 启用,避免移动端计算报错)
if (window.innerWidth >= 1024) {
gsap.to(".timeline-progress-fill", {
scaleY: 1,
@@ -675,7 +721,7 @@ export default function ArchivePage() {
}, pageRef);
return () => ctx.revert();
}, [years, activeTab]); // 过滤引起 years 变动时,安全重建 ScrollTrigger 保证坐标绝对精准
}, [yearsKey, activeTab]);
// 锚点滚动
const scrollToYear = (year: string) => {
@@ -892,17 +938,45 @@ export default function ArchivePage() {
/>
</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>
{/* 卡片网格:全部归档时按类别分区展示,避免不同类型卡片相互挤压 */}
{activeTab === "all" ? (
<div className="space-y-10">
{CATEGORY_META.map((cat) => {
const catItems = groups[year].filter((item) => item.type === cat.type);
if (catItems.length === 0) return null;
return (
<section key={cat.type} className="space-y-4">
{/* 类别小标题:图标 + 中英文名 + 数量 + 细分隔线 */}
<div className="flex items-center gap-2.5">
<span className={`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[9px] font-sans font-semibold uppercase tracking-widest ${cat.badgeClass}`}>
{cat.icon}
{cat.label}
</span>
<span className="text-[9px] font-mono uppercase tracking-wider text-charcoal/35 dark:text-white/35">
{cat.en} · {catItems.length}
</span>
<div className="grow h-px bg-charcoal/5 dark:bg-white/5" />
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8">
{catItems.map((item) => (
<div key={item.key} className="archive-card-anim">
<ArchiveCard item={item} />
</div>
))}
</div>
</section>
);
})}
</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>
))
)}
+6 -6
View File
@@ -112,7 +112,7 @@ export default function GalleryPage() {
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="notebook-dots 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">
@@ -122,7 +122,7 @@ export default function GalleryPage() {
Gallery / 影像档案
</h1>
<p className="font-sans text-xs text-charcoal/50 dark:text-white/50 tracking-wider mt-2">
用镜头与感光胶片物理定格的光影。已升级为极简无界艺术杂志排版,左右侧列辅以不对称顶部偏置与 GSAP 视差,实现顺畅呼吸的观看体验。
用镜头与感光胶片物理定格的光影。手账式的拍立得照片墙——每张相纸微微倾斜、画框各不相同,像被认真贴进笔记本里的每一帧。
</p>
</div>
@@ -151,17 +151,17 @@ export default function GalleryPage() {
// 决定不对称顶部偏置,增加版面韵律感 (仅在多列且挂载后应用)
let colOffsetClass = "";
if (columnsCount === 3) {
if (colIdx === 1) colOffsetClass = "pt-20";
if (colIdx === 2) colOffsetClass = "pt-10";
if (colIdx === 1) colOffsetClass = "pt-14";
if (colIdx === 2) colOffsetClass = "pt-6";
} else if (columnsCount === 2) {
if (colIdx === 1) colOffsetClass = "pt-12";
if (colIdx === 1) colOffsetClass = "pt-8";
}
return (
<div
key={colIdx}
ref={colRef}
className={`flex-1 flex flex-col gap-12 will-change-transform ${colOffsetClass}`}
className={`flex-1 flex flex-col gap-10 will-change-transform ${colOffsetClass}`}
>
<AnimatePresence mode="popLayout">
{columnItems.map((photo) => {
+267 -1
View File
@@ -35,6 +35,13 @@
--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;
--font-hero-display-val: var(--font-anton), var(--font-noto-serif-sc), system-ui, sans-serif;
/* 首页区块(Zentry 标题 × Poetize 内容)描边文字颜色 */
--stroke-soft: rgba(34, 51, 38, 0.28);
--stroke-thin: rgba(34, 51, 38, 0.3);
/* 底片缩略图齿孔带颜色 */
--film-perf: rgba(34, 51, 38, 0.14);
}
/* 暗黑模式变量配置 */
@@ -47,6 +54,9 @@
--font-body: var(--font-inter);
--accent-color: #F1A77C;
--accent-light-color: #F5C6A8;
--stroke-soft: rgba(247, 248, 241, 0.32);
--stroke-thin: rgba(247, 248, 241, 0.3);
--film-perf: rgba(247, 248, 241, 0.16);
}
@theme {
@@ -70,6 +80,7 @@
--font-gallery-h: var(--font-gallery-h-val);
--font-gallery-b: var(--font-gallery-b-val);
--font-quote-h: var(--font-quote-h-val);
--font-display: var(--font-hero-display-val);
}
/* ==========================================================================
@@ -296,6 +307,27 @@ html.lenis, html.lenis body {
-webkit-mask-image: linear-gradient(to right, transparent, white 15%, white 85%, transparent);
}
/* Zentry 式横幅 Marquee 滚动字幕条(轨道需复制两份等宽内容,平移 -50% 实现无缝无限循环) */
@keyframes atlas-marquee-scroll {
from {
transform: translateX(0);
}
to {
transform: translateX(-50%);
}
}
.atlas-marquee-track {
display: flex;
width: max-content;
will-change: transform;
animation: atlas-marquee-scroll 28s linear infinite;
}
.atlas-marquee-track:hover {
animation-play-state: paused;
}
/* 首页开屏底部的低矮动态波浪 */
.home-hero-wave {
height: clamp(5rem, 10vw, 8.5rem);
@@ -311,7 +343,9 @@ html.lenis, html.lenis body {
}
.wave-parallax > use {
animation: atlas-wave-drift 25s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite;
animation-name: atlas-wave-drift;
animation-timing-function: cubic-bezier(0.55, 0.5, 0.45, 0.5);
animation-iteration-count: infinite;
will-change: transform;
}
@@ -417,6 +451,15 @@ html.lenis, html.lenis body {
}
}
/* 手账点阵纸背景(拍立得相纸的衬底) */
.notebook-dots {
background-image: radial-gradient(circle, rgba(34, 51, 38, 0.06) 1px, transparent 1.4px);
background-size: 22px 22px;
}
.dark .notebook-dots {
background-image: radial-gradient(circle, rgba(247, 248, 241, 0.05) 1px, transparent 1.4px);
}
@media (prefers-reduced-motion: reduce) {
.wave-parallax > use {
animation: none;
@@ -596,3 +639,226 @@ nextjs-portal, #__next-prerender-indicator {
animation: spin-linear 20s linear infinite;
}
/* ==========================================================================
首页开屏巨字(Zentry 风格 Hero,HomeHero 专用)
========================================================================== */
/* 遮罩垂直余量防裁切:padding 撑大裁剪区,负 margin 抵消保持布局不变 */
.giant-title .char-mask {
padding: 0.12em 0;
margin: -0.12em 0;
}
.giant-title .char-inner {
animation: hero-char-rise 1.1s cubic-bezier(0.16, 1, 0.3, 1) both;
animation-delay: calc(0.15s + var(--i, 0) * 0.05s);
}
.giant-title .char-inner.accent {
color: var(--color-gold);
text-shadow: 0 0 32px rgba(217, 134, 95, 0.35);
}
/* 次级描边巨行:clip 展开进场,滚动视差由 GSAP ScrollTrigger 驱动 */
.giant-outline {
color: transparent;
-webkit-text-stroke: 1.5px rgba(247, 248, 241, 0.38);
clip-path: inset(0 100% 0 0);
animation: hero-outline-reveal 1s cubic-bezier(0.22, 1, 0.36, 1) 0.75s both;
will-change: transform;
}
/* 开屏内容块淡入上移(时序由内联 animation-delay 控制) */
.hero-fade {
opacity: 0;
animation: hero-fade-up 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* 沉浸式滚动提示竖线 */
.hero-scroll-line {
width: 1px;
height: 42px;
background: linear-gradient(180deg, transparent, var(--color-gold-light) 45%, var(--color-cream));
transform-origin: top;
animation: hero-scroll-line 2.2s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite;
}
@keyframes hero-char-rise {
from {
transform: translateY(130%);
filter: blur(8px);
opacity: 0;
}
to {
transform: translateY(0);
filter: blur(0);
opacity: 1;
}
}
@keyframes hero-outline-reveal {
from {
clip-path: inset(0 100% 0 0);
}
to {
clip-path: inset(0 0 0 0);
}
}
@keyframes hero-fade-up {
from {
transform: translateY(20px);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
@keyframes hero-scroll-line {
0% {
transform: scaleY(0);
transform-origin: top;
}
45% {
transform: scaleY(1);
transform-origin: top;
}
55% {
transform: scaleY(1);
transform-origin: bottom;
}
100% {
transform: scaleY(0);
transform-origin: bottom;
}
}
/* ==========================================================================
首页区块:Zentry 巨字标题 × Poetize 编辑式内容(首屏以下)
========================================================================== */
/* 巨字描边:浅色区块用炭色、暗色区块(含 .gallery-zone)用奶油色,颜色走变量 */
.text-stroke-soft {
color: transparent;
-webkit-text-stroke: 1.5px var(--stroke-soft);
}
.text-stroke-thin {
color: transparent;
-webkit-text-stroke: 1px var(--stroke-thin);
}
/* 编辑式清单的描边序号(固定金色,不随主题翻转) */
.num-stroke {
color: transparent;
-webkit-text-stroke: 1px rgba(217, 134, 95, 0.75);
}
/* Poetize 清单行:悬停金色下划线从左侧铺开 */
.post-underline {
position: relative;
}
.post-underline::after {
content: "";
position: absolute;
left: 0;
bottom: -1px;
height: 2px;
width: 0;
background: var(--accent-color);
transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.post-underline:hover::after {
width: 100%;
}
/* Zentry 深色反转区块(相册):固定深炭色 + 氛围光 + 细网格,文字固定奶油色 */
.gallery-zone {
--stroke-soft: rgba(247, 248, 241, 0.32);
--stroke-thin: rgba(247, 248, 241, 0.3);
color: #F7F8F1;
background:
radial-gradient(60% 50% at 85% 0%, rgba(217, 134, 95, 0.18), transparent 55%),
radial-gradient(45% 40% at 5% 60%, rgba(241, 184, 148, 0.08), transparent 50%),
linear-gradient(rgba(247, 248, 241, 0.03) 1px, transparent 1px),
linear-gradient(90deg, rgba(247, 248, 241, 0.03) 1px, transparent 1px),
#17211B;
background-size: auto, auto, 64px 64px, 64px 64px;
}
.dark .gallery-zone {
background:
radial-gradient(60% 50% at 85% 0%, rgba(217, 134, 95, 0.16), transparent 55%),
radial-gradient(45% 40% at 5% 60%, rgba(241, 184, 148, 0.07), transparent 50%),
linear-gradient(rgba(247, 248, 241, 0.028) 1px, transparent 1px),
linear-gradient(90deg, rgba(247, 248, 241, 0.028) 1px, transparent 1px),
#141B16;
background-size: auto, auto, 64px 64px, 64px 64px;
}
/* Zentry 胶片网格:首图跨 2×2,第四张跨 2 列 */
.film-grid {
display: grid;
grid-template-columns: 1fr;
gap: 14px;
}
@media (min-width: 720px) {
.film-grid {
grid-template-columns: repeat(4, 1fr);
grid-auto-rows: 290px;
}
.film-grid > :nth-child(1) {
grid-column: span 2;
grid-row: span 2;
}
.film-grid > :nth-child(4) {
grid-column: span 2;
}
}
/* 底片缩略图:上下胶片齿孔带,孔透出页面背景色(走 --film-perf 变量适配明暗) */
.film-sprocket {
position: relative;
}
.film-sprocket::before,
.film-sprocket::after {
content: "";
position: absolute;
left: 0;
right: 0;
height: 7px;
z-index: 2;
background-image: radial-gradient(circle at 4.5px 3.5px, transparent 0 2.4px, var(--film-perf) 2.8px);
background-size: 9px 7px;
background-repeat: repeat-x;
pointer-events: none;
}
.film-sprocket::before {
top: 0;
}
.film-sprocket::after {
bottom: 0;
}
@media (prefers-reduced-motion: reduce) {
.giant-title .char-inner,
.giant-outline,
.hero-fade {
animation: none;
opacity: 1;
transform: none;
filter: none;
clip-path: none;
}
.hero-scroll-line {
animation: none;
transform: scaleY(1);
}
.post-underline::after {
transition: none;
}
}
+11 -4
View File
@@ -1,5 +1,5 @@
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 { Inter, Cormorant_Garamond, Playfair_Display, Space_Grotesk, Space_Mono, Jost, Noto_Serif_SC, Ma_Shan_Zheng, Anton } from "next/font/google";
import "./globals.css";
import Navbar from "@/components/Navbar";
import Footer from "@/components/Footer";
@@ -62,6 +62,13 @@ const maShanZheng = Ma_Shan_Zheng({
preload: false,
});
const anton = Anton({
variable: "--font-anton",
subsets: ["latin"],
weight: "400",
display: "swap",
});
export async function generateMetadata(): Promise<Metadata> {
let title = "春风不解别离 | 个人生活档案馆";
let faviconUrl = "/icon.png";
@@ -92,9 +99,9 @@ export default async function RootLayout({
return (
<html
lang="zh"
className={`${inter.variable} ${cormorant.variable} ${playfair.variable} ${spaceGrotesk.variable} ${spaceMono.variable} ${jost.variable} ${notoSerifSC.variable} ${maShanZheng.variable} h-full antialiased`}
className={`${inter.variable} ${cormorant.variable} ${playfair.variable} ${spaceGrotesk.variable} ${spaceMono.variable} ${jost.variable} ${notoSerifSC.variable} ${maShanZheng.variable} ${anton.variable} h-full antialiased`}
>
<body className="min-h-full flex flex-col text-charcoal bg-transparent">
<body className="min-h-screen flex flex-col text-charcoal bg-transparent">
<SysConfigProvider initialConfigs={configs}>
<ThemeApplier />
{/* 1. 全局底色层 (z-0) */}
@@ -116,7 +123,7 @@ export default async function RootLayout({
<div className="film-grain" />
{/* 4. 网页主内容容器 (z-10),拥有显式正值 z-index,保证所有文字、按钮绝对不被背景或视频遮挡 */}
<div className="relative z-10 min-h-full flex flex-col">
<div className="relative z-10 grow min-h-full flex flex-col">
<SmoothScroll>
<Navbar />
<main className="grow flex flex-col">{children}</main>
+8 -8
View File
@@ -1,17 +1,17 @@
"use client";
"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
NotebookIcon as Notebook,
ClockIcon as Clock,
FunnelIcon as Funnel,
SparkleIcon as Sparkle,
PaperPlaneRightIcon as PaperPlaneRight,
DatabaseIcon as Database,
TextAlignLeftIcon as TextAlignLeft
} from "@phosphor-icons/react";
interface Note {
+23 -19
View File
@@ -2,24 +2,25 @@
import React, { useState, useEffect, useRef, useMemo } from "react";
import { getFeedbackList, createFeedback, likeFeedback, getFeedbackTypes } from "@/api/pond";
import { useAuthorProfile } from "@/hooks/useSysConfig";
import { motion, AnimatePresence } from "framer-motion";
import gsap from "gsap";
import {
Fish,
Heart,
Lightbulb,
Sparkle,
Bug,
WarningCircle,
CheckCircle,
PushPin,
PaperPlaneRight,
Megaphone,
Globe,
EnvelopeSimple,
CircleNotch,
ChatCircleText,
CaretDown
FishIcon as Fish,
HeartIcon as Heart,
LightbulbIcon as Lightbulb,
SparkleIcon as Sparkle,
BugIcon as Bug,
WarningCircleIcon as WarningCircle,
CheckCircleIcon as CheckCircle,
PushPinIcon as PushPin,
PaperPlaneRightIcon as PaperPlaneRight,
MegaphoneIcon as Megaphone,
GlobeIcon as Globe,
EnvelopeSimpleIcon as EnvelopeSimple,
CircleNotchIcon as CircleNotch,
ChatCircleTextIcon as ChatCircleText,
CaretDownIcon as CaretDown
} from "@phosphor-icons/react";
interface PondFeedbackReply {
@@ -354,6 +355,7 @@ const FeedbackCard = ({ fb, onLike, dbTypes }: { fb: PondFeedback; onLike: (id:
};
export default function PondPage() {
const author = useAuthorProfile();
const [feedbacks, setFeedbacks] = useState<PondFeedback[]>([]);
const [loading, setLoading] = useState(true);
const [activePool, setActivePool] = useState("all");
@@ -449,6 +451,8 @@ export default function PondPage() {
};
const getMockFallbackList = (cat: string) => {
const adminNickname = author.name ? `${author.name} (博主)` : "RRTiamo (博主)";
const adminAvatar = author.avatar || "/life-assets/avatar.jpg";
const mockDbFeedbacks = [
{
id: 1,
@@ -469,8 +473,8 @@ export default function PondPage() {
tags: [{ id: 1, name: "UI", color: "#ec4899" }],
replies: [{
id: 1,
nickname: "RRTiamo (博主)",
avatar: "/life-assets/avatar.jpg",
nickname: adminNickname,
avatar: adminAvatar,
content: "谢谢你的喜欢!写前端最开心的就是能用代码把心里的想法‘物理显化’出来。流体背景和 3D 卡片确实调了很久,能被你注意到这些细节真的非常欣慰!",
isAdmin: true,
createdAt: "2026-06-24T14:20:00"
@@ -496,8 +500,8 @@ export default function PondPage() {
tags: [{ id: 2, name: "后台", color: "#3b82f6" }],
replies: [{
id: 2,
nickname: "RRTiamo (博主)",
avatar: "/life-assets/avatar.jpg",
nickname: adminNickname,
avatar: adminAvatar,
content: "这个改进点提得太及时了!最近重构了系统配置页面,已经把外观配置、背景切换和视频链接动态绑定的模块都完成了,目前前台已支持一键实时换肤和背景视频渲染,欢迎测试!",
isAdmin: true,
createdAt: "2026-06-23T11:00:00"
+6 -4
View File
@@ -7,6 +7,7 @@ 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 { useAuthorProfile } from "@/hooks/useSysConfig";
import ParallaxImage from "@/components/ui/ParallaxImage";
import PasscodeGate from "@/components/ui/PasscodeGate";
import Markdown from "@/components/ui/Markdown";
@@ -14,6 +15,7 @@ import Markdown from "@/components/ui/Markdown";
export default function PostPage() {
const params = useParams();
const slug = params.slug as string;
const author = useAuthorProfile();
const [post, setPost] = useState<Post | null>(null);
const [loading, setLoading] = useState(true);
@@ -177,7 +179,7 @@ export default function PostPage() {
<PasscodeGate
onUnlock={() => setUnlocked(true)}
title={`解锁加密档案:《${post.title}》`}
description="此随笔包含隐私片段。请输入访问口令(默认:2026)解锁查看全站加密内容。"
description="此随笔包含隐私片段。请输入访问口令解锁查看全站加密内容。"
/>
);
}
@@ -323,15 +325,15 @@ export default function PostPage() {
<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"
src={author.avatar || "/assets/avtor-boy.jpg"}
alt={author.name || "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-xs font-semibold text-charcoal dark:text-cream">{author.name || "Rrtiamo"}</p>
<p className="text-[10px] text-charcoal/40 dark:text-cream/40 font-sans tracking-wide">
Archivist & Author
</p>
+3 -2
View File
@@ -1,10 +1,11 @@
"use client";
import FooterPeekers from "@/components/ui/FooterPeekers";
import { useSysConfig } from "@/hooks/useSysConfig";
import { useSysConfig, useAuthorProfile } from "@/hooks/useSysConfig";
export default function Footer() {
const { configs } = useSysConfig();
const author = useAuthorProfile();
const getConfigValue = (key: string, defaultValue = "") => {
const cfg = configs.find((c) => c.configKey === key);
@@ -31,7 +32,7 @@ export default function Footer() {
{/* 2. 强力驱动与版权声明 */}
<p className="flex flex-wrap items-center justify-center gap-x-2.5 gap-y-1 font-medium">
<span>© 2026 Rrtiamo. All rights reserved.</span>
<span>© 2026 {author.name || "Rrtiamo"}. All rights reserved.</span>
<span className="inline-block w-1 h-1 rounded-full bg-charcoal/10 dark:bg-cream/10" />
<span>本网站由 Spring Breeze 强力驱动</span>
</p>
+3
View File
@@ -253,6 +253,7 @@ export default function Navbar() {
>
<Link
href={item.path}
prefetch={false}
className={`relative z-10 text-[10px] uppercase tracking-widest transition-colors duration-300 font-sans py-2 px-3 rounded-full inline-block ${
isActive ? "text-gold font-semibold" : "text-charcoal/60 hover:text-charcoal"
}`}
@@ -293,6 +294,7 @@ export default function Navbar() {
<Link
key={item.path}
href={item.path}
prefetch={false}
className={`rounded-full px-2.5 py-1.5 font-sans text-[9px] uppercase tracking-wider transition-all ${
isActive
? "text-gold font-semibold bg-charcoal/5 dark:bg-white/5"
@@ -358,6 +360,7 @@ export default function Navbar() {
<Link
key={item.path}
href={item.path}
prefetch={false}
onClick={() => setIsMenuOpen(false)}
className={`group flex flex-col justify-center items-start p-2.5 rounded-2xl border border-charcoal/5 dark:border-white/5 bg-cream-dark/20 dark:bg-charcoal/20 hover:bg-cream-dark/60 dark:hover:bg-charcoal/60 hover:border-charcoal/10 dark:hover:border-white/10 transition-all duration-300 active:scale-[0.98] ${
isActive ? "border-gold/30 bg-gold/5 dark:bg-gold/10" : ""
@@ -6,6 +6,7 @@ import { Compass, Calendar, MapPin, X, Info } from "lucide-react";
import * as Icons from "lucide-react";
import gsap from "gsap";
import { DynamicIcon } from "@/icon/love";
import { useAuthorProfile, useCoupleProfile } from "@/hooks/useSysConfig";
interface FootprintItem {
id: string;
@@ -89,6 +90,10 @@ export default function FootprintsPageClient({
apiMapCode,
categories = defaultCategories,
}: FootprintsPageClientProps) {
const author = useAuthorProfile();
const couple = useCoupleProfile();
const boyAvatar = author.avatar || "/assets/avtor-boy.jpg";
const girlAvatar = couple.avatar ?? "";
const [items] = useState<FootprintItem[]>(initialItems);
const [filter, setFilter] = useState<string>("all");
const [selectedItem, setSelectedItem] = useState<FootprintItem | null>(null);
@@ -263,20 +268,44 @@ export default function FootprintsPageClient({
filteredItems.forEach((item) => {
const markerContent = document.createElement("div");
markerContent.className = "custom-map-marker group/marker";
// 男生头像代表光影照片,女生头像代表甜蜜恋爱瞬间
const avatarSrc = item.type === "love" ? "/assets/avtor-girl.jpg" : "/assets/avtor-boy.jpg";
markerContent.innerHTML = `
<div class="marker-wrapper relative flex items-center justify-center transition-all duration-300">
<div class="marker-pulse-ring absolute inset-0 rounded-full bg-amber-500/30 border border-amber-500/40 animate-ping opacity-60"></div>
<div class="marker-glow-ring absolute -inset-0.5 rounded-full border border-amber-500/50 bg-cream/90 shadow-lg dark:bg-charcoal"></div>
<div class="marker-avatar-circle relative h-8 w-8 overflow-hidden rounded-full border border-charcoal/10 dark:border-white/15 bg-white">
<img src="${avatarSrc}" alt="avatar" class="h-full w-full object-cover transition-transform duration-300 group-hover/marker:scale-110" />
</div>
<div class="marker-dot-bottom absolute -bottom-0.5 left-1/2 h-1.5 w-1.5 -translate-x-1/2 rounded-full bg-amber-500 border border-white dark:border-charcoal shadow-sm"></div>
</div>
`;
// 男生头像代表光影照片,女生头像代表甜蜜恋爱瞬间(身份媒体均在管理端配置,未配置时留空)
// 用 DOM API 构建而非 innerHTML 拼接,避免管理端可配置的 URL 造成注入
const avatarSrc = item.type === "love" ? girlAvatar : boyAvatar;
const wrapper = document.createElement("div");
wrapper.className =
"marker-wrapper relative flex items-center justify-center transition-all duration-300";
const pulse = document.createElement("div");
pulse.className =
"marker-pulse-ring absolute inset-0 rounded-full bg-amber-500/30 border border-amber-500/40 animate-ping opacity-60";
const glow = document.createElement("div");
glow.className =
"marker-glow-ring absolute -inset-0.5 rounded-full border border-amber-500/50 bg-cream/90 shadow-lg dark:bg-charcoal";
const avatarCircle = document.createElement("div");
avatarCircle.className =
"marker-avatar-circle relative h-8 w-8 overflow-hidden rounded-full border border-charcoal/10 dark:border-white/15 bg-white";
if (avatarSrc) {
const img = document.createElement("img");
img.src = avatarSrc;
img.alt = "avatar";
img.className =
"h-full w-full object-cover transition-transform duration-300 group-hover/marker:scale-110";
avatarCircle.appendChild(img);
}
const dot = document.createElement("div");
dot.className =
"marker-dot-bottom absolute -bottom-0.5 left-1/2 h-1.5 w-1.5 -translate-x-1/2 rounded-full bg-amber-500 border border-white dark:border-charcoal shadow-sm";
wrapper.appendChild(pulse);
wrapper.appendChild(glow);
wrapper.appendChild(avatarCircle);
wrapper.appendChild(dot);
markerContent.appendChild(wrapper);
const marker = new AMap.Marker({
position: [item.longitude, item.latitude],
@@ -323,7 +352,7 @@ export default function FootprintsPageClient({
map.setFitView(Object.values(markersRef.current), false, [60, 60, 60, 60], 12);
}
}
}, [filteredItems, mapLoaded]);
}, [filteredItems, mapLoaded, boyAvatar, girlAvatar]);
// 6. 列表卡片与地图 Marker 联动
const handleItemHover = (id: string | null) => {
+94 -112
View File
@@ -9,19 +9,30 @@ interface GalleryCardProps {
onClick: () => void;
}
// 手账拍立得相纸:统一白相纸 + 纸胶带粘贴,仅倾斜角度不同营造随手贴的错落感
const TILTS = [
"-rotate-2",
"rotate-[1.6deg]",
"-rotate-[1.2deg]",
"rotate-[2deg]",
"-rotate-[1.8deg]",
"rotate-[0.9deg]",
];
export default function GalleryCard({ photo, index, onClick }: GalleryCardProps) {
const isVideo = photo.type === "video";
const itemNumber = index < 9 ? `0${index + 1}` : `${index + 1}`;
const tilt = TILTS[index % TILTS.length];
// 根据相机品牌决定渲染何种艺术印戳
// 手账印章:常驻半透明,悬停加深
const renderDarkroomStamp = () => {
const cam = photo.camera.toLowerCase();
const base = "absolute top-3 right-3 z-30 pointer-events-none select-none opacity-30 transition-opacity duration-500 group-hover:opacity-70";
if (cam.includes("leica")) {
return (
<div className="absolute top-4 right-4 z-30 pointer-events-none select-none opacity-0 group-hover:opacity-40 transition-opacity duration-500 scale-90 origin-top-right">
{/* 红色 Leica 圆戳 */}
<div className="w-14 h-14 rounded-full border-2 border-red-500/70 flex flex-col items-center justify-center text-red-500 font-mono text-[6px] tracking-tighter leading-none rotate-12">
<div className={`${base} scale-90 origin-top-right`}>
<div className="w-14 h-14 rounded-full border-2 border-red-500/80 flex flex-col items-center justify-center text-red-500 font-mono text-[6px] tracking-tighter leading-none rotate-12">
<span className="font-bold border-b border-red-500/40 pb-0.5 mb-0.5">LEICA LAB</span>
<span>WET PROCESS</span>
<span className="scale-75 mt-0.5">PASS // OK</span>
@@ -29,35 +40,29 @@ export default function GalleryCard({ photo, index, onClick }: GalleryCardProps)
</div>
);
}
if (cam.includes("contax")) {
return (
<div className="absolute top-4 right-4 z-30 pointer-events-none select-none opacity-0 group-hover:opacity-35 transition-opacity duration-500 scale-90 origin-top-right">
{/* 矩形 Contax 双线印戳 */}
<div className="px-2 py-1 border-2 double border-zinc-500/70 text-zinc-500 dark:text-zinc-400 font-mono text-[6px] tracking-wider leading-none -rotate-6 flex flex-col items-center space-y-0.5">
<div className={`${base} scale-90 origin-top-right`}>
<div className="px-2 py-1 border-2 double border-zinc-600/80 text-zinc-600 font-mono text-[6px] tracking-wider leading-none -rotate-6 flex flex-col items-center space-y-0.5">
<span className="font-bold tracking-widest">CONTAX T2</span>
<span className="scale-90 border-t border-zinc-500/30 pt-0.5">ZEISS T* COMPACT</span>
</div>
</div>
);
}
if (cam.includes("hasselblad")) {
return (
<div className="absolute top-4 right-4 z-30 pointer-events-none select-none opacity-0 group-hover:opacity-35 transition-opacity duration-500 scale-90 origin-top-right">
{/* 长条哈苏印戳 */}
<div className="px-2 py-0.5 border border-dashed border-amber-600/70 text-amber-600 font-mono text-[5.5px] tracking-widest leading-none rotate-45 flex flex-col items-center">
<div className={`${base} scale-90 origin-top-right`}>
<div className="px-2 py-0.5 border border-dashed border-amber-600/80 text-amber-600 font-mono text-[5.5px] tracking-widest leading-none rotate-45 flex flex-col items-center">
<span className="font-bold">HASSELBLAD</span>
<span className="scale-75">503CX // 6x6</span>
</div>
</div>
);
}
// 默认通用暗房戳
return (
<div className="absolute top-4 right-4 z-30 pointer-events-none select-none opacity-0 group-hover:opacity-30 transition-opacity duration-500 scale-90 origin-top-right">
<div className="px-2 py-1 border border-charcoal/30 dark:border-white/30 text-charcoal/50 dark:text-white/50 font-mono text-[5.5px] tracking-widest leading-none -rotate-12">
<div className={`${base} scale-90 origin-top-right`}>
<div className="px-2 py-1 border border-charcoal/40 dark:border-white/40 text-charcoal/60 dark:text-white/60 font-mono text-[5.5px] tracking-widest leading-none -rotate-12">
DARKROOM / SHEET
</div>
</div>
@@ -67,116 +72,93 @@ export default function GalleryCard({ photo, index, onClick }: GalleryCardProps)
return (
<div
onClick={onClick}
className="group cursor-pointer bg-transparent border-0 p-0 transition-all duration-300 relative flex flex-col space-y-4 select-none mb-12"
className={`group relative cursor-pointer select-none transition-all duration-500 ease-out hover:z-10 hover:rotate-0 hover:-translate-y-2 ${tilt} shadow-[0_10px_28px_rgba(34,51,38,0.12)] hover:shadow-[0_24px_54px_rgba(23,33,27,0.22)]`}
>
{/* 媒体展示框 - 无卡框极简设计 */}
<div className="relative overflow-hidden w-full bg-stone-100 dark:bg-stone-950 rounded-none shadow-[0_2px_12px_rgba(0,0,0,0.03)] group-hover:shadow-[0_12px_32px_rgba(0,0,0,0.12)] transition-shadow duration-500">
{/* 精致的物理底片边缘刻度饰线 (仅在悬停时隐约可见) */}
<div className="absolute inset-0 border border-charcoal/5 dark:border-white/5 pointer-events-none z-20 transition-colors group-hover:border-charcoal/20" />
{/* 纸胶带装饰 */}
<div
className="absolute -top-3 left-1/2 z-20 h-6 w-20 -translate-x-1/2 -rotate-3 bg-[#F1E4C3]/85 shadow-sm"
aria-hidden="true"
/>
{/* 动态暗房印章叠加 */}
{renderDarkroomStamp()}
{/* 媒体呈现 */}
{isVideo ? (
<div className="relative w-full aspect-video md:aspect-[4/3] flex items-center justify-center bg-zinc-950 overflow-hidden">
{/* 电影底片小齿孔 (左右装饰) */}
<div className="absolute left-1.5 top-0 bottom-0 z-20 flex flex-col justify-around opacity-25">
{Array.from({ length: 6 }).map((_, i) => (
<div key={i} className="w-1 h-2 bg-zinc-900 border border-white/5 rounded-3xs" />
))}
</div>
<div className="absolute right-1.5 top-0 bottom-0 z-20 flex flex-col justify-around opacity-25">
{Array.from({ length: 6 }).map((_, i) => (
<div key={i} className="w-1 h-2 bg-zinc-900 border border-white/5 rounded-3xs" />
))}
</div>
{/* 视频单帧静态渲染 - preload=metadata, 且不设置 autoplay/loop,达到静态占位效果,彻底避免卡顿 */}
<video
src={photo.src}
preload="metadata"
autoPlay={false}
loop={false}
muted
playsInline
className="w-full h-full object-cover transition-all duration-700 brightness-90 group-hover:brightness-95 scale-100 group-hover:scale-102"
/>
{/* 精美高定 Cine Play 徽章 (Cine光圈播放图标) */}
<div className="absolute inset-0 flex items-center justify-center z-20">
<div className="w-12 h-12 rounded-full border border-white/30 bg-black/40 backdrop-blur-xs flex items-center justify-center transition-all duration-300 group-hover:scale-110 group-hover:bg-gold/80 group-hover:border-gold shadow-md">
<Play className="w-4 h-4 text-white fill-white translate-x-[1px] transition-transform duration-300 group-hover:scale-95" />
{/* 相纸 */}
<div className="bg-[#FDFBF4] p-[10px] pb-4">
{/* 媒体区 */}
<div
className={`relative w-full overflow-hidden ${
isVideo
? "aspect-video md:aspect-[4/3] bg-zinc-950"
: "min-h-[120px] bg-stone-200"
}`}
>
{isVideo ? (
<>
{/* 电影底片小齿孔 */}
<div className="absolute left-1.5 top-0 bottom-0 z-20 flex flex-col justify-around opacity-25">
{Array.from({ length: 6 }).map((_, i) => (
<div key={i} className="w-1 h-2 bg-zinc-900 border border-white/5 rounded-3xs" />
))}
</div>
<div className="absolute right-1.5 top-0 bottom-0 z-20 flex flex-col justify-around opacity-25">
{Array.from({ length: 6 }).map((_, i) => (
<div key={i} className="w-1 h-2 bg-zinc-900 border border-white/5 rounded-3xs" />
))}
</div>
</div>
{/* 视频状态微标 */}
<span className="absolute bottom-2.5 left-6 text-[7px] font-mono tracking-widest text-white/50 uppercase scale-75 origin-left">
CINE FILM // MP4
</span>
</div>
) : (
<div className="relative w-full overflow-hidden">
{/* 极轻微的暗角与网格纹理叠加层 */}
<div className="absolute inset-0 bg-radial-vignette opacity-15 pointer-events-none z-10 transition-opacity group-hover:opacity-5" />
{/* Admin-managed images have unknown intrinsic dimensions and may use arbitrary storage origins. */}
{/* eslint-disable-next-line @next/next/no-img-element */}
<video
src={photo.src}
preload="metadata"
autoPlay={false}
loop={false}
muted
playsInline
className="w-full h-full object-cover transition-all duration-700 brightness-90 group-hover:brightness-95 scale-100 group-hover:scale-102"
/>
<div className="absolute inset-0 flex items-center justify-center z-20">
<div className="w-12 h-12 rounded-full border border-white/30 bg-black/40 backdrop-blur-xs flex items-center justify-center transition-all duration-300 group-hover:scale-110 group-hover:bg-gold/80 group-hover:border-gold shadow-md">
<Play className="w-4 h-4 text-white fill-white translate-x-[1px] transition-transform duration-300 group-hover:scale-95" />
</div>
</div>
<span className="absolute bottom-2.5 left-6 text-[7px] font-mono tracking-widest text-white/50 uppercase scale-75 origin-left">
CINE FILM // MP4
</span>
</>
) : (
<img
src={photo.src}
alt={photo.title}
className="w-full object-cover transition-all duration-700 scale-100 group-hover:scale-102 group-hover:saturate-[1.03]"
className="block w-full h-auto transition-all duration-700 scale-100 group-hover:scale-102 group-hover:saturate-[1.03]"
loading="lazy"
/>
</div>
)}
</div>
)}
{/* 极简无界画廊说明标签 (Museum Label Layout) */}
<div className="space-y-2.5 pt-1">
{/* 极细的博物馆说明分割线 */}
<div className="h-[1px] bg-charcoal/10 dark:bg-white/10 w-full relative">
{/* 金色光效条,悬停时漫过 */}
<div className="absolute inset-y-0 left-0 bg-gold w-0 group-hover:w-full transition-all duration-700 ease-out" />
{/* 暗房印章(手账贴纸感) */}
{renderDarkroomStamp()}
{/* 相纸内编号 */}
<span className="absolute bottom-2 left-2 z-20 text-[8px] font-mono tracking-widest text-gold uppercase drop-shadow-[0_1px_2px_rgba(0,0,0,0.35)]">
[{itemNumber}]
</span>
</div>
{/* 编号、标题与参数 */}
<div className="flex justify-between items-start gap-4">
<div className="space-y-1">
<div className="flex items-center space-x-2">
<span className="text-[8px] font-mono text-gold/80 tracking-widest uppercase">
[{itemNumber}]
</span>
<h3 className="font-serif text-[15px] font-light text-charcoal dark:text-cream leading-tight">
{photo.title}
</h3>
</div>
{/* 拍摄规格 */}
<div className="flex items-center space-x-1 text-[8px] font-mono text-charcoal/40 dark:text-white/40 tracking-wider">
<Camera className="w-2.5 h-2.5" />
<span>{photo.camera} / {photo.lens}</span>
</div>
</div>
{/* 时间地点 */}
<div className="text-right shrink-0">
<span className="block text-[8px] font-mono text-charcoal/40 dark:text-white/40 tracking-widest uppercase">
{photo.date}
</span>
<span className="inline-flex items-center text-[7.5px] font-mono text-gold/80 tracking-wider mt-0.5">
<MapPin className="w-2.5 h-2.5 mr-0.5 text-gold/75" />
{/* 相纸底部手写留白 */}
<div className="pt-2.5 text-left text-charcoal">
<h3 className="font-serif text-[13px] font-semibold leading-snug tracking-[0.02em]">
{photo.title}
</h3>
<div className="mt-1.5 flex items-center gap-1.5 text-[8px] tracking-widest uppercase text-charcoal/50">
<span>{photo.date}</span>
<span aria-hidden="true">·</span>
<span className="inline-flex items-center">
<MapPin className="w-2.5 h-2.5 mr-0.5" />
{photo.location.split(",")[0]}
</span>
</div>
</div>
{/* 激光雕刻感的底片规格 (Film Stock Badge) */}
<div className="flex justify-between items-center text-[7px] font-mono text-charcoal/30 dark:text-white/30 uppercase tracking-widest select-none pt-1">
<span>PLATFORM: ATLAS // EXH_05</span>
<span className="text-gold font-semibold tracking-[0.2em]">{photo.filmStock}</span>
<div className="mt-1 flex items-center gap-1 text-[7px] font-mono tracking-[0.2em] uppercase text-charcoal/35">
<Camera className="w-2.5 h-2.5" />
<span>{photo.camera} · {photo.filmStock}</span>
</div>
</div>
</div>
</div>
+47 -43
View File
@@ -1,55 +1,59 @@
import Link from "next/link";
import { ArrowUpRight } from "lucide-react";
import type { RefObject } from "react";
import type { Post } from "@/data/writing";
import ParallaxImage from "@/components/ui/ParallaxImage";
interface ArticleRailProps {
posts: Post[];
trackRef: RefObject<HTMLDivElement | null>;
}
export default function ArticleRail({ posts, trackRef }: ArticleRailProps) {
export default function ArticleRail({ posts }: ArticleRailProps) {
return (
<div className="mask-image-horizontal overflow-x-auto py-2 no-scrollbar lg:overflow-hidden">
<div ref={trackRef} className="flex w-max gap-5 pr-4 gpu-accelerated-track">
{posts.map((post) => (
<article
key={post.slug}
className="article-card-element group w-[270px] shrink-0 overflow-hidden rounded-[1.6rem] border border-charcoal/8 bg-white/72 p-3 shadow-sm backdrop-blur transition duration-300 hover:-translate-y-1 hover:shadow-[0_18px_50px_-32px_rgba(26,26,26,0.38)] dark:border-white/10 dark:bg-white/8 sm:w-[320px]"
>
<Link href={`/writing/${post.slug}`} className="block">
<div className="overflow-hidden rounded-[1.2rem]">
<ParallaxImage
src={post.cover}
alt={post.title}
aspectRatio="aspect-[16/10]"
sizes="(min-width: 1024px) 320px, 82vw"
tone="warm"
horizontal={true}
/>
</div>
<div className="space-y-3 px-1 pb-2 pt-4">
<div className="flex flex-wrap gap-2 text-[12px] text-charcoal/45 dark:text-cream/45">
<span>{post.date}</span>
<span>{post.category}</span>
<span>{post.mood}</span>
</div>
<h2 className="line-clamp-2 text-lg font-semibold leading-snug text-charcoal transition-colors duration-300 group-hover:text-gold dark:text-cream">
{post.title}
</h2>
<p className="line-clamp-3 text-[13px] leading-6 text-charcoal/62 dark:text-cream/68">
{post.description}
</p>
<span className="inline-flex items-center gap-1 text-sm font-medium text-charcoal/72 dark:text-cream/72">
继续阅读
<ArrowUpRight className="h-3.5 w-3.5 transition-transform duration-300 group-hover:translate-x-0.5 group-hover:-translate-y-0.5" />
</span>
</div>
</Link>
</article>
))}
</div>
<div className="mt-10 flex flex-col gap-5 md:mt-14 md:gap-6">
{posts.map((post, i) => (
<Link
key={post.slug}
href={`/writing/${post.slug}`}
prefetch={false}
className="article-card-element group grid overflow-hidden rounded-2xl border border-charcoal/10 bg-white/55 shadow-[0_1px_0_rgba(34,51,38,0.04)] transition-all duration-300 hover:-translate-y-1 hover:border-gold/45 hover:shadow-[0_20px_50px_rgba(34,51,38,0.1)] dark:border-white/10 dark:bg-white/[0.02] dark:hover:border-gold/40 dark:hover:shadow-[0_20px_50px_rgba(0,0,0,0.35)] sm:grid sm:grid-cols-[40%_1fr]"
>
<div className="relative aspect-[4/3] overflow-hidden sm:aspect-auto sm:h-[240px] md:h-[260px]">
<img
src={post.cover}
alt={post.title}
loading="lazy"
className="h-full w-full object-cover saturate-[0.95] transition-transform duration-700 ease-out group-hover:scale-105"
/>
<div className="absolute inset-0 bg-gradient-to-t from-charcoal/25 via-transparent to-transparent opacity-0 transition-opacity duration-300 group-hover:opacity-100" />
</div>
<div className="flex min-w-0 flex-col p-5 sm:p-7 md:p-8">
<div className="flex items-baseline gap-3">
<span className="num-stroke font-display text-xl leading-none">
{String(i + 1).padStart(2, "0")}
</span>
<span className="text-[10px] uppercase tracking-[0.24em] text-charcoal/40 dark:text-cream/45">
{post.category}
</span>
</div>
<h3 className="mt-3 font-serif text-xl font-semibold leading-snug tracking-[0.01em] text-charcoal transition-colors duration-300 group-hover:text-gold dark:text-cream sm:text-2xl">
{post.title}
</h3>
<p className="mt-3 line-clamp-2 text-[13px] leading-7 text-charcoal/55 dark:text-cream/60">
{post.description}
</p>
<div className="mt-auto flex items-center gap-2 pt-6 text-xs tracking-[0.08em] text-charcoal/42 dark:text-cream/45">
<span>{post.date}</span>
<span className="h-[3px] w-[3px] rounded-full bg-gold/60" />
<span className="rounded-full border border-gold/40 px-2.5 py-0.5 font-serif text-xs tracking-wide text-charcoal/60 dark:text-cream/60">
{post.mood}
</span>
<ArrowUpRight className="ml-auto h-5 w-5 text-charcoal/35 transition-all duration-300 group-hover:translate-x-1 group-hover:translate-y-[-2px] group-hover:text-gold dark:text-cream/35" />
</div>
</div>
</Link>
))}
</div>
);
}
+43 -63
View File
@@ -1,75 +1,55 @@
import { Camera, MapPin, Play } from "lucide-react";
import type { RefObject } from "react";
import { Camera } from "lucide-react";
import type { GalleryPhoto } from "@/data/gallery";
import ParallaxImage from "@/components/ui/ParallaxImage";
interface GalleryRailProps {
photos: GalleryPhoto[];
trackRef: RefObject<HTMLDivElement | null>;
onSelect: (photo: GalleryPhoto) => void;
}
export default function GalleryRail({ photos, trackRef, onSelect }: GalleryRailProps) {
export default function GalleryRail({ photos, onSelect }: GalleryRailProps) {
return (
<div className="mask-image-horizontal overflow-x-auto py-2 no-scrollbar lg:overflow-hidden">
<div ref={trackRef} className="flex w-max gap-5 pr-4 gpu-accelerated-track">
{photos.map((slice) => (
<button
key={slice.id}
type="button"
onClick={() => onSelect(slice)}
className="gallery-slice-element group w-[270px] shrink-0 overflow-hidden rounded-[1.6rem] border border-charcoal/8 bg-white/72 p-3 text-left shadow-sm backdrop-blur transition duration-300 hover:-translate-y-1 hover:shadow-[0_18px_50px_-32px_rgba(26,26,26,0.4)] dark:border-white/10 dark:bg-white/8 sm:w-[320px]"
>
<div className="relative overflow-hidden rounded-[1.2rem] aspect-[4/3] bg-charcoal/5">
{slice.type === "video" ? (
<>
<video
src={slice.src}
muted
loop
playsInline
autoPlay
className="h-full w-full object-cover transition duration-700 group-hover:scale-105 group-hover:brightness-105"
/>
<span className="absolute right-3 top-3 inline-flex items-center gap-1 rounded-full bg-cream/86 px-2 py-1 text-[11px] font-medium text-charcoal/70 backdrop-blur">
<Play className="h-3 w-3 fill-gold text-gold" />
动态
</span>
</>
) : (
<ParallaxImage
src={slice.src}
alt={slice.title}
aspectRatio="aspect-[4/3]"
sizes="(min-width: 1024px) 320px, 82vw"
tone="natural"
horizontal={true}
/>
)}
<div className="film-grid mt-10 md:mt-14">
{photos.map((slice, i) => (
<button
key={slice.id}
type="button"
onClick={() => onSelect(slice)}
className="gallery-slice-element group relative cursor-pointer overflow-hidden rounded-[1.1rem] border border-white/10 bg-charcoal/40 text-left"
>
{slice.type === "video" ? (
<video
src={slice.src}
muted
loop
playsInline
autoPlay
className="h-full w-full object-cover brightness-[0.8] saturate-[0.94] transition duration-700 group-hover:scale-105 group-hover:brightness-95 group-hover:saturate-100"
/>
) : (
<img
src={slice.src}
alt={slice.title}
className="h-full w-full object-cover brightness-[0.8] saturate-[0.94] transition duration-700 group-hover:scale-105 group-hover:brightness-95 group-hover:saturate-100"
/>
)}
{/* 底部压暗渐变 */}
<div className="pointer-events-none absolute inset-0 bg-gradient-to-t from-black/85 via-transparent to-black/5" />
<div className="absolute inset-x-0 bottom-0 p-4">
<span className="text-[11px] tracking-[0.24em] text-gold-light">
FRAME {String(i + 1).padStart(2, "0")}
</span>
<h3 className="mt-1 line-clamp-1 font-serif text-[15px] font-semibold text-cream">
{slice.title}
</h3>
<div className="mt-1 flex items-center gap-1.5 text-[11px] tracking-[0.1em] text-cream/60">
<Camera className="h-3 w-3" />
<span className="truncate">
{slice.location} · {slice.filmStock}
</span>
</div>
<div className="space-y-3 px-1 pb-2 pt-4">
<div className="flex items-center justify-between gap-3 text-[12px] text-charcoal/45 dark:text-cream/45">
<span>{slice.date}</span>
<span className="inline-flex items-center gap-1 truncate">
<MapPin className="h-3.5 w-3.5 text-gold" />
{slice.location}
</span>
</div>
<h2 className="line-clamp-1 text-lg font-semibold text-charcoal transition-colors duration-300 group-hover:text-gold dark:text-cream">
{slice.title}
</h2>
<p className="line-clamp-2 text-[13px] leading-6 text-charcoal/62 dark:text-cream/68">
{slice.description}
</p>
<p className="flex items-center gap-2 truncate text-[12px] text-charcoal/45 dark:text-cream/45">
<Camera className="h-3.5 w-3.5" />
{slice.camera} / {slice.filmStock}
</p>
</div>
</button>
))}
</div>
</div>
</button>
))}
</div>
);
}
+221 -170
View File
@@ -1,34 +1,102 @@
"use client";
import { useState } from "react";
import { useEffect, useRef, useState, type CSSProperties } from "react";
import Image from "next/image";
import Link from "next/link";
import { ArrowDown, Camera, Feather, PenLine } from "lucide-react";
import { Camera, Feather, PenLine } from "lucide-react";
import SocialDock from "@/components/home/SocialDock";
import { useAuthorProfile } from "@/hooks/useSysConfig";
import gsap from "gsap";
import TextType from "@/components/ui/TextType";
import { ScrollTrigger } from "gsap/ScrollTrigger";
if (typeof window !== "undefined") {
gsap.registerPlugin(ScrollTrigger);
}
interface HomeHeroProps {
featuredCount: number;
galleryCount: number;
heroBgUrl?: string;
eyebrowTag?: string;
heroTitle?: string;
welcomeText?: string;
welcomeSubtitle?: string;
logoText?: string;
heroDescription?: string;
}
export default function HomeHero({
featuredCount,
galleryCount,
/** 确定性强调字符:取最靠近单词中点的元音,无元音则取中间字符(服务端/客户端渲染一致,防 hydration 抖动) */
function accentIndex(word: string): number {
const chars = Array.from(word);
const vowels = new Set(["A", "E", "I", "O", "U"]);
const mid = (chars.length - 1) / 2;
let best = -1;
let bestDist = Infinity;
chars.forEach((c, i) => {
if (vowels.has(c.toUpperCase())) {
const dist = Math.abs(i - mid);
if (dist < bestDist) {
bestDist = dist;
best = i;
}
}
});
return best >= 0 ? best : Math.round(mid);
}
export default function HomeHero({
featuredCount,
galleryCount,
heroBgUrl,
eyebrowTag,
heroTitle,
welcomeText,
welcomeSubtitle,
logoText
heroDescription,
}: HomeHeroProps) {
const [mediaFailed, setMediaFailed] = useState(false);
const author = useAuthorProfile();
const sectionRef = useRef<HTMLElement>(null);
const outlineRef = useRef<HTMLParagraphElement>(null);
const titleText = heroTitle || "Awakening";
const titleChars = Array.from(titleText);
const accentAt = accentIndex(titleText);
useEffect(() => {
const section = sectionRef.current;
const outline = outlineRef.current;
if (!section || !outline) return;
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const isDesktop = window.matchMedia("(min-width: 1024px)").matches;
if (reduceMotion || !isDesktop) return;
// 描边巨行随滚动轻微漂移(静止时与巨字左对齐,与预览一致)
const ctx = gsap.context(() => {
gsap.fromTo(
outline,
{ xPercent: 0 },
{
xPercent: 1.5,
ease: "none",
scrollTrigger: {
trigger: section,
start: "top top",
end: "bottom top",
scrub: true,
},
}
);
}, section);
return () => ctx.revert();
}, []);
return (
<section className="relative isolate min-h-[100dvh] overflow-hidden bg-charcoal px-4 pt-24 text-cream sm:px-6 lg:px-8">
<section
ref={sectionRef}
className="relative isolate min-h-[100dvh] overflow-hidden bg-charcoal px-4 pt-24 text-cream sm:px-6 lg:px-8"
>
<div className="absolute inset-0">
{heroBgUrl && !mediaFailed ? (
heroBgUrl.match(/\.(mp4|webm|ogg|mov|m4v)($|\?)/i) ? (
@@ -58,194 +126,177 @@ export default function HomeHero({
src="/bg-image.png"
alt="月色与花枝"
fill
preload
priority
sizes="100vw"
className="object-cover object-[62%_center] brightness-[0.82] saturate-[1.14] dark:brightness-[0.7]"
/>
)}
<div className="absolute inset-0 bg-[linear-gradient(90deg,rgba(23,33,27,0.82)_0%,rgba(23,33,27,0.46)_42%,rgba(23,33,27,0.12)_74%),linear-gradient(180deg,rgba(23,33,27,0.24)_0%,rgba(23,33,27,0.08)_50%,rgba(23,33,27,0.62)_100%)]" />
<div className="absolute inset-0 bg-[radial-gradient(circle_at_20%_42%,rgba(247,248,241,0.2),transparent_34%),radial-gradient(circle_at_68%_28%,rgba(217,134,95,0.22),transparent_32%)] dark:bg-[radial-gradient(circle_at_20%_42%,rgba(241,244,234,0.13),transparent_34%),radial-gradient(circle_at_68%_28%,rgba(241,167,124,0.18),transparent_32%)]" />
{/* 渐变遮罩比旧版更轻:巨字排版对背景可读性要求更低 */}
<div className="absolute inset-0 bg-[linear-gradient(90deg,rgba(23,33,27,0.55)_0%,rgba(23,33,27,0.28)_42%,rgba(23,33,27,0.05)_74%),linear-gradient(180deg,rgba(23,33,27,0.30)_0%,rgba(23,33,27,0.08)_50%,rgba(23,33,27,0.62)_100%)]" />
<div className="absolute inset-0 bg-[radial-gradient(circle_at_20%_42%,rgba(247,248,241,0.16),transparent_34%),radial-gradient(circle_at_68%_28%,rgba(217,134,95,0.22),transparent_32%)] dark:bg-[radial-gradient(circle_at_20%_42%,rgba(241,244,234,0.13),transparent_34%),radial-gradient(circle_at_68%_28%,rgba(241,167,124,0.18),transparent_32%)]" />
</div>
<div className="relative z-10 mx-auto flex min-h-[calc(100dvh-6rem)] w-full max-w-6xl flex-col justify-center pb-44 sm:pb-48 lg:pb-52">
<div className="home-reveal max-w-full sm:max-w-3xl">
<div
<div className="relative z-10 mx-auto flex min-h-[calc(100dvh-6rem)] w-full max-w-7xl flex-col justify-center pb-44 sm:pb-48 lg:pb-52">
<div className="inline-flex max-w-full items-center gap-3 self-start rounded-full border border-white/22 bg-white/14 px-3 py-2 shadow-[0_18px_60px_-32px_rgba(0,0,0,0.65)] backdrop-blur-md">
<div className="relative h-11 w-11 overflow-hidden rounded-full border border-white/45 bg-white/55 p-0.5">
<div className="relative h-full w-full overflow-hidden rounded-full">
<Image
src={author.avatar || "/assets/avtor-boy.jpg"}
alt={author.name || "Rrtiamo"}
fill
loading="eager"
sizes="44px"
className="object-cover saturate-[1.08]"
/>
</div>
</div>
<span className="min-w-0 text-[13px] font-medium text-cream/82">
个人博客 / 生活记录 / 彩色相册
</span>
</div>
<div className="hero-fade mt-8 flex flex-wrap items-baseline gap-x-3.5 gap-y-1" style={{ animationDelay: "0.05s" }}>
<span className="text-[13px] font-semibold uppercase tracking-[0.35em] text-gold-light">
{eyebrowTag || "Welcome"}
</span>
<span className="h-1 w-1 self-center rounded-full bg-cream/40" />
<span className="font-serif text-[15px] font-semibold text-cream/85 md:text-[19px]">
{welcomeSubtitle || "此间主人"}
</span>
</div>
<h1
aria-label={titleText}
className="giant-title mt-3 font-display text-[clamp(4rem,15vw,12rem)] font-normal uppercase leading-[0.85] tracking-[0.01em] [text-shadow:0_10px_30px_rgba(0,0,0,0.16)] sm:mt-4"
>
{titleChars.map((char, index) => (
<span key={index} className="char-mask">
<span
className={`char-inner${index === accentAt ? " accent" : ""}`}
style={{ "--i": index } as CSSProperties}
>
{char}
</span>
</span>
))}
</h1>
<p
ref={outlineRef}
aria-hidden="true"
className="giant-outline mt-2 w-fit max-w-full font-display text-[clamp(2rem,8vw,6rem)] uppercase leading-[1.02] tracking-[0.02em]"
>
{welcomeText || "Spring Breeze"}
</p>
<p
className="hero-fade mt-6 max-w-[32rem] text-[15px] font-light leading-8 text-cream/78 md:text-base"
style={{ animationDelay: "0.85s" }}
>
{heroDescription || "写一点代码,拍一些照片,记下那些普通但值得被留下的日子。"}
</p>
<div className="hero-fade mt-7 flex flex-wrap items-center gap-3" style={{ animationDelay: "0.95s" }}>
<Link
href="/writing"
prefetch={false}
onMouseEnter={(e) => {
gsap.to(e.currentTarget, {
y: -4,
backgroundColor: "rgba(255, 255, 255, 0.18)",
borderColor: "rgba(255, 255, 255, 0.35)",
scale: 1.02,
backgroundColor: "#ffffff",
boxShadow: "0 24px 48px -18px rgba(0,0,0,0.8)",
duration: 0.35,
ease: "power2.out",
});
const imgContainer = e.currentTarget.querySelector(".avatar-img-container");
if (imgContainer) {
gsap.to(imgContainer, { rotate: 6, duration: 0.4, ease: "back.out(1.7)" });
}
const img = e.currentTarget.querySelector("img");
if (img) {
gsap.to(img, { scale: 1.1, duration: 0.4, ease: "power2.out" });
}
const txt = e.currentTarget.querySelector(".avatar-text");
if (txt) {
gsap.to(txt, { color: "#ffffff", duration: 0.3 });
const icon = e.currentTarget.querySelector("svg");
if (icon) {
gsap.to(icon, { rotate: 8, scale: 1.1, duration: 0.3, ease: "power2.out" });
}
}}
onMouseLeave={(e) => {
gsap.to(e.currentTarget, {
y: 0,
backgroundColor: "rgba(255, 255, 255, 0.14)",
borderColor: "rgba(255, 255, 255, 0.22)",
scale: 1,
backgroundColor: "#f7f8f1",
boxShadow: "0 18px 42px -24px rgba(0,0,0,0.7)",
duration: 0.35,
ease: "power2.out",
});
const imgContainer = e.currentTarget.querySelector(".avatar-img-container");
if (imgContainer) {
gsap.to(imgContainer, { rotate: 0, duration: 0.4, ease: "power2.out" });
}
const img = e.currentTarget.querySelector("img");
if (img) {
gsap.to(img, { scale: 1, duration: 0.4, ease: "power2.out" });
}
const txt = e.currentTarget.querySelector(".avatar-text");
if (txt) {
gsap.to(txt, { color: "rgba(247, 248, 241, 0.82)", duration: 0.3 });
const icon = e.currentTarget.querySelector("svg");
if (icon) {
gsap.to(icon, { rotate: 0, scale: 1, duration: 0.3, ease: "power2.out" });
}
}}
className="group inline-flex max-w-full items-center gap-3 rounded-full border border-white/22 bg-white/14 px-3 py-2 shadow-[0_18px_60px_-32px_rgba(0,0,0,0.65)] backdrop-blur-md cursor-pointer"
className="inline-flex items-center gap-2 rounded-full bg-cream px-5 py-3 text-sm font-semibold text-charcoal shadow-[0_18px_42px_-24px_rgba(0,0,0,0.7)]"
>
<div className="avatar-img-container relative h-11 w-11 overflow-hidden rounded-full border border-white/45 bg-white/55 p-0.5">
<div className="relative h-full w-full overflow-hidden rounded-full">
<Image
src="/assets/avtor-boy.jpg"
alt="Rrtiamo"
fill
loading="eager"
sizes="44px"
className="object-cover saturate-[1.08]"
/>
</div>
</div>
<span className="avatar-text min-w-0 text-[13px] font-medium text-cream/82">
个人博客 / 生活记录 / 彩色相册
</span>
</div>
<div className="mt-8 max-w-full space-y-5 sm:max-w-3xl">
<h1 className="font-hero-h text-[3.55rem] font-semibold leading-[0.95] tracking-normal text-cream drop-shadow-[0_18px_48px_rgba(0,0,0,0.28)] sm:text-7xl md:text-8xl">
<TextType
text={[logoText || "Rrtiamo", welcomeText || "Spring Breeze", welcomeSubtitle || "此间主人"]}
typingSpeed={90}
deletingSpeed={50}
pauseDuration={2500}
showCursor={true}
cursorCharacter="|"
cursorClassName="text-gold ml-1.5"
as="span"
/>
</h1>
<p className="max-w-[32rem] break-words text-[15px] leading-8 text-cream/78 md:text-base">
写一点代码,拍一些照片,记下那些普通但值得被留下的日子。
</p>
</div>
<div className="mt-8 flex flex-wrap items-center gap-3">
<Link
href="/writing"
onMouseEnter={(e) => {
gsap.to(e.currentTarget, {
y: -4,
scale: 1.02,
backgroundColor: "#ffffff",
boxShadow: "0 24px 48px -18px rgba(0,0,0,0.8)",
duration: 0.35,
ease: "power2.out",
});
const icon = e.currentTarget.querySelector("svg");
if (icon) {
gsap.to(icon, { rotate: 8, scale: 1.1, duration: 0.3, ease: "power2.out" });
}
}}
onMouseLeave={(e) => {
gsap.to(e.currentTarget, {
y: 0,
scale: 1,
backgroundColor: "#f7f8f1",
boxShadow: "0 18px 42px -24px rgba(0,0,0,0.7)",
duration: 0.35,
ease: "power2.out",
});
const icon = e.currentTarget.querySelector("svg");
if (icon) {
gsap.to(icon, { rotate: 0, scale: 1, duration: 0.3, ease: "power2.out" });
}
}}
className="inline-flex items-center gap-2 rounded-full bg-cream px-5 py-3 text-sm font-semibold text-charcoal shadow-[0_18px_42px_-24px_rgba(0,0,0,0.7)]"
>
<PenLine className="h-4 w-4" />
随笔
</Link>
<Link
href="/gallery"
onMouseEnter={(e) => {
gsap.to(e.currentTarget, {
y: -4,
scale: 1.02,
backgroundColor: "rgba(255, 255, 255, 0.18)",
borderColor: "rgba(255, 255, 255, 0.42)",
color: "#ffffff",
boxShadow: "0 24px 48px -18px rgba(0,0,0,0.8)",
duration: 0.35,
ease: "power2.out",
});
const icon = e.currentTarget.querySelector("svg");
if (icon) {
gsap.to(icon, { rotate: -8, scale: 1.1, duration: 0.3, ease: "power2.out" });
}
}}
onMouseLeave={(e) => {
gsap.to(e.currentTarget, {
y: 0,
scale: 1,
backgroundColor: "rgba(255, 255, 255, 0.12)",
borderColor: "rgba(255, 255, 255, 0.24)",
color: "rgba(247, 248, 241, 0.86)",
boxShadow: "none",
duration: 0.35,
ease: "power2.out",
});
const icon = e.currentTarget.querySelector("svg");
if (icon) {
gsap.to(icon, { rotate: 0, scale: 1, duration: 0.3, ease: "power2.out" });
}
}}
className="inline-flex items-center gap-2 rounded-full border border-white/24 bg-white/12 px-5 py-3 text-sm font-medium text-cream/86 shadow-sm backdrop-blur-md"
>
<Camera className="h-4 w-4" />
相册
</Link>
<SocialDock />
</div>
</div>
<div className="home-reveal absolute inset-x-0 bottom-28 mx-auto flex w-full max-w-6xl items-end justify-start px-2 text-left text-[13px] text-cream/68 sm:bottom-32 sm:justify-between lg:bottom-36">
<div className="hidden items-center gap-3 rounded-full border border-white/16 bg-white/12 px-4 py-2 shadow-[0_14px_48px_-32px_rgba(0,0,0,0.8)] backdrop-blur-md sm:flex">
<Feather className="h-4 w-4 text-gold-light" />
<span>{featuredCount} 篇精选文章</span>
<span className="h-1 w-1 rounded-full bg-cream/35" />
<span>{galleryCount} 个相册切片</span>
</div>
<a
href="#home-sections"
className="inline-flex items-center gap-2 rounded-full border border-white/16 bg-white/12 px-4 py-2 shadow-[0_14px_48px_-32px_rgba(0,0,0,0.8)] backdrop-blur-md transition-colors hover:border-white/34 hover:text-cream sm:ml-auto"
<PenLine className="h-4 w-4" />
随笔
</Link>
<Link
href="/gallery"
prefetch={false}
onMouseEnter={(e) => {
gsap.to(e.currentTarget, {
y: -4,
scale: 1.02,
backgroundColor: "rgba(255, 255, 255, 0.18)",
borderColor: "rgba(255, 255, 255, 0.42)",
color: "#ffffff",
boxShadow: "0 24px 48px -18px rgba(0,0,0,0.8)",
duration: 0.35,
ease: "power2.out",
});
const icon = e.currentTarget.querySelector("svg");
if (icon) {
gsap.to(icon, { rotate: -8, scale: 1.1, duration: 0.3, ease: "power2.out" });
}
}}
onMouseLeave={(e) => {
gsap.to(e.currentTarget, {
y: 0,
scale: 1,
backgroundColor: "rgba(255, 255, 255, 0.12)",
borderColor: "rgba(255, 255, 255, 0.24)",
color: "rgba(247, 248, 241, 0.86)",
boxShadow: "none",
duration: 0.35,
ease: "power2.out",
});
const icon = e.currentTarget.querySelector("svg");
if (icon) {
gsap.to(icon, { rotate: 0, scale: 1, duration: 0.3, ease: "power2.out" });
}
}}
className="inline-flex items-center gap-2 rounded-full border border-white/24 bg-white/12 px-5 py-3 text-sm font-medium text-cream/86 shadow-sm backdrop-blur-md"
>
进入首页
<ArrowDown className="h-4 w-4" />
</a>
<Camera className="h-4 w-4" />
相册
</Link>
<SocialDock />
</div>
</div>
<div
className="hero-fade absolute inset-x-0 bottom-24 z-10 mx-auto flex w-full max-w-7xl items-end justify-between text-left text-[13px] text-cream/68 sm:bottom-28 lg:bottom-32"
style={{ animationDelay: "1.1s" }}
>
<div className="hidden items-center gap-3 rounded-full border border-white/16 bg-white/12 px-4 py-2 shadow-[0_14px_48px_-32px_rgba(0,0,0,0.8)] backdrop-blur-md sm:flex">
<Feather className="h-4 w-4 text-gold-light" />
<span>{featuredCount} 篇精选文章</span>
<span className="h-1 w-1 rounded-full bg-cream/35" />
<span>{galleryCount} 个相册切片</span>
</div>
<a
href="#home-sections"
className="ml-auto inline-flex items-center gap-3 text-[11px] uppercase tracking-[0.24em] text-cream/70 transition-colors hover:text-cream"
>
<span className="hidden sm:inline">Scroll to immerse</span>
<span className="font-serif text-[12px] tracking-[0.3em]">向下沉浸</span>
<span className="hero-scroll-line" aria-hidden="true" />
</a>
</div>
<div className="home-hero-wave pointer-events-none absolute inset-x-0 bottom-0 z-[3]" aria-hidden="true">
<svg
className="waves"
+30 -55
View File
@@ -1,7 +1,6 @@
"use client";
import { useEffect, useRef, useState } from "react";
import { Camera, Coffee, Compass } from "lucide-react";
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import type { GalleryPhoto } from "@/data/gallery";
@@ -32,41 +31,13 @@ export default function HomePageClient({
const [selectedPhoto, setSelectedPhoto] = useState<GalleryPhoto | null>(null);
const rootRef = useRef<HTMLDivElement>(null);
const articlesSectionRef = useRef<HTMLElement>(null);
const articlesTrackRef = useRef<HTMLDivElement>(null);
const gallerySectionRef = useRef<HTMLElement>(null);
const galleryTrackRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const root = rootRef.current;
if (!root) return;
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const isDesktop = window.matchMedia("(min-width: 1024px)").matches;
const setupRail = (section: HTMLElement | null, track: HTMLDivElement | null) => {
if (!section || !track || reduceMotion || !isDesktop) return;
const getDistance = () => {
const viewport = track.parentElement?.clientWidth ?? window.innerWidth;
return Math.max(0, track.scrollWidth - viewport);
};
if (getDistance() < 80) return;
gsap.to(track, {
x: () => -getDistance(),
ease: "none",
scrollTrigger: {
trigger: section,
start: "top 88px",
end: () => `+=${getDistance()}`,
pin: true,
scrub: 0.8,
invalidateOnRefresh: true,
anticipatePin: 1,
},
});
};
const ctx = gsap.context(() => {
if (reduceMotion) {
@@ -142,9 +113,6 @@ export default function HomePageClient({
},
}
);
setupRail(articlesSectionRef.current, articlesTrackRef.current);
setupRail(gallerySectionRef.current, galleryTrackRef.current);
}, root);
const refreshTimer = window.setTimeout(() => ScrollTrigger.refresh(), 250);
@@ -164,34 +132,41 @@ export default function HomePageClient({
featuredCount={featuredPosts.length}
galleryCount={homeGallerySlices.length}
heroBgUrl={configs?.["page.home.heroBgUrl"]}
eyebrowTag={configs?.["page.home.eyebrowTag"]}
heroTitle={configs?.["page.home.heroTitle"]}
welcomeText={configs?.["page.home.welcomeText"]}
welcomeSubtitle={configs?.["page.home.welcomeSubtitle"]}
logoText={configs?.["site.logo.text"]}
heroDescription={configs?.["page.home.heroDescription"]}
/>
{/* 精选文章:Zentry 标题 + Poetize 编辑式清单 */}
<section
id="home-sections"
ref={articlesSectionRef}
className="relative border-y border-charcoal/8 px-4 py-9 dark:border-white/10 sm:px-6 md:py-11 lg:px-8"
className="border-b border-charcoal/10 px-4 py-14 sm:px-6 md:py-20 lg:px-8 dark:border-white/10"
>
<div className="mx-auto grid max-w-7xl gap-6 lg:grid-cols-[0.34fr_0.66fr] lg:items-center">
<div className="mx-auto max-w-7xl">
<SectionIntro
icon={Coffee}
title="精选文章"
body="最近最想被读到的几篇,关于旅途、咖啡馆、代码和一些没那么急着说完的念头。"
num="01"
enLabel="Featured Writing"
enMain="FEATURED"
enOutline="精选"
cnTitle="精选文章"
href="/writing"
action="全部随笔"
/>
<ArticleRail posts={featuredPosts} trackRef={articlesTrackRef} />
<ArticleRail posts={featuredPosts} />
</div>
</section>
<section className="bento-grid-trigger px-4 py-9 sm:px-6 md:py-11 lg:px-8">
<div className="mx-auto grid max-w-7xl gap-6 lg:grid-cols-[0.34fr_0.66fr] lg:items-start">
{/* 此时状态:Zentry 标题 + Poetize 手账便签卡 */}
<section className="border-b border-charcoal/10 px-4 py-14 sm:px-6 md:py-20 lg:px-8 dark:border-white/10">
<div className="mx-auto max-w-7xl">
<SectionIntro
icon={Compass}
title="此时状态"
body="不是仪表盘,更像一张小便签。记录正在读、正在做和正在循环的声音。"
num="02"
enLabel="What I'm Doing Now"
enMain="NOW"
enOutline="此刻"
cnTitle="此时状态"
href="/now"
action="完整状态"
/>
@@ -199,23 +174,23 @@ export default function HomePageClient({
</div>
</section>
{/* 彩色相册:Zentry 深色反转区块 + 胶片网格 */}
<section
ref={gallerySectionRef}
className="relative border-y border-charcoal/8 px-4 py-9 dark:border-white/10 sm:px-6 md:py-11 lg:px-8"
className="gallery-zone border-b border-white/10 px-4 py-14 sm:px-6 md:py-20 lg:px-8"
>
<div className="mx-auto grid max-w-7xl gap-6 lg:grid-cols-[0.34fr_0.66fr] lg:items-center">
<div className="mx-auto max-w-7xl">
<SectionIntro
icon={Camera}
title="彩色相册"
body="日常光线、旅行色彩和偶然遇见的小片段,都先以自然的颜色留在这里。"
dark
num="03"
enLabel="Film & Light"
enMain="GALLERY"
enOutline="相册"
cnTitle="彩色相册"
href="/gallery"
action="打开相册"
/>
<GalleryRail
photos={homeGallerySlices}
trackRef={galleryTrackRef}
onSelect={setSelectedPhoto}
/>
<GalleryRail photos={homeGallerySlices} onSelect={setSelectedPhoto} />
</div>
</section>
+13 -35
View File
@@ -1,40 +1,18 @@
import { Compass } from "lucide-react";
export default function HomeQuote() {
return (
<section className="px-4 pt-10 pb-28 sm:px-6 md:pt-12 md:pb-36 lg:px-8">
<div className="home-card-reveal relative mx-auto max-w-4xl overflow-hidden rounded-[2rem] border border-gold/15 bg-gradient-to-br from-cream-dark/80 via-cream/65 to-gold-light/15 p-7 shadow-[0_18px_44px_-26px_rgba(217,134,95,0.5)] backdrop-blur dark:border-white/10 dark:from-white/8 dark:via-white/[0.04] dark:to-gold/10 md:p-10">
{/* 装饰性引号字形 */}
<span
aria-hidden="true"
className="pointer-events-none absolute -right-1 -top-7 select-none font-serif text-[8rem] leading-none text-gold/15 dark:text-gold/20 md:text-[10rem]"
>
”
</span>
{/* 暖色柔光晕 */}
<div
aria-hidden="true"
className="pointer-events-none absolute -bottom-12 -left-10 h-44 w-44 rounded-full bg-gold-light/25 blur-3xl dark:bg-gold/15"
/>
<div className="relative grid gap-6 md:grid-cols-[auto_1fr] md:items-start md:gap-7">
<div className="flex h-12 w-12 items-center justify-center rounded-2xl bg-gold/15 text-gold ring-1 ring-gold/20">
<Compass className="h-5 w-5 stroke-[1.6]" />
</div>
<div className="space-y-4">
<p className="text-pretty text-xl font-semibold leading-snug text-charcoal dark:text-cream md:text-[1.7rem]">
世界不是物体的集合,而是事件的集合。
</p>
<p className="max-w-xl text-sm leading-7 text-charcoal/60 dark:text-cream/65">
我喜欢把这句话放在首页末尾。它提醒我,博客不只是页面的集合,而是日常事件慢慢留下来的路径。
</p>
<div className="flex items-center gap-3 pt-1">
<span className="h-px w-8 bg-gold/45" />
<p className="text-[13px] font-medium tracking-wide text-charcoal/55 dark:text-cream/55">
卡洛·罗韦利 · 《时间的秩序》
</p>
</div>
</div>
<section className="px-4 py-20 sm:px-6 md:py-28 lg:px-8">
<div className="home-card-reveal mx-auto max-w-3xl text-center">
<div className="mx-auto mb-6 h-11 w-px bg-gradient-to-b from-transparent to-gold" />
<p className="text-balance font-serif text-2xl font-bold leading-relaxed tracking-wide text-charcoal dark:text-cream md:text-4xl">
世界不是物体的集合,而是事件的集合。
</p>
<div className="text-stroke-thin mt-5 font-display text-[clamp(1.5rem,4.2vw,2.8rem)] uppercase leading-none">
Events over Objects
</div>
<div className="mt-6 flex items-center justify-center gap-3.5 text-xs tracking-[0.2em] text-charcoal/55 dark:text-cream/55">
<span className="h-px w-7 bg-gold/50" />
卡洛·罗韦利 · 《时间的秩序》
<span className="h-px w-7 bg-gold/50" />
</div>
</div>
</section>
+51 -15
View File
@@ -1,30 +1,66 @@
import Link from "next/link";
import { ArrowUpRight } from "lucide-react";
import type { ComponentType } from "react";
interface SectionIntroProps {
icon: ComponentType<{ className?: string }>;
title: string;
body: string;
num: string;
enLabel: string;
enMain: string;
enOutline?: string;
cnTitle: string;
href: string;
action: string;
/** 深色反转区块(如相册 .gallery-zone)内使用:文字固定奶油色 */
dark?: boolean;
}
export default function SectionIntro({ icon: Icon, title, body, href, action }: SectionIntroProps) {
export default function SectionIntro({
num,
enLabel,
enMain,
enOutline,
cnTitle,
href,
action,
dark,
}: SectionIntroProps) {
return (
<div className="home-card-reveal max-w-md space-y-4">
<div className="flex h-11 w-11 items-center justify-center rounded-2xl bg-gold/14 text-gold">
<Icon className="h-5 w-5 stroke-[1.6]" />
</div>
<div className="space-y-3">
<h2 className="text-2xl font-semibold tracking-normal text-charcoal dark:text-cream md:text-3xl">
{title}
</h2>
<p className="text-sm leading-7 text-charcoal/62 dark:text-cream/68">{body}</p>
<div className="home-card-reveal">
{/* 编号行:编号 + 细分隔线 + 英文小标 */}
<div className="mb-3.5 flex items-center gap-4">
<span className="text-xs font-medium tracking-[0.3em] text-gold">{num}</span>
<span
className={`h-px flex-1 ${
dark ? "bg-white/12" : "bg-charcoal/10 dark:bg-white/10"
}`}
/>
<span
className={`text-[11px] font-medium uppercase tracking-[0.28em] ${
dark ? "text-cream/50" : "text-charcoal/45 dark:text-cream/50"
}`}
>
{enLabel}
</span>
</div>
{/* 巨字标题:实心英文 + 描边 + 金色中文 */}
<h2 className="flex flex-wrap items-baseline gap-x-3 gap-y-1 font-display text-[clamp(2.6rem,8vw,6rem)] uppercase leading-[0.94] tracking-[0.01em]">
<span className={dark ? "text-cream" : "text-charcoal dark:text-cream"}>
{enMain}
</span>
{enOutline && <span className="text-stroke-soft">{enOutline}</span>}
<span className="pb-[0.4em] font-serif text-[clamp(1rem,2vw,1.45rem)] font-bold normal-case tracking-[0.14em] text-gold">
{cnTitle}
</span>
</h2>
<Link
href={href}
className="inline-flex items-center gap-1.5 text-sm font-medium text-charcoal/70 transition-colors hover:text-charcoal dark:text-cream/70 dark:hover:text-cream"
prefetch={false}
className={`mt-5 inline-flex items-center gap-2.5 rounded-full border px-5 py-2.5 text-xs font-medium uppercase tracking-[0.24em] transition-colors duration-300 ${
dark
? "border-white/20 text-cream/65 hover:border-gold/60 hover:bg-gold/10 hover:text-gold-light"
: "border-charcoal/20 text-charcoal/60 hover:border-gold/70 hover:bg-gold/5 hover:text-gold dark:border-white/20 dark:text-cream/65 dark:hover:border-gold/60 dark:hover:bg-gold/10 dark:hover:text-gold-light"
}`}
>
{action}
<ArrowUpRight className="h-3.5 w-3.5" />
+1 -1
View File
@@ -1,5 +1,5 @@
import { Mail } from "lucide-react";
import { GithubLogo, XLogo } from "@phosphor-icons/react";
import { GithubLogoIcon as GithubLogo, XLogoIcon as XLogo } from "@phosphor-icons/react";
import gsap from "gsap";
export default function SocialDock() {
+35 -68
View File
@@ -1,97 +1,64 @@
"use client";
import { useEffect, useRef } from "react";
import { BookOpen, Film, Music } from "lucide-react";
import gsap from "gsap";
const statusCards = [
{
icon: BookOpen,
title: "正在读",
label: "正在读",
value: "《时间的秩序》",
body: "把夜晚留给物理、散文和几页慢读。读到好的句子就收进手账。",
},
{
icon: Film,
title: "正在做",
label: "正在做",
value: "春风不解别离",
body: "把文章、相册和生活状态重新整理成一个更像家的个人博客。",
},
{
icon: Music,
title: "正在听",
label: "正在听",
value: "Bill Evans Trio",
body: "钢琴声很轻,适合写代码、整理照片,也适合把页面留白收紧一点。",
},
];
// 重复 3 次卡片列表以实现无缝水平循环滚动
const extendedCards = [...statusCards, ...statusCards, ...statusCards];
export default function StatusGrid() {
const trackRef = useRef<HTMLDivElement>(null);
const tweenRef = useRef<gsap.core.Tween | null>(null);
useEffect(() => {
const track = trackRef.current;
if (!track) return;
const ctx = gsap.context(() => {
// 计算单组卡片(共3张卡片加对应间距)的总宽度,作为滚动的循环临界点
const getTranslateDistance = () => track.scrollWidth / 3;
// 创建平滑的无限水平滚动动画
tweenRef.current = gsap.to(track, {
x: () => -getTranslateDistance(),
duration: 20, // 调整滚动速度(数值越大滚动越慢)
ease: "none",
repeat: -1,
});
}, track);
const handleResize = () => {
if (tweenRef.current) {
tweenRef.current.invalidate();
tweenRef.current.restart();
}
};
window.addEventListener("resize", handleResize);
return () => {
ctx.revert();
window.removeEventListener("resize", handleResize);
};
}, []);
const handleMouseEnter = () => {
tweenRef.current?.pause();
};
const handleMouseLeave = () => {
tweenRef.current?.play();
};
return (
<div className="mask-image-horizontal overflow-hidden w-full py-2">
<div
ref={trackRef}
className="flex gap-4 w-max gpu-accelerated-track"
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
>
{extendedCards.map((item, index) => {
<div className="home-card-reveal mt-10 overflow-hidden rounded-[1.4rem] border border-charcoal/10 bg-gradient-to-br from-gold/5 via-transparent to-transparent md:mt-14 dark:border-white/10">
{/* 顶部金色饰条 */}
<div className="h-[3px] w-full bg-gradient-to-r from-gold via-gold-light to-transparent" />
{/* 手账头 */}
<div className="flex items-center justify-between gap-4 border-b border-charcoal/10 px-6 py-4 sm:px-8 dark:border-white/10">
<div className="flex items-baseline gap-3">
<b className="font-display text-base tracking-[0.24em] text-gold">NOW</b>
<span className="font-serif text-sm text-charcoal/60 dark:text-cream/60">
不是仪表盘,更像一张贴在手账上的小便签
</span>
</div>
<span className="hidden shrink-0 items-center gap-2 text-[11px] tracking-[0.2em] text-charcoal/40 dark:text-cream/40 sm:flex">
<span className="h-[3px] w-[3px] rounded-full bg-gold/70" />
LOCAL · NOW
</span>
</div>
{/* 三列状态 */}
<div className="grid md:grid-cols-3">
{statusCards.map((item) => {
const Icon = item.icon;
return (
<div
key={`${item.title}-${index}`}
className="home-card-reveal w-[260px] shrink-0 rounded-[1.6rem] border border-charcoal/8 bg-white/68 p-5 shadow-sm backdrop-blur transition duration-300 hover:bg-white/82 dark:border-white/10 dark:bg-white/8 dark:hover:bg-white/12 sm:w-[300px]"
key={item.label}
className="px-6 py-6 transition-colors duration-300 hover:bg-gold/5 sm:px-8 md:py-8 md:[&+div]:border-l md:[&+div]:border-charcoal/10 md:[&+div]:dark:border-white/10"
>
<div className="mb-5 flex h-11 w-11 items-center justify-center rounded-2xl bg-gold/14 text-gold">
<Icon className="h-5 w-5 stroke-[1.6]" />
</div>
<p className="text-[13px] text-charcoal/50 dark:text-cream/50">{item.title}</p>
<h3 className="mt-2 text-lg font-semibold text-charcoal dark:text-cream">{item.value}</h3>
<p className="mt-3 text-[13px] leading-6 text-charcoal/62 dark:text-cream/68">{item.body}</p>
<span className="font-serif text-[13px] tracking-[0.22em] text-gold">
{item.label}
</span>
<h4 className="mt-2 font-serif text-lg font-semibold leading-snug text-charcoal dark:text-cream">
{item.value}
</h4>
<p className="mt-2 text-[13px] leading-6 text-charcoal/55 dark:text-cream/60">
{item.body}
</p>
</div>
);
})}
+3 -1
View File
@@ -4,6 +4,7 @@ import { useRef, useEffect } from "react";
import { Lock, Eye } from "lucide-react";
import CountdownTimer from "./CountdownTimer";
import gsap from "gsap";
import { useAuthorProfile } from "@/hooks/useSysConfig";
interface CapsuleLetter {
id: string;
@@ -21,6 +22,7 @@ interface EnvelopeCardProps {
}
export default function EnvelopeCard({ letter, unlockedIds, onClick }: EnvelopeCardProps) {
const author = useAuthorProfile();
const cardRef = useRef<HTMLDivElement>(null);
const stampRef = useRef<HTMLDivElement>(null);
const sealRef = useRef<HTMLDivElement>(null);
@@ -187,7 +189,7 @@ export default function EnvelopeCard({ letter, unlockedIds, onClick }: EnvelopeC
style={{ transform: "translateZ(8px)" }}
>
<span className="font-serif italic text-xs text-charcoal/50 uppercase tracking-wider">
To: 未来的 Rrtiamo
To: 未来的 {author.name || "Rrtiamo"}
</span>
<span className="font-serif italic text-[11px] text-charcoal/40 uppercase tracking-wider">
From: {is2027 ? "2026年夏夜 · Private Atlas" : "2026年秋分 · 逻辑信箱"}
+3 -1
View File
@@ -4,6 +4,7 @@ import { useState, useRef, useEffect } from "react";
import { Mail, Key, Eye, X, Image as ImageIcon } from "lucide-react";
import { motion, AnimatePresence } from "framer-motion";
import gsap from "gsap";
import { useAuthorProfile } from "@/hooks/useSysConfig";
interface CapsuleLetter {
id: string;
@@ -28,6 +29,7 @@ export default function LetterModal({
unlockedIds,
onUnlockSuccess,
}: LetterModalProps) {
const author = useAuthorProfile();
const [bypassInput, setBypassInput] = useState("");
const [error, setError] = useState(false);
const [isOpeningTransition, setIsOpeningTransition] = useState(false);
@@ -246,7 +248,7 @@ export default function LetterModal({
<span>书于:2026 年夏日傍晚</span>
</div>
<div className="flex items-center space-x-2">
<span className="italic">Rrtiamo</span>
<span className="italic">{author.name || "Rrtiamo"}</span>
{/* 红色微型火漆私印 */}
<div className="w-5 h-5 rounded-full bg-red-800/80 flex items-center justify-center text-[7px] text-cream font-bold border border-red-700 shadow-sm">
印
+4 -4
View File
@@ -207,7 +207,7 @@ export default function LoveArticleRail({ entries, onSelect }: LoveArticleRailPr
type="button"
aria-label="向左查看更多日记"
onClick={() => handleManualNavigate("prev")}
className="p-2.5 rounded-full bg-white/70 dark:bg-zinc-900/80 backdrop-blur-md border border-charcoal/8 dark:border-white/10 text-charcoal hover:text-amber-600 dark:text-cream shadow-md transition-all duration-200 hover:scale-105 active:scale-95 flex items-center justify-center cursor-pointer focus-visible:outline-none"
className="p-2.5 rounded-full bg-white/70 dark:bg-zinc-900/80 backdrop-blur-md border border-charcoal/8 dark:border-white/10 text-charcoal hover:text-rose-500 dark:text-cream shadow-md transition-all duration-200 hover:scale-105 active:scale-95 flex items-center justify-center cursor-pointer focus-visible:outline-none"
>
<ChevronLeft className="w-5 h-5 stroke-[2]" />
</button>
@@ -217,7 +217,7 @@ export default function LoveArticleRail({ entries, onSelect }: LoveArticleRailPr
type="button"
aria-label="向右查看更多日记"
onClick={() => handleManualNavigate("next")}
className="p-2.5 rounded-full bg-white/70 dark:bg-zinc-900/80 backdrop-blur-md border border-charcoal/8 dark:border-white/10 text-charcoal hover:text-amber-600 dark:text-cream shadow-md transition-all duration-200 hover:scale-105 active:scale-95 flex items-center justify-center cursor-pointer focus-visible:outline-none"
className="p-2.5 rounded-full bg-white/70 dark:bg-zinc-900/80 backdrop-blur-md border border-charcoal/8 dark:border-white/10 text-charcoal hover:text-rose-500 dark:text-cream shadow-md transition-all duration-200 hover:scale-105 active:scale-95 flex items-center justify-center cursor-pointer focus-visible:outline-none"
>
<ChevronRight className="w-5 h-5 stroke-[2]" />
</button>
@@ -242,7 +242,7 @@ export default function LoveArticleRail({ entries, onSelect }: LoveArticleRailPr
key={`${entry.id}-${idx}`}
type="button"
onClick={() => onSelect(entry)}
className="article-card-element group w-[270px] shrink-0 overflow-hidden rounded-[1.6rem] border border-charcoal/8 bg-white/72 p-3 text-left shadow-sm backdrop-blur transition duration-300 hover:-translate-y-1 hover:shadow-[0_18px_50px_-32px_rgba(26,26,26,0.38)] dark:border-white/10 dark:bg-white/8 sm:w-[320px] focus-visible:outline-none focus-visible:border-amber-500/30"
className="article-card-element group w-[270px] shrink-0 overflow-hidden rounded-[1.6rem] border border-charcoal/8 bg-white/72 p-3 text-left shadow-sm backdrop-blur transition duration-300 hover:-translate-y-1 hover:shadow-[0_18px_50px_-32px_rgba(26,26,26,0.38)] dark:border-white/10 dark:bg-white/8 sm:w-[320px] focus-visible:outline-none focus-visible:border-rose-500/30"
>
<div className="overflow-hidden rounded-[1.2rem] aspect-[16/10] bg-charcoal/5 relative">
<ParallaxImage
@@ -275,7 +275,7 @@ export default function LoveArticleRail({ entries, onSelect }: LoveArticleRailPr
阅读故事
<ArrowUpRight className="h-3.5 w-3.5 transition-transform duration-300 group-hover:translate-x-0.5 group-hover:-translate-y-0.5" />
</span>
<span className="text-[10px] text-amber-600/70 dark:text-amber-400/70 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity duration-300">
<span className="text-[10px] text-rose-600/70 dark:text-rose-400/70 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity duration-300">
<Sparkles className="w-2.5 h-2.5" />
翻阅回忆
</span>
+26 -28
View File
@@ -4,6 +4,7 @@ import { useState, useRef } from "react";
import Image from "next/image";
import type { BucketItem } from "@/interface/love";
import { Check, Heart, Smile, Plane, Utensils, Home, Compass } from "lucide-react";
import LoveSectionHeading from "./LoveSectionHeading";
interface LoveBucketListProps {
items: BucketItem[];
@@ -32,22 +33,19 @@ export default function LoveBucketList({ items }: LoveBucketListProps) {
return (
<div className="w-full py-12 px-4 max-w-7xl mx-auto sm:px-6 lg:px-8">
{/* 头部进度信息 */}
<div className="flex flex-col lg:flex-row lg:items-center justify-between gap-6 mb-10 border-b border-charcoal/5 dark:border-white/5 pb-8">
<div>
<span className="text-sm font-semibold text-gold">
慢慢完成的约定
</span>
<h2 className="mt-1 text-3xl font-semibold tracking-[-0.02em] text-charcoal dark:text-cream">
爱的 100 件事
</h2>
<p className="text-sm tone-muted mt-2 font-sans">
将对未来的期待写进清单,然后一件件,用温度与光影将它们逐一“点亮”。
</p>
</div>
{/* 头部:统一巨字标题 + 进度环看板 */}
<div className="flex flex-col lg:flex-row lg:items-end justify-between gap-8 mb-12">
<LoveSectionHeading
num="05"
label="Bucket List"
enMain="100"
enOutline="THINGS"
cnTitle="爱的 100 件事"
description="将对未来的期待写进清单,然后一件件,用温度与光影将它们逐一“点亮”。"
/>
{/* 精美进度环看板 */}
<div className="flex items-center gap-4 bg-amber-50/50 dark:bg-amber-950/15 border border-amber-900/10 dark:border-amber-400/10 rounded-2xl p-4 sm:px-6 shrink-0">
<div className="flex items-center gap-4 bg-rose-50/50 dark:bg-rose-950/15 border border-rose-900/10 dark:border-rose-400/10 rounded-2xl p-4 sm:px-6 shrink-0">
<div className="relative w-16 h-16 flex items-center justify-center shrink-0">
<svg className="w-full h-full transform -rotate-90">
<circle
@@ -57,7 +55,7 @@ export default function LoveBucketList({ items }: LoveBucketListProps) {
stroke="currentColor"
strokeWidth="4"
fill="transparent"
className="text-amber-900/10 dark:text-amber-400/10"
className="text-rose-900/10 dark:text-rose-400/10"
/>
<circle
cx="32"
@@ -69,16 +67,16 @@ export default function LoveBucketList({ items }: LoveBucketListProps) {
strokeDashoffset={2 * Math.PI * 26 * (1 - percent / 100)}
strokeLinecap="round"
fill="transparent"
className="text-amber-600 dark:text-amber-400 transition-all duration-1000"
className="text-rose-600 dark:text-rose-400 transition-all duration-1000"
/>
</svg>
<span className="absolute text-sm font-mono font-bold text-amber-950 dark:text-amber-100">
<span className="absolute text-sm font-mono font-bold text-rose-950 dark:text-rose-100">
{percent}%
</span>
</div>
<div>
<div className="text-xs tone-muted font-sans font-semibold">已点亮愿望</div>
<div className="text-lg font-serif font-bold text-amber-950 dark:text-amber-100 mt-0.5">
<div className="text-lg font-serif font-bold text-rose-950 dark:text-rose-100 mt-0.5">
{completed} <span className="text-xs tone-muted">/ {total}</span>
</div>
</div>
@@ -93,8 +91,8 @@ export default function LoveBucketList({ items }: LoveBucketListProps) {
onClick={() => setActiveFilter(cat.key)}
className={`cursor-pointer rounded-full px-4 py-2 text-sm font-semibold transition-all duration-300 ${
activeFilter === cat.key
? "bg-amber-600 dark:bg-amber-500 text-white shadow-sm"
: "border border-charcoal/8 dark:border-white/10 hover:border-amber-600/50 hover:text-amber-600 tone-muted"
? "bg-rose-600 dark:bg-rose-500 text-white shadow-sm"
: "border border-charcoal/8 dark:border-white/10 hover:border-rose-600/50 hover:text-rose-600 tone-muted"
}`}
>
{cat.label}
@@ -218,7 +216,7 @@ function BucketCard({ item }: { item: BucketItem }) {
onClick={handleCardClick}
className={`relative overflow-hidden border rounded-2xl p-5 flex flex-col justify-between h-[180px] cursor-pointer select-none transition-all duration-300 ${
item.completed
? "bg-amber-50/20 dark:bg-amber-950/5 border-amber-900/10 dark:border-amber-400/10 shadow-sm hover:shadow-md"
? "bg-rose-50/20 dark:bg-rose-950/5 border-rose-900/10 dark:border-rose-400/10 shadow-sm hover:shadow-md"
: "bg-cream/40 dark:bg-charcoal/40 border-charcoal/8 dark:border-white/10 hover:border-charcoal/15 dark:hover:border-white/20 hover:scale-[1.02]"
}`}
>
@@ -234,7 +232,7 @@ function BucketCard({ item }: { item: BucketItem }) {
{getCategoryName(item.category)}
</span>
{item.completed && (
<span className="text-amber-600 dark:text-amber-400 p-1 bg-amber-500/10 rounded-full">
<span className="text-rose-600 dark:text-rose-400 p-1 bg-rose-500/10 rounded-full">
<Check className="w-3.5 h-3.5 stroke-[2.5]" />
</span>
)}
@@ -254,7 +252,7 @@ function BucketCard({ item }: { item: BucketItem }) {
<div className="mt-4 flex justify-between items-end border-t border-charcoal/5 dark:border-white/5 pt-3">
{item.completed ? (
<>
<span className="text-[10px] font-mono font-semibold text-amber-800/60 dark:text-amber-400/60 leading-none">
<span className="text-[10px] font-mono font-semibold text-rose-800/60 dark:text-rose-400/60 leading-none">
{item.completedDate}
</span>
{/* 拟物斜印章印记 */}
@@ -272,7 +270,7 @@ function BucketCard({ item }: { item: BucketItem }) {
</>
) : (
/* 反面卡片展示想法回忆 */
<div className="absolute inset-0 bg-amber-50 dark:bg-zinc-950 p-4 flex flex-col justify-between z-20 overflow-hidden animate-fade-in text-left">
<div className="absolute inset-0 bg-rose-50 dark:bg-zinc-950 p-4 flex flex-col justify-between z-20 overflow-hidden animate-fade-in text-left">
{item.cover ? (
<div className="flex gap-3 h-full items-center">
<div className="relative w-20 h-full rounded-lg overflow-hidden shrink-0 border border-charcoal/10 bg-black/5">
@@ -285,20 +283,20 @@ function BucketCard({ item }: { item: BucketItem }) {
/>
</div>
<div className="flex-1 min-w-0 flex flex-col justify-between h-full py-1">
<p className="text-xs leading-normal font-sans font-medium text-amber-950 dark:text-zinc-300 line-clamp-4 italic">
<p className="text-xs leading-normal font-sans font-medium text-rose-950 dark:text-zinc-300 line-clamp-4 italic">
“{item.thoughts || "完成这件事的感动,都藏在合照里。"}”
</p>
<span className="text-[9px] font-mono text-amber-800/50 dark:text-zinc-500 block">
<span className="text-[9px] font-mono text-rose-800/50 dark:text-zinc-500 block">
点亮日期: {item.completedDate}
</span>
</div>
</div>
) : (
<div className="flex flex-col justify-between h-full py-1">
<p className="text-xs leading-relaxed font-sans font-medium text-amber-950 dark:text-zinc-300 italic whitespace-pre-line overflow-y-auto">
<p className="text-xs leading-relaxed font-sans font-medium text-rose-950 dark:text-zinc-300 italic whitespace-pre-line overflow-y-auto">
“{item.thoughts}”
</p>
<span className="text-[9px] font-mono text-amber-800/50 dark:text-zinc-500 block mt-2 border-t border-amber-900/5 pt-1">
<span className="text-[9px] font-mono text-rose-800/50 dark:text-zinc-500 block mt-2 border-t border-rose-900/5 pt-1">
点亮日期: {item.completedDate}
</span>
</div>
+4 -4
View File
@@ -207,7 +207,7 @@ export default function LoveGalleryRail({ photos, onSelect }: LoveGalleryRailPro
type="button"
aria-label="向左查看更多照片"
onClick={() => handleManualNavigate("prev")}
className="p-2.5 rounded-full bg-white/70 dark:bg-zinc-900/80 backdrop-blur-md border border-charcoal/8 dark:border-white/10 text-charcoal hover:text-amber-600 dark:text-cream shadow-md transition-all duration-200 hover:scale-105 active:scale-95 flex items-center justify-center cursor-pointer focus-visible:outline-none"
className="p-2.5 rounded-full bg-white/70 dark:bg-zinc-900/80 backdrop-blur-md border border-charcoal/8 dark:border-white/10 text-charcoal hover:text-rose-500 dark:text-cream shadow-md transition-all duration-200 hover:scale-105 active:scale-95 flex items-center justify-center cursor-pointer focus-visible:outline-none"
>
<ChevronLeft className="w-5 h-5 stroke-[2]" />
</button>
@@ -217,7 +217,7 @@ export default function LoveGalleryRail({ photos, onSelect }: LoveGalleryRailPro
type="button"
aria-label="向右查看更多照片"
onClick={() => handleManualNavigate("next")}
className="p-2.5 rounded-full bg-white/70 dark:bg-zinc-900/80 backdrop-blur-md border border-charcoal/8 dark:border-white/10 text-charcoal hover:text-amber-600 dark:text-cream shadow-md transition-all duration-200 hover:scale-105 active:scale-95 flex items-center justify-center cursor-pointer focus-visible:outline-none"
className="p-2.5 rounded-full bg-white/70 dark:bg-zinc-900/80 backdrop-blur-md border border-charcoal/8 dark:border-white/10 text-charcoal hover:text-rose-500 dark:text-cream shadow-md transition-all duration-200 hover:scale-105 active:scale-95 flex items-center justify-center cursor-pointer focus-visible:outline-none"
>
<ChevronRight className="w-5 h-5 stroke-[2]" />
</button>
@@ -242,7 +242,7 @@ export default function LoveGalleryRail({ photos, onSelect }: LoveGalleryRailPro
key={`${entry.id}-${idx}`}
type="button"
onClick={() => onSelect(entry)}
className="gallery-slice-element group w-[270px] shrink-0 overflow-hidden rounded-[1.6rem] border border-charcoal/8 bg-white/72 p-3 text-left shadow-sm backdrop-blur transition duration-300 hover:-translate-y-1 hover:shadow-[0_18px_50px_-32px_rgba(26,26,26,0.4)] dark:border-white/10 dark:bg-white/8 sm:w-[320px] focus-visible:outline-none focus-visible:border-amber-500/30"
className="gallery-slice-element group w-[270px] shrink-0 overflow-hidden rounded-[1.6rem] border border-charcoal/8 bg-white/72 p-3 text-left shadow-sm backdrop-blur transition duration-300 hover:-translate-y-1 hover:shadow-[0_18px_50px_-32px_rgba(26,26,26,0.4)] dark:border-white/10 dark:bg-white/8 sm:w-[320px] focus-visible:outline-none focus-visible:border-rose-500/30"
>
<div className="relative overflow-hidden rounded-[1.2rem] aspect-[4/3] bg-charcoal/5">
<ParallaxImage
@@ -274,7 +274,7 @@ export default function LoveGalleryRail({ photos, onSelect }: LoveGalleryRailPro
<Heart className="h-3.5 w-3.5 text-rose-500 fill-rose-500/20" />
<span>心情: {moodLabelMap[entry.mood] || entry.mood}</span>
</p>
<span className="text-[10px] text-amber-600/70 dark:text-amber-400/70 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity duration-300">
<span className="text-[10px] text-rose-600/70 dark:text-rose-400/70 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity duration-300">
<Sparkles className="w-2.5 h-2.5" />
放大瞬间
</span>
+98 -24
View File
@@ -1,7 +1,7 @@
"use client";
import { useEffect, useRef, useState } from "react";
import { Camera, Heart, Lock, Unlock } from "lucide-react";
import { Heart, Lock, Unlock } from "lucide-react";
import type { GalleryPhoto } from "@/data/gallery";
import type { LoveEntry } from "@/interface/love";
import {
@@ -11,11 +11,11 @@ import {
useLoveStats,
} from "@/hooks/useLove";
import Lightbox from "@/components/gallery/Lightbox";
import SectionIntro from "@/components/home/SectionIntro";
import LoveArticleRail from "@/components/love/LoveArticleRail";
import LoveBucketList from "@/components/love/LoveBucketList";
import LoveGalleryRail from "@/components/love/LoveGalleryRail";
import LoveQuote from "@/components/love/LoveQuote";
import LoveSectionHeading from "@/components/love/LoveSectionHeading";
import LoveStats from "@/components/love/LoveStats";
import LoveTimeCapsule from "@/components/love/LoveTimeCapsule";
import LoveTimeline from "@/components/love/LoveTimeline";
@@ -23,9 +23,22 @@ import LoveHero from "@/components/love/hero/LoveHero";
import PasscodeGate from "@/components/ui/PasscodeGate";
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import { useCoupleProfile } from "@/hooks/useSysConfig";
gsap.registerPlugin(ScrollTrigger);
// Zentry 式 Marquee 滚动字幕条文案(每半段重复多遍,保证任意屏幕宽度下均无缝无限滚动)
const MARQUEE_ITEMS = [
"Sweet Moments",
"Love Diary",
"恋爱编年史",
"爱的 100 件事",
"时光信箱",
"我们的档案馆",
];
const MARQUEE_SET = [...MARQUEE_ITEMS, ...MARQUEE_ITEMS, ...MARQUEE_ITEMS];
function galleryPhotoOfLoveEntry(entry: LoveEntry): GalleryPhoto {
return {
id: entry.id,
@@ -56,6 +69,7 @@ export default function LovePageClient({ configs }: LovePageClientProps) {
const { bucketItems, loading: bucketLoading } = useLoveBucket();
const { capsules, loading: capsuleLoading } = useLoveCapsules();
const { stats: loveStats, loading: statsLoading } = useLoveStats();
const couple = useCoupleProfile();
const [selectedPhoto, setSelectedPhoto] = useState<GalleryPhoto | null>(null);
const [showGate, setShowGate] = useState(false);
@@ -102,14 +116,66 @@ export default function LovePageClient({ configs }: LovePageClientProps) {
contentRef.current?.scrollIntoView({ behavior: "smooth", block: "start" });
};
// 伴侣信息(昵称/头像)由管理端个人中心卡片 C 维护;未配置时仅顶部提示,不整页阻断
const coupleConfigured = Boolean(couple.name || couple.avatar);
const handleGoToProfile = () => {
let adminUrl = "http://localhost:5173/#/profile";
if (typeof window !== "undefined") {
const origin = window.location.origin;
if (origin.includes(":3000")) {
adminUrl = origin.replace(":3000", ":5173") + "/#/profile";
} else {
// 生产环境通常挂载在 /admin 下
adminUrl = origin + "/admin/#/profile";
}
}
window.open(adminUrl, "_blank");
};
const coupleBanner = !coupleConfigured ? (
<div className="mx-auto max-w-7xl px-4 pt-6 sm:px-6 lg:px-8">
<div className="flex flex-wrap items-center gap-3 rounded-2xl border border-rose-500/20 bg-rose-500/5 px-4 py-3 text-sm text-charcoal/75 dark:text-cream/75">
<Heart className="h-4 w-4 shrink-0 text-rose-500" />
<span>恋爱记伴侣信息尚未配置,部分内容将以默认样式展示。</span>
<button
type="button"
onClick={handleGoToProfile}
className="ml-auto shrink-0 text-xs font-semibold text-rose-500 hover:underline"
>
前往后台配置
</button>
</div>
</div>
) : null;
return (
<div className="w-full max-w-full overflow-x-hidden bg-cream text-charcoal transition-colors duration-500 dark:bg-charcoal dark:text-cream">
{coupleBanner}
<LoveHero
onScrollDown={handleScrollDown}
heroBgUrl={configs?.["page.love.heroBgUrl"]}
atmospheresJson={configs?.["page.love.atmospheres"]}
/>
{/* Zentry 式 Marquee 滚动字幕条 */}
<div className="overflow-hidden border-y border-charcoal/8 bg-rose-500/[0.04] py-3 select-none dark:border-white/10">
<div className="atlas-marquee-track">
{[0, 1].map((dup) => (
<div key={dup} className="flex items-center" aria-hidden={dup === 1}>
{MARQUEE_SET.map((item, i) => (
<span key={`${dup}-${i}`} className="flex items-center whitespace-nowrap">
<span className="px-6 font-display text-sm uppercase tracking-[0.22em] text-charcoal/70 dark:text-cream/70">
{item}
</span>
<Heart className="size-3 shrink-0 fill-rose-500/70 text-rose-500/70" />
</span>
))}
</div>
))}
</div>
</div>
<div
ref={contentRef}
className="relative w-full scroll-mt-5 bg-cream transition-colors duration-500 dark:bg-charcoal"
@@ -156,34 +222,42 @@ export default function LovePageClient({ configs }: LovePageClientProps) {
<div className="w-full">
<section className="relative border-y border-charcoal/8 bg-cream/45 px-4 py-8 dark:border-white/10 dark:bg-charcoal/45 sm:px-6 md:py-10 lg:px-8">
<div className="mx-auto grid max-w-7xl gap-6 lg:grid-cols-[minmax(240px,0.32fr)_minmax(0,0.68fr)] lg:items-center">
<SectionIntro
icon={Camera}
title="甜蜜瞬间"
body="把日常光影、偶然相遇和一起停下来的时刻,按自然色彩留在这里。"
href="/love"
action="查看照片"
/>
<LoveGalleryRail
photos={visibleEntries}
onSelect={(entry) => setSelectedPhoto(galleryPhotoOfLoveEntry(entry))}
<div className="mx-auto max-w-7xl">
<LoveSectionHeading
num="03"
label="Sweet Moments"
enMain="SWEET"
enOutline="MOMENTS"
cnTitle="甜蜜瞬间"
description="把日常光影、偶然相遇和一起停下来的时刻,按自然色彩留在这里。"
action={{ href: "/love", text: "查看照片" }}
/>
<div className="mt-10">
<LoveGalleryRail
photos={visibleEntries}
onSelect={(entry) => setSelectedPhoto(galleryPhotoOfLoveEntry(entry))}
/>
</div>
</div>
</section>
<section className="relative border-b border-charcoal/8 bg-cream/45 px-4 py-8 dark:border-white/10 dark:bg-charcoal/45 sm:px-6 md:py-10 lg:px-8">
<div className="mx-auto grid max-w-7xl gap-6 lg:grid-cols-[minmax(240px,0.32fr)_minmax(0,0.68fr)] lg:items-center">
<SectionIntro
icon={Heart}
title="恋爱日记"
body="那些小笑声、绕远路和晚归路上的灯,都可以被慢慢写下来。"
href="/love"
action="阅读故事"
/>
<LoveArticleRail
entries={visibleEntries}
onSelect={(entry) => setSelectedPhoto(galleryPhotoOfLoveEntry(entry))}
<div className="mx-auto max-w-7xl">
<LoveSectionHeading
num="04"
label="Love Diary"
enMain="LOVE"
enOutline="DIARY"
cnTitle="恋爱日记"
description="那些小笑声、绕远路和晚归路上的灯,都可以被慢慢写下来。"
action={{ href: "/love", text: "阅读故事" }}
/>
<div className="mt-10">
<LoveArticleRail
entries={visibleEntries}
onSelect={(entry) => setSelectedPhoto(galleryPhotoOfLoveEntry(entry))}
/>
</div>
</div>
</section>
</div>
+56 -19
View File
@@ -1,42 +1,79 @@
"use client";
import { Heart } from "lucide-react";
import { useAuthorProfile, useCoupleProfile } from "@/hooks/useSysConfig";
export default function LoveQuote() {
const author = useAuthorProfile();
const couple = useCoupleProfile();
return (
<section className="px-4 pt-10 pb-28 sm:px-6 md:pt-12 md:pb-36 lg:px-8">
<div className="home-card-reveal relative mx-auto max-w-4xl overflow-hidden rounded-[2rem] border border-rose-500/15 bg-gradient-to-br from-cream-dark/80 via-cream/65 to-rose-400/15 p-7 shadow-[0_18px_44px_-26px_rgba(244,63,94,0.3)] backdrop-blur dark:border-white/10 dark:from-white/8 dark:via-white/[0.04] dark:to-rose-500/10 md:p-10">
{/* 章末装饰分隔线:金线 + 爱心菱形 */}
<div className="home-card-reveal mx-auto mb-8 flex max-w-3xl items-center gap-4">
<div className="h-px grow bg-gradient-to-r from-transparent via-rose-500/25 to-rose-500/45" />
<div className="flex shrink-0 items-center gap-2 text-rose-500/60">
<span className="block size-1.5 rotate-45 bg-rose-500/60" />
<Heart className="size-3 fill-current" />
<span className="block size-1.5 rotate-45 bg-rose-500/60" />
</div>
<div className="h-px grow bg-gradient-to-l from-transparent via-rose-500/25 to-rose-500/45" />
</div>
<div className="home-card-reveal relative mx-auto max-w-3xl overflow-hidden rounded-[1.75rem] border border-rose-500/15 bg-gradient-to-br from-cream-dark/80 via-cream/65 to-rose-400/15 p-6 shadow-[0_18px_44px_-26px_rgba(244,63,94,0.3)] backdrop-blur dark:border-white/10 dark:from-white/8 dark:via-white/[0.04] dark:to-rose-500/10 md:p-10">
{/* 装饰性双引号背景字 */}
<span
aria-hidden="true"
className="pointer-events-none absolute -right-1 -top-7 select-none font-serif text-[8rem] leading-none text-rose-500/10 dark:text-rose-500/20 md:text-[10rem]"
className="pointer-events-none absolute -right-1 -top-6 select-none font-serif text-[6rem] leading-none text-rose-500/10 dark:text-rose-500/20 md:text-[8rem]"
>
”
</span>
{/* 暖粉色柔光晕 */}
<div
aria-hidden="true"
className="pointer-events-none absolute -bottom-12 -left-10 h-44 w-44 rounded-full bg-rose-300/25 blur-3xl dark:bg-rose-500/15"
className="pointer-events-none absolute -bottom-10 -left-8 h-36 w-36 rounded-full bg-rose-300/25 blur-3xl dark:bg-rose-500/15"
/>
<div className="relative grid gap-6 md:grid-cols-[auto_1fr] md:items-start md:gap-7">
<div className="flex h-12 w-12 items-center justify-center rounded-2xl bg-rose-500/10 text-rose-500 ring-1 ring-rose-500/20">
<Heart className="h-5 w-5 stroke-[1.6]" />
{/* 四角档案印章角标 */}
<span aria-hidden="true" className="pointer-events-none absolute left-3.5 top-3.5 size-1.5 rotate-45 border border-rose-500/40" />
<span aria-hidden="true" className="pointer-events-none absolute right-3.5 top-3.5 size-1.5 rotate-45 border border-rose-500/40" />
<span aria-hidden="true" className="pointer-events-none absolute bottom-3.5 left-3.5 size-1.5 rotate-45 border border-rose-500/40" />
<span aria-hidden="true" className="pointer-events-none absolute bottom-3.5 right-3.5 size-1.5 rotate-45 border border-rose-500/40" />
{/* 居中仪式感内容 */}
<div className="relative flex flex-col items-center text-center">
{/* 爱心徽记 */}
<div className="flex size-11 items-center justify-center rounded-full bg-rose-500/10 text-rose-500 ring-1 ring-rose-500/20">
<Heart className="size-5 stroke-[1.6]" />
</div>
<div className="space-y-4">
<p className="text-pretty text-xl font-semibold leading-snug text-charcoal dark:text-cream md:text-[1.7rem]">
我们携手走过四季,把时间酿成记忆。
</p>
<p className="max-w-xl text-sm leading-7 text-charcoal/62 dark:text-cream/68">
我喜欢把这句话放在恋爱记的末尾。它提醒我们,每一个稀疏平常的日常里,有你在身旁,就是最温柔的时光档案馆。
</p>
<div className="flex items-center gap-3 pt-1">
<span className="h-px w-8 bg-rose-500/45" />
<p className="text-[13px] font-medium tracking-wide text-charcoal/55 dark:text-cream/55">
Rrtiamo & Sweetheart · 《生活档案馆》
</p>
</div>
{/* 主引文 */}
<p className="mt-5 text-pretty font-serif text-lg font-medium leading-snug text-charcoal dark:text-cream md:text-xl">
我们携手走过四季,把时间酿成记忆。
</p>
{/* 副文案 */}
<p className="mt-4 max-w-md text-sm leading-7 text-charcoal/62 dark:text-cream/68">
我喜欢把这句话放在恋爱记的末尾。它提醒我们,每一个稀疏平常的日常里,有你在身旁,就是最温柔的时光档案馆。
</p>
{/* 署名金线分隔 */}
<div className="mt-6 flex items-center gap-3">
<span className="h-px w-8 bg-gradient-to-r from-transparent to-rose-500/50" />
<span className="block size-1.5 rotate-45 bg-rose-500/60" />
<span className="h-px w-8 bg-gradient-to-l from-transparent to-rose-500/50" />
</div>
{/* 手写体署名(内联字体变量,不依赖 LetterModal 注入的全局类) */}
<p
className="mt-3 text-lg text-rose-900/75 dark:text-rose-300/80"
style={{ fontFamily: "var(--font-ma-shan-zheng), cursive, sans-serif" }}
>
{author.name || "Rrtiamo"}
{couple.name ? ` & ${couple.name}` : ""}
</p>
<p className="mt-1 text-[11px] font-medium uppercase tracking-[0.28em] text-charcoal/45 dark:text-cream/45">
《生活档案馆》
</p>
</div>
</div>
</section>
@@ -0,0 +1,67 @@
"use client";
import Link from "next/link";
import { ArrowUpRight } from "lucide-react";
interface LoveSectionHeadingProps {
num: string;
label: string;
enMain: string;
enOutline?: string;
cnTitle: string;
description?: string;
action?: { href: string; text: string };
}
/** 恋爱页统一章节标题:Zentry 式巨字排版(实心 + 描边 + 金色中文),玫瑰色编号小标签 */
export default function LoveSectionHeading({
num,
label,
enMain,
enOutline,
cnTitle,
description,
action,
}: LoveSectionHeadingProps) {
return (
<div className="home-card-reveal w-full">
{/* 编号 + 细分隔线 + 英文小标签 */}
<div className="mb-4 flex items-center gap-4">
<span className="text-xs font-medium tracking-[0.3em] text-rose-500">{num}</span>
<span className="h-px flex-1 bg-charcoal/10 dark:bg-white/10" />
<span className="text-[11px] font-medium uppercase tracking-[0.28em] text-charcoal/45 dark:text-cream/50">
{label}
</span>
</div>
{/* 巨字标题行 + 右侧描述/按钮 */}
<div className="flex flex-wrap items-end justify-between gap-x-8 gap-y-5">
<h2 className="font-display text-[clamp(2.6rem,7.5vw,5.5rem)] uppercase leading-[0.92] tracking-[0.01em]">
<span className="text-charcoal dark:text-cream">{enMain}</span>
{enOutline && <span className="ml-1 text-stroke-soft">{enOutline}</span>}
<span className="ml-2 inline-block pb-[0.4em] font-serif text-[clamp(1.1rem,2vw,1.5rem)] font-bold normal-case tracking-[0.14em] text-gold">
{cnTitle}
</span>
</h2>
<div className="flex shrink-0 flex-col items-start gap-3 pb-1.5">
{description && (
<p className="max-w-sm text-sm leading-7 text-charcoal/62 dark:text-cream/68">
{description}
</p>
)}
{action && (
<Link
href={action.href}
prefetch={false}
className="inline-flex items-center gap-2.5 rounded-full border border-charcoal/20 px-5 py-2.5 text-xs font-medium uppercase tracking-[0.24em] text-charcoal/60 transition-colors duration-300 hover:border-rose-500/60 hover:bg-rose-500/5 hover:text-rose-500 dark:border-white/20 dark:text-cream/65 dark:hover:border-rose-400/60 dark:hover:text-rose-400"
>
{action.text}
<ArrowUpRight className="h-3.5 w-3.5" />
</Link>
)}
</div>
</div>
</div>
);
}
+13 -15
View File
@@ -5,6 +5,7 @@ import { LoveStats as StatsType } from "@/interface/love";
import { Calendar, Compass, Film, Utensils } from "lucide-react";
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import LoveSectionHeading from "./LoveSectionHeading";
if (typeof window !== "undefined") {
gsap.registerPlugin(ScrollTrigger);
@@ -122,25 +123,22 @@ export default function LoveStats({ stats }: LoveStatsProps) {
return (
<div ref={containerRef} className="w-full py-10 px-4 max-w-7xl mx-auto sm:px-6 lg:px-8">
{/* 模块标题 */}
<div className="mb-8 flex flex-col md:flex-row md:items-end justify-between gap-4">
<div>
<span className="text-sm font-semibold text-gold">
被时间认真记下的日常
</span>
<h2 className="mt-1 text-3xl font-semibold tracking-[-0.02em] text-charcoal dark:text-cream">
陪伴档案馆
</h2>
</div>
<p className="text-sm tone-muted max-w-md font-sans">
时光如水,而数字是我们携手走过四季最忠实的刻度。
</p>
{/* 模块标题(统一巨字排版) */}
<div className="mb-12">
<LoveSectionHeading
num="01"
label="Companion Archive"
enMain="COMPANION"
enOutline="ARCHIVE"
cnTitle="陪伴档案馆"
description="时光如水,而数字是我们携手走过四季最忠实的刻度。"
/>
</div>
{/* Bento Grid 布局 */}
<div className="grid grid-cols-1 md:grid-cols-4 gap-6">
{/* 卡片 1: 相识天数 (双倍宽) */}
<div className="md:col-span-2 relative overflow-hidden bg-amber-50/40 dark:bg-amber-950/10 border border-amber-900/10 dark:border-amber-400/10 rounded-2xl p-6 sm:p-8 flex flex-col justify-between group hover:border-amber-900/20 dark:hover:border-amber-400/20 transition-all duration-300">
<div className="md:col-span-2 relative overflow-hidden bg-rose-50/40 dark:bg-rose-950/10 border border-rose-900/10 dark:border-rose-400/10 rounded-2xl p-6 sm:p-8 flex flex-col justify-between group hover:border-rose-900/20 dark:hover:border-rose-400/20 transition-all duration-300">
<div className="flex items-center justify-between">
<div className="p-3 bg-gold/12 rounded-xl text-gold">
<Calendar className="w-6 h-6 stroke-[1.5]" />
@@ -231,7 +229,7 @@ export default function LoveStats({ stats }: LoveStatsProps) {
strokeDasharray="4 6"
className="text-charcoal/30 dark:text-cream/30"
/>
<g ref={planeRef} className="text-amber-800 dark:text-amber-400">
<g ref={planeRef} className="text-rose-800 dark:text-rose-400">
{/* 纸飞机 SVG */}
<polygon points="0,-4 10,0 0,4 2,0" fill="currentColor" />
</g>
+19 -19
View File
@@ -5,6 +5,7 @@ import type { TimeCapsule } from "@/interface/love";
import { Lock, Unlock, Mail, ArrowUpRight } from "lucide-react";
import gsap from "gsap";
import LetterModal from "@/components/letter/LetterModal";
import LoveSectionHeading from "./LoveSectionHeading";
interface LoveTimeCapsuleProps {
capsules: TimeCapsule[];
@@ -13,17 +14,16 @@ interface LoveTimeCapsuleProps {
export default function LoveTimeCapsule({ capsules }: LoveTimeCapsuleProps) {
return (
<div className="w-full py-12 px-4 max-w-7xl mx-auto sm:px-6 lg:px-8">
{/* 模块标题 */}
<div className="mb-10 text-center lg:text-left">
<span className="text-xs font-semibold text-amber-800 dark:text-amber-400">
写给未来的悄悄话
</span>
<h2 className="mt-1 text-3xl font-semibold tracking-[-0.02em] text-charcoal dark:text-cream">
时光信箱
</h2>
<p className="text-sm tone-muted mt-2 font-sans max-w-md">
有些话,只说给未来的我们听。在这里寄存秘密信件,直到指定的一天被开启。
</p>
{/* 模块标题(统一巨字排版) */}
<div className="mb-12">
<LoveSectionHeading
num="06"
label="Time Capsule"
enMain="TIME"
enOutline="CAPSULE"
cnTitle="时光信箱"
description="有些话,只说给未来的我们听。在这里寄存秘密信件,直到指定的一天被开启。"
/>
</div>
{/* 胶囊卡片网络 */}
@@ -124,8 +124,8 @@ function CapsuleEnvelope({ capsule }: { capsule: TimeCapsule }) {
onClick={handleEnvelopeClick}
className={`relative overflow-hidden border rounded-2xl p-6 flex flex-col justify-between h-[210px] cursor-pointer select-none transition-all duration-300 ${
isLocked && !unlockedIds.includes(String(capsule.id))
? "bg-amber-950/5 dark:bg-charcoal/20 border-amber-900/10 dark:border-white/5 opacity-80"
: "bg-amber-50/20 dark:bg-amber-950/5 border-amber-900/15 dark:border-amber-400/15 shadow-sm hover:shadow-md hover:scale-[1.01]"
? "bg-rose-950/5 dark:bg-charcoal/20 border-rose-900/10 dark:border-white/5 opacity-80"
: "bg-rose-50/20 dark:bg-rose-950/5 border-rose-900/15 dark:border-rose-400/15 shadow-sm hover:shadow-md hover:scale-[1.01]"
}`}
>
{/* 背景信封折痕纹理 */}
@@ -139,7 +139,7 @@ function CapsuleEnvelope({ capsule }: { capsule: TimeCapsule }) {
{capsule.sender} ➔ {capsule.receiver}
</span>
{isLocked && !unlockedIds.includes(String(capsule.id)) ? (
<span className="text-amber-600 dark:text-amber-400 flex items-center gap-1 text-[10px] font-mono font-semibold">
<span className="text-rose-600 dark:text-rose-400 flex items-center gap-1 text-[10px] font-mono font-semibold">
<Lock className="w-3 h-3" />
未解封
</span>
@@ -161,22 +161,22 @@ function CapsuleEnvelope({ capsule }: { capsule: TimeCapsule }) {
{isLocked && !unlockedIds.includes(String(capsule.id)) && timeLeft ? (
<div className="flex gap-2 items-center mt-3 font-mono">
<div className="text-center">
<span className="text-lg font-bold text-amber-950 dark:text-amber-200">{timeLeft.d}</span>
<span className="text-lg font-bold text-rose-950 dark:text-rose-200">{timeLeft.d}</span>
<span className="text-[9px] text-charcoal/50 dark:text-cream/50 ml-0.5">天</span>
</div>
<span className="tone-faint text-xs">:</span>
<div className="text-center">
<span className="text-lg font-bold text-amber-950 dark:text-amber-200">{timeLeft.h}</span>
<span className="text-lg font-bold text-rose-950 dark:text-rose-200">{timeLeft.h}</span>
<span className="text-[9px] text-charcoal/50 dark:text-cream/50 ml-0.5">时</span>
</div>
<span className="tone-faint text-xs">:</span>
<div className="text-center">
<span className="text-lg font-bold text-amber-950 dark:text-amber-200">{timeLeft.m}</span>
<span className="text-lg font-bold text-rose-950 dark:text-rose-200">{timeLeft.m}</span>
<span className="text-[9px] text-charcoal/50 dark:text-cream/50 ml-0.5">分</span>
</div>
<span className="tone-faint text-xs">:</span>
<div className="text-center">
<span className="text-lg font-bold text-amber-950 dark:text-amber-200">{timeLeft.s}</span>
<span className="text-lg font-bold text-rose-950 dark:text-rose-200">{timeLeft.s}</span>
<span className="text-[9px] text-charcoal/50 dark:text-cream/50 ml-0.5">秒</span>
</div>
</div>
@@ -197,7 +197,7 @@ function CapsuleEnvelope({ capsule }: { capsule: TimeCapsule }) {
</span>
<span className="text-[10px] font-mono tone-muted flex items-center gap-0.5">
解封日: {capsule.openDate}
{!(isLocked && !unlockedIds.includes(String(capsule.id))) && <ArrowUpRight className="w-3 h-3 ml-0.5 text-amber-600 animate-pulse" />}
{!(isLocked && !unlockedIds.includes(String(capsule.id))) && <ArrowUpRight className="w-3 h-3 ml-0.5 text-rose-600 animate-pulse" />}
</span>
</div>
+97 -194
View File
@@ -1,10 +1,11 @@
"use client";
"use client";
import { useEffect, useMemo, useRef, useState } from "react";
import Image from "next/image";
import type { LoveEntry } from "@/interface/love";
import { MapPin, Sparkles, MailOpen, Heart, ChevronLeft, ChevronRight } from "lucide-react";
import gsap from "gsap";
import LoveSectionHeading from "./LoveSectionHeading";
interface LoveTimelineProps {
entries: LoveEntry[];
@@ -15,37 +16,20 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
const containerRef = useRef<HTMLDivElement>(null);
const trackRef = useRef<HTMLDivElement>(null);
// 排序:时间轴由远及近(升序)
// 排序:时间轴由远及近(升序),单周期展示,不再复制循环
const sortedEntries = useMemo(
() => [...entries].sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()),
[entries],
);
// 复制 entries 以保证有足够的长度进行无缝滚动(至少渲染 3 个周期且大于 10 个卡片)
const displayEntries = useMemo(() => {
if (sortedEntries.length === 0) return [];
const minItems = 12;
const repeatCount = Math.max(3, Math.ceil(minItems / sortedEntries.length));
const list: LoveEntry[] = [];
for (let i = 0; i < repeatCount; i++) {
list.push(...sortedEntries);
}
return list;
}, [sortedEntries]);
const [isDesktop, setIsDesktop] = useState(false);
const [isInView, setIsInView] = useState(false);
// 自动播放与控制相关的 refs
// 手动翻页相关 refs
const currentX = useRef(0);
const activeSpeed = useRef(0.8); // 自动滚动的目标速度 (px/frame)
const currentSpeed = useRef(0.8); // 当前的实际滚动速度
const isAutoPlaying = useRef(true);
const rafRef = useRef<number | null>(null);
const autoPlayTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const manualTweenRef = useRef<gsap.core.Tween | null>(null);
// 监听组件是否在视口内以按需启动/停止自动滚动和漂浮动画
// 监听组件是否在视口内以按需启动漂浮动画
useEffect(() => {
const section = sectionRef.current;
if (!section) return;
@@ -71,12 +55,19 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
return () => window.removeEventListener("resize", checkDesktop);
}, []);
// 可滚动边界:容器内轨道可平移的最大距离
const getMaxScroll = () => {
const container = containerRef.current;
if (!container) return 0;
return Math.max(0, container.scrollWidth - container.clientWidth);
};
// 翻转卡片,直接操作 DOM toggle class 实现状态同步,彻底消除重渲染开销
const toggleFlip = (id: string, e: React.MouseEvent) => {
e.stopPropagation();
if (!trackRef.current) return;
// 寻找同一 id 的所有复制卡片容器并 toggle 它们的翻转状态
// 寻找同一 id 的所有卡片容器并 toggle 它们的翻转状态
const cards = trackRef.current.querySelectorAll(`[data-card-id="${id}"]`);
cards.forEach((card) => {
card.classList.toggle("rotate-y-180");
@@ -115,60 +106,52 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
e.currentTarget.style.transform = "rotateX(0deg) rotateY(0deg) scale(1)";
};
// GSAP 驱动的水平自动滚动与无缝循环 (仅在视口内时按需开启)
useEffect(() => {
if (!isDesktop || sortedEntries.length === 0 || !isInView) {
if (rafRef.current) cancelAnimationFrame(rafRef.current);
if (manualTweenRef.current) manualTweenRef.current.kill();
if (trackRef.current && (!isDesktop || sortedEntries.length === 0)) {
gsap.set(trackRef.current, { x: 0 });
}
return;
}
// 手动翻页(左右按钮):单周期内平滑平移,越界自动夹取
const handleManualNavigate = (direction: "next" | "prev") => {
if (sortedEntries.length === 0) return;
const cardWidth = 380;
const gap = 32;
const step = cardWidth + gap;
const singleCycleWidth = sortedEntries.length * step;
isAutoPlaying.current = true;
currentSpeed.current = activeSpeed.current;
const tick = () => {
if (isAutoPlaying.current) {
// 平滑插值速度以实现悬停减速暂停
currentSpeed.current = gsap.utils.interpolate(
currentSpeed.current,
activeSpeed.current,
0.06
);
currentX.current -= currentSpeed.current;
// 无缝取模
if (currentX.current <= -singleCycleWidth) {
currentX.current += singleCycleWidth;
}
const step = 412; // 卡片 380 + 间距 32
const maxScroll = getMaxScroll();
const targetX = gsap.utils.clamp(
-maxScroll,
0,
currentX.current + (direction === "next" ? -step : step)
);
if (manualTweenRef.current) manualTweenRef.current.kill();
manualTweenRef.current = gsap.to(trackRef.current, {
x: targetX,
duration: 0.8,
ease: "power3.out",
onUpdate: () => {
if (trackRef.current) {
gsap.set(trackRef.current, { x: currentX.current });
currentX.current = gsap.getProperty(trackRef.current, "x") as number;
}
},
});
};
// 窗口尺寸变化时:非桌面端复位,桌面端把越界位置夹取回边界内
useEffect(() => {
const onResize = () => {
if (!trackRef.current) return;
if (window.innerWidth < 1024) {
currentX.current = 0;
gsap.set(trackRef.current, { x: 0 });
return;
}
rafRef.current = requestAnimationFrame(tick);
const maxScroll = getMaxScroll();
const clamped = Math.max(-maxScroll, currentX.current);
currentX.current = clamped;
gsap.set(trackRef.current, { x: clamped });
};
rafRef.current = requestAnimationFrame(tick);
return () => {
if (rafRef.current) cancelAnimationFrame(rafRef.current);
if (manualTweenRef.current) manualTweenRef.current.kill();
};
}, [isDesktop, sortedEntries, isInView]);
window.addEventListener("resize", onResize);
return () => window.removeEventListener("resize", onResize);
}, []);
// 卡片轻微的上下漂浮动画 (仅在视口内时运行以节约开销,限制选择范围在轨道容器内)
useEffect(() => {
if (!isDesktop || displayEntries.length === 0 || !isInView) return;
if (!isDesktop || sortedEntries.length === 0 || !isInView) return;
if (!trackRef.current) return;
const cards = gsap.utils.toArray<HTMLElement>(trackRef.current.querySelectorAll(".timeline-card"));
@@ -186,127 +169,46 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
return () => {
floatingTweens.forEach((tween: any) => tween.kill());
};
}, [isDesktop, displayEntries, isInView]);
// 恢复自动播放的定时器
const resetAutoPlayTimer = () => {
if (autoPlayTimeoutRef.current) clearTimeout(autoPlayTimeoutRef.current);
autoPlayTimeoutRef.current = setTimeout(() => {
isAutoPlaying.current = true;
activeSpeed.current = 0.8;
}, 5000); // 手动交互后 5 秒恢复自动滚动
};
// 左右控制按钮逻辑
const handleManualNavigate = (direction: "next" | "prev") => {
if (sortedEntries.length === 0) return;
const cardWidth = 380;
const gap = 32;
const step = cardWidth + gap;
const singleCycleWidth = sortedEntries.length * step;
// 暂停自动播放
isAutoPlaying.current = false;
if (autoPlayTimeoutRef.current) clearTimeout(autoPlayTimeoutRef.current);
// 1. 规范化当前坐标到 [-singleCycleWidth, 0] 范围内
let currX = currentX.current;
if (currX <= -singleCycleWidth) {
currX = currX % singleCycleWidth;
} else if (currX > 0) {
currX = (currX % singleCycleWidth) - singleCycleWidth;
}
currentX.current = currX;
gsap.set(trackRef.current, { x: currX });
// 2. 计算最接近的卡片索引并加上方向偏移
const currIndex = Math.round(currX / step);
const targetIndex = direction === "next" ? currIndex - 1 : currIndex + 1;
const targetX = targetIndex * step;
// 3. 平滑过渡到目标位置
if (manualTweenRef.current) manualTweenRef.current.kill();
manualTweenRef.current = gsap.to(trackRef.current, {
x: targetX,
duration: 0.8,
ease: "power3.out",
onUpdate: () => {
if (trackRef.current) {
currentX.current = gsap.getProperty(trackRef.current, "x") as number;
}
},
onComplete: () => {
// 动画完成后重新规范化,确保始终处于基础周期内
let finalX = currentX.current;
while (finalX <= -singleCycleWidth) finalX += singleCycleWidth;
while (finalX > 0) finalX -= singleCycleWidth;
currentX.current = finalX;
gsap.set(trackRef.current, { x: finalX });
// 开启自动播放延迟启动器
resetAutoPlayTimer();
}
});
};
// 鼠标移入轨道减速暂停
const handleMouseEnterTrack = () => {
if (isAutoPlaying.current) {
activeSpeed.current = 0;
}
};
// 鼠标移出轨道恢复速度
const handleMouseLeaveTrack = () => {
if (isAutoPlaying.current) {
activeSpeed.current = 0.8;
}
};
}, [isDesktop, sortedEntries, isInView]);
useEffect(() => {
return () => {
if (autoPlayTimeoutRef.current) clearTimeout(autoPlayTimeoutRef.current);
if (manualTweenRef.current) manualTweenRef.current.kill();
};
}, []);
return (
<div
ref={sectionRef}
className="w-full py-20 bg-gradient-to-b from-pink-50/20 via-pink-100/10 to-amber-50/10 dark:from-zinc-950 dark:via-zinc-900/30 dark:to-zinc-950 border-y border-pink-200/10 dark:border-zinc-800/40 relative overflow-hidden"
className="w-full py-20 bg-cream/45 border-y border-charcoal/8 dark:bg-charcoal/45 dark:border-white/10 relative overflow-hidden"
>
{/* 模块标题(大气排版) */}
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 mb-16 text-center relative z-20">
<span className="text-xs uppercase tracking-widest text-amber-700 dark:text-amber-400 font-sans font-bold bg-amber-500/5 dark:bg-amber-400/10 px-3 py-1 rounded-full border border-amber-500/10 dark:border-amber-400/20">
ANNIVERSARY CHRONICLE
</span>
<h2 className="text-4xl sm:text-5xl font-serif mt-5 font-bold text-charcoal dark:text-cream tracking-wide">
恋爱编年史
</h2>
<div className="w-16 h-[2px] bg-gradient-to-r from-transparent via-amber-500 to-transparent mx-auto mt-4" />
<p className="text-sm text-charcoal/65 dark:text-cream/65 mt-4 max-w-md mx-auto font-sans leading-relaxed">
时光静流,万物生长。我们在年华的脉络里,写下相依前行的波澜诗篇。
</p>
{/* 模块标题(统一巨字排版) */}
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 mb-12 relative z-20">
<LoveSectionHeading
num="02"
label="Anniversary Chronicle"
enMain="LOVE"
enOutline="TIMELINE"
cnTitle="恋爱编年史"
description="时光静流,万物生长。我们在年华的脉络里,写下相依前行的波澜诗篇。"
/>
</div>
{/* 滚动容器 */}
<div
ref={containerRef}
className="w-full relative overflow-x-auto lg:overflow-x-hidden no-scrollbar py-8 z-20"
>
{/* 桌面端左右悬浮导航按钮 */}
{/* 滚动容器(宽度与其他区域统一,不铺满全屏) */}
<div className="relative mx-auto w-full max-w-7xl px-4 sm:px-6 lg:px-8">
{/* 桌面端左右悬浮导航按钮(外移到卡片区域外侧,避免遮挡) */}
{isDesktop && sortedEntries.length > 0 && (
<>
<button
onClick={() => handleManualNavigate("prev")}
className="absolute left-6 top-1/2 -translate-y-1/2 z-40 w-14 h-14 rounded-full flex items-center justify-center bg-white/70 dark:bg-zinc-900/80 backdrop-blur-md border border-amber-500/20 dark:border-amber-400/30 text-amber-900 dark:text-amber-400 shadow-lg hover:bg-amber-500 hover:text-white dark:hover:bg-amber-400 dark:hover:text-zinc-950 transition-all duration-300 transform hover:scale-105 active:scale-95 group focus-visible:outline-none"
className="absolute -left-4 top-1/2 -translate-y-1/2 z-40 w-14 h-14 rounded-full flex items-center justify-center bg-white/70 dark:bg-zinc-900/80 backdrop-blur-md border border-rose-500/20 dark:border-rose-400/30 text-rose-900 dark:text-rose-400 shadow-lg hover:bg-rose-500 hover:text-white dark:hover:bg-rose-400 dark:hover:text-zinc-950 transition-all duration-300 transform hover:scale-105 active:scale-95 group focus-visible:outline-none"
aria-label="上一张"
>
<ChevronLeft className="w-6 h-6 stroke-[2] group-hover:-translate-x-0.5 transition-transform" />
</button>
<button
onClick={() => handleManualNavigate("next")}
className="absolute right-6 top-1/2 -translate-y-1/2 z-40 w-14 h-14 rounded-full flex items-center justify-center bg-white/70 dark:bg-zinc-900/80 backdrop-blur-md border border-amber-500/20 dark:border-amber-400/30 text-amber-900 dark:text-amber-400 shadow-lg hover:bg-amber-500 hover:text-white dark:hover:bg-amber-400 dark:hover:text-zinc-950 transition-all duration-300 transform hover:scale-105 active:scale-95 group focus-visible:outline-none"
className="absolute -right-4 top-1/2 -translate-y-1/2 z-40 w-14 h-14 rounded-full flex items-center justify-center bg-white/70 dark:bg-zinc-900/80 backdrop-blur-md border border-rose-500/20 dark:border-rose-400/30 text-rose-900 dark:text-rose-400 shadow-lg hover:bg-rose-500 hover:text-white dark:hover:bg-rose-400 dark:hover:text-zinc-950 transition-all duration-300 transform hover:scale-105 active:scale-95 group focus-visible:outline-none"
aria-label="下一张"
>
<ChevronRight className="w-6 h-6 stroke-[2] group-hover:translate-x-0.5 transition-transform" />
@@ -314,38 +216,40 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
</>
)}
{/* 滚动长轨道容器 */}
<div
ref={containerRef}
className="w-full relative overflow-x-auto lg:overflow-x-hidden no-scrollbar py-8 z-20"
>
{/* 滚动长轨道 */}
<div
ref={trackRef}
onMouseEnter={handleMouseEnterTrack}
onMouseLeave={handleMouseLeaveTrack}
className="relative flex items-center h-[560px] px-8 lg:px-[10vw] gap-8 w-max select-none gpu-accelerated-track"
className="relative flex items-center h-[560px] px-8 gap-8 w-max select-none gpu-accelerated-track"
>
{/* 中央时光轴线 */}
<div className="absolute left-0 right-0 top-[280px] -translate-y-1/2 h-[2px] pointer-events-none z-10">
<div className="w-full h-full border-t border-dashed border-amber-600/15 dark:border-amber-400/20" />
<div className="absolute inset-0 bg-gradient-to-r from-transparent via-amber-500/10 to-transparent" />
<div className="w-full h-full border-t border-dashed border-rose-500/15 dark:border-rose-400/20" />
<div className="absolute inset-0 bg-gradient-to-r from-transparent via-rose-500/10 to-transparent" />
</div>
{displayEntries.map((entry, index) => {
{sortedEntries.map((entry, index) => {
const isOdd = index % 2 === 0;
const cardKey = `${entry.id}-${index}`;
return (
<div
key={cardKey}
key={entry.id}
className="relative flex flex-col items-center shrink-0 w-[380px] h-full justify-center"
>
{/* 轴上节点 */}
<div className="absolute left-1/2 top-[280px] w-5 h-5 bg-pink-50 dark:bg-zinc-950 border-2 border-amber-500 dark:border-amber-400 rounded-full -translate-x-1/2 -translate-y-1/2 z-20 flex items-center justify-center shadow-md">
<span className="w-2 h-2 bg-amber-500 dark:bg-amber-400 rounded-full animate-ping opacity-75"></span>
<div className="absolute left-1/2 top-[280px] w-5 h-5 bg-pink-50 dark:bg-zinc-950 border-2 border-rose-500 dark:border-rose-400 rounded-full -translate-x-1/2 -translate-y-1/2 z-20 flex items-center justify-center shadow-md">
<span className="w-2 h-2 bg-rose-500 dark:bg-rose-400 rounded-full animate-ping opacity-75"></span>
</div>
{/* 垂直连接虚线 */}
{isOdd ? (
<div className="absolute top-[260px] bottom-[280px] left-1/2 w-0 border-l border-dashed border-amber-500/30 dark:border-amber-400/35 pointer-events-none z-10 animate-pulse" />
<div className="absolute top-[260px] bottom-[280px] left-1/2 w-0 border-l border-dashed border-rose-500/30 dark:border-rose-400/35 pointer-events-none z-10 animate-pulse" />
) : (
<div className="absolute top-[280px] bottom-[300px] left-1/2 w-0 border-l border-dashed border-amber-500/30 dark:border-amber-400/35 pointer-events-none z-10 animate-pulse" />
<div className="absolute top-[280px] bottom-[300px] left-1/2 w-0 border-l border-dashed border-rose-500/30 dark:border-rose-400/35 pointer-events-none z-10 animate-pulse" />
)}
{/* 宽幅电影感故事卡片容器 */}
@@ -373,9 +277,7 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
className="relative w-full h-full transition-transform duration-700 transform-style-3d"
>
{/* 正面:电影画幅故事卡 */}
<div
className="absolute inset-0 bg-white/80 dark:bg-zinc-900/80 backdrop-blur-md border border-amber-500/10 dark:border-amber-400/15 rounded-2xl p-4 shadow-[0_20px_50px_rgba(219,39,119,0.04)] dark:shadow-[0_25px_60px_rgba(0,0,0,0.35)] flex flex-col backface-hidden z-20 group/card"
>
<div className="absolute inset-0 bg-white/80 dark:bg-zinc-900/80 backdrop-blur-md border border-rose-500/10 dark:border-rose-400/15 rounded-2xl p-4 shadow-[0_20px_50px_rgba(219,39,119,0.04)] dark:shadow-[0_25px_60px_rgba(0,0,0,0.35)] flex flex-col backface-hidden z-20 group/card">
{/* 电影宽幅图像 */}
<div className="w-full h-[210px] bg-zinc-100 dark:bg-zinc-950 rounded-xl overflow-hidden relative shrink-0 border border-charcoal/5 dark:border-white/5 shadow-inner">
<Image
@@ -386,10 +288,10 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
className="object-cover group-hover/card:scale-105 transition-transform duration-700 ease-out"
/>
<div className="absolute inset-0 bg-gradient-to-t from-black/40 via-transparent to-transparent opacity-60" />
{/* 右上角精致地点小金章 */}
<div className="absolute top-3 right-3 px-2.5 py-1 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-md text-[10px] text-amber-900 dark:text-amber-400 rounded-full font-sans flex items-center gap-1 shadow-sm border border-amber-500/10 dark:border-amber-400/20">
<MapPin className="w-3 h-3 text-amber-600 dark:text-amber-400" />
<div className="absolute top-3 right-3 px-2.5 py-1 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-md text-[10px] text-rose-900 dark:text-rose-400 rounded-full font-sans flex items-center gap-1 shadow-sm border border-rose-500/10 dark:border-rose-400/20">
<MapPin className="w-3 h-3 text-rose-600 dark:text-rose-400" />
<span className="font-semibold">{entry.location}</span>
</div>
</div>
@@ -399,7 +301,7 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
<div className="space-y-2">
{/* 大衬线日期 */}
<div className="flex items-center gap-3 font-serif">
<span className="text-2xl font-bold text-amber-700 dark:text-amber-400 tracking-tight">
<span className="text-2xl font-bold text-rose-700 dark:text-rose-400 tracking-tight">
{entry.date.substring(5)}
</span>
<span className="h-3.5 w-[1px] bg-charcoal/15 dark:bg-white/20" />
@@ -420,11 +322,11 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
{/* 底部精细微章 */}
<div className="mt-3 pt-3 border-t border-charcoal/5 dark:border-white/5 flex items-center justify-between text-[10px] text-charcoal/40 dark:text-cream/45 font-sans">
<span className="flex items-center gap-1 text-pink-600 dark:text-pink-400 font-medium">
<span className="flex items-center gap-1 text-rose-500 font-medium">
<Heart className="w-3.5 h-3.5 fill-current animate-pulse" />
Love Memoir
</span>
<span className="flex items-center gap-1 text-amber-600 dark:text-amber-400 font-medium group-hover/card:text-amber-700 dark:group-hover/card:text-amber-300 transition-colors">
<span className="flex items-center gap-1 text-rose-600 dark:text-rose-400 font-medium group-hover/card:text-rose-700 dark:group-hover/card:text-rose-300 transition-colors">
<Sparkles className="w-3 h-3 animate-spin-slow" />
点击翻阅回想
</span>
@@ -433,7 +335,7 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
</div>
{/* 背面:复古信笺故事 */}
<div className="absolute inset-0 bg-[#FCFAF2] dark:bg-zinc-950 border border-amber-900/15 dark:border-amber-400/20 rounded-2xl p-5 shadow-[0_20px_50px_rgba(0,0,0,0.06)] dark:shadow-[0_25px_60px_rgba(0,0,0,0.4)] rotate-y-180 backface-hidden flex flex-col justify-between z-10 overflow-hidden">
<div className="absolute inset-0 bg-[#FCFAF2] dark:bg-zinc-950 border border-rose-900/15 dark:border-rose-400/20 rounded-2xl p-5 shadow-[0_20px_50px_rgba(0,0,0,0.06)] dark:shadow-[0_25px_60px_rgba(0,0,0,0.4)] rotate-y-180 backface-hidden flex flex-col justify-between z-10 overflow-hidden">
{/* 优雅信纸横线格 */}
<div
className="absolute inset-0 opacity-25 dark:opacity-10 pointer-events-none"
@@ -446,9 +348,9 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
<div className="grow flex flex-col min-h-0 z-10 relative text-left">
{/* 背面页眉 */}
<div className="border-b border-amber-900/15 dark:border-white/10 pb-2 mb-3 flex items-center justify-between">
<span className="text-xs font-serif font-bold text-amber-900 dark:text-amber-400 flex items-center gap-1.5 tracking-wider">
<MailOpen className="w-4 h-4 text-amber-700 dark:text-amber-400" />
<div className="border-b border-rose-900/15 dark:border-white/10 pb-2 mb-3 flex items-center justify-between">
<span className="text-xs font-serif font-bold text-rose-900 dark:text-rose-400 flex items-center gap-1.5 tracking-wider">
<MailOpen className="w-4 h-4 text-rose-700 dark:text-rose-400" />
MEMOIR / 爱的回想
</span>
<div className="w-6 h-6 rounded-full bg-red-600 dark:bg-red-700/80 flex items-center justify-center shadow-md rotate-[15deg]">
@@ -458,7 +360,7 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
{/* 信札内容 */}
<div
className="mt-1 grow overflow-y-auto pr-1 text-xs font-sans leading-[24px] text-amber-950 dark:text-zinc-200 font-medium whitespace-pre-line text-left scrollbar-none"
className="mt-1 grow overflow-y-auto pr-1 text-xs font-sans leading-[24px] text-rose-950 dark:text-zinc-200 font-medium whitespace-pre-line text-left scrollbar-none"
style={{ paddingTop: "1px" }}
>
{entry.content}
@@ -466,8 +368,8 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
</div>
{/* 返回提示 */}
<div className="mt-3 border-t border-amber-900/10 dark:border-white/10 pt-2 text-[10px] text-amber-800/60 dark:text-zinc-400/60 text-center flex items-center justify-center gap-1 z-10 font-sans">
<Sparkles className="w-3 h-3 text-amber-500" />
<div className="mt-3 border-t border-rose-900/10 dark:border-white/10 pt-2 text-[10px] text-rose-800/60 dark:text-zinc-400/60 text-center flex items-center justify-center gap-1 z-10 font-sans">
<Sparkles className="w-3 h-3 text-rose-500" />
<span>点击卡片翻回正面</span>
</div>
</div>
@@ -478,6 +380,7 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
);
})}
</div>
</div>
</div>
</div>
);
+17 -12
View File
@@ -6,6 +6,7 @@ import { ArrowDown, Sparkles, Volume2, VolumeX } from "lucide-react";
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import EcgLine from "./EcgLine";
import { useAuthorProfile, useCoupleProfile } from "@/hooks/useSysConfig";
gsap.registerPlugin(ScrollTrigger);
@@ -64,6 +65,8 @@ export default function LoveHero({ onScrollDown, heroBgUrl, atmospheresJson }: L
const [daysCount, setDaysCount] = useState(0);
const [daysToAnniversary, setDaysToAnniversary] = useState(0);
const [yearsCount, setYearsCount] = useState(0);
const author = useAuthorProfile();
const couple = useCoupleProfile();
// 氛围状态
const [atmosphereIndex, setAtmosphereIndex] = useState(0);
@@ -550,8 +553,8 @@ export default function LoveHero({ onScrollDown, heroBgUrl, atmospheresJson }: L
<div className="relative h-20 w-20 rounded-full border border-white/30 bg-white/15 p-1.5 shadow-[0_20px_50px_-8px_rgba(0,0,0,0.4)] backdrop-blur-lg transition-transform duration-300 sm:h-24 sm:w-24 md:h-36 md:w-36 lg:h-40 lg:w-40">
<div className="relative w-full h-full rounded-full overflow-hidden">
<Image
src="/assets/avtor-boy.jpg"
alt="Rrtiamo"
src={author.avatar || "/assets/avtor-boy.jpg"}
alt={author.name || "Rrtiamo"}
fill
sizes="(max-width: 768px) 112px, 160px"
className="object-cover pointer-events-none"
@@ -559,7 +562,7 @@ export default function LoveHero({ onScrollDown, heroBgUrl, atmospheresJson }: L
/>
</div>
</div>
<span className="text-xs font-sans font-medium text-white drop-shadow-md md:text-sm">Rrtiamo</span>
<span className="text-xs font-sans font-medium text-white drop-shadow-md md:text-sm">{author.name || "Rrtiamo"}</span>
</div>
{/* 左侧心电图组件 */}
@@ -594,17 +597,19 @@ export default function LoveHero({ onScrollDown, heroBgUrl, atmospheresJson }: L
>
<div className="relative h-20 w-20 rounded-full border border-white/30 bg-white/15 p-1.5 shadow-[0_20px_50px_-8px_rgba(0,0,0,0.4)] backdrop-blur-lg transition-transform duration-300 sm:h-24 sm:w-24 md:h-36 md:w-36 lg:h-40 lg:w-40">
<div className="relative w-full h-full rounded-full overflow-hidden">
<Image
src="/assets/avtor-girl.jpg"
alt="Sweetheart"
fill
sizes="(max-width: 768px) 112px, 160px"
className="object-cover pointer-events-none"
priority
/>
{couple.avatar ? (
<Image
src={couple.avatar}
alt={couple.name || ""}
fill
sizes="(max-width: 768px) 112px, 160px"
className="object-cover pointer-events-none"
priority
/>
) : null}
</div>
</div>
<span className="text-xs font-sans font-medium text-white drop-shadow-md md:text-sm">Sweetheart</span>
<span className="text-xs font-sans font-medium text-white drop-shadow-md md:text-sm">{couple.name}</span>
</div>
</div>
+20
View File
@@ -73,6 +73,7 @@ export default function ArchivePlayer() {
createPlaylist,
renamePlaylist,
removePlaylist,
addTrackToPlaylist,
addTracksToPlaylist,
removeTrackFromPlaylist,
handleTrackPlayback,
@@ -118,6 +119,23 @@ export default function ArchivePlayer() {
[setPlaylist, showToast]
);
// 将单曲保存到已有的“我的歌单”
const handleSaveTrackToPlaylist = useCallback(
(playlistId: string, track: TrackDetail) => {
addTrackToPlaylist(playlistId, track);
},
[addTrackToPlaylist]
);
// 新建“我的歌单”并保存单曲
const handleCreateAndSaveTrack = useCallback(
(name: string, track: TrackDetail) => {
const id = createPlaylist(name, [track]);
if (id) showToast(`已新建歌单《${name}》并保存《${track.title}》`);
},
[createPlaylist, showToast]
);
// 一键清空当前播放队列
const handleClearPlaylist = useCallback(() => {
setPlaylist([]);
@@ -229,6 +247,8 @@ export default function ArchivePlayer() {
addPlaylistToQueue={addPlaylistToQueue}
playPlaylistTrack={playPlaylistTrack}
onAddTrackToQueue={handleAddTrackToQueue}
onAddTrackToPlaylist={handleSaveTrackToPlaylist}
onCreateAndSavePlaylist={handleCreateAndSaveTrack}
onClearPlaylist={handleClearPlaylist}
/>
+102 -2
View File
@@ -4,6 +4,8 @@ import React, { useState, useEffect } from "react";
import { createPortal } from "react-dom";
import hljs from "highlight.js";
import "highlight.js/styles/github-dark.css";
import katex from "katex";
import "katex/dist/katex.min.css";
import {
Copy,
Check,
@@ -113,12 +115,25 @@ function CopyButton({ code }: { code: string }) {
);
}
// Recursive inline markdown parser for Bold, Italic, Strikethrough, Highlight, Kbd, Code, Links, Task checkbox, Images
// KaTeX 公式渲染(throwOnError: false 时语法错误会渲染为红色提示而非抛异常)
function renderMath(tex: string, displayMode: boolean): string {
try {
return katex.renderToString(tex, { displayMode, throwOnError: false, strict: false });
} catch (err) {
console.warn("KaTeX render failed:", err);
const escaped = tex.replace(/[&<>"]/g, (c) =>
({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c] || c
);
return `<code>${escaped}</code>`;
}
}
// Recursive inline markdown parser for Bold, Italic, Strikethrough, Highlight, Kbd, Code, Links, Task checkbox, Images, Math
export function parseInline(text: string, onImageClick?: (url: string, alt: string) => void, offset: number = 0): React.ReactNode[] {
if (!text) return [];
let minIndex = Infinity;
let matchType: "image" | "bold" | "italic" | "strike" | "highlight" | "kbd" | "code" | "link" | "task_checked" | "task_unchecked" | null = null;
let matchType: "image" | "bold" | "italic" | "strike" | "highlight" | "kbd" | "code" | "link" | "task_checked" | "task_unchecked" | "math" | "math_display" | null = null;
let matchedString = "";
let matchData: any = null;
@@ -138,6 +153,24 @@ export function parseInline(text: string, onImageClick?: (url: string, alt: stri
matchedString = taskUncheckedMatch[0];
}
// 0.5 Math ($$...$$ 块级内嵌 与 $...$ 行内;$ 后不能紧跟空白、闭 $ 前不能是空白,避免把 "$5 和 $6" 这类金额当公式)
const mathDisplayRegex = /\$\$([^$\n]+?)\$\$/;
const mathDisplayMatch = mathDisplayRegex.exec(text);
if (mathDisplayMatch && mathDisplayMatch.index < minIndex) {
minIndex = mathDisplayMatch.index;
matchType = "math_display";
matchedString = mathDisplayMatch[0];
matchData = mathDisplayMatch[1];
}
const mathRegex = /\$((?:[^$\s\\]|\\.)[^\n$]*?[^$\s\\]|[^\s$\\])\$/;
const mathMatch = mathRegex.exec(text);
if (mathMatch && mathMatch.index < minIndex) {
minIndex = mathMatch.index;
matchType = "math";
matchedString = mathMatch[0];
matchData = mathMatch[1];
}
// 1. Image (![alt](url))
const imageRegex = /!\[([^\]]*)\]\(([^)]+)\)/;
const imageMatch = imageRegex.exec(text);
@@ -244,6 +277,22 @@ export function parseInline(text: string, onImageClick?: (url: string, alt: stri
<Square className="w-4 h-4" />
</span>
);
} else if (matchType === "math" && typeof matchData === "string") {
result.push(
<span
key={key}
className="text-(--fg-color)"
dangerouslySetInnerHTML={{ __html: renderMath(matchData, false) }}
/>
);
} else if (matchType === "math_display" && typeof matchData === "string") {
result.push(
<span
key={key}
className="block my-4 overflow-x-auto text-(--fg-color)"
dangerouslySetInnerHTML={{ __html: renderMath(matchData, true) }}
/>
);
} else if (matchType === "bold" && typeof matchData === "string") {
result.push(
<strong key={key} className="font-bold text-(--fg-color)">
@@ -376,6 +425,7 @@ export interface Block {
| "ol"
| "code"
| "table"
| "math"
| "hr";
content?: string;
lines?: string[];
@@ -454,6 +504,46 @@ export function parseBlocks(content: string): Block[] {
continue;
}
// 1.5 Math Block ($$...$$,可跨多行;须在代码块状态判断之后,代码块内的 $$ 不参与解析)
if (trimmed.startsWith("$$")) {
// 单行:$$E=mc^2$$
if (trimmed.length > 4 && trimmed.endsWith("$$")) {
if (currentBlock) {
blocks.push(currentBlock);
currentBlock = null;
}
blocks.push({ type: "math", content: trimmed.slice(2, -2).trim() });
continue;
}
// 多行:收集到闭合 $$ 为止
if (currentBlock) {
blocks.push(currentBlock);
currentBlock = null;
}
const mathLines: string[] = [];
const openTail = trimmed.slice(2).trim();
if (openTail) mathLines.push(openTail);
let closed = false;
while (++i < lines.length) {
const mathLine = lines[i].trim();
if (mathLine.endsWith("$$")) {
const before = mathLine.slice(0, -2).trim();
if (before) mathLines.push(before);
closed = true;
break;
}
mathLines.push(lines[i]);
}
if (closed) {
blocks.push({ type: "math", content: mathLines.join("\n").trim() });
} else {
// 未闭合回退为普通段落,保留原文
blocks.push({ type: "paragraph", lines: ["$$", ...mathLines] });
}
continue;
}
// 2. Horizontal Rule (---, ***, ___)
if (/^(---|[*]{3,}|_{3,})$/.test(trimmed)) {
if (currentBlock) {
@@ -718,6 +808,16 @@ export default function Markdown({ content }: { content: string }) {
);
}
case "math": {
return (
<div
key={key}
className="my-8 py-2 overflow-x-auto rounded-2xl border border-(--border-line-color) bg-(--bg-dark-color)/30 shadow-sm text-(--fg-color)"
dangerouslySetInnerHTML={{ __html: renderMath(block.content || "", true) }}
/>
);
}
case "h1":
case "h2":
case "h3":
+35 -57
View File
@@ -1,74 +1,50 @@
"use client";
import { useState, useEffect } from "react";
import { useState } from "react";
import { Lock } from "lucide-react";
import { motion, AnimatePresence } from "framer-motion";
import { getPublicConfig } from "@/api/config";
import { verifyPasscode } from "@/api/config";
interface PasscodeGateProps {
onUnlock: () => void;
passcode?: string; // 默认口令
passcode?: string; // 兼容旧签名:仅作展示文案兜底,实际校验走服务端
title?: string;
description?: string;
}
export default function PasscodeGate({
onUnlock,
passcode = "2026",
title = "数字档案馆加密区",
description = "本区块包含私人信件与恋爱相册。请输入访问口令(默认:2026)解锁查看。",
description = "本区块包含私人信件与恋爱相册。请输入访问口令解锁查看。",
}: PasscodeGateProps) {
const [input, setInput] = useState("");
const [error, setError] = useState(false);
const [shake, setShake] = useState(false);
const [verifying, setVerifying] = useState(false);
const [currentPasscode, setCurrentPasscode] = useState(passcode);
const [remotePasscodeLoaded, setRemotePasscodeLoaded] = useState(false);
const fail = () => {
setError(true);
setShake(true);
setInput("");
setTimeout(() => setShake(false), 500);
};
useEffect(() => {
// 检查本会话中是否已经解锁过
const isUnlocked = sessionStorage.getItem("atlas_unlocked") === "true";
if (isUnlocked) {
onUnlock();
}
}, [onUnlock]);
useEffect(() => {
const fetchRemotePasscode = async () => {
try {
const response = await getPublicConfig();
const payload = response.data;
if (payload?.code === 200 && Array.isArray(payload.data)) {
const passcodeItem = payload.data.find(
(item: any) => item.configKey === "site.access.passcode"
);
if (passcodeItem?.configValue) {
setCurrentPasscode(passcodeItem.configValue);
setRemotePasscodeLoaded(true);
}
}
} catch (err) {
console.warn("Failed to fetch remote passcode, using local fallback.", err);
}
};
fetchRemotePasscode();
}, []);
const displayDescription =
remotePasscodeLoaded && currentPasscode !== "2026"
? description.replace("(默认:2026)", "")
: description;
const handleSubmit = (e: React.FormEvent) => {
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (input === currentPasscode) {
sessionStorage.setItem("atlas_unlocked", "true");
onUnlock();
} else {
setError(true);
setShake(true);
setTimeout(() => setShake(false), 500);
setInput("");
if (!input || verifying) return;
setVerifying(true);
try {
const result = await verifyPasscode(input);
if (result.code === 200) {
sessionStorage.setItem("atlas_unlocked", "true");
onUnlock();
} else {
fail();
}
} catch {
fail();
} finally {
setVerifying(false);
}
};
@@ -80,10 +56,10 @@ export default function PasscodeGate({
className="max-w-md w-full border border-charcoal/10 bg-white/40 backdrop-blur-md p-10 md:p-12 text-center relative"
>
{/* 复古精致四角边框线 */}
<div className="absolute top-0 left-0 w-3 h-3 border-t border-l border-charcoal/30" />
<div className="absolute top-0 right-0 w-3 h-3 border-t border-r border-charcoal/30" />
<div className="absolute bottom-0 left-0 w-3 h-3 border-b border-l border-charcoal/30" />
<div className="absolute bottom-0 right-0 w-3 h-3 border-b border-r border-charcoal/30" />
<div className="absolute top-0 left-0 w-4 h-4 border-t border-l border-charcoal/30" />
<div className="absolute top-0 right-0 w-4 h-4 border-t border-r border-charcoal/30" />
<div className="absolute bottom-0 left-0 w-4 h-4 border-b border-l border-charcoal/30" />
<div className="absolute bottom-0 right-0 w-4 h-4 border-b border-r border-charcoal/30" />
<div className="inline-flex items-center justify-center w-12 h-12 rounded-full border border-charcoal/10 mb-6 text-charcoal/50">
<Lock className="w-5 h-5 stroke-[1.25]" />
@@ -93,7 +69,7 @@ export default function PasscodeGate({
{title}
</h2>
<p className="text-xs md:text-sm font-sans text-charcoal/60 leading-relaxed tracking-wider mb-8 max-w-70 mx-auto">
{displayDescription}
{description}
</p>
<form onSubmit={handleSubmit} className="space-y-4">
@@ -102,6 +78,7 @@ export default function PasscodeGate({
type="password"
placeholder="ENTER PASSCODE"
value={input}
disabled={verifying}
onChange={(e) => {
setInput(e.target.value);
setError(false);
@@ -126,9 +103,10 @@ export default function PasscodeGate({
<button
type="submit"
className="w-full mt-6 bg-charcoal text-cream hover:bg-gold hover:text-charcoal transition-colors py-3 text-xs tracking-widest font-sans font-light uppercase cursor-pointer"
disabled={verifying}
className="w-full mt-6 bg-charcoal text-cream hover:bg-gold hover:text-charcoal transition-colors py-3 text-xs tracking-widest font-sans font-light uppercase cursor-pointer disabled:opacity-60"
>
解锁数字档案
{verifying ? "验证中..." : "解锁数字档案"}
</button>
</form>
</motion.div>
+13
View File
@@ -55,6 +55,8 @@ interface PlayerDrawerSheetProps {
addPlaylistToQueue?: (playlistId: string, append?: boolean) => void;
playPlaylistTrack?: (track: TrackDetail) => void;
onAddTrackToQueue?: (track: TrackDetail) => void;
onAddTrackToPlaylist?: (playlistId: string, track: TrackDetail) => void;
onCreateAndSavePlaylist?: (name: string, track: TrackDetail) => void;
onClearPlaylist?: () => void;
}
@@ -92,6 +94,8 @@ export default function PlayerDrawerSheet({
addPlaylistToQueue,
playPlaylistTrack,
onAddTrackToQueue,
onAddTrackToPlaylist,
onCreateAndSavePlaylist,
onClearPlaylist,
}: PlayerDrawerSheetProps) {
const [activeTab, setActiveTab] = useState<"playlist" | "favorites" | "playlists" | "search" | "import">("playlist");
@@ -279,6 +283,9 @@ export default function PlayerDrawerSheet({
onRemoveTrack={onRemoveTrack}
onToggleFavorite={onToggleFavorite}
isFavorite={isFavorite}
playlists={playlists}
onAddTrackToPlaylist={onAddTrackToPlaylist}
onCreateAndSavePlaylist={onCreateAndSavePlaylist}
/>
)}
@@ -292,6 +299,9 @@ export default function PlayerDrawerSheet({
onToggleFavorite={onToggleFavorite}
onPlayFavoriteTrack={onPlayFavoriteTrack}
onSwitchToSearch={() => setActiveTab("search")}
playlists={playlists}
onAddTrackToPlaylist={onAddTrackToPlaylist}
onCreateAndSavePlaylist={onCreateAndSavePlaylist}
/>
)}
@@ -327,6 +337,9 @@ export default function PlayerDrawerSheet({
isResolvingTrack={isResolvingTrack}
onToggleFavorite={onToggleFavorite}
isFavorite={isFavorite}
playlists={playlists}
onAddTrackToPlaylist={onAddTrackToPlaylist}
onCreateAndSavePlaylist={onCreateAndSavePlaylist}
/>
)}
-14
View File
@@ -1,14 +0,0 @@
.text-type {
display: inline-block;
white-space: pre-wrap;
}
.text-type__cursor {
margin-left: 0.25rem;
display: inline-block;
opacity: 1;
}
.text-type__cursor--hidden {
display: none;
}
-201
View File
@@ -1,201 +0,0 @@
"use client";
import { useEffect, useRef, useState, useMemo, useCallback, ElementType, ReactNode } from "react";
import { gsap } from "gsap";
import "./TextType.css";
export interface TextTypeProps {
text: string | string[];
as?: ElementType;
typingSpeed?: number;
initialDelay?: number;
pauseDuration?: number;
deletingSpeed?: number;
loop?: boolean;
className?: string;
showCursor?: boolean;
hideCursorWhileTyping?: boolean;
cursorCharacter?: string | ReactNode;
cursorClassName?: string;
cursorBlinkDuration?: number;
textColors?: string[];
variableSpeed?: { min: number; max: number };
onSentenceComplete?: (sentence: string, index: number) => void;
startOnVisible?: boolean;
reverseMode?: boolean;
[key: string]: any;
}
const TextType = ({
text,
as: Component = "div",
typingSpeed = 50,
initialDelay = 0,
pauseDuration = 2000,
deletingSpeed = 30,
loop = true,
className = "",
showCursor = true,
hideCursorWhileTyping = false,
cursorCharacter = "|",
cursorClassName = "",
cursorBlinkDuration = 0.5,
textColors = [],
variableSpeed,
onSentenceComplete,
startOnVisible = false,
reverseMode = false,
...props
}: TextTypeProps) => {
const [displayedText, setDisplayedText] = useState("");
const [currentCharIndex, setCurrentCharIndex] = useState(0);
const [isDeleting, setIsDeleting] = useState(false);
const [currentTextIndex, setCurrentTextIndex] = useState(0);
const [isVisible, setIsVisible] = useState(!startOnVisible);
const cursorRef = useRef<HTMLSpanElement>(null);
const containerRef = useRef<HTMLElement>(null);
const textArray = useMemo(() => (Array.isArray(text) ? text : [text]), [text]);
const getRandomSpeed = useCallback(() => {
if (!variableSpeed) return typingSpeed;
const { min, max } = variableSpeed;
return Math.random() * (max - min) + min;
}, [variableSpeed, typingSpeed]);
const getCurrentTextColor = () => {
if (textColors.length === 0) return "inherit";
return textColors[currentTextIndex % textColors.length];
};
useEffect(() => {
if (!startOnVisible || !containerRef.current) return;
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
setIsVisible(true);
}
});
},
{ threshold: 0.1 }
);
observer.observe(containerRef.current);
return () => observer.disconnect();
}, [startOnVisible]);
useEffect(() => {
if (showCursor && cursorRef.current) {
gsap.set(cursorRef.current, { opacity: 1 });
const anim = gsap.to(cursorRef.current, {
opacity: 0,
duration: cursorBlinkDuration,
repeat: -1,
yoyo: true,
ease: "power2.inOut",
});
return () => {
anim.kill();
};
}
}, [showCursor, cursorBlinkDuration]);
useEffect(() => {
if (!isVisible) return;
let timeout: NodeJS.Timeout;
const currentText = textArray[currentTextIndex] || "";
const processedText = reverseMode ? currentText.split("").reverse().join("") : currentText;
const executeTypingAnimation = () => {
if (isDeleting) {
if (displayedText === "") {
setIsDeleting(false);
if (currentTextIndex === textArray.length - 1 && !loop) {
return;
}
if (onSentenceComplete) {
onSentenceComplete(textArray[currentTextIndex], currentTextIndex);
}
setCurrentTextIndex((prev) => (prev + 1) % textArray.length);
setCurrentCharIndex(0);
timeout = setTimeout(() => {}, pauseDuration);
} else {
timeout = setTimeout(() => {
setDisplayedText((prev) => prev.slice(0, -1));
}, deletingSpeed);
}
} else {
if (currentCharIndex < processedText.length) {
timeout = setTimeout(
() => {
setDisplayedText((prev) => prev + processedText[currentCharIndex]);
setCurrentCharIndex((prev) => prev + 1);
},
variableSpeed ? getRandomSpeed() : typingSpeed
);
} else if (textArray.length >= 1) {
if (!loop && currentTextIndex === textArray.length - 1) return;
timeout = setTimeout(() => {
setIsDeleting(true);
}, pauseDuration);
}
}
};
if (currentCharIndex === 0 && !isDeleting && displayedText === "") {
timeout = setTimeout(executeTypingAnimation, initialDelay);
} else {
executeTypingAnimation();
}
return () => clearTimeout(timeout);
}, [
currentCharIndex,
displayedText,
isDeleting,
typingSpeed,
deletingSpeed,
pauseDuration,
textArray,
currentTextIndex,
loop,
initialDelay,
isVisible,
reverseMode,
variableSpeed,
getRandomSpeed,
onSentenceComplete,
]);
const shouldHideCursor =
hideCursorWhileTyping && (currentCharIndex < (textArray[currentTextIndex] || "").length || isDeleting);
const CustomComponent = Component as any;
return (
<CustomComponent
ref={containerRef}
className={`text-type ${className}`}
{...props}
>
<span className="text-type__content" style={{ color: getCurrentTextColor() || "inherit" }}>
{displayedText}
</span>
{showCursor && (
<span
ref={cursorRef}
className={`text-type__cursor ${cursorClassName} ${shouldHideCursor ? 'text-type__cursor--hidden' : ''}`}
>
{cursorCharacter}
</span>
)}
</CustomComponent>
);
};
export default TextType;
@@ -3,7 +3,9 @@
import React, { useState } from "react";
import { musicIcons } from "@/icon/music";
import type { TrackDetail } from "@/interface/music";
import type { PlaylistFolder } from "@/hooks/usePlayerPlaylists";
import AnimatedList from "../AnimatedList";
import SaveToPlaylistButton from "./SaveToPlaylistButton";
const {
heart: HeartIcon,
@@ -50,6 +52,9 @@ interface DrawerFavoritesTabProps {
onToggleFavorite?: (track: TrackDetail) => void;
onPlayFavoriteTrack?: (track: TrackDetail) => void;
onSwitchToSearch: () => void;
playlists?: PlaylistFolder[];
onAddTrackToPlaylist?: (playlistId: string, track: TrackDetail) => void;
onCreateAndSavePlaylist?: (name: string, track: TrackDetail) => void;
}
export default function DrawerFavoritesTab({
@@ -61,6 +66,9 @@ export default function DrawerFavoritesTab({
onToggleFavorite,
onPlayFavoriteTrack,
onSwitchToSearch,
playlists,
onAddTrackToPlaylist,
onCreateAndSavePlaylist,
}: DrawerFavoritesTabProps) {
return (
<div className="grow min-h-0 flex flex-col space-y-3 overscroll-contain">
@@ -143,6 +151,15 @@ export default function DrawerFavoritesTab({
<HeartIcon size={15} weight="fill" />
</button>
)}
{onAddTrackToPlaylist && playlists && (
<SaveToPlaylistButton
track={track}
playlists={playlists}
onAdd={onAddTrackToPlaylist}
onCreate={onCreateAndSavePlaylist || (() => {})}
/>
)}
</div>
);
}}
@@ -3,7 +3,9 @@
import React, { useState, useEffect } from "react";
import { musicIcons } from "@/icon/music";
import type { TrackDetail } from "@/interface/music";
import type { PlaylistFolder } from "@/hooks/usePlayerPlaylists";
import AnimatedList from "../AnimatedList";
import SaveToPlaylistButton from "./SaveToPlaylistButton";
const {
heart: HeartIcon,
@@ -21,6 +23,9 @@ interface DrawerPlaylistTabProps {
onRemoveTrack?: (index: number) => void;
onToggleFavorite?: (track: TrackDetail) => void;
isFavorite?: (track: TrackDetail) => boolean;
playlists?: PlaylistFolder[];
onAddTrackToPlaylist?: (playlistId: string, track: TrackDetail) => void;
onCreateAndSavePlaylist?: (name: string, track: TrackDetail) => void;
}
const DefaultVinylCover = () => (
@@ -63,6 +68,9 @@ export default function DrawerPlaylistTab({
onRemoveTrack,
onToggleFavorite,
isFavorite,
playlists,
onAddTrackToPlaylist,
onCreateAndSavePlaylist,
}: DrawerPlaylistTabProps) {
const [visibleLimit, setVisibleLimit] = useState(25);
const [showAll, setShowAll] = useState(false);
@@ -185,6 +193,15 @@ export default function DrawerPlaylistTab({
</button>
)}
{onAddTrackToPlaylist && playlists && (
<SaveToPlaylistButton
track={track}
playlists={playlists}
onAdd={onAddTrackToPlaylist}
onCreate={onCreateAndSavePlaylist || (() => {})}
/>
)}
{onRemoveTrack && (
<button
type="button"
@@ -3,6 +3,8 @@
import React, { useRef, useState, useEffect } from "react";
import { musicIcons } from "@/icon/music";
import type { ApiSearchResult, MusicSource, TrackDetail } from "@/interface/music";
import type { PlaylistFolder } from "@/hooks/usePlayerPlaylists";
import SaveToPlaylistButton from "./SaveToPlaylistButton";
const {
caretDown: CaretDownIcon,
@@ -33,6 +35,9 @@ interface DrawerSearchTabProps {
isResolvingTrack: boolean;
onToggleFavorite?: (track: TrackDetail) => void;
isFavorite?: (track: TrackDetail) => boolean;
playlists?: PlaylistFolder[];
onAddTrackToPlaylist?: (playlistId: string, track: TrackDetail) => void;
onCreateAndSavePlaylist?: (name: string, track: TrackDetail) => void;
}
export default function DrawerSearchTab({
@@ -48,6 +53,9 @@ export default function DrawerSearchTab({
isResolvingTrack,
onToggleFavorite,
isFavorite,
playlists,
onAddTrackToPlaylist,
onCreateAndSavePlaylist,
}: DrawerSearchTabProps) {
const [isSelectDropdownOpen, setIsSelectDropdownOpen] = useState(false);
const [resolvingId, setResolvingId] = useState<string | null>(null);
@@ -217,6 +225,15 @@ export default function DrawerSearchTab({
</button>
)}
{onAddTrackToPlaylist && playlists && (
<SaveToPlaylistButton
track={searchTrackItem}
playlists={playlists}
onAdd={onAddTrackToPlaylist}
onCreate={onCreateAndSavePlaylist || (() => {})}
/>
)}
<button
type="button"
disabled={isResolvingTrack}
+165 -134
View File
@@ -50,21 +50,12 @@ interface PlayerCapsuleBarProps {
formatTime: (seconds: number) => string;
}
const DefaultVinylCover = ({ isPlaying = false }: { isPlaying?: boolean }) => (
<div
className="size-full bg-radial from-[#22232a] to-[#0f1015] flex items-center justify-center relative shadow-inner select-none pointer-events-none animate-spin-slow"
style={{ animationPlayState: isPlaying ? "running" : "paused", willChange: "transform", transform: "translateZ(0)" }}
>
{/* 唱片的同心圆纹路 */}
<div className="absolute inset-1 rounded-full border border-white/5" />
<div className="absolute inset-2 rounded-full border border-white/5" />
<div className="absolute inset-3 rounded-full border border-white/5" />
{/* 红心胶心 */}
<div className="size-3.5 rounded-full bg-rose-500 flex items-center justify-center shadow-xs">
<MusicIcon size={8} className="text-white/80" />
</div>
</div>
);
/** 播放模式文案 */
function modeLabel(mode: PlaybackMode): string {
if (mode === "repeat") return "单曲循环";
if (mode === "shuffle") return "随机播放";
return "顺序播放";
}
export default function PlayerCapsuleBar({
currentTrack,
@@ -97,7 +88,8 @@ export default function PlayerCapsuleBar({
const [showVolumeSlider, setShowVolumeSlider] = useState(false);
const [isDraggingVolume, setIsDraggingVolume] = useState(false);
const [isCollapsed, setIsCollapsed] = useState(false);
// 初始即折叠:避免刷新页面时先展开、5 秒后又被自动收起(表现为“弹出又隐藏”)
const [isCollapsed, setIsCollapsed] = useState(true);
const [localCoverFailed, setLocalCoverFailed] = useState(false);
useEffect(() => {
@@ -185,11 +177,13 @@ export default function PlayerCapsuleBar({
const ModeIcon = playMode === "repeat" ? RepeatOneIcon : playMode === "shuffle" ? ShuffleIcon : RepeatIcon;
const coverIsAvailable = Boolean(
playlistLength > 0 &&
currentTrack?.cover &&
!brokenCovers.has(currentTrack.id) &&
currentTrack?.cover &&
!brokenCovers.has(currentTrack.id) &&
!localCoverFailed
);
const displayFallbackMessage = playerMessage || currentTrack.album || "等待一段声音开始";
const spinning = isPlaying;
const hasTrack = playlistLength > 0;
return (
<div
@@ -198,11 +192,13 @@ export default function PlayerCapsuleBar({
data-player-style="floating-drawer-dock"
style={{
transform: isCollapsed
? "translate(-50%, calc(100% - 24px))"
? "translate(-50%, calc(100% - 20px))"
: "translate(-50%, 0)",
}}
className={`fixed bottom-0 left-1/2 z-70 w-[calc(100%-2rem)] max-w-6xl backdrop-blur-2xl bg-(--bg-dark-color)/95 text-(--fg-color) border-t border-x border-(--border-line-color) shadow-[0_-12px_40px_rgba(0,0,0,0.3)] rounded-t-3xl px-5 pt-3 pb-3 transition-transform duration-500 cubic-bezier(0.16,1,0.3,1) select-none overflow-visible group/drawer ${
isCollapsed ? "cursor-pointer hover:border-(--accent-color)/60" : ""
className={`fixed bottom-0 left-1/2 z-70 w-[calc(100%-2rem)] max-w-3xl rounded-t-2xl border-t border-x border-(--border-line-color)/60 bg-(--bg-dark-color)/90 text-(--fg-color) shadow-[0_-16px_44px_rgba(0,0,0,0.26)] px-4 sm:px-5 pt-2.5 pb-3 transition-all duration-500 cubic-bezier(0.16,1,0.3,1) select-none overflow-visible group/drawer ${
isCollapsed
? "cursor-pointer hover:border-(--accent-color)/50"
: "opacity-90 hover:opacity-100"
}`}
onClick={() => {
if (isCollapsed) {
@@ -211,67 +207,84 @@ export default function PlayerCapsuleBar({
}
}}
>
{/* 顶部微型的 Drawer 指示条 */}
<div className="w-full pb-2 flex flex-col items-center shrink-0 cursor-pointer">
<div className={`h-1 rounded-full transition-all duration-300 ${
isCollapsed ? "w-16 bg-(--accent-color) animate-pulse" : "w-10 bg-(--fg-color)/20 group-hover/drawer:bg-(--fg-color)/40"
}`} />
{/* 顶部手柄:折叠时一条细条,展开时小圆点 */}
<div className="w-full flex flex-col items-center shrink-0 cursor-pointer">
{isCollapsed ? (
<div className="h-1 w-20 rounded-full bg-(--accent-color)/70 shadow-[0_0_10px_var(--accent-color)] transition-all duration-500" />
) : (
<div className="size-1.5 rounded-full bg-(--fg-color)/25 transition-all duration-300 group-hover/drawer:bg-(--fg-color)/40" />
)}
</div>
<PlayerProgressBar
currentTime={currentTime}
duration={duration}
onSeek={onSeek}
formatTime={formatTime}
hasTrack={playlistLength > 0}
/>
<div className="flex items-center justify-between gap-3 pt-1">
{/* 左侧:专辑封面与歌曲信息 */}
<div className="flex items-center gap-3.5 min-w-0 grow md:grow-0">
<button
type="button"
onClick={(e) => {
if (isCollapsed) return;
e.stopPropagation();
onOpenExpandedModal();
{/* 主行:圆形封面 + 歌曲信息 + 播放控制(折叠时整体隐藏) */}
<div className={`flex items-center gap-3 sm:gap-4 pt-1.5 transition-opacity duration-300 ${isCollapsed ? "opacity-0 pointer-events-none" : "opacity-100"}`}>
{/* 圆形封面(黑胶唱片) */}
<button
type="button"
onClick={(e) => {
if (isCollapsed) return;
e.stopPropagation();
onOpenExpandedModal();
}}
className="relative size-12 sm:size-14 shrink-0 rounded-full overflow-hidden border border-(--border-line-color) shadow-sm group/cover cursor-pointer transition-all duration-300 hover:scale-105 active:scale-95"
title="打开沉浸式歌词大屏"
>
{coverIsAvailable ? (
// eslint-disable-next-line @next/next/no-img-element
<img
src={currentTrack.cover}
alt={`${currentTrack.title} 封面`}
className="absolute inset-0 size-full object-cover animate-spin-slow"
style={{ animationPlayState: spinning ? "running" : "paused", willChange: "transform", transform: "translateZ(0)" }}
onError={() => {
onMarkBrokenCover(currentTrack.id);
setLocalCoverFailed(true);
}}
/>
) : (
<div className="absolute inset-0 bg-radial from-[#22232a] to-[#0f1015] flex items-center justify-center animate-spin-slow" style={{ animationPlayState: spinning ? "running" : "paused" }}>
<div className="absolute inset-1 rounded-full border border-white/5" />
<div className="absolute inset-2 rounded-full border border-white/5" />
<div className="absolute inset-3 rounded-full border border-white/5" />
<div className="size-3 rounded-full bg-rose-500 shadow-[0_0_8px_rgba(244,63,94,0.6)] flex items-center justify-center">
<MusicIcon size={7} className="text-white/80" />
</div>
</div>
)}
{/* 唱片黑胶外圈与光泽 */}
<div className="absolute inset-0 rounded-full ring-1 ring-inset ring-white/10" />
<div
className="absolute inset-0 rounded-full animate-spin-slow pointer-events-none"
style={{
animationPlayState: spinning ? "running" : "paused",
background: "conic-gradient(from 0deg, transparent 0deg, rgba(255,255,255,0.14) 40deg, transparent 80deg)",
}}
className="relative size-10 sm:size-11 shrink-0 rounded-full overflow-hidden border border-(--border-line-color) shadow-sm group cursor-pointer transition-transform hover:scale-105 active:scale-95"
title="打开沉浸式歌词大屏"
>
{coverIsAvailable ? (
// eslint-disable-next-line @next/next/no-img-element
<img
src={currentTrack.cover}
alt={`${currentTrack.title} 封面`}
className="size-full object-cover animate-spin-slow"
style={{ animationPlayState: isPlaying ? "running" : "paused", willChange: "transform", transform: "translateZ(0)" }}
onError={() => {
onMarkBrokenCover(currentTrack.id);
setLocalCoverFailed(true);
}}
/>
) : (
<DefaultVinylCover isPlaying={isPlaying} />
)}
<div className="absolute inset-0 bg-black/30 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-white">
<LyricsIcon size={14} weight="bold" />
</div>
</button>
/>
<div className="absolute inset-0 rounded-full bg-black/25 opacity-0 group-hover/cover:opacity-100 transition-opacity duration-200 flex items-center justify-center text-white">
<LyricsIcon size={14} weight="bold" />
</div>
</button>
<div className="min-w-0 max-w-[260px] sm:max-w-md md:max-w-lg lg:max-w-xl">
<div className="flex items-center gap-2 truncate">
<p className="truncate text-xs sm:text-sm font-semibold text-(--fg-color) tracking-tight">
{playlistLength > 0 ? currentTrack.title : "暂无歌曲播放"}
</p>
{playlistLength > 0 && (
<span className="hidden sm:inline text-[10px] text-(--fg-color)/60 truncate">
• {currentTrack.artist}
</span>
)}
</div>
<div className="text-[11px] sm:text-xs text-(--fg-color)/70 mt-0.5 truncate">
{playlistLength > 0 ? (
{/* 歌曲信息 */}
<div className="min-w-0 grow">
<div className="flex items-center gap-2 min-w-0">
<p className="truncate text-sm font-bold text-(--fg-color) tracking-tight">
{hasTrack ? currentTrack.title : "暂无歌曲播放"}
</p>
{hasTrack && (
<span className="hidden sm:inline truncate text-[11px] text-(--fg-color)/60">
• {currentTrack.artist}
</span>
)}
</div>
<div className="flex items-center gap-2 mt-1 min-w-0">
{hasTrack && (
<span className="shrink-0 rounded-full px-2 py-0.5 text-[9px] font-semibold bg-(--accent-color)/12 text-(--accent-color) border border-(--accent-color)/25">
{modeLabel(playMode)}
</span>
)}
<span className="truncate text-[11px] text-(--fg-color)/60">
{hasTrack ? (
<RollingLyrics
lyric={currentTrack.lyric}
translatedLyric={currentTrack.tlyric}
@@ -279,54 +292,24 @@ export default function PlayerCapsuleBar({
fallback={displayFallbackMessage}
/>
) : (
<span className="text-[11px] text-(--fg-color)/40">开启您的音乐生活档案</span>
"开启您的音乐生活档案"
)}
</div>
</span>
</div>
</div>
{/* 中间:播放控制核心组 */}
<div className="flex items-center gap-1 sm:gap-2 shrink-0">
<button
type="button"
onClick={(e) => {
e.stopPropagation();
onToggleFavorite();
}}
className={`grid size-8 place-items-center rounded-full transition-all active:scale-90 cursor-pointer ${
isFavorite
? "text-rose-500 bg-rose-500/10 hover:bg-rose-500/20"
: "text-(--fg-color)/60 hover:text-rose-500 hover:bg-(--fg-color)/10"
}`}
title={isFavorite ? "取消收藏" : "加入收藏"}
>
<HeartIcon size={16} weight={isFavorite ? "fill" : "regular"} />
</button>
<button
type="button"
onClick={(e) => {
e.stopPropagation();
onCycleMode();
}}
className={`hidden sm:grid size-8 place-items-center rounded-full transition-colors hover:bg-(--fg-color)/10 ${
playMode === "sequence" ? "text-(--fg-color)/60" : "text-(--accent-color)"
}`}
title={playMode === "repeat" ? "单曲循环" : playMode === "shuffle" ? "随机播放" : "顺序播放"}
>
<ModeIcon size={16} weight="bold" />
</button>
{/* 播放控制:上一首 / 播放 / 下一首 */}
<div className="flex items-center gap-1 shrink-0">
<button
type="button"
onClick={(e) => {
e.stopPropagation();
onPlayPrev();
}}
className="grid size-8 sm:size-9 place-items-center rounded-full text-(--fg-color)/80 hover:text-(--fg-color) hover:bg-(--fg-color)/10 transition-all active:scale-90 cursor-pointer"
className="grid size-8 place-items-center rounded-full text-(--fg-color)/70 hover:text-(--fg-color) hover:bg-(--fg-color)/8 transition-all hover:scale-105 active:scale-90 cursor-pointer"
title="上一首"
>
<PreviousIcon size={18} weight="fill" />
<PreviousIcon size={17} weight="fill" />
</button>
<button
@@ -336,7 +319,7 @@ export default function PlayerCapsuleBar({
onTogglePlay();
}}
disabled={isResolvingTrack}
className="grid size-9 sm:size-10 place-items-center rounded-full bg-(--accent-color) text-white shadow-sm transition-transform hover:scale-105 active:scale-95 disabled:opacity-50 cursor-pointer"
className="grid size-9 sm:size-10 place-items-center rounded-full bg-(--accent-color) text-white shadow-[0_2px_12px_color-mix(in_srgb,var(--accent-color)_40%,transparent)] transition-all hover:scale-105 hover:shadow-[0_2px_18px_color-mix(in_srgb,var(--accent-color)_55%,transparent)] active:scale-95 disabled:opacity-50 cursor-pointer"
title={isPlaying ? "暂停" : "播放"}
>
{isResolvingTrack ? (
@@ -344,7 +327,7 @@ export default function PlayerCapsuleBar({
) : isPlaying ? (
<PauseIcon size={18} weight="fill" />
) : (
<PlayIcon size={18} weight="fill" className="translate-x-0.5" />
<PlayIcon size={18} weight="fill" />
)}
</button>
@@ -354,22 +337,71 @@ export default function PlayerCapsuleBar({
e.stopPropagation();
onPlayNext();
}}
className="grid size-8 sm:size-9 place-items-center rounded-full text-(--fg-color)/80 hover:text-(--fg-color) hover:bg-(--fg-color)/10 transition-all active:scale-90 cursor-pointer"
className="grid size-8 place-items-center rounded-full text-(--fg-color)/70 hover:text-(--fg-color) hover:bg-(--fg-color)/8 transition-all hover:scale-105 active:scale-90 cursor-pointer"
title="下一首"
>
<NextIcon size={18} weight="fill" />
<NextIcon size={17} weight="fill" />
</button>
</div>
</div>
<span className="hidden lg:inline-block ml-1 font-mono text-[10px] text-(--fg-color)/60 shrink-0">
{formatTime(currentTime)} / {formatTime(duration)}
{/* 底行:工具 + 进度 + 工具(折叠时整体隐藏) */}
<div className={`flex items-center gap-2 sm:gap-3 pt-2 transition-opacity duration-300 ${isCollapsed ? "opacity-0 pointer-events-none" : "opacity-100"}`}>
<div className="flex items-center gap-0.5 shrink-0">
<button
type="button"
onClick={(e) => {
e.stopPropagation();
onToggleFavorite();
}}
className={`grid size-7 place-items-center rounded-full transition-all active:scale-90 cursor-pointer ${
isFavorite
? "text-rose-500 bg-rose-500/10 hover:bg-rose-500/15"
: "text-(--fg-color)/55 hover:text-rose-500 hover:bg-(--fg-color)/8"
}`}
title={isFavorite ? "取消收藏" : "加入收藏"}
>
<HeartIcon size={14} weight={isFavorite ? "fill" : "regular"} />
</button>
<button
type="button"
onClick={(e) => {
e.stopPropagation();
onCycleMode();
}}
className={`grid size-7 place-items-center rounded-full transition-colors hover:bg-(--fg-color)/8 ${
playMode === "sequence" ? "text-(--fg-color)/55" : "text-(--accent-color)"
}`}
title={`${modeLabel(playMode)}(点击切换)`}
>
<ModeIcon size={14} weight="bold" />
</button>
</div>
{/* 进度:当前时间 — 轨道 — 总时长 */}
<div className="flex items-center gap-2 grow min-w-0">
<span className="shrink-0 font-mono text-[10px] text-(--fg-color)/50 tabular-nums leading-none">
{formatTime(currentTime)}
</span>
<div className="grow min-w-0">
<PlayerProgressBar
currentTime={currentTime}
duration={duration}
onSeek={onSeek}
formatTime={formatTime}
hasTrack={hasTrack}
/>
</div>
<span className="shrink-0 font-mono text-[10px] text-(--fg-color)/50 tabular-nums leading-none">
{formatTime(duration)}
</span>
</div>
{/* 右侧:音量控制 & 播放队列(采用绝对定位向左连体平滑展开,绝对不挤压左侧操控按钮) */}
<div className="flex items-center gap-1.5 sm:gap-2 shrink-0">
<div className="flex items-center gap-0.5 sm:gap-1 shrink-0">
{/* 音量(桌面端悬浮展开) */}
<div
ref={volumeContainerRef}
className="relative hidden md:block size-8 sm:size-9"
className="relative hidden md:block size-7"
onMouseEnter={() => setShowVolumeSlider(true)}
onMouseLeave={() => {
if (!isDraggingVolume) setShowVolumeSlider(false);
@@ -378,8 +410,8 @@ export default function PlayerCapsuleBar({
<div
className={`absolute right-0 top-0 h-full flex flex-row-reverse items-center transition-all duration-300 ease-out z-20 backdrop-blur-md rounded-full bg-(--fg-color)/5 hover:bg-(--fg-color)/10 border border-(--border-line-color)/40 ${
showVolumeSlider || isDraggingVolume
? "w-40 sm:w-44 px-2.5 sm:px-3 shadow-lg bg-(--fg-color)/8 border-(--border-line-color)/60 overflow-visible"
: "w-8 sm:w-9 px-0 justify-center overflow-hidden"
? "w-36 sm:w-40 px-2 shadow-lg bg-(--fg-color)/8 border-(--border-line-color)/60 overflow-visible"
: "w-7 px-0 justify-center overflow-hidden"
}`}
>
<button
@@ -396,21 +428,20 @@ export default function PlayerCapsuleBar({
e.stopPropagation();
onToggleMute();
}}
className="grid size-7 sm:size-8 place-items-center rounded-full text-(--fg-color)/70 hover:text-(--fg-color) transition-colors cursor-pointer shrink-0"
className="grid size-7 place-items-center rounded-full text-(--fg-color)/65 hover:text-(--fg-color) transition-colors cursor-pointer shrink-0"
title={isMuted ? "取消静音" : "调整音量 (双击静音)"}
>
{isMuted || volume === 0 ? <VolumeMutedIcon size={15} /> : <VolumeIcon size={15} />}
{isMuted || volume === 0 ? <VolumeMutedIcon size={14} /> : <VolumeIcon size={14} />}
</button>
<div
className={`flex items-center gap-2 grow min-w-0 transition-opacity duration-200 ${
className={`flex items-center gap-1.5 grow min-w-0 transition-opacity duration-200 ${
showVolumeSlider || isDraggingVolume ? "opacity-100" : "opacity-0 pointer-events-none"
}`}
>
<span className="font-mono text-[9px] font-bold text-(--fg-color)/50 shrink-0 select-none">
<span className="font-mono text-[9px] font-bold text-(--fg-color)/50 shrink-0 select-none tabular-nums">
{Math.round((isMuted ? 0 : volume) * 100)}%
</span>
<div
onPointerDown={handleVolumePointerDown}
onPointerMove={handleVolumePointerMove}
@@ -423,7 +454,7 @@ export default function PlayerCapsuleBar({
className="h-full bg-(--accent-color) rounded-full relative transition-all duration-75"
style={{ width: `${(isMuted ? 0 : volume) * 100}%` }}
>
<div className="absolute right-0 top-1/2 -translate-y-1/2 translate-x-1/2 size-2.5 rounded-full bg-white border border-(--accent-color) shadow-sm group-hover/voltrack:scale-125 transition-transform z-30" />
<div className="absolute right-0 top-1/2 -translate-y-1/2 translate-x-1/2 size-2 rounded-full bg-white border border-(--accent-color) shadow-[0_0_6px_var(--accent-color)] group-hover/voltrack:scale-125 transition-transform z-30" />
</div>
</div>
</div>
@@ -438,11 +469,11 @@ export default function PlayerCapsuleBar({
e.stopPropagation();
onOpenDrawer();
}}
className="flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-(--fg-color)/8 hover:bg-(--fg-color)/15 text-xs text-(--fg-color) font-medium transition-all border border-(--border-line-color) cursor-pointer"
className="flex items-center gap-1 px-2.5 py-1 rounded-full bg-(--fg-color)/8 hover:bg-(--fg-color)/14 text-xs text-(--fg-color) font-medium transition-all border border-(--border-line-color)/70 hover:border-(--accent-color)/40 cursor-pointer active:scale-95"
title="打开播放队列与搜索"
>
<PlaylistIcon size={15} weight="bold" />
<span className="hidden sm:inline text-[11px]">队列 ({playlistLength})</span>
<PlaylistIcon size={13} weight="bold" />
<span className="hidden sm:inline text-[10px] tabular-nums">{playlistLength}</span>
</button>
</div>
</div>
+22 -22
View File
@@ -10,6 +10,10 @@ interface PlayerProgressBarProps {
hasTrack?: boolean;
}
/**
* 播放进度条:流式布局(非绝对定位),轨道与拖拽圆点垂直居中于同一条线上。
* 高度固定 h-4,方便在 flex 行内与时间标签垂直对齐。
*/
export default function PlayerProgressBar({
currentTime,
duration,
@@ -22,7 +26,8 @@ export default function PlayerProgressBar({
const [hoverTime, setHoverTime] = useState<number | null>(null);
const [hoverPositionRatio, setHoverPositionRatio] = useState(0);
const progressPercent = duration > 0 ? (currentTime / duration) * 100 : 0;
const progressPercent =
duration > 0 ? Math.min(100, Math.max(0, (currentTime / duration) * 100)) : 0;
const calculateRatioFromEvent = (e: React.PointerEvent<HTMLDivElement>) => {
const rect = e.currentTarget.getBoundingClientRect();
@@ -68,35 +73,30 @@ export default function PlayerProgressBar({
setIsHovered(false);
setHoverTime(null);
}}
className="absolute top-0 left-0 right-0 h-3.5 flex items-start cursor-pointer group z-20"
className="relative w-full h-4 flex items-center cursor-pointer group"
title="点击或拖动调整播放进度"
>
{/* 局部裁剪容器:高度与大圆角半径一致 (24px/h-6),利用 rounded-t-3xl 与 overflow-hidden 完美截断溢出圆弧的直角轨道 */}
<div className="absolute top-0 left-0 right-0 h-6 overflow-hidden rounded-t-3xl pointer-events-none w-full">
{/* 实际的进度条轨道 */}
<div className="w-full h-1 bg-(--fg-color)/15 transition-all duration-200 group-hover:h-2 relative">
{/* 轨道:圆点绝对定位相对此容器,保证与轨道同轴 */}
<div className="relative w-full h-1.5 bg-(--fg-color)/15 rounded-full transition-all duration-200 group-hover:h-2">
<div
className="h-full bg-(--accent-color) rounded-full transition-all duration-75"
style={{ width: `${progressPercent}%` }}
/>
{hasTrack && (
<div
className="h-full bg-(--accent-color) transition-all duration-75"
style={{ width: `${progressPercent}%` }}
className="absolute top-1/2 size-3.5 rounded-full bg-white border-2 border-(--accent-color) shadow-md animate-in zoom-in duration-150 z-30 pointer-events-none"
style={{
left: `calc(7px + ${progressPercent} * (100% - 14px) / 100)`,
transform: "translate(-50%, -50%)",
}}
/>
</div>
)}
</div>
{/* 进度条控制圆点:脱离 overflow-hidden 轨道层放置,以防边界剪裁 */}
{hasTrack && (
<div
className="absolute size-3.5 rounded-full bg-white border-2 border-(--accent-color) shadow-md animate-in zoom-in duration-150 z-30 pointer-events-none"
style={{
left: `calc(7px + ${progressPercent} * (100% - 14px) / 100)`,
top: isHovered ? "4px" : "2px",
transform: "translate(-50%, -50%)"
}}
/>
)}
{/* 悬停时间气泡(轨道上方) */}
{isHovered && hoverTime !== null && (
<div
className="absolute top-4 -translate-x-1/2 px-2 py-0.5 rounded-md bg-(--bg-dark-color) border border-(--border-line-color) text-[10px] font-mono text-(--fg-color) shadow-lg pointer-events-none z-30 animate-in fade-in duration-100"
className="absolute bottom-full mb-1.5 -translate-x-1/2 px-2 py-0.5 rounded-md bg-(--bg-dark-color) border border-(--border-line-color) text-[10px] font-mono text-(--fg-color) shadow-lg pointer-events-none z-30 animate-in fade-in duration-100"
style={{ left: `${hoverPositionRatio * 100}%` }}
>
{formatTime(hoverTime)}
@@ -0,0 +1,125 @@
"use client";
import React, { useEffect, useRef, useState } from "react";
import { musicIcons } from "@/icon/music";
import type { TrackDetail } from "@/interface/music";
import type { PlaylistFolder } from "@/hooks/usePlayerPlaylists";
const { folderPlus: FolderPlusIcon, plus: PlusIcon, music: MusicIcon } = musicIcons;
interface SaveToPlaylistButtonProps {
track: TrackDetail;
playlists: PlaylistFolder[];
onAdd: (playlistId: string, track: TrackDetail) => void;
onCreate: (name: string, track: TrackDetail) => void;
}
/**
* “保存到我的歌单”按钮:弹出歌单列表选择,或就地新建歌单并保存
*/
export default function SaveToPlaylistButton({
track,
playlists,
onAdd,
onCreate,
}: SaveToPlaylistButtonProps) {
const [open, setOpen] = useState(false);
const [newName, setNewName] = useState("");
const rootRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!open) return;
const handleClickOutside = (e: MouseEvent) => {
if (rootRef.current && !rootRef.current.contains(e.target as Node)) {
setOpen(false);
}
};
document.addEventListener("mousedown", handleClickOutside);
return () => document.removeEventListener("mousedown", handleClickOutside);
}, [open]);
const handleCreate = () => {
const name = newName.trim();
if (!name) return;
onCreate(name, track);
setNewName("");
setOpen(false);
};
const handlePick = (id: string) => {
onAdd(id, track);
setOpen(false);
};
return (
<div ref={rootRef} className="relative shrink-0">
<button
type="button"
onClick={(e) => {
e.stopPropagation();
setOpen((o) => !o);
}}
className="opacity-0 group-hover:opacity-100 p-2 rounded-xl bg-(--fg-color)/6 text-(--fg-color)/50 hover:text-amber-500 hover:bg-amber-500/10 transition-all cursor-pointer border border-transparent hover:border-amber-500/20"
title="保存到我的歌单"
aria-label="保存到我的歌单"
>
<FolderPlusIcon size={15} />
</button>
{open && (
<div
onClick={(e) => e.stopPropagation()}
className="absolute bottom-full right-0 mb-2 w-56 rounded-2xl bg-(--bg-dark-color) border border-(--border-line-color) shadow-2xl z-50 p-2 backdrop-blur-3xl animate-in fade-in zoom-in-95 duration-150"
>
<p className="px-3 py-1.5 text-[11px] font-semibold text-(--fg-color)/50">
保存到歌单
</p>
<div className="max-h-52 overflow-y-auto overscroll-contain space-y-0.5">
{playlists.length === 0 && (
<p className="px-3 py-2 text-[11px] text-(--fg-color)/40">
还没有歌单,可新建一个
</p>
)}
{playlists.map((pl) => (
<button
key={pl.id}
type="button"
onClick={() => handlePick(pl.id)}
className="w-full flex items-center gap-2 px-3 py-2 rounded-xl text-xs text-(--fg-color)/80 hover:bg-(--fg-color)/8 hover:text-(--fg-color) transition-colors cursor-pointer text-left"
>
<MusicIcon size={13} className="shrink-0 text-(--fg-color)/40" />
<span className="truncate grow">{pl.name}</span>
<span className="text-[10px] text-(--fg-color)/35 shrink-0">{pl.tracks.length}首</span>
</button>
))}
</div>
<div className="mt-1.5 pt-1.5 border-t border-(--border-line-color)/50 flex items-center gap-1.5">
<input
type="text"
value={newName}
onChange={(e) => setNewName(e.target.value)}
onKeyDown={(e) => {
e.stopPropagation();
if (e.key === "Enter") handleCreate();
}}
placeholder="新建歌单名称..."
className="w-full grow bg-(--fg-color)/6 border border-(--border-line-color) rounded-xl px-3 py-1.5 text-xs text-(--fg-color) placeholder-(--fg-color)/35 focus:outline-hidden focus:border-(--accent-color)/50"
/>
<button
type="button"
onClick={handleCreate}
disabled={!newName.trim()}
className="grid size-7 place-items-center rounded-xl bg-(--accent-color) text-white transition-all hover:scale-105 active:scale-95 disabled:opacity-40 disabled:hover:scale-100 cursor-pointer shrink-0"
title="新建并保存"
aria-label="新建并保存"
>
<PlusIcon size={13} weight="bold" />
</button>
</div>
</div>
)}
</div>
);
}
+30 -4
View File
@@ -2,7 +2,7 @@
import { useCallback, useEffect, useRef, useState } from "react";
import type { ApiSearchResult, MusicSource, PlaybackMode, TrackDetail } from "@/interface/music";
import { resolveTrackDetails, searchMusic } from "@/api/music";
import { fetchHotPlaylist, resolveTrackDetails, searchMusic } from "@/api/music";
import { mockDefaultTracks } from "@/mock/music";
function formatTime(seconds: number) {
@@ -109,6 +109,26 @@ export function useAudioPlayer() {
// 页面初始化:从 localStorage 恢复记录、进度与状态
useEffect(() => {
let cancelled = false;
// 无有效历史记录时:默认拉取网易云热歌榜作为播放列表,失败回退内置 mock 曲目
const loadDefaultPlaylist = async () => {
try {
const hot = await fetchHotPlaylist(20);
if (!cancelled && hot.length > 0) {
setPlaylist(hot);
setCurrentIndex(0);
return;
}
} catch {
// ignore
}
if (!cancelled) {
setPlaylist(mockDefaultTracks);
setCurrentIndex(0);
}
};
try {
const saved = localStorage.getItem("archive_player_state");
if (saved) {
@@ -121,11 +141,12 @@ export function useAudioPlayer() {
t.id === "uPZirG1+JSxugKvPA7pyJQ=="
);
if (hasInvalidCache) {
setPlaylist(mockDefaultTracks);
setCurrentIndex(0);
void loadDefaultPlaylist();
} else {
setPlaylist(parsed.playlist);
}
} else {
void loadDefaultPlaylist();
}
if (typeof parsed.currentIndex === "number") {
setCurrentIndex(parsed.currentIndex);
@@ -143,10 +164,15 @@ export function useAudioPlayer() {
initialPositionRef.current = parsed.currentTime;
setCurrentTime(parsed.currentTime);
}
} else {
void loadDefaultPlaylist();
}
} catch {
// ignore storage error
void loadDefaultPlaylist();
}
return () => {
cancelled = true;
};
}, []);
// 页面离开/刷新瞬间强行同步写入当前精确播放位置
+44
View File
@@ -43,3 +43,47 @@ export function SysConfigProvider({
export function useSysConfig() {
return useContext(SysConfigContext);
}
export interface AuthorProfile {
name?: string;
role?: string;
tags?: string[];
avatar?: string;
[key: string]: unknown;
}
/** 从全局配置中解析作者身份档案(page.about.profile,about_* 关系表拼装) */
export function useAuthorProfile(): AuthorProfile {
const { configs } = useSysConfig();
return useMemo(() => {
const item = configs.find((c) => c.configKey === "page.about.profile");
if (!item?.configValue) return {};
try {
const parsed = JSON.parse(item.configValue);
return parsed && typeof parsed === "object" ? parsed : {};
} catch {
return {};
}
}, [configs]);
}
export interface CoupleProfile {
name?: string;
avatar?: string;
[key: string]: unknown;
}
/** 从全局配置中解析伴侣信息(love.couple.info,管理端个人中心维护) */
export function useCoupleProfile(): CoupleProfile {
const { configs } = useSysConfig();
return useMemo(() => {
const item = configs.find((c) => c.configKey === "love.couple.info");
if (!item?.configValue) return {};
try {
const parsed = JSON.parse(item.configValue);
return parsed && typeof parsed === "object" ? parsed : {};
} catch {
return {};
}
}, [configs]);
}
+12 -12
View File
@@ -1,16 +1,16 @@
import {
ArrowUpRight,
BracketsCurly,
Camera,
Compass,
Database,
GitBranch,
ImageSquare,
Lightning,
MapTrifold,
Notebook,
Palette,
ShieldCheck,
ArrowUpRightIcon as ArrowUpRight,
BracketsCurlyIcon as BracketsCurly,
CameraIcon as Camera,
CompassIcon as Compass,
DatabaseIcon as Database,
GitBranchIcon as GitBranch,
ImageSquareIcon as ImageSquare,
LightningIcon as Lightning,
MapTrifoldIcon as MapTrifold,
NotebookIcon as Notebook,
PaletteIcon as Palette,
ShieldCheckIcon as ShieldCheck,
} from "@phosphor-icons/react";
import type { Icon } from "@phosphor-icons/react";
import type { AboutIconName } from "@/interface/about";
+27 -25
View File
@@ -1,29 +1,30 @@
import {
CaretDown,
CaretUp,
CaretLeft,
MagnifyingGlass,
MusicNotes,
Pause,
Play,
Playlist,
Radio,
Repeat,
RepeatOnce,
Shuffle,
SkipBack,
SkipForward,
SpeakerHigh,
SpeakerSlash,
SpinnerGap,
Trash,
Waveform,
X,
Article,
Heart,
Folder,
PencilSimple,
Plus,
CaretDownIcon as CaretDown,
CaretUpIcon as CaretUp,
CaretLeftIcon as CaretLeft,
MagnifyingGlassIcon as MagnifyingGlass,
MusicNotesIcon as MusicNotes,
PauseIcon as Pause,
PlayIcon as Play,
PlaylistIcon as Playlist,
RadioIcon as Radio,
RepeatIcon as Repeat,
RepeatOnceIcon as RepeatOnce,
ShuffleIcon as Shuffle,
SkipBackIcon as SkipBack,
SkipForwardIcon as SkipForward,
SpeakerHighIcon as SpeakerHigh,
SpeakerSlashIcon as SpeakerSlash,
SpinnerGapIcon as SpinnerGap,
TrashIcon as Trash,
WaveformIcon as Waveform,
XIcon as X,
ArticleIcon as Article,
HeartIcon as Heart,
FolderIcon as Folder,
FolderPlusIcon as FolderPlus,
PencilSimpleIcon as PencilSimple,
PlusIcon as Plus,
} from '@phosphor-icons/react';
export const musicIcons = {
@@ -50,6 +51,7 @@ export const musicIcons = {
volumeMuted: SpeakerSlash,
waveform: Waveform,
folder: Folder,
folderPlus: FolderPlus,
edit: PencilSimple,
plus: Plus,
} as const;