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. # Used by Server Components and the development rewrite target.
SERVER_API_BASE_URL=http://localhost:8080/api 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. # Internal address used only by the Next.js server on the production host.
SERVER_API_BASE_URL=http://127.0.0.1:8080/api 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" />
/// <reference types="next/image-types/global" /> /// <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 // NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. // 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", "framer-motion": "^12.40.0",
"gsap": "^3.15.0", "gsap": "^3.15.0",
"highlight.js": "^11.11.1", "highlight.js": "^11.11.1",
"katex": "^0.18.9",
"leaflet": "^1.9.4", "leaflet": "^1.9.4",
"lenis": "^1.3.23", "lenis": "^1.3.23",
"lucide-react": "^1.21.0", "lucide-react": "^1.21.0",
@@ -2882,6 +2883,15 @@
"node": ">= 0.8" "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": { "node_modules/concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmmirror.com/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmmirror.com/concat-map/-/concat-map-0.0.1.tgz",
@@ -4887,6 +4897,22 @@
"node": ">=4.0" "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": { "node_modules/keyv": {
"version": "4.5.4", "version": "4.5.4",
"resolved": "https://registry.npmmirror.com/keyv/-/keyv-4.5.4.tgz", "resolved": "https://registry.npmmirror.com/keyv/-/keyv-4.5.4.tgz",
+1
View File
@@ -15,6 +15,7 @@
"framer-motion": "^12.40.0", "framer-motion": "^12.40.0",
"gsap": "^3.15.0", "gsap": "^3.15.0",
"highlight.js": "^11.11.1", "highlight.js": "^11.11.1",
"katex": "^0.18.9",
"leaflet": "^1.9.4", "leaflet": "^1.9.4",
"lenis": "^1.3.23", "lenis": "^1.3.23",
"lucide-react": "^1.21.0", "lucide-react": "^1.21.0",
+126 -4
View File
@@ -6,13 +6,124 @@ export interface PublicConfigItem {
configValue: string configValue: string
} }
export function getPublicConfig() { /** 主题强类型字段 → page.theme.* 后缀(与 theme_config 表列一一对应) */
return request.get('/config/public') 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]) { export async function fetchPublicConfigForServer(init?: Parameters<typeof fetch>[1]) {
try { try {
const response = await fetch(getServerApiURL('/config/public'), { const response = await fetch(getServerApiURL('/config/bootstrap'), {
...init, ...init,
// 容错超时防刷屏 // 容错超时防刷屏
signal: AbortSignal.timeout(3000) signal: AbortSignal.timeout(3000)
@@ -20,7 +131,8 @@ export async function fetchPublicConfigForServer(init?: Parameters<typeof fetch>
if (!response.ok) { if (!response.ok) {
return { code: response.status, data: [] } return { code: response.status, data: [] }
} }
return await response.json() const payload = await response.json()
return { ...payload, data: flattenBootstrap(payload) }
} catch { } catch {
// 静默兜底,避免打印庞大的 Socket 异常日志 // 静默兜底,避免打印庞大的 Socket 异常日志
return { code: 500, data: [] } return { code: 500, data: [] }
@@ -36,3 +148,13 @@ export const getPublicConfigSnapshot = cache(async (): Promise<PublicConfigItem[
return typeof candidate.configKey === 'string' && typeof candidate.configValue === 'string' 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); 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> { export async function generateMetadata(): Promise<Metadata> {
let title = "春风不解别离意,今日方知我是春。"; let title = "春风不解别离意,今日方知我是春。";
let authorName = "RRTiamo";
try { try {
const response = await getPublicConfig(); const response = await getPublicConfig();
const configs = response.data?.data; const configs = response.data?.data;
@@ -18,6 +19,19 @@ export async function generateMetadata(): Promise<Metadata> {
if (titleConfig?.configValue) { if (titleConfig?.configValue) {
title = 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) { } catch (error) {
console.warn("Failed to generate About page metadata:", error); console.warn("Failed to generate About page metadata:", error);
@@ -25,7 +39,7 @@ export async function generateMetadata(): Promise<Metadata> {
return { return {
title, title,
description: "我在代码、文字和生活的缝隙里,慢慢搭建一个属于自己的小宇宙。关于 RRTiamo,此间主人。", description: `我在代码、文字和生活的缝隙里,慢慢搭建一个属于自己的小宇宙。关于 ${authorName},此间主人。`,
}; };
} }
+185 -1
View File
@@ -1,8 +1,16 @@
import { readFileSync } from 'node:fs';
import { isIP } from 'node:net'; import { isIP } from 'node:net';
import { NextResponse } from 'next/server'; 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'; 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_SOURCES = new Set<MusicSource>(['netease', 'tencent', 'kugou', 'kuwo', 'bilibili', 'joox']);
const ALLOWED_TYPES = new Set(['search', 'url', 'pic', 'lyric', 'stream', 'playlist']); 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' }; 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) { export async function GET(request: Request) {
const { searchParams } = new URL(request.url); const { searchParams } = new URL(request.url);
const requestType = searchParams.get('types') || 'search'; const requestType = searchParams.get('types') || 'search';
@@ -208,6 +356,15 @@ export async function GET(request: Request) {
try { try {
if (requestType === 'search') { 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); let data = await requestMusicApi('search', params);
if (Array.isArray(data) && data.length === 0) { if (Array.isArray(data) && data.length === 0) {
const fallbackSource: MusicSource = source === 'netease' ? 'kuwo' : 'netease'; const fallbackSource: MusicSource = source === 'netease' ? 'kuwo' : 'netease';
@@ -217,11 +374,29 @@ export async function GET(request: Request) {
} }
if (requestType === 'lyric') { 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); const lyricData = await resolveLyricWithFallback(source, id, name);
return NextResponse.json(lyricData); return NextResponse.json(lyricData);
} }
if (requestType === 'stream') { 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); const audioUrl = await resolveAudioUrlWithFallback(source, id, name, br);
if (!audioUrl) { if (!audioUrl) {
return errorResponse('TRACK_UNAVAILABLE', '全网暂无可用的音频播放路径', 404); return errorResponse('TRACK_UNAVAILABLE', '全网暂无可用的音频播放路径', 404);
@@ -377,6 +552,15 @@ export async function GET(request: Request) {
return NextResponse.json(Array.isArray(data) ? data : []); 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); const data = await requestMusicApi(requestType, params);
if (requestType === 'url' && !(data as { url?: string })?.url) { if (requestType === 'url' && !(data as { url?: string })?.url) {
const audioUrl = await resolveAudioUrlWithFallback(source, id, name, br); const audioUrl = await resolveAudioUrlWithFallback(source, id, name, br);
+101 -27
View File
@@ -6,15 +6,15 @@ import Image from "next/image";
import gsap from "gsap"; import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger"; import { ScrollTrigger } from "gsap/ScrollTrigger";
import { import {
BookOpen, BookOpenIcon as BookOpen,
Heart, HeartIcon as Heart,
Camera, CameraIcon as Camera,
Lock, LockIcon as Lock,
EyeSlash, EyeSlashIcon as EyeSlash,
MapPin, MapPinIcon as MapPin,
Smiley, SmileyIcon as Smiley,
Funnel, FunnelIcon as Funnel,
CalendarBlank CalendarBlankIcon as CalendarBlank
} from "@phosphor-icons/react"; } from "@phosphor-icons/react";
import { writingData } from "@/data/writing"; 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 getInitialYears = () => {
const dates = [ const dates = [
@@ -566,7 +597,11 @@ export default function ArchivePage() {
}); });
}; };
// GSAP 首次加载动画及 ScrollTrigger 物理联动 // 年份列表稳定标识:years 是每次渲染都新生成的数组引用,
// 直接作为 effect 依赖会导致 ScrollTrigger 与入场动画在每个渲染周期反复重建/重播(表现为页面疯狂闪烁刷新)
const yearsKey = years.join("|");
// GSAP 入场动画:仅挂载时执行一次,避免后续渲染(如数据陆续返回、切换分类)反复重播造成页面闪烁
useEffect(() => { useEffect(() => {
const ctx = gsap.context(() => { const ctx = gsap.context(() => {
// 1. 顶部索引卡与便签滑入 (优雅的弹性入场) // 1. 顶部索引卡与便签滑入 (优雅的弹性入场)
@@ -595,7 +630,7 @@ export default function ArchivePage() {
ease: "elastic.out(1.1, 0.45)" ease: "elastic.out(1.1, 0.45)"
} }
); );
// 2. 过滤栏滑入 // 3. 过滤栏滑入
gsap.from(".archive-filter-bar", { gsap.from(".archive-filter-bar", {
opacity: 0, opacity: 0,
y: 25, y: 25,
@@ -603,7 +638,7 @@ export default function ArchivePage() {
delay: 0.15, delay: 0.15,
ease: "power3.out" ease: "power3.out"
}); });
// 3. 侧边栏时间轴滑入 // 4. 侧边栏时间轴滑入
gsap.from(".archive-timeline-sidebar", { gsap.from(".archive-timeline-sidebar", {
opacity: 0, opacity: 0,
x: -30, x: -30,
@@ -611,11 +646,19 @@ export default function ArchivePage() {
delay: 0.25, delay: 0.25,
ease: "power3.out" ease: "power3.out"
}); });
}, pageRef);
// 4. 首次加载卡片 Stagger 物理发牌滑入 return () => ctx.revert();
const firstCards = pageRef.current?.querySelectorAll(".archive-card-anim"); }, []);
if (firstCards && firstCards.length > 0) {
gsap.from(firstCards, { // 卡片网格首次数据到达后播放一次 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, opacity: 0,
y: 45, y: 45,
rotation: () => (Math.random() - 0.5) * 2.5, rotation: () => (Math.random() - 0.5) * 2.5,
@@ -624,9 +667,12 @@ export default function ArchivePage() {
delay: 0.35, delay: 0.35,
ease: "power4.out" ease: "power4.out"
}); });
} }, [yearsKey]);
// 5. 年份标题横线 ScrollTrigger 动态横向拉伸生长 // ScrollTrigger 物理联动:仅在年份列表内容或分类页签真正变化时安全重建,保证坐标绝对精准
useEffect(() => {
const ctx = gsap.context(() => {
// 1. 年份标题横线 ScrollTrigger 动态横向拉伸生长
years.forEach((year) => { years.forEach((year) => {
gsap.fromTo(`#divider-${year}`, gsap.fromTo(`#divider-${year}`,
{ scaleX: 0, opacity: 0 }, { scaleX: 0, opacity: 0 },
@@ -644,7 +690,7 @@ export default function ArchivePage() {
); );
}); });
// 6. 滚动联动高亮左侧年份刻度 // 2. 滚动联动高亮左侧年份刻度
years.forEach((year) => { years.forEach((year) => {
ScrollTrigger.create({ ScrollTrigger.create({
trigger: `#year-${year}`, trigger: `#year-${year}`,
@@ -658,7 +704,7 @@ export default function ArchivePage() {
}); });
}); });
// 7. 时光轴流逝线滚动比例拉伸 (只在桌面端 sticky sidebar 启用,避免移动端计算报错) // 3. 时光轴流逝线滚动比例拉伸 (只在桌面端 sticky sidebar 启用,避免移动端计算报错)
if (window.innerWidth >= 1024) { if (window.innerWidth >= 1024) {
gsap.to(".timeline-progress-fill", { gsap.to(".timeline-progress-fill", {
scaleY: 1, scaleY: 1,
@@ -675,7 +721,7 @@ export default function ArchivePage() {
}, pageRef); }, pageRef);
return () => ctx.revert(); return () => ctx.revert();
}, [years, activeTab]); // 过滤引起 years 变动时,安全重建 ScrollTrigger 保证坐标绝对精准 }, [yearsKey, activeTab]);
// 锚点滚动 // 锚点滚动
const scrollToYear = (year: string) => { const scrollToYear = (year: string) => {
@@ -892,17 +938,45 @@ export default function ArchivePage() {
/> />
</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"> <div className="grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8">
{groups[year].map((item) => ( {catItems.map((item) => (
<div <div key={item.key} className="archive-card-anim">
key={item.key}
className="archive-card-anim"
>
<ArchiveCard item={item} /> <ArchiveCard item={item} />
</div> </div>
))} ))}
</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> </div>
)) ))
)} )}
+6 -6
View File
@@ -112,7 +112,7 @@ export default function GalleryPage() {
const columns = getColumnsData(); const columns = getColumnsData();
return ( 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"> <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"> <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 / 影像档案 Gallery / 影像档案
</h1> </h1>
<p className="font-sans text-xs text-charcoal/50 dark:text-white/50 tracking-wider mt-2"> <p className="font-sans text-xs text-charcoal/50 dark:text-white/50 tracking-wider mt-2">
用镜头与感光胶片物理定格的光影。已升级为极简无界艺术杂志排版,左右侧列辅以不对称顶部偏置与 GSAP 视差,实现顺畅呼吸的观看体验。 用镜头与感光胶片物理定格的光影。手账式的拍立得照片墙——每张相纸微微倾斜、画框各不相同,像被认真贴进笔记本里的每一帧。
</p> </p>
</div> </div>
@@ -151,17 +151,17 @@ export default function GalleryPage() {
// 决定不对称顶部偏置,增加版面韵律感 (仅在多列且挂载后应用) // 决定不对称顶部偏置,增加版面韵律感 (仅在多列且挂载后应用)
let colOffsetClass = ""; let colOffsetClass = "";
if (columnsCount === 3) { if (columnsCount === 3) {
if (colIdx === 1) colOffsetClass = "pt-20"; if (colIdx === 1) colOffsetClass = "pt-14";
if (colIdx === 2) colOffsetClass = "pt-10"; if (colIdx === 2) colOffsetClass = "pt-6";
} else if (columnsCount === 2) { } else if (columnsCount === 2) {
if (colIdx === 1) colOffsetClass = "pt-12"; if (colIdx === 1) colOffsetClass = "pt-8";
} }
return ( return (
<div <div
key={colIdx} key={colIdx}
ref={colRef} 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"> <AnimatePresence mode="popLayout">
{columnItems.map((photo) => { {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-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-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-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); --font-body: var(--font-inter);
--accent-color: #F1A77C; --accent-color: #F1A77C;
--accent-light-color: #F5C6A8; --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 { @theme {
@@ -70,6 +80,7 @@
--font-gallery-h: var(--font-gallery-h-val); --font-gallery-h: var(--font-gallery-h-val);
--font-gallery-b: var(--font-gallery-b-val); --font-gallery-b: var(--font-gallery-b-val);
--font-quote-h: var(--font-quote-h-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); -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 { .home-hero-wave {
height: clamp(5rem, 10vw, 8.5rem); height: clamp(5rem, 10vw, 8.5rem);
@@ -311,7 +343,9 @@ html.lenis, html.lenis body {
} }
.wave-parallax > use { .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; 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) { @media (prefers-reduced-motion: reduce) {
.wave-parallax > use { .wave-parallax > use {
animation: none; animation: none;
@@ -596,3 +639,226 @@ nextjs-portal, #__next-prerender-indicator {
animation: spin-linear 20s linear infinite; 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 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 "./globals.css";
import Navbar from "@/components/Navbar"; import Navbar from "@/components/Navbar";
import Footer from "@/components/Footer"; import Footer from "@/components/Footer";
@@ -62,6 +62,13 @@ const maShanZheng = Ma_Shan_Zheng({
preload: false, preload: false,
}); });
const anton = Anton({
variable: "--font-anton",
subsets: ["latin"],
weight: "400",
display: "swap",
});
export async function generateMetadata(): Promise<Metadata> { export async function generateMetadata(): Promise<Metadata> {
let title = "春风不解别离 | 个人生活档案馆"; let title = "春风不解别离 | 个人生活档案馆";
let faviconUrl = "/icon.png"; let faviconUrl = "/icon.png";
@@ -92,9 +99,9 @@ export default async function RootLayout({
return ( return (
<html <html
lang="zh" 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}> <SysConfigProvider initialConfigs={configs}>
<ThemeApplier /> <ThemeApplier />
{/* 1. 全局底色层 (z-0) */} {/* 1. 全局底色层 (z-0) */}
@@ -116,7 +123,7 @@ export default async function RootLayout({
<div className="film-grain" /> <div className="film-grain" />
{/* 4. 网页主内容容器 (z-10),拥有显式正值 z-index,保证所有文字、按钮绝对不被背景或视频遮挡 */} {/* 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> <SmoothScroll>
<Navbar /> <Navbar />
<main className="grow flex flex-col">{children}</main> <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 React, { useState, useEffect, useRef, useMemo } from "react";
import { getNotesList, createNote } from "@/api/notes"; import { getNotesList, createNote } from "@/api/notes";
import { motion, AnimatePresence } from "framer-motion"; import { motion, AnimatePresence } from "framer-motion";
import gsap from "gsap"; import gsap from "gsap";
import { import {
Notebook, NotebookIcon as Notebook,
Clock, ClockIcon as Clock,
Funnel, FunnelIcon as Funnel,
Sparkle, SparkleIcon as Sparkle,
PaperPlaneRight, PaperPlaneRightIcon as PaperPlaneRight,
Database, DatabaseIcon as Database,
TextAlignLeft TextAlignLeftIcon as TextAlignLeft
} from "@phosphor-icons/react"; } from "@phosphor-icons/react";
interface Note { interface Note {
+23 -19
View File
@@ -2,24 +2,25 @@
import React, { useState, useEffect, useRef, useMemo } from "react"; import React, { useState, useEffect, useRef, useMemo } from "react";
import { getFeedbackList, createFeedback, likeFeedback, getFeedbackTypes } from "@/api/pond"; import { getFeedbackList, createFeedback, likeFeedback, getFeedbackTypes } from "@/api/pond";
import { useAuthorProfile } from "@/hooks/useSysConfig";
import { motion, AnimatePresence } from "framer-motion"; import { motion, AnimatePresence } from "framer-motion";
import gsap from "gsap"; import gsap from "gsap";
import { import {
Fish, FishIcon as Fish,
Heart, HeartIcon as Heart,
Lightbulb, LightbulbIcon as Lightbulb,
Sparkle, SparkleIcon as Sparkle,
Bug, BugIcon as Bug,
WarningCircle, WarningCircleIcon as WarningCircle,
CheckCircle, CheckCircleIcon as CheckCircle,
PushPin, PushPinIcon as PushPin,
PaperPlaneRight, PaperPlaneRightIcon as PaperPlaneRight,
Megaphone, MegaphoneIcon as Megaphone,
Globe, GlobeIcon as Globe,
EnvelopeSimple, EnvelopeSimpleIcon as EnvelopeSimple,
CircleNotch, CircleNotchIcon as CircleNotch,
ChatCircleText, ChatCircleTextIcon as ChatCircleText,
CaretDown CaretDownIcon as CaretDown
} from "@phosphor-icons/react"; } from "@phosphor-icons/react";
interface PondFeedbackReply { interface PondFeedbackReply {
@@ -354,6 +355,7 @@ const FeedbackCard = ({ fb, onLike, dbTypes }: { fb: PondFeedback; onLike: (id:
}; };
export default function PondPage() { export default function PondPage() {
const author = useAuthorProfile();
const [feedbacks, setFeedbacks] = useState<PondFeedback[]>([]); const [feedbacks, setFeedbacks] = useState<PondFeedback[]>([]);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [activePool, setActivePool] = useState("all"); const [activePool, setActivePool] = useState("all");
@@ -449,6 +451,8 @@ export default function PondPage() {
}; };
const getMockFallbackList = (cat: string) => { const getMockFallbackList = (cat: string) => {
const adminNickname = author.name ? `${author.name} (博主)` : "RRTiamo (博主)";
const adminAvatar = author.avatar || "/life-assets/avatar.jpg";
const mockDbFeedbacks = [ const mockDbFeedbacks = [
{ {
id: 1, id: 1,
@@ -469,8 +473,8 @@ export default function PondPage() {
tags: [{ id: 1, name: "UI", color: "#ec4899" }], tags: [{ id: 1, name: "UI", color: "#ec4899" }],
replies: [{ replies: [{
id: 1, id: 1,
nickname: "RRTiamo (博主)", nickname: adminNickname,
avatar: "/life-assets/avatar.jpg", avatar: adminAvatar,
content: "谢谢你的喜欢!写前端最开心的就是能用代码把心里的想法‘物理显化’出来。流体背景和 3D 卡片确实调了很久,能被你注意到这些细节真的非常欣慰!", content: "谢谢你的喜欢!写前端最开心的就是能用代码把心里的想法‘物理显化’出来。流体背景和 3D 卡片确实调了很久,能被你注意到这些细节真的非常欣慰!",
isAdmin: true, isAdmin: true,
createdAt: "2026-06-24T14:20:00" createdAt: "2026-06-24T14:20:00"
@@ -496,8 +500,8 @@ export default function PondPage() {
tags: [{ id: 2, name: "后台", color: "#3b82f6" }], tags: [{ id: 2, name: "后台", color: "#3b82f6" }],
replies: [{ replies: [{
id: 2, id: 2,
nickname: "RRTiamo (博主)", nickname: adminNickname,
avatar: "/life-assets/avatar.jpg", avatar: adminAvatar,
content: "这个改进点提得太及时了!最近重构了系统配置页面,已经把外观配置、背景切换和视频链接动态绑定的模块都完成了,目前前台已支持一键实时换肤和背景视频渲染,欢迎测试!", content: "这个改进点提得太及时了!最近重构了系统配置页面,已经把外观配置、背景切换和视频链接动态绑定的模块都完成了,目前前台已支持一键实时换肤和背景视频渲染,欢迎测试!",
isAdmin: true, isAdmin: true,
createdAt: "2026-06-23T11:00:00" 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 { ArrowLeft, Lock, Calendar, Tag, Smile, AlignLeft, Compass } from "lucide-react";
import { writingData, Post } from "@/data/writing"; import { writingData, Post } from "@/data/writing";
import { getBlogDetailBySlug } from "@/api/blogs"; import { getBlogDetailBySlug } from "@/api/blogs";
import { useAuthorProfile } from "@/hooks/useSysConfig";
import ParallaxImage from "@/components/ui/ParallaxImage"; import ParallaxImage from "@/components/ui/ParallaxImage";
import PasscodeGate from "@/components/ui/PasscodeGate"; import PasscodeGate from "@/components/ui/PasscodeGate";
import Markdown from "@/components/ui/Markdown"; import Markdown from "@/components/ui/Markdown";
@@ -14,6 +15,7 @@ import Markdown from "@/components/ui/Markdown";
export default function PostPage() { export default function PostPage() {
const params = useParams(); const params = useParams();
const slug = params.slug as string; const slug = params.slug as string;
const author = useAuthorProfile();
const [post, setPost] = useState<Post | null>(null); const [post, setPost] = useState<Post | null>(null);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
@@ -177,7 +179,7 @@ export default function PostPage() {
<PasscodeGate <PasscodeGate
onUnlock={() => setUnlocked(true)} onUnlock={() => setUnlocked(true)}
title={`解锁加密档案:《${post.title}》`} 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="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"> <div className="relative w-10 h-10 overflow-hidden rounded-full border border-gold/15">
<Image <Image
src="/assets/avtor-boy.jpg" src={author.avatar || "/assets/avtor-boy.jpg"}
alt="Rrtiamo" alt={author.name || "Rrtiamo"}
fill fill
sizes="40px" sizes="40px"
className="object-cover" className="object-cover"
/> />
</div> </div>
<div className="space-y-0.5"> <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"> <p className="text-[10px] text-charcoal/40 dark:text-cream/40 font-sans tracking-wide">
Archivist & Author Archivist & Author
</p> </p>
+3 -2
View File
@@ -1,10 +1,11 @@
"use client"; "use client";
import FooterPeekers from "@/components/ui/FooterPeekers"; import FooterPeekers from "@/components/ui/FooterPeekers";
import { useSysConfig } from "@/hooks/useSysConfig"; import { useSysConfig, useAuthorProfile } from "@/hooks/useSysConfig";
export default function Footer() { export default function Footer() {
const { configs } = useSysConfig(); const { configs } = useSysConfig();
const author = useAuthorProfile();
const getConfigValue = (key: string, defaultValue = "") => { const getConfigValue = (key: string, defaultValue = "") => {
const cfg = configs.find((c) => c.configKey === key); const cfg = configs.find((c) => c.configKey === key);
@@ -31,7 +32,7 @@ export default function Footer() {
{/* 2. 强力驱动与版权声明 */} {/* 2. 强力驱动与版权声明 */}
<p className="flex flex-wrap items-center justify-center gap-x-2.5 gap-y-1 font-medium"> <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 className="inline-block w-1 h-1 rounded-full bg-charcoal/10 dark:bg-cream/10" />
<span>本网站由 Spring Breeze 强力驱动</span> <span>本网站由 Spring Breeze 强力驱动</span>
</p> </p>
+3
View File
@@ -253,6 +253,7 @@ export default function Navbar() {
> >
<Link <Link
href={item.path} 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 ${ 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" isActive ? "text-gold font-semibold" : "text-charcoal/60 hover:text-charcoal"
}`} }`}
@@ -293,6 +294,7 @@ export default function Navbar() {
<Link <Link
key={item.path} key={item.path}
href={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 ${ className={`rounded-full px-2.5 py-1.5 font-sans text-[9px] uppercase tracking-wider transition-all ${
isActive isActive
? "text-gold font-semibold bg-charcoal/5 dark:bg-white/5" ? "text-gold font-semibold bg-charcoal/5 dark:bg-white/5"
@@ -358,6 +360,7 @@ export default function Navbar() {
<Link <Link
key={item.path} key={item.path}
href={item.path} href={item.path}
prefetch={false}
onClick={() => setIsMenuOpen(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] ${ 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" : "" 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 * as Icons from "lucide-react";
import gsap from "gsap"; import gsap from "gsap";
import { DynamicIcon } from "@/icon/love"; import { DynamicIcon } from "@/icon/love";
import { useAuthorProfile, useCoupleProfile } from "@/hooks/useSysConfig";
interface FootprintItem { interface FootprintItem {
id: string; id: string;
@@ -89,6 +90,10 @@ export default function FootprintsPageClient({
apiMapCode, apiMapCode,
categories = defaultCategories, categories = defaultCategories,
}: FootprintsPageClientProps) { }: 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 [items] = useState<FootprintItem[]>(initialItems);
const [filter, setFilter] = useState<string>("all"); const [filter, setFilter] = useState<string>("all");
const [selectedItem, setSelectedItem] = useState<FootprintItem | null>(null); const [selectedItem, setSelectedItem] = useState<FootprintItem | null>(null);
@@ -264,19 +269,43 @@ export default function FootprintsPageClient({
const markerContent = document.createElement("div"); const markerContent = document.createElement("div");
markerContent.className = "custom-map-marker group/marker"; markerContent.className = "custom-map-marker group/marker";
// 男生头像代表光影照片,女生头像代表甜蜜恋爱瞬间 // 男生头像代表光影照片,女生头像代表甜蜜恋爱瞬间(身份媒体均在管理端配置,未配置时留空)
const avatarSrc = item.type === "love" ? "/assets/avtor-girl.jpg" : "/assets/avtor-boy.jpg"; // 用 DOM API 构建而非 innerHTML 拼接,避免管理端可配置的 URL 造成注入
const avatarSrc = item.type === "love" ? girlAvatar : boyAvatar;
markerContent.innerHTML = ` const wrapper = document.createElement("div");
<div class="marker-wrapper relative flex items-center justify-center transition-all duration-300"> wrapper.className =
<div class="marker-pulse-ring absolute inset-0 rounded-full bg-amber-500/30 border border-amber-500/40 animate-ping opacity-60"></div> "marker-wrapper relative flex items-center justify-center transition-all duration-300";
<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"> const pulse = document.createElement("div");
<img src="${avatarSrc}" alt="avatar" class="h-full w-full object-cover transition-transform duration-300 group-hover/marker:scale-110" /> pulse.className =
</div> "marker-pulse-ring absolute inset-0 rounded-full bg-amber-500/30 border border-amber-500/40 animate-ping opacity-60";
<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> 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({ const marker = new AMap.Marker({
position: [item.longitude, item.latitude], 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); map.setFitView(Object.values(markersRef.current), false, [60, 60, 60, 60], 12);
} }
} }
}, [filteredItems, mapLoaded]); }, [filteredItems, mapLoaded, boyAvatar, girlAvatar]);
// 6. 列表卡片与地图 Marker 联动 // 6. 列表卡片与地图 Marker 联动
const handleItemHover = (id: string | null) => { const handleItemHover = (id: string | null) => {
+58 -76
View File
@@ -9,19 +9,30 @@ interface GalleryCardProps {
onClick: () => void; 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) { export default function GalleryCard({ photo, index, onClick }: GalleryCardProps) {
const isVideo = photo.type === "video"; const isVideo = photo.type === "video";
const itemNumber = index < 9 ? `0${index + 1}` : `${index + 1}`; const itemNumber = index < 9 ? `0${index + 1}` : `${index + 1}`;
const tilt = TILTS[index % TILTS.length];
// 根据相机品牌决定渲染何种艺术印戳 // 手账印章:常驻半透明,悬停加深
const renderDarkroomStamp = () => { const renderDarkroomStamp = () => {
const cam = photo.camera.toLowerCase(); 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")) { if (cam.includes("leica")) {
return ( 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"> <div className={`${base} scale-90 origin-top-right`}>
{/* 红色 Leica 圆戳 */} <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">
<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">
<span className="font-bold border-b border-red-500/40 pb-0.5 mb-0.5">LEICA LAB</span> <span className="font-bold border-b border-red-500/40 pb-0.5 mb-0.5">LEICA LAB</span>
<span>WET PROCESS</span> <span>WET PROCESS</span>
<span className="scale-75 mt-0.5">PASS // OK</span> <span className="scale-75 mt-0.5">PASS // OK</span>
@@ -29,35 +40,29 @@ export default function GalleryCard({ photo, index, onClick }: GalleryCardProps)
</div> </div>
); );
} }
if (cam.includes("contax")) { if (cam.includes("contax")) {
return ( 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={`${base} scale-90 origin-top-right`}>
{/* 矩形 Contax 双线印戳 */} <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">
<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">
<span className="font-bold tracking-widest">CONTAX T2</span> <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> <span className="scale-90 border-t border-zinc-500/30 pt-0.5">ZEISS T* COMPACT</span>
</div> </div>
</div> </div>
); );
} }
if (cam.includes("hasselblad")) { if (cam.includes("hasselblad")) {
return ( 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={`${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">
<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">
<span className="font-bold">HASSELBLAD</span> <span className="font-bold">HASSELBLAD</span>
<span className="scale-75">503CX // 6x6</span> <span className="scale-75">503CX // 6x6</span>
</div> </div>
</div> </div>
); );
} }
// 默认通用暗房戳
return ( 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={`${base} 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="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 DARKROOM / SHEET
</div> </div>
</div> </div>
@@ -67,22 +72,27 @@ export default function GalleryCard({ photo, index, onClick }: GalleryCardProps)
return ( return (
<div <div
onClick={onClick} 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 -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"
/>
{/* 精致的物理底片边缘刻度饰线 (仅在悬停时隐约可见) */} {/* 相纸 */}
<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="bg-[#FDFBF4] p-[10px] pb-4">
{/* 媒体区 */}
{/* 动态暗房印章叠加 */} <div
{renderDarkroomStamp()} className={`relative w-full overflow-hidden ${
isVideo
{/* 媒体呈现 */} ? "aspect-video md:aspect-[4/3] bg-zinc-950"
: "min-h-[120px] bg-stone-200"
}`}
>
{isVideo ? ( {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"> <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) => ( {Array.from({ length: 6 }).map((_, i) => (
<div key={i} className="w-1 h-2 bg-zinc-900 border border-white/5 rounded-3xs" /> <div key={i} className="w-1 h-2 bg-zinc-900 border border-white/5 rounded-3xs" />
@@ -94,7 +104,6 @@ export default function GalleryCard({ photo, index, onClick }: GalleryCardProps)
))} ))}
</div> </div>
{/* 视频单帧静态渲染 - preload=metadata, 且不设置 autoplay/loop,达到静态占位效果,彻底避免卡顿 */}
<video <video
src={photo.src} src={photo.src}
preload="metadata" preload="metadata"
@@ -105,78 +114,51 @@ export default function GalleryCard({ photo, index, onClick }: GalleryCardProps)
className="w-full h-full object-cover transition-all duration-700 brightness-90 group-hover:brightness-95 scale-100 group-hover:scale-102" 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="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"> <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" /> <Play className="w-4 h-4 text-white fill-white translate-x-[1px] transition-transform duration-300 group-hover:scale-95" />
</div> </div>
</div> </div>
{/* 视频状态微标 */}
<span className="absolute bottom-2.5 left-6 text-[7px] font-mono tracking-widest text-white/50 uppercase scale-75 origin-left"> <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 CINE FILM // MP4
</span> </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 */}
<img <img
src={photo.src} src={photo.src}
alt={photo.title} 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" loading="lazy"
/> />
</div>
)} )}
</div>
{/* 极简无界画廊说明标签 (Museum Label Layout) */} {/* 暗房印章(手账贴纸感) */}
<div className="space-y-2.5 pt-1"> {renderDarkroomStamp()}
{/* 极细的博物馆说明分割线 */}
<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" />
</div>
{/* 编号、标题与参数 */} {/* 相纸内编号 */}
<div className="flex justify-between items-start gap-4"> <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)]">
<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}] [{itemNumber}]
</span> </span>
<h3 className="font-serif text-[15px] font-light text-charcoal dark:text-cream leading-tight"> </div>
{/* 相纸底部手写留白 */}
<div className="pt-2.5 text-left text-charcoal">
<h3 className="font-serif text-[13px] font-semibold leading-snug tracking-[0.02em]">
{photo.title} {photo.title}
</h3> </h3>
</div> <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>
<div className="flex items-center space-x-1 text-[8px] font-mono text-charcoal/40 dark:text-white/40 tracking-wider"> <span className="inline-flex items-center">
<Camera className="w-2.5 h-2.5" /> <MapPin className="w-2.5 h-2.5 mr-0.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" />
{photo.location.split(",")[0]} {photo.location.split(",")[0]}
</span> </span>
</div> </div>
<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>
{/* 激光雕刻感的底片规格 (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> </div>
</div> </div>
</div> </div>
+38 -34
View File
@@ -1,55 +1,59 @@
import Link from "next/link"; import Link from "next/link";
import { ArrowUpRight } from "lucide-react"; import { ArrowUpRight } from "lucide-react";
import type { RefObject } from "react";
import type { Post } from "@/data/writing"; import type { Post } from "@/data/writing";
import ParallaxImage from "@/components/ui/ParallaxImage";
interface ArticleRailProps { interface ArticleRailProps {
posts: Post[]; posts: Post[];
trackRef: RefObject<HTMLDivElement | null>;
} }
export default function ArticleRail({ posts, trackRef }: ArticleRailProps) { export default function ArticleRail({ posts }: ArticleRailProps) {
return ( return (
<div className="mask-image-horizontal overflow-x-auto py-2 no-scrollbar lg:overflow-hidden"> <div className="mt-10 flex flex-col gap-5 md:mt-14 md:gap-6">
<div ref={trackRef} className="flex w-max gap-5 pr-4 gpu-accelerated-track"> {posts.map((post, i) => (
{posts.map((post) => ( <Link
<article
key={post.slug} 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]" 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]"
> >
<Link href={`/writing/${post.slug}`} className="block"> <div className="relative aspect-[4/3] overflow-hidden sm:aspect-auto sm:h-[240px] md:h-[260px]">
<div className="overflow-hidden rounded-[1.2rem]"> <img
<ParallaxImage
src={post.cover} src={post.cover}
alt={post.title} alt={post.title}
aspectRatio="aspect-[16/10]" loading="lazy"
sizes="(min-width: 1024px) 320px, 82vw" className="h-full w-full object-cover saturate-[0.95] transition-transform duration-700 ease-out group-hover:scale-105"
tone="warm"
horizontal={true}
/> />
<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>
<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"> <div className="flex min-w-0 flex-col p-5 sm:p-7 md:p-8">
<span>{post.date}</span> <div className="flex items-baseline gap-3">
<span>{post.category}</span> <span className="num-stroke font-display text-xl leading-none">
<span>{post.mood}</span> {String(i + 1).padStart(2, "0")}
</div> </span>
<h2 className="line-clamp-2 text-lg font-semibold leading-snug text-charcoal transition-colors duration-300 group-hover:text-gold dark:text-cream"> <span className="text-[10px] uppercase tracking-[0.24em] text-charcoal/40 dark:text-cream/45">
{post.title} {post.category}
</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> </span>
</div> </div>
</Link>
</article> <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>
</div> </div>
</Link>
))}
</div>
); );
} }
+21 -41
View File
@@ -1,75 +1,55 @@
import { Camera, MapPin, Play } from "lucide-react"; import { Camera } from "lucide-react";
import type { RefObject } from "react";
import type { GalleryPhoto } from "@/data/gallery"; import type { GalleryPhoto } from "@/data/gallery";
import ParallaxImage from "@/components/ui/ParallaxImage";
interface GalleryRailProps { interface GalleryRailProps {
photos: GalleryPhoto[]; photos: GalleryPhoto[];
trackRef: RefObject<HTMLDivElement | null>;
onSelect: (photo: GalleryPhoto) => void; onSelect: (photo: GalleryPhoto) => void;
} }
export default function GalleryRail({ photos, trackRef, onSelect }: GalleryRailProps) { export default function GalleryRail({ photos, onSelect }: GalleryRailProps) {
return ( return (
<div className="mask-image-horizontal overflow-x-auto py-2 no-scrollbar lg:overflow-hidden"> <div className="film-grid mt-10 md:mt-14">
<div ref={trackRef} className="flex w-max gap-5 pr-4 gpu-accelerated-track"> {photos.map((slice, i) => (
{photos.map((slice) => (
<button <button
key={slice.id} key={slice.id}
type="button" type="button"
onClick={() => onSelect(slice)} 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]" className="gallery-slice-element group relative cursor-pointer overflow-hidden rounded-[1.1rem] border border-white/10 bg-charcoal/40 text-left"
> >
<div className="relative overflow-hidden rounded-[1.2rem] aspect-[4/3] bg-charcoal/5">
{slice.type === "video" ? ( {slice.type === "video" ? (
<>
<video <video
src={slice.src} src={slice.src}
muted muted
loop loop
playsInline playsInline
autoPlay autoPlay
className="h-full w-full object-cover transition duration-700 group-hover:scale-105 group-hover:brightness-105" 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"
/> />
<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 <img
src={slice.src} src={slice.src}
alt={slice.title} alt={slice.title}
aspectRatio="aspect-[4/3]" 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"
sizes="(min-width: 1024px) 320px, 82vw"
tone="natural"
horizontal={true}
/> />
)} )}
</div> {/* 底部压暗渐变 */}
<div className="pointer-events-none absolute inset-0 bg-gradient-to-t from-black/85 via-transparent to-black/5" />
<div className="space-y-3 px-1 pb-2 pt-4"> <div className="absolute inset-x-0 bottom-0 p-4">
<div className="flex items-center justify-between gap-3 text-[12px] text-charcoal/45 dark:text-cream/45"> <span className="text-[11px] tracking-[0.24em] text-gold-light">
<span>{slice.date}</span> FRAME {String(i + 1).padStart(2, "0")}
<span className="inline-flex items-center gap-1 truncate"> </span>
<MapPin className="h-3.5 w-3.5 text-gold" /> <h3 className="mt-1 line-clamp-1 font-serif text-[15px] font-semibold text-cream">
{slice.location} {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> </span>
</div> </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> </div>
</button> </button>
))} ))}
</div> </div>
</div>
); );
} }
+134 -83
View File
@@ -1,34 +1,102 @@
"use client"; "use client";
import { useState } from "react"; import { useEffect, useRef, useState, type CSSProperties } from "react";
import Image from "next/image"; import Image from "next/image";
import Link from "next/link"; 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 SocialDock from "@/components/home/SocialDock";
import { useAuthorProfile } from "@/hooks/useSysConfig";
import gsap from "gsap"; import gsap from "gsap";
import TextType from "@/components/ui/TextType"; import { ScrollTrigger } from "gsap/ScrollTrigger";
if (typeof window !== "undefined") {
gsap.registerPlugin(ScrollTrigger);
}
interface HomeHeroProps { interface HomeHeroProps {
featuredCount: number; featuredCount: number;
galleryCount: number; galleryCount: number;
heroBgUrl?: string; heroBgUrl?: string;
eyebrowTag?: string;
heroTitle?: string;
welcomeText?: string; welcomeText?: string;
welcomeSubtitle?: string; welcomeSubtitle?: string;
logoText?: string; heroDescription?: string;
}
/** 确定性强调字符:取最靠近单词中点的元音,无元音则取中间字符(服务端/客户端渲染一致,防 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({ export default function HomeHero({
featuredCount, featuredCount,
galleryCount, galleryCount,
heroBgUrl, heroBgUrl,
eyebrowTag,
heroTitle,
welcomeText, welcomeText,
welcomeSubtitle, welcomeSubtitle,
logoText heroDescription,
}: HomeHeroProps) { }: HomeHeroProps) {
const [mediaFailed, setMediaFailed] = useState(false); 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 ( 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"> <div className="absolute inset-0">
{heroBgUrl && !mediaFailed ? ( {heroBgUrl && !mediaFailed ? (
heroBgUrl.match(/\.(mp4|webm|ogg|mov|m4v)($|\?)/i) ? ( heroBgUrl.match(/\.(mp4|webm|ogg|mov|m4v)($|\?)/i) ? (
@@ -58,67 +126,23 @@ export default function HomeHero({
src="/bg-image.png" src="/bg-image.png"
alt="月色与花枝" alt="月色与花枝"
fill fill
preload priority
sizes="100vw" sizes="100vw"
className="object-cover object-[62%_center] brightness-[0.82] saturate-[1.14] dark:brightness-[0.7]" 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>
<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="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="home-reveal max-w-full sm:max-w-3xl"> <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 <div className="relative h-11 w-11 overflow-hidden rounded-full border border-white/45 bg-white/55 p-0.5">
onMouseEnter={(e) => {
gsap.to(e.currentTarget, {
y: -4,
backgroundColor: "rgba(255, 255, 255, 0.18)",
borderColor: "rgba(255, 255, 255, 0.35)",
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 });
}
}}
onMouseLeave={(e) => {
gsap.to(e.currentTarget, {
y: 0,
backgroundColor: "rgba(255, 255, 255, 0.14)",
borderColor: "rgba(255, 255, 255, 0.22)",
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 });
}
}}
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"
>
<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"> <div className="relative h-full w-full overflow-hidden rounded-full">
<Image <Image
src="/assets/avtor-boy.jpg" src={author.avatar || "/assets/avtor-boy.jpg"}
alt="Rrtiamo" alt={author.name || "Rrtiamo"}
fill fill
loading="eager" loading="eager"
sizes="44px" sizes="44px"
@@ -126,32 +150,56 @@ export default function HomeHero({
/> />
</div> </div>
</div> </div>
<span className="avatar-text min-w-0 text-[13px] font-medium text-cream/82"> <span className="min-w-0 text-[13px] font-medium text-cream/82">
个人博客 / 生活记录 / 彩色相册 个人博客 / 生活记录 / 彩色相册
</span> </span>
</div> </div>
<div className="mt-8 max-w-full space-y-5 sm:max-w-3xl"> <div className="hero-fade mt-8 flex flex-wrap items-baseline gap-x-3.5 gap-y-1" style={{ animationDelay: "0.05s" }}>
<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"> <span className="text-[13px] font-semibold uppercase tracking-[0.35em] text-gold-light">
<TextType {eyebrowTag || "Welcome"}
text={[logoText || "Rrtiamo", welcomeText || "Spring Breeze", welcomeSubtitle || "此间主人"]} </span>
typingSpeed={90} <span className="h-1 w-1 self-center rounded-full bg-cream/40" />
deletingSpeed={50} <span className="font-serif text-[15px] font-semibold text-cream/85 md:text-[19px]">
pauseDuration={2500} {welcomeSubtitle || "此间主人"}
showCursor={true} </span>
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>
<div className="mt-8 flex flex-wrap items-center gap-3"> <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 <Link
href="/writing" href="/writing"
prefetch={false}
onMouseEnter={(e) => { onMouseEnter={(e) => {
gsap.to(e.currentTarget, { gsap.to(e.currentTarget, {
y: -4, y: -4,
@@ -187,6 +235,7 @@ export default function HomeHero({
</Link> </Link>
<Link <Link
href="/gallery" href="/gallery"
prefetch={false}
onMouseEnter={(e) => { onMouseEnter={(e) => {
gsap.to(e.currentTarget, { gsap.to(e.currentTarget, {
y: -4, y: -4,
@@ -226,10 +275,12 @@ export default function HomeHero({
</Link> </Link>
<SocialDock /> <SocialDock />
</div> </div>
</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="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"> <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" /> <Feather className="h-4 w-4 text-gold-light" />
<span>{featuredCount} 篇精选文章</span> <span>{featuredCount} 篇精选文章</span>
@@ -238,13 +289,13 @@ export default function HomeHero({
</div> </div>
<a <a
href="#home-sections" 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" 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>
<ArrowDown className="h-4 w-4" /> <span className="font-serif text-[12px] tracking-[0.3em]">向下沉浸</span>
<span className="hero-scroll-line" aria-hidden="true" />
</a> </a>
</div> </div>
</div>
<div className="home-hero-wave pointer-events-none absolute inset-x-0 bottom-0 z-[3]" aria-hidden="true"> <div className="home-hero-wave pointer-events-none absolute inset-x-0 bottom-0 z-[3]" aria-hidden="true">
<svg <svg
+30 -55
View File
@@ -1,7 +1,6 @@
"use client"; "use client";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { Camera, Coffee, Compass } from "lucide-react";
import gsap from "gsap"; import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger"; import { ScrollTrigger } from "gsap/ScrollTrigger";
import type { GalleryPhoto } from "@/data/gallery"; import type { GalleryPhoto } from "@/data/gallery";
@@ -32,41 +31,13 @@ export default function HomePageClient({
const [selectedPhoto, setSelectedPhoto] = useState<GalleryPhoto | null>(null); const [selectedPhoto, setSelectedPhoto] = useState<GalleryPhoto | null>(null);
const rootRef = useRef<HTMLDivElement>(null); const rootRef = useRef<HTMLDivElement>(null);
const articlesSectionRef = useRef<HTMLElement>(null); const articlesSectionRef = useRef<HTMLElement>(null);
const articlesTrackRef = useRef<HTMLDivElement>(null);
const gallerySectionRef = useRef<HTMLElement>(null); const gallerySectionRef = useRef<HTMLElement>(null);
const galleryTrackRef = useRef<HTMLDivElement>(null);
useEffect(() => { useEffect(() => {
const root = rootRef.current; const root = rootRef.current;
if (!root) return; if (!root) return;
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches; 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(() => { const ctx = gsap.context(() => {
if (reduceMotion) { if (reduceMotion) {
@@ -142,9 +113,6 @@ export default function HomePageClient({
}, },
} }
); );
setupRail(articlesSectionRef.current, articlesTrackRef.current);
setupRail(gallerySectionRef.current, galleryTrackRef.current);
}, root); }, root);
const refreshTimer = window.setTimeout(() => ScrollTrigger.refresh(), 250); const refreshTimer = window.setTimeout(() => ScrollTrigger.refresh(), 250);
@@ -164,34 +132,41 @@ export default function HomePageClient({
featuredCount={featuredPosts.length} featuredCount={featuredPosts.length}
galleryCount={homeGallerySlices.length} galleryCount={homeGallerySlices.length}
heroBgUrl={configs?.["page.home.heroBgUrl"]} heroBgUrl={configs?.["page.home.heroBgUrl"]}
eyebrowTag={configs?.["page.home.eyebrowTag"]}
heroTitle={configs?.["page.home.heroTitle"]}
welcomeText={configs?.["page.home.welcomeText"]} welcomeText={configs?.["page.home.welcomeText"]}
welcomeSubtitle={configs?.["page.home.welcomeSubtitle"]} welcomeSubtitle={configs?.["page.home.welcomeSubtitle"]}
logoText={configs?.["site.logo.text"]} heroDescription={configs?.["page.home.heroDescription"]}
/> />
{/* 精选文章:Zentry 标题 + Poetize 编辑式清单 */}
<section <section
id="home-sections"
ref={articlesSectionRef} 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 <SectionIntro
icon={Coffee} num="01"
title="精选文章" enLabel="Featured Writing"
body="最近最想被读到的几篇,关于旅途、咖啡馆、代码和一些没那么急着说完的念头。" enMain="FEATURED"
enOutline="精选"
cnTitle="精选文章"
href="/writing" href="/writing"
action="全部随笔" action="全部随笔"
/> />
<ArticleRail posts={featuredPosts} trackRef={articlesTrackRef} /> <ArticleRail posts={featuredPosts} />
</div> </div>
</section> </section>
<section className="bento-grid-trigger px-4 py-9 sm:px-6 md:py-11 lg:px-8"> {/* 此时状态:Zentry 标题 + Poetize 手账便签卡 */}
<div className="mx-auto grid max-w-7xl gap-6 lg:grid-cols-[0.34fr_0.66fr] lg:items-start"> <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 <SectionIntro
icon={Compass} num="02"
title="此时状态" enLabel="What I'm Doing Now"
body="不是仪表盘,更像一张小便签。记录正在读、正在做和正在循环的声音。" enMain="NOW"
enOutline="此刻"
cnTitle="此时状态"
href="/now" href="/now"
action="完整状态" action="完整状态"
/> />
@@ -199,23 +174,23 @@ export default function HomePageClient({
</div> </div>
</section> </section>
{/* 彩色相册:Zentry 深色反转区块 + 胶片网格 */}
<section <section
ref={gallerySectionRef} 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 <SectionIntro
icon={Camera} dark
title="彩色相册" num="03"
body="日常光线、旅行色彩和偶然遇见的小片段,都先以自然的颜色留在这里。" enLabel="Film & Light"
enMain="GALLERY"
enOutline="相册"
cnTitle="彩色相册"
href="/gallery" href="/gallery"
action="打开相册" action="打开相册"
/> />
<GalleryRail <GalleryRail photos={homeGallerySlices} onSelect={setSelectedPhoto} />
photos={homeGallerySlices}
trackRef={galleryTrackRef}
onSelect={setSelectedPhoto}
/>
</div> </div>
</section> </section>
+10 -32
View File
@@ -1,40 +1,18 @@
import { Compass } from "lucide-react";
export default function HomeQuote() { export default function HomeQuote() {
return ( return (
<section className="px-4 pt-10 pb-28 sm:px-6 md:pt-12 md:pb-36 lg:px-8"> <section className="px-4 py-20 sm:px-6 md:py-28 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"> <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" />
<span <p className="text-balance font-serif text-2xl font-bold leading-relaxed tracking-wide text-charcoal dark:text-cream md:text-4xl">
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>
<p className="max-w-xl text-sm leading-7 text-charcoal/60 dark:text-cream/65"> <div className="text-stroke-thin mt-5 font-display text-[clamp(1.5rem,4.2vw,2.8rem)] uppercase leading-none">
我喜欢把这句话放在首页末尾。它提醒我,博客不只是页面的集合,而是日常事件慢慢留下来的路径。 Events over Objects
</p> </div>
<div className="flex items-center gap-3 pt-1"> <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-8 bg-gold/45" /> <span className="h-px w-7 bg-gold/50" />
<p className="text-[13px] font-medium tracking-wide text-charcoal/55 dark:text-cream/55">
卡洛·罗韦利 · 《时间的秩序》 卡洛·罗韦利 · 《时间的秩序》
</p> <span className="h-px w-7 bg-gold/50" />
</div>
</div>
</div> </div>
</div> </div>
</section> </section>
+50 -14
View File
@@ -1,30 +1,66 @@
import Link from "next/link"; import Link from "next/link";
import { ArrowUpRight } from "lucide-react"; import { ArrowUpRight } from "lucide-react";
import type { ComponentType } from "react";
interface SectionIntroProps { interface SectionIntroProps {
icon: ComponentType<{ className?: string }>; num: string;
title: string; enLabel: string;
body: string; enMain: string;
enOutline?: string;
cnTitle: string;
href: string; href: string;
action: 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 ( return (
<div className="home-card-reveal max-w-md space-y-4"> <div className="home-card-reveal">
<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 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> </div>
<div className="space-y-3">
<h2 className="text-2xl font-semibold tracking-normal text-charcoal dark:text-cream md:text-3xl"> {/* 巨字标题:实心英文 + 描边 + 金色中文 */}
{title} <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> </h2>
<p className="text-sm leading-7 text-charcoal/62 dark:text-cream/68">{body}</p>
</div>
<Link <Link
href={href} 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} {action}
<ArrowUpRight className="h-3.5 w-3.5" /> <ArrowUpRight className="h-3.5 w-3.5" />
+1 -1
View File
@@ -1,5 +1,5 @@
import { Mail } from "lucide-react"; 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"; import gsap from "gsap";
export default function SocialDock() { 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 { BookOpen, Film, Music } from "lucide-react";
import gsap from "gsap";
const statusCards = [ const statusCards = [
{ {
icon: BookOpen, icon: BookOpen,
title: "正在读", label: "正在读",
value: "《时间的秩序》", value: "《时间的秩序》",
body: "把夜晚留给物理、散文和几页慢读。读到好的句子就收进手账。", body: "把夜晚留给物理、散文和几页慢读。读到好的句子就收进手账。",
}, },
{ {
icon: Film, icon: Film,
title: "正在做", label: "正在做",
value: "春风不解别离", value: "春风不解别离",
body: "把文章、相册和生活状态重新整理成一个更像家的个人博客。", body: "把文章、相册和生活状态重新整理成一个更像家的个人博客。",
}, },
{ {
icon: Music, icon: Music,
title: "正在听", label: "正在听",
value: "Bill Evans Trio", value: "Bill Evans Trio",
body: "钢琴声很轻,适合写代码、整理照片,也适合把页面留白收紧一点。", body: "钢琴声很轻,适合写代码、整理照片,也适合把页面留白收紧一点。",
}, },
]; ];
// 重复 3 次卡片列表以实现无缝水平循环滚动
const extendedCards = [...statusCards, ...statusCards, ...statusCards];
export default function StatusGrid() { 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 ( return (
<div className="mask-image-horizontal overflow-hidden w-full py-2"> <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 {/* 顶部金色饰条 */}
ref={trackRef} <div className="h-[3px] w-full bg-gradient-to-r from-gold via-gold-light to-transparent" />
className="flex gap-4 w-max gpu-accelerated-track"
onMouseEnter={handleMouseEnter} {/* 手账头 */}
onMouseLeave={handleMouseLeave} <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">
{extendedCards.map((item, index) => { <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; const Icon = item.icon;
return ( return (
<div <div
key={`${item.title}-${index}`} key={item.label}
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]" 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"> <span className="font-serif text-[13px] tracking-[0.22em] text-gold">
<Icon className="h-5 w-5 stroke-[1.6]" /> {item.label}
</div> </span>
<p className="text-[13px] text-charcoal/50 dark:text-cream/50">{item.title}</p> <h4 className="mt-2 font-serif text-lg font-semibold leading-snug text-charcoal dark:text-cream">
<h3 className="mt-2 text-lg font-semibold text-charcoal dark:text-cream">{item.value}</h3> {item.value}
<p className="mt-3 text-[13px] leading-6 text-charcoal/62 dark:text-cream/68">{item.body}</p> </h4>
<p className="mt-2 text-[13px] leading-6 text-charcoal/55 dark:text-cream/60">
{item.body}
</p>
</div> </div>
); );
})} })}
+3 -1
View File
@@ -4,6 +4,7 @@ import { useRef, useEffect } from "react";
import { Lock, Eye } from "lucide-react"; import { Lock, Eye } from "lucide-react";
import CountdownTimer from "./CountdownTimer"; import CountdownTimer from "./CountdownTimer";
import gsap from "gsap"; import gsap from "gsap";
import { useAuthorProfile } from "@/hooks/useSysConfig";
interface CapsuleLetter { interface CapsuleLetter {
id: string; id: string;
@@ -21,6 +22,7 @@ interface EnvelopeCardProps {
} }
export default function EnvelopeCard({ letter, unlockedIds, onClick }: EnvelopeCardProps) { export default function EnvelopeCard({ letter, unlockedIds, onClick }: EnvelopeCardProps) {
const author = useAuthorProfile();
const cardRef = useRef<HTMLDivElement>(null); const cardRef = useRef<HTMLDivElement>(null);
const stampRef = useRef<HTMLDivElement>(null); const stampRef = useRef<HTMLDivElement>(null);
const sealRef = useRef<HTMLDivElement>(null); const sealRef = useRef<HTMLDivElement>(null);
@@ -187,7 +189,7 @@ export default function EnvelopeCard({ letter, unlockedIds, onClick }: EnvelopeC
style={{ transform: "translateZ(8px)" }} style={{ transform: "translateZ(8px)" }}
> >
<span className="font-serif italic text-xs text-charcoal/50 uppercase tracking-wider"> <span className="font-serif italic text-xs text-charcoal/50 uppercase tracking-wider">
To: 未来的 Rrtiamo To: 未来的 {author.name || "Rrtiamo"}
</span> </span>
<span className="font-serif italic text-[11px] text-charcoal/40 uppercase tracking-wider"> <span className="font-serif italic text-[11px] text-charcoal/40 uppercase tracking-wider">
From: {is2027 ? "2026年夏夜 · Private Atlas" : "2026年秋分 · 逻辑信箱"} 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 { Mail, Key, Eye, X, Image as ImageIcon } from "lucide-react";
import { motion, AnimatePresence } from "framer-motion"; import { motion, AnimatePresence } from "framer-motion";
import gsap from "gsap"; import gsap from "gsap";
import { useAuthorProfile } from "@/hooks/useSysConfig";
interface CapsuleLetter { interface CapsuleLetter {
id: string; id: string;
@@ -28,6 +29,7 @@ export default function LetterModal({
unlockedIds, unlockedIds,
onUnlockSuccess, onUnlockSuccess,
}: LetterModalProps) { }: LetterModalProps) {
const author = useAuthorProfile();
const [bypassInput, setBypassInput] = useState(""); const [bypassInput, setBypassInput] = useState("");
const [error, setError] = useState(false); const [error, setError] = useState(false);
const [isOpeningTransition, setIsOpeningTransition] = useState(false); const [isOpeningTransition, setIsOpeningTransition] = useState(false);
@@ -246,7 +248,7 @@ export default function LetterModal({
<span>书于:2026 年夏日傍晚</span> <span>书于:2026 年夏日傍晚</span>
</div> </div>
<div className="flex items-center space-x-2"> <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"> <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" type="button"
aria-label="向左查看更多日记" aria-label="向左查看更多日记"
onClick={() => handleManualNavigate("prev")} 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]" /> <ChevronLeft className="w-5 h-5 stroke-[2]" />
</button> </button>
@@ -217,7 +217,7 @@ export default function LoveArticleRail({ entries, onSelect }: LoveArticleRailPr
type="button" type="button"
aria-label="向右查看更多日记" aria-label="向右查看更多日记"
onClick={() => handleManualNavigate("next")} 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]" /> <ChevronRight className="w-5 h-5 stroke-[2]" />
</button> </button>
@@ -242,7 +242,7 @@ export default function LoveArticleRail({ entries, onSelect }: LoveArticleRailPr
key={`${entry.id}-${idx}`} key={`${entry.id}-${idx}`}
type="button" type="button"
onClick={() => onSelect(entry)} 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"> <div className="overflow-hidden rounded-[1.2rem] aspect-[16/10] bg-charcoal/5 relative">
<ParallaxImage <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" /> <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>
<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" /> <Sparkles className="w-2.5 h-2.5" />
翻阅回忆 翻阅回忆
</span> </span>
+26 -28
View File
@@ -4,6 +4,7 @@ import { useState, useRef } from "react";
import Image from "next/image"; import Image from "next/image";
import type { BucketItem } from "@/interface/love"; import type { BucketItem } from "@/interface/love";
import { Check, Heart, Smile, Plane, Utensils, Home, Compass } from "lucide-react"; import { Check, Heart, Smile, Plane, Utensils, Home, Compass } from "lucide-react";
import LoveSectionHeading from "./LoveSectionHeading";
interface LoveBucketListProps { interface LoveBucketListProps {
items: BucketItem[]; items: BucketItem[];
@@ -32,22 +33,19 @@ export default function LoveBucketList({ items }: LoveBucketListProps) {
return ( return (
<div className="w-full py-12 px-4 max-w-7xl mx-auto sm:px-6 lg:px-8"> <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 className="flex flex-col lg:flex-row lg:items-end justify-between gap-8 mb-12">
<div> <LoveSectionHeading
<span className="text-sm font-semibold text-gold"> num="05"
慢慢完成的约定 label="Bucket List"
</span> enMain="100"
<h2 className="mt-1 text-3xl font-semibold tracking-[-0.02em] text-charcoal dark:text-cream"> enOutline="THINGS"
爱的 100 件事 cnTitle="爱的 100 件事"
</h2> description="将对未来的期待写进清单,然后一件件,用温度与光影将它们逐一“点亮”。"
<p className="text-sm tone-muted mt-2 font-sans"> />
将对未来的期待写进清单,然后一件件,用温度与光影将它们逐一“点亮”。
</p>
</div>
{/* 精美进度环看板 */} {/* 精美进度环看板 */}
<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"> <div className="relative w-16 h-16 flex items-center justify-center shrink-0">
<svg className="w-full h-full transform -rotate-90"> <svg className="w-full h-full transform -rotate-90">
<circle <circle
@@ -57,7 +55,7 @@ export default function LoveBucketList({ items }: LoveBucketListProps) {
stroke="currentColor" stroke="currentColor"
strokeWidth="4" strokeWidth="4"
fill="transparent" fill="transparent"
className="text-amber-900/10 dark:text-amber-400/10" className="text-rose-900/10 dark:text-rose-400/10"
/> />
<circle <circle
cx="32" cx="32"
@@ -69,16 +67,16 @@ export default function LoveBucketList({ items }: LoveBucketListProps) {
strokeDashoffset={2 * Math.PI * 26 * (1 - percent / 100)} strokeDashoffset={2 * Math.PI * 26 * (1 - percent / 100)}
strokeLinecap="round" strokeLinecap="round"
fill="transparent" 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> </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}% {percent}%
</span> </span>
</div> </div>
<div> <div>
<div className="text-xs tone-muted font-sans font-semibold">已点亮愿望</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> {completed} <span className="text-xs tone-muted">/ {total}</span>
</div> </div>
</div> </div>
@@ -93,8 +91,8 @@ export default function LoveBucketList({ items }: LoveBucketListProps) {
onClick={() => setActiveFilter(cat.key)} onClick={() => setActiveFilter(cat.key)}
className={`cursor-pointer rounded-full px-4 py-2 text-sm font-semibold transition-all duration-300 ${ className={`cursor-pointer rounded-full px-4 py-2 text-sm font-semibold transition-all duration-300 ${
activeFilter === cat.key activeFilter === cat.key
? "bg-amber-600 dark:bg-amber-500 text-white shadow-sm" ? "bg-rose-600 dark:bg-rose-500 text-white shadow-sm"
: "border border-charcoal/8 dark:border-white/10 hover:border-amber-600/50 hover:text-amber-600 tone-muted" : "border border-charcoal/8 dark:border-white/10 hover:border-rose-600/50 hover:text-rose-600 tone-muted"
}`} }`}
> >
{cat.label} {cat.label}
@@ -218,7 +216,7 @@ function BucketCard({ item }: { item: BucketItem }) {
onClick={handleCardClick} 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 ${ 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 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]" : "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)} {getCategoryName(item.category)}
</span> </span>
{item.completed && ( {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]" /> <Check className="w-3.5 h-3.5 stroke-[2.5]" />
</span> </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"> <div className="mt-4 flex justify-between items-end border-t border-charcoal/5 dark:border-white/5 pt-3">
{item.completed ? ( {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} {item.completedDate}
</span> </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 ? ( {item.cover ? (
<div className="flex gap-3 h-full items-center"> <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"> <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>
<div className="flex-1 min-w-0 flex flex-col justify-between h-full py-1"> <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 || "完成这件事的感动,都藏在合照里。"}” “{item.thoughts || "完成这件事的感动,都藏在合照里。"}”
</p> </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} 点亮日期: {item.completedDate}
</span> </span>
</div> </div>
</div> </div>
) : ( ) : (
<div className="flex flex-col justify-between h-full py-1"> <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}” “{item.thoughts}”
</p> </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} 点亮日期: {item.completedDate}
</span> </span>
</div> </div>
+4 -4
View File
@@ -207,7 +207,7 @@ export default function LoveGalleryRail({ photos, onSelect }: LoveGalleryRailPro
type="button" type="button"
aria-label="向左查看更多照片" aria-label="向左查看更多照片"
onClick={() => handleManualNavigate("prev")} 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]" /> <ChevronLeft className="w-5 h-5 stroke-[2]" />
</button> </button>
@@ -217,7 +217,7 @@ export default function LoveGalleryRail({ photos, onSelect }: LoveGalleryRailPro
type="button" type="button"
aria-label="向右查看更多照片" aria-label="向右查看更多照片"
onClick={() => handleManualNavigate("next")} 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]" /> <ChevronRight className="w-5 h-5 stroke-[2]" />
</button> </button>
@@ -242,7 +242,7 @@ export default function LoveGalleryRail({ photos, onSelect }: LoveGalleryRailPro
key={`${entry.id}-${idx}`} key={`${entry.id}-${idx}`}
type="button" type="button"
onClick={() => onSelect(entry)} 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"> <div className="relative overflow-hidden rounded-[1.2rem] aspect-[4/3] bg-charcoal/5">
<ParallaxImage <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" /> <Heart className="h-3.5 w-3.5 text-rose-500 fill-rose-500/20" />
<span>心情: {moodLabelMap[entry.mood] || entry.mood}</span> <span>心情: {moodLabelMap[entry.mood] || entry.mood}</span>
</p> </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" /> <Sparkles className="w-2.5 h-2.5" />
放大瞬间 放大瞬间
</span> </span>
+90 -16
View File
@@ -1,7 +1,7 @@
"use client"; "use client";
import { useEffect, useRef, useState } from "react"; 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 { GalleryPhoto } from "@/data/gallery";
import type { LoveEntry } from "@/interface/love"; import type { LoveEntry } from "@/interface/love";
import { import {
@@ -11,11 +11,11 @@ import {
useLoveStats, useLoveStats,
} from "@/hooks/useLove"; } from "@/hooks/useLove";
import Lightbox from "@/components/gallery/Lightbox"; import Lightbox from "@/components/gallery/Lightbox";
import SectionIntro from "@/components/home/SectionIntro";
import LoveArticleRail from "@/components/love/LoveArticleRail"; import LoveArticleRail from "@/components/love/LoveArticleRail";
import LoveBucketList from "@/components/love/LoveBucketList"; import LoveBucketList from "@/components/love/LoveBucketList";
import LoveGalleryRail from "@/components/love/LoveGalleryRail"; import LoveGalleryRail from "@/components/love/LoveGalleryRail";
import LoveQuote from "@/components/love/LoveQuote"; import LoveQuote from "@/components/love/LoveQuote";
import LoveSectionHeading from "@/components/love/LoveSectionHeading";
import LoveStats from "@/components/love/LoveStats"; import LoveStats from "@/components/love/LoveStats";
import LoveTimeCapsule from "@/components/love/LoveTimeCapsule"; import LoveTimeCapsule from "@/components/love/LoveTimeCapsule";
import LoveTimeline from "@/components/love/LoveTimeline"; import LoveTimeline from "@/components/love/LoveTimeline";
@@ -23,9 +23,22 @@ import LoveHero from "@/components/love/hero/LoveHero";
import PasscodeGate from "@/components/ui/PasscodeGate"; import PasscodeGate from "@/components/ui/PasscodeGate";
import gsap from "gsap"; import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger"; import { ScrollTrigger } from "gsap/ScrollTrigger";
import { useCoupleProfile } from "@/hooks/useSysConfig";
gsap.registerPlugin(ScrollTrigger); 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 { function galleryPhotoOfLoveEntry(entry: LoveEntry): GalleryPhoto {
return { return {
id: entry.id, id: entry.id,
@@ -56,6 +69,7 @@ export default function LovePageClient({ configs }: LovePageClientProps) {
const { bucketItems, loading: bucketLoading } = useLoveBucket(); const { bucketItems, loading: bucketLoading } = useLoveBucket();
const { capsules, loading: capsuleLoading } = useLoveCapsules(); const { capsules, loading: capsuleLoading } = useLoveCapsules();
const { stats: loveStats, loading: statsLoading } = useLoveStats(); const { stats: loveStats, loading: statsLoading } = useLoveStats();
const couple = useCoupleProfile();
const [selectedPhoto, setSelectedPhoto] = useState<GalleryPhoto | null>(null); const [selectedPhoto, setSelectedPhoto] = useState<GalleryPhoto | null>(null);
const [showGate, setShowGate] = useState(false); const [showGate, setShowGate] = useState(false);
@@ -102,14 +116,66 @@ export default function LovePageClient({ configs }: LovePageClientProps) {
contentRef.current?.scrollIntoView({ behavior: "smooth", block: "start" }); 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 ( 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"> <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 <LoveHero
onScrollDown={handleScrollDown} onScrollDown={handleScrollDown}
heroBgUrl={configs?.["page.love.heroBgUrl"]} heroBgUrl={configs?.["page.love.heroBgUrl"]}
atmospheresJson={configs?.["page.love.atmospheres"]} 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 <div
ref={contentRef} ref={contentRef}
className="relative w-full scroll-mt-5 bg-cream transition-colors duration-500 dark:bg-charcoal" className="relative w-full scroll-mt-5 bg-cream transition-colors duration-500 dark:bg-charcoal"
@@ -156,35 +222,43 @@ export default function LovePageClient({ configs }: LovePageClientProps) {
<div className="w-full"> <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"> <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"> <div className="mx-auto max-w-7xl">
<SectionIntro <LoveSectionHeading
icon={Camera} num="03"
title="甜蜜瞬间" label="Sweet Moments"
body="把日常光影、偶然相遇和一起停下来的时刻,按自然色彩留在这里。" enMain="SWEET"
href="/love" enOutline="MOMENTS"
action="查看照片" cnTitle="甜蜜瞬间"
description="把日常光影、偶然相遇和一起停下来的时刻,按自然色彩留在这里。"
action={{ href: "/love", text: "查看照片" }}
/> />
<div className="mt-10">
<LoveGalleryRail <LoveGalleryRail
photos={visibleEntries} photos={visibleEntries}
onSelect={(entry) => setSelectedPhoto(galleryPhotoOfLoveEntry(entry))} onSelect={(entry) => setSelectedPhoto(galleryPhotoOfLoveEntry(entry))}
/> />
</div> </div>
</div>
</section> </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"> <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"> <div className="mx-auto max-w-7xl">
<SectionIntro <LoveSectionHeading
icon={Heart} num="04"
title="恋爱日记" label="Love Diary"
body="那些小笑声、绕远路和晚归路上的灯,都可以被慢慢写下来。" enMain="LOVE"
href="/love" enOutline="DIARY"
action="阅读故事" cnTitle="恋爱日记"
description="那些小笑声、绕远路和晚归路上的灯,都可以被慢慢写下来。"
action={{ href: "/love", text: "阅读故事" }}
/> />
<div className="mt-10">
<LoveArticleRail <LoveArticleRail
entries={visibleEntries} entries={visibleEntries}
onSelect={(entry) => setSelectedPhoto(galleryPhotoOfLoveEntry(entry))} onSelect={(entry) => setSelectedPhoto(galleryPhotoOfLoveEntry(entry))}
/> />
</div> </div>
</div>
</section> </section>
</div> </div>
+52 -15
View File
@@ -1,42 +1,79 @@
"use client"; "use client";
import { Heart } from "lucide-react"; import { Heart } from "lucide-react";
import { useAuthorProfile, useCoupleProfile } from "@/hooks/useSysConfig";
export default function LoveQuote() { export default function LoveQuote() {
const author = useAuthorProfile();
const couple = useCoupleProfile();
return ( return (
<section className="px-4 pt-10 pb-28 sm:px-6 md:pt-12 md:pb-36 lg:px-8"> <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 <span
aria-hidden="true" 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> </span>
{/* 暖粉色柔光晕 */} {/* 暖粉色柔光晕 */}
<div <div
aria-hidden="true" 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"> <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" />
<Heart className="h-5 w-5 stroke-[1.6]" /> <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>
<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 className="mt-5 text-pretty font-serif text-lg font-medium leading-snug text-charcoal dark:text-cream md:text-xl">
我们携手走过四季,把时间酿成记忆。 我们携手走过四季,把时间酿成记忆。
</p> </p>
<p className="max-w-xl text-sm leading-7 text-charcoal/62 dark:text-cream/68">
{/* 副文案 */}
<p className="mt-4 max-w-md text-sm leading-7 text-charcoal/62 dark:text-cream/68">
我喜欢把这句话放在恋爱记的末尾。它提醒我们,每一个稀疏平常的日常里,有你在身旁,就是最温柔的时光档案馆。 我喜欢把这句话放在恋爱记的末尾。它提醒我们,每一个稀疏平常的日常里,有你在身旁,就是最温柔的时光档案馆。
</p> </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"> <div className="mt-6 flex items-center gap-3">
Rrtiamo & Sweetheart · 《生活档案馆》 <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> </p>
</div>
</div>
</div> </div>
</div> </div>
</section> </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 { Calendar, Compass, Film, Utensils } from "lucide-react";
import gsap from "gsap"; import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger"; import { ScrollTrigger } from "gsap/ScrollTrigger";
import LoveSectionHeading from "./LoveSectionHeading";
if (typeof window !== "undefined") { if (typeof window !== "undefined") {
gsap.registerPlugin(ScrollTrigger); gsap.registerPlugin(ScrollTrigger);
@@ -122,25 +123,22 @@ export default function LoveStats({ stats }: LoveStatsProps) {
return ( return (
<div ref={containerRef} className="w-full py-10 px-4 max-w-7xl mx-auto sm:px-6 lg:px-8"> <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 className="mb-12">
<div> <LoveSectionHeading
<span className="text-sm font-semibold text-gold"> num="01"
被时间认真记下的日常 label="Companion Archive"
</span> enMain="COMPANION"
<h2 className="mt-1 text-3xl font-semibold tracking-[-0.02em] text-charcoal dark:text-cream"> enOutline="ARCHIVE"
陪伴档案馆 cnTitle="陪伴档案馆"
</h2> description="时光如水,而数字是我们携手走过四季最忠实的刻度。"
</div> />
<p className="text-sm tone-muted max-w-md font-sans">
时光如水,而数字是我们携手走过四季最忠实的刻度。
</p>
</div> </div>
{/* Bento Grid 布局 */} {/* Bento Grid 布局 */}
<div className="grid grid-cols-1 md:grid-cols-4 gap-6"> <div className="grid grid-cols-1 md:grid-cols-4 gap-6">
{/* 卡片 1: 相识天数 (双倍宽) */} {/* 卡片 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="flex items-center justify-between">
<div className="p-3 bg-gold/12 rounded-xl text-gold"> <div className="p-3 bg-gold/12 rounded-xl text-gold">
<Calendar className="w-6 h-6 stroke-[1.5]" /> <Calendar className="w-6 h-6 stroke-[1.5]" />
@@ -231,7 +229,7 @@ export default function LoveStats({ stats }: LoveStatsProps) {
strokeDasharray="4 6" strokeDasharray="4 6"
className="text-charcoal/30 dark:text-cream/30" 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 */} {/* 纸飞机 SVG */}
<polygon points="0,-4 10,0 0,4 2,0" fill="currentColor" /> <polygon points="0,-4 10,0 0,4 2,0" fill="currentColor" />
</g> </g>
+19 -19
View File
@@ -5,6 +5,7 @@ import type { TimeCapsule } from "@/interface/love";
import { Lock, Unlock, Mail, ArrowUpRight } from "lucide-react"; import { Lock, Unlock, Mail, ArrowUpRight } from "lucide-react";
import gsap from "gsap"; import gsap from "gsap";
import LetterModal from "@/components/letter/LetterModal"; import LetterModal from "@/components/letter/LetterModal";
import LoveSectionHeading from "./LoveSectionHeading";
interface LoveTimeCapsuleProps { interface LoveTimeCapsuleProps {
capsules: TimeCapsule[]; capsules: TimeCapsule[];
@@ -13,17 +14,16 @@ interface LoveTimeCapsuleProps {
export default function LoveTimeCapsule({ capsules }: LoveTimeCapsuleProps) { export default function LoveTimeCapsule({ capsules }: LoveTimeCapsuleProps) {
return ( return (
<div className="w-full py-12 px-4 max-w-7xl mx-auto sm:px-6 lg:px-8"> <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"> <div className="mb-12">
<span className="text-xs font-semibold text-amber-800 dark:text-amber-400"> <LoveSectionHeading
写给未来的悄悄话 num="06"
</span> label="Time Capsule"
<h2 className="mt-1 text-3xl font-semibold tracking-[-0.02em] text-charcoal dark:text-cream"> enMain="TIME"
时光信箱 enOutline="CAPSULE"
</h2> cnTitle="时光信箱"
<p className="text-sm tone-muted mt-2 font-sans max-w-md"> description="有些话,只说给未来的我们听。在这里寄存秘密信件,直到指定的一天被开启。"
有些话,只说给未来的我们听。在这里寄存秘密信件,直到指定的一天被开启。 />
</p>
</div> </div>
{/* 胶囊卡片网络 */} {/* 胶囊卡片网络 */}
@@ -124,8 +124,8 @@ function CapsuleEnvelope({ capsule }: { capsule: TimeCapsule }) {
onClick={handleEnvelopeClick} 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 ${ 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)) 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-rose-950/5 dark:bg-charcoal/20 border-rose-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-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} {capsule.sender} ➔ {capsule.receiver}
</span> </span>
{isLocked && !unlockedIds.includes(String(capsule.id)) ? ( {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" /> <Lock className="w-3 h-3" />
未解封 未解封
</span> </span>
@@ -161,22 +161,22 @@ function CapsuleEnvelope({ capsule }: { capsule: TimeCapsule }) {
{isLocked && !unlockedIds.includes(String(capsule.id)) && timeLeft ? ( {isLocked && !unlockedIds.includes(String(capsule.id)) && timeLeft ? (
<div className="flex gap-2 items-center mt-3 font-mono"> <div className="flex gap-2 items-center mt-3 font-mono">
<div className="text-center"> <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> <span className="text-[9px] text-charcoal/50 dark:text-cream/50 ml-0.5">天</span>
</div> </div>
<span className="tone-faint text-xs">:</span> <span className="tone-faint text-xs">:</span>
<div className="text-center"> <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> <span className="text-[9px] text-charcoal/50 dark:text-cream/50 ml-0.5">时</span>
</div> </div>
<span className="tone-faint text-xs">:</span> <span className="tone-faint text-xs">:</span>
<div className="text-center"> <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> <span className="text-[9px] text-charcoal/50 dark:text-cream/50 ml-0.5">分</span>
</div> </div>
<span className="tone-faint text-xs">:</span> <span className="tone-faint text-xs">:</span>
<div className="text-center"> <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> <span className="text-[9px] text-charcoal/50 dark:text-cream/50 ml-0.5">秒</span>
</div> </div>
</div> </div>
@@ -197,7 +197,7 @@ function CapsuleEnvelope({ capsule }: { capsule: TimeCapsule }) {
</span> </span>
<span className="text-[10px] font-mono tone-muted flex items-center gap-0.5"> <span className="text-[10px] font-mono tone-muted flex items-center gap-0.5">
解封日: {capsule.openDate} 解封日: {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> </span>
</div> </div>
+97 -194
View File
@@ -1,10 +1,11 @@
"use client"; "use client";
import { useEffect, useMemo, useRef, useState } from "react"; import { useEffect, useMemo, useRef, useState } from "react";
import Image from "next/image"; import Image from "next/image";
import type { LoveEntry } from "@/interface/love"; import type { LoveEntry } from "@/interface/love";
import { MapPin, Sparkles, MailOpen, Heart, ChevronLeft, ChevronRight } from "lucide-react"; import { MapPin, Sparkles, MailOpen, Heart, ChevronLeft, ChevronRight } from "lucide-react";
import gsap from "gsap"; import gsap from "gsap";
import LoveSectionHeading from "./LoveSectionHeading";
interface LoveTimelineProps { interface LoveTimelineProps {
entries: LoveEntry[]; entries: LoveEntry[];
@@ -15,37 +16,20 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
const containerRef = useRef<HTMLDivElement>(null); const containerRef = useRef<HTMLDivElement>(null);
const trackRef = useRef<HTMLDivElement>(null); const trackRef = useRef<HTMLDivElement>(null);
// 排序:时间轴由远及近(升序) // 排序:时间轴由远及近(升序),单周期展示,不再复制循环
const sortedEntries = useMemo( const sortedEntries = useMemo(
() => [...entries].sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()), () => [...entries].sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()),
[entries], [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 [isDesktop, setIsDesktop] = useState(false);
const [isInView, setIsInView] = useState(false); const [isInView, setIsInView] = useState(false);
// 自动播放与控制相关的 refs // 手动翻页相关 refs
const currentX = useRef(0); 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); const manualTweenRef = useRef<gsap.core.Tween | null>(null);
// 监听组件是否在视口内以按需启动/停止自动滚动和漂浮动画 // 监听组件是否在视口内以按需启动漂浮动画
useEffect(() => { useEffect(() => {
const section = sectionRef.current; const section = sectionRef.current;
if (!section) return; if (!section) return;
@@ -71,12 +55,19 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
return () => window.removeEventListener("resize", checkDesktop); 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 实现状态同步,彻底消除重渲染开销 // 翻转卡片,直接操作 DOM toggle class 实现状态同步,彻底消除重渲染开销
const toggleFlip = (id: string, e: React.MouseEvent) => { const toggleFlip = (id: string, e: React.MouseEvent) => {
e.stopPropagation(); e.stopPropagation();
if (!trackRef.current) return; if (!trackRef.current) return;
// 寻找同一 id 的所有复制卡片容器并 toggle 它们的翻转状态 // 寻找同一 id 的所有卡片容器并 toggle 它们的翻转状态
const cards = trackRef.current.querySelectorAll(`[data-card-id="${id}"]`); const cards = trackRef.current.querySelectorAll(`[data-card-id="${id}"]`);
cards.forEach((card) => { cards.forEach((card) => {
card.classList.toggle("rotate-y-180"); 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)"; e.currentTarget.style.transform = "rotateX(0deg) rotateY(0deg) scale(1)";
}; };
// GSAP 驱动的水平自动滚动与无缝循环 (仅在视口内时按需开启) // 手动翻页(左右按钮):单周期内平滑平移,越界自动夹取
useEffect(() => { const handleManualNavigate = (direction: "next" | "prev") => {
if (!isDesktop || sortedEntries.length === 0 || !isInView) { if (sortedEntries.length === 0) return;
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 cardWidth = 380; const step = 412; // 卡片 380 + 间距 32
const gap = 32; const maxScroll = getMaxScroll();
const step = cardWidth + gap; const targetX = gsap.utils.clamp(
const singleCycleWidth = sortedEntries.length * step; -maxScroll,
0,
isAutoPlaying.current = true; currentX.current + (direction === "next" ? -step : step)
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;
}
if (trackRef.current) {
gsap.set(trackRef.current, { x: currentX.current });
}
}
rafRef.current = requestAnimationFrame(tick);
};
rafRef.current = requestAnimationFrame(tick);
return () => {
if (rafRef.current) cancelAnimationFrame(rafRef.current);
if (manualTweenRef.current) manualTweenRef.current.kill(); 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;
}
},
});
}; };
}, [isDesktop, sortedEntries, isInView]);
// 窗口尺寸变化时:非桌面端复位,桌面端把越界位置夹取回边界内
useEffect(() => {
const onResize = () => {
if (!trackRef.current) return;
if (window.innerWidth < 1024) {
currentX.current = 0;
gsap.set(trackRef.current, { x: 0 });
return;
}
const maxScroll = getMaxScroll();
const clamped = Math.max(-maxScroll, currentX.current);
currentX.current = clamped;
gsap.set(trackRef.current, { x: clamped });
};
window.addEventListener("resize", onResize);
return () => window.removeEventListener("resize", onResize);
}, []);
// 卡片轻微的上下漂浮动画 (仅在视口内时运行以节约开销,限制选择范围在轨道容器内) // 卡片轻微的上下漂浮动画 (仅在视口内时运行以节约开销,限制选择范围在轨道容器内)
useEffect(() => { useEffect(() => {
if (!isDesktop || displayEntries.length === 0 || !isInView) return; if (!isDesktop || sortedEntries.length === 0 || !isInView) return;
if (!trackRef.current) return; if (!trackRef.current) return;
const cards = gsap.utils.toArray<HTMLElement>(trackRef.current.querySelectorAll(".timeline-card")); const cards = gsap.utils.toArray<HTMLElement>(trackRef.current.querySelectorAll(".timeline-card"));
@@ -186,127 +169,46 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
return () => { return () => {
floatingTweens.forEach((tween: any) => tween.kill()); floatingTweens.forEach((tween: any) => tween.kill());
}; };
}, [isDesktop, displayEntries, isInView]); }, [isDesktop, sortedEntries, 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;
}
};
useEffect(() => { useEffect(() => {
return () => { return () => {
if (autoPlayTimeoutRef.current) clearTimeout(autoPlayTimeoutRef.current); if (manualTweenRef.current) manualTweenRef.current.kill();
}; };
}, []); }, []);
return ( return (
<div <div
ref={sectionRef} 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"> <div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 mb-12 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"> <LoveSectionHeading
ANNIVERSARY CHRONICLE num="02"
</span> label="Anniversary Chronicle"
<h2 className="text-4xl sm:text-5xl font-serif mt-5 font-bold text-charcoal dark:text-cream tracking-wide"> enMain="LOVE"
恋爱编年史 enOutline="TIMELINE"
</h2> cnTitle="恋爱编年史"
<div className="w-16 h-[2px] bg-gradient-to-r from-transparent via-amber-500 to-transparent mx-auto mt-4" /> description="时光静流,万物生长。我们在年华的脉络里,写下相依前行的波澜诗篇。"
<p className="text-sm text-charcoal/65 dark:text-cream/65 mt-4 max-w-md mx-auto font-sans leading-relaxed"> />
时光静流,万物生长。我们在年华的脉络里,写下相依前行的波澜诗篇。
</p>
</div> </div>
{/* 滚动容器 */} {/* 滚动容器(宽度与其他区域统一,不铺满全屏) */}
<div <div className="relative mx-auto w-full max-w-7xl px-4 sm:px-6 lg:px-8">
ref={containerRef} {/* 桌面端左右悬浮导航按钮(外移到卡片区域外侧,避免遮挡) */}
className="w-full relative overflow-x-auto lg:overflow-x-hidden no-scrollbar py-8 z-20"
>
{/* 桌面端左右悬浮导航按钮 */}
{isDesktop && sortedEntries.length > 0 && ( {isDesktop && sortedEntries.length > 0 && (
<> <>
<button <button
onClick={() => handleManualNavigate("prev")} 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="上一张" aria-label="上一张"
> >
<ChevronLeft className="w-6 h-6 stroke-[2] group-hover:-translate-x-0.5 transition-transform" /> <ChevronLeft className="w-6 h-6 stroke-[2] group-hover:-translate-x-0.5 transition-transform" />
</button> </button>
<button <button
onClick={() => handleManualNavigate("next")} 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="下一张" aria-label="下一张"
> >
<ChevronRight className="w-6 h-6 stroke-[2] group-hover:translate-x-0.5 transition-transform" /> <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 <div
ref={trackRef} ref={trackRef}
onMouseEnter={handleMouseEnterTrack} className="relative flex items-center h-[560px] px-8 gap-8 w-max select-none gpu-accelerated-track"
onMouseLeave={handleMouseLeaveTrack}
className="relative flex items-center h-[560px] px-8 lg:px-[10vw] 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="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="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-amber-500/10 to-transparent" /> <div className="absolute inset-0 bg-gradient-to-r from-transparent via-rose-500/10 to-transparent" />
</div> </div>
{displayEntries.map((entry, index) => { {sortedEntries.map((entry, index) => {
const isOdd = index % 2 === 0; const isOdd = index % 2 === 0;
const cardKey = `${entry.id}-${index}`;
return ( return (
<div <div
key={cardKey} key={entry.id}
className="relative flex flex-col items-center shrink-0 w-[380px] h-full justify-center" 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"> <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-amber-500 dark:bg-amber-400 rounded-full animate-ping opacity-75"></span> <span className="w-2 h-2 bg-rose-500 dark:bg-rose-400 rounded-full animate-ping opacity-75"></span>
</div> </div>
{/* 垂直连接虚线 */} {/* 垂直连接虚线 */}
{isOdd ? ( {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" className="relative w-full h-full transition-transform duration-700 transform-style-3d"
> >
{/* 正面:电影画幅故事卡 */} {/* 正面:电影画幅故事卡 */}
<div <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">
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="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"> <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 <Image
@@ -388,8 +290,8 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
<div className="absolute inset-0 bg-gradient-to-t from-black/40 via-transparent to-transparent opacity-60" /> <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"> <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-amber-600 dark:text-amber-400" /> <MapPin className="w-3 h-3 text-rose-600 dark:text-rose-400" />
<span className="font-semibold">{entry.location}</span> <span className="font-semibold">{entry.location}</span>
</div> </div>
</div> </div>
@@ -399,7 +301,7 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
<div className="space-y-2"> <div className="space-y-2">
{/* 大衬线日期 */} {/* 大衬线日期 */}
<div className="flex items-center gap-3 font-serif"> <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)} {entry.date.substring(5)}
</span> </span>
<span className="h-3.5 w-[1px] bg-charcoal/15 dark:bg-white/20" /> <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"> <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" /> <Heart className="w-3.5 h-3.5 fill-current animate-pulse" />
Love Memoir Love Memoir
</span> </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" /> <Sparkles className="w-3 h-3 animate-spin-slow" />
点击翻阅回想 点击翻阅回想
</span> </span>
@@ -433,7 +335,7 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
</div> </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 <div
className="absolute inset-0 opacity-25 dark:opacity-10 pointer-events-none" 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="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"> <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-amber-900 dark:text-amber-400 flex items-center gap-1.5 tracking-wider"> <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-amber-700 dark:text-amber-400" /> <MailOpen className="w-4 h-4 text-rose-700 dark:text-rose-400" />
MEMOIR / 爱的回想 MEMOIR / 爱的回想
</span> </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]"> <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 <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" }} style={{ paddingTop: "1px" }}
> >
{entry.content} {entry.content}
@@ -466,8 +368,8 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
</div> </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"> <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-amber-500" /> <Sparkles className="w-3 h-3 text-rose-500" />
<span>点击卡片翻回正面</span> <span>点击卡片翻回正面</span>
</div> </div>
</div> </div>
@@ -480,5 +382,6 @@ export default function LoveTimeline({ entries }: LoveTimelineProps) {
</div> </div>
</div> </div>
</div> </div>
</div>
); );
} }
+11 -6
View File
@@ -6,6 +6,7 @@ import { ArrowDown, Sparkles, Volume2, VolumeX } from "lucide-react";
import gsap from "gsap"; import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger"; import { ScrollTrigger } from "gsap/ScrollTrigger";
import EcgLine from "./EcgLine"; import EcgLine from "./EcgLine";
import { useAuthorProfile, useCoupleProfile } from "@/hooks/useSysConfig";
gsap.registerPlugin(ScrollTrigger); gsap.registerPlugin(ScrollTrigger);
@@ -64,6 +65,8 @@ export default function LoveHero({ onScrollDown, heroBgUrl, atmospheresJson }: L
const [daysCount, setDaysCount] = useState(0); const [daysCount, setDaysCount] = useState(0);
const [daysToAnniversary, setDaysToAnniversary] = useState(0); const [daysToAnniversary, setDaysToAnniversary] = useState(0);
const [yearsCount, setYearsCount] = useState(0); const [yearsCount, setYearsCount] = useState(0);
const author = useAuthorProfile();
const couple = useCoupleProfile();
// 氛围状态 // 氛围状态
const [atmosphereIndex, setAtmosphereIndex] = useState(0); 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 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"> <div className="relative w-full h-full rounded-full overflow-hidden">
<Image <Image
src="/assets/avtor-boy.jpg" src={author.avatar || "/assets/avtor-boy.jpg"}
alt="Rrtiamo" alt={author.name || "Rrtiamo"}
fill fill
sizes="(max-width: 768px) 112px, 160px" sizes="(max-width: 768px) 112px, 160px"
className="object-cover pointer-events-none" className="object-cover pointer-events-none"
@@ -559,7 +562,7 @@ export default function LoveHero({ onScrollDown, heroBgUrl, atmospheresJson }: L
/> />
</div> </div>
</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> </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 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"> <div className="relative w-full h-full rounded-full overflow-hidden">
{couple.avatar ? (
<Image <Image
src="/assets/avtor-girl.jpg" src={couple.avatar}
alt="Sweetheart" alt={couple.name || ""}
fill fill
sizes="(max-width: 768px) 112px, 160px" sizes="(max-width: 768px) 112px, 160px"
className="object-cover pointer-events-none" className="object-cover pointer-events-none"
priority priority
/> />
) : null}
</div> </div>
</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>
</div> </div>
+20
View File
@@ -73,6 +73,7 @@ export default function ArchivePlayer() {
createPlaylist, createPlaylist,
renamePlaylist, renamePlaylist,
removePlaylist, removePlaylist,
addTrackToPlaylist,
addTracksToPlaylist, addTracksToPlaylist,
removeTrackFromPlaylist, removeTrackFromPlaylist,
handleTrackPlayback, handleTrackPlayback,
@@ -118,6 +119,23 @@ export default function ArchivePlayer() {
[setPlaylist, showToast] [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(() => { const handleClearPlaylist = useCallback(() => {
setPlaylist([]); setPlaylist([]);
@@ -229,6 +247,8 @@ export default function ArchivePlayer() {
addPlaylistToQueue={addPlaylistToQueue} addPlaylistToQueue={addPlaylistToQueue}
playPlaylistTrack={playPlaylistTrack} playPlaylistTrack={playPlaylistTrack}
onAddTrackToQueue={handleAddTrackToQueue} onAddTrackToQueue={handleAddTrackToQueue}
onAddTrackToPlaylist={handleSaveTrackToPlaylist}
onCreateAndSavePlaylist={handleCreateAndSaveTrack}
onClearPlaylist={handleClearPlaylist} onClearPlaylist={handleClearPlaylist}
/> />
+102 -2
View File
@@ -4,6 +4,8 @@ import React, { useState, useEffect } from "react";
import { createPortal } from "react-dom"; import { createPortal } from "react-dom";
import hljs from "highlight.js"; import hljs from "highlight.js";
import "highlight.js/styles/github-dark.css"; import "highlight.js/styles/github-dark.css";
import katex from "katex";
import "katex/dist/katex.min.css";
import { import {
Copy, Copy,
Check, 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[] { export function parseInline(text: string, onImageClick?: (url: string, alt: string) => void, offset: number = 0): React.ReactNode[] {
if (!text) return []; if (!text) return [];
let minIndex = Infinity; 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 matchedString = "";
let matchData: any = null; let matchData: any = null;
@@ -138,6 +153,24 @@ export function parseInline(text: string, onImageClick?: (url: string, alt: stri
matchedString = taskUncheckedMatch[0]; 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)) // 1. Image (![alt](url))
const imageRegex = /!\[([^\]]*)\]\(([^)]+)\)/; const imageRegex = /!\[([^\]]*)\]\(([^)]+)\)/;
const imageMatch = imageRegex.exec(text); 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" /> <Square className="w-4 h-4" />
</span> </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") { } else if (matchType === "bold" && typeof matchData === "string") {
result.push( result.push(
<strong key={key} className="font-bold text-(--fg-color)"> <strong key={key} className="font-bold text-(--fg-color)">
@@ -376,6 +425,7 @@ export interface Block {
| "ol" | "ol"
| "code" | "code"
| "table" | "table"
| "math"
| "hr"; | "hr";
content?: string; content?: string;
lines?: string[]; lines?: string[];
@@ -454,6 +504,46 @@ export function parseBlocks(content: string): Block[] {
continue; 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 (---, ***, ___) // 2. Horizontal Rule (---, ***, ___)
if (/^(---|[*]{3,}|_{3,})$/.test(trimmed)) { if (/^(---|[*]{3,}|_{3,})$/.test(trimmed)) {
if (currentBlock) { 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 "h1":
case "h2": case "h2":
case "h3": case "h3":
+31 -53
View File
@@ -1,74 +1,50 @@
"use client"; "use client";
import { useState, useEffect } from "react"; import { useState } from "react";
import { Lock } from "lucide-react"; import { Lock } from "lucide-react";
import { motion, AnimatePresence } from "framer-motion"; import { motion, AnimatePresence } from "framer-motion";
import { getPublicConfig } from "@/api/config"; import { verifyPasscode } from "@/api/config";
interface PasscodeGateProps { interface PasscodeGateProps {
onUnlock: () => void; onUnlock: () => void;
passcode?: string; // 默认口令 passcode?: string; // 兼容旧签名:仅作展示文案兜底,实际校验走服务端
title?: string; title?: string;
description?: string; description?: string;
} }
export default function PasscodeGate({ export default function PasscodeGate({
onUnlock, onUnlock,
passcode = "2026",
title = "数字档案馆加密区", title = "数字档案馆加密区",
description = "本区块包含私人信件与恋爱相册。请输入访问口令(默认:2026)解锁查看。", description = "本区块包含私人信件与恋爱相册。请输入访问口令解锁查看。",
}: PasscodeGateProps) { }: PasscodeGateProps) {
const [input, setInput] = useState(""); const [input, setInput] = useState("");
const [error, setError] = useState(false); const [error, setError] = useState(false);
const [shake, setShake] = useState(false); const [shake, setShake] = useState(false);
const [verifying, setVerifying] = useState(false);
const [currentPasscode, setCurrentPasscode] = useState(passcode); const fail = () => {
const [remotePasscodeLoaded, setRemotePasscodeLoaded] = useState(false); setError(true);
setShake(true);
useEffect(() => { setInput("");
// 检查本会话中是否已经解锁过 setTimeout(() => setShake(false), 500);
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 = const handleSubmit = async (e: React.FormEvent) => {
remotePasscodeLoaded && currentPasscode !== "2026"
? description.replace("(默认:2026)", "")
: description;
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault(); e.preventDefault();
if (input === currentPasscode) { if (!input || verifying) return;
setVerifying(true);
try {
const result = await verifyPasscode(input);
if (result.code === 200) {
sessionStorage.setItem("atlas_unlocked", "true"); sessionStorage.setItem("atlas_unlocked", "true");
onUnlock(); onUnlock();
} else { } else {
setError(true); fail();
setShake(true); }
setTimeout(() => setShake(false), 500); } catch {
setInput(""); 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" 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 left-0 w-4 h-4 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 top-0 right-0 w-4 h-4 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 left-0 w-4 h-4 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 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"> <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]" /> <Lock className="w-5 h-5 stroke-[1.25]" />
@@ -93,7 +69,7 @@ export default function PasscodeGate({
{title} {title}
</h2> </h2>
<p className="text-xs md:text-sm font-sans text-charcoal/60 leading-relaxed tracking-wider mb-8 max-w-70 mx-auto"> <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> </p>
<form onSubmit={handleSubmit} className="space-y-4"> <form onSubmit={handleSubmit} className="space-y-4">
@@ -102,6 +78,7 @@ export default function PasscodeGate({
type="password" type="password"
placeholder="ENTER PASSCODE" placeholder="ENTER PASSCODE"
value={input} value={input}
disabled={verifying}
onChange={(e) => { onChange={(e) => {
setInput(e.target.value); setInput(e.target.value);
setError(false); setError(false);
@@ -126,9 +103,10 @@ export default function PasscodeGate({
<button <button
type="submit" 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> </button>
</form> </form>
</motion.div> </motion.div>
+13
View File
@@ -55,6 +55,8 @@ interface PlayerDrawerSheetProps {
addPlaylistToQueue?: (playlistId: string, append?: boolean) => void; addPlaylistToQueue?: (playlistId: string, append?: boolean) => void;
playPlaylistTrack?: (track: TrackDetail) => void; playPlaylistTrack?: (track: TrackDetail) => void;
onAddTrackToQueue?: (track: TrackDetail) => void; onAddTrackToQueue?: (track: TrackDetail) => void;
onAddTrackToPlaylist?: (playlistId: string, track: TrackDetail) => void;
onCreateAndSavePlaylist?: (name: string, track: TrackDetail) => void;
onClearPlaylist?: () => void; onClearPlaylist?: () => void;
} }
@@ -92,6 +94,8 @@ export default function PlayerDrawerSheet({
addPlaylistToQueue, addPlaylistToQueue,
playPlaylistTrack, playPlaylistTrack,
onAddTrackToQueue, onAddTrackToQueue,
onAddTrackToPlaylist,
onCreateAndSavePlaylist,
onClearPlaylist, onClearPlaylist,
}: PlayerDrawerSheetProps) { }: PlayerDrawerSheetProps) {
const [activeTab, setActiveTab] = useState<"playlist" | "favorites" | "playlists" | "search" | "import">("playlist"); const [activeTab, setActiveTab] = useState<"playlist" | "favorites" | "playlists" | "search" | "import">("playlist");
@@ -279,6 +283,9 @@ export default function PlayerDrawerSheet({
onRemoveTrack={onRemoveTrack} onRemoveTrack={onRemoveTrack}
onToggleFavorite={onToggleFavorite} onToggleFavorite={onToggleFavorite}
isFavorite={isFavorite} isFavorite={isFavorite}
playlists={playlists}
onAddTrackToPlaylist={onAddTrackToPlaylist}
onCreateAndSavePlaylist={onCreateAndSavePlaylist}
/> />
)} )}
@@ -292,6 +299,9 @@ export default function PlayerDrawerSheet({
onToggleFavorite={onToggleFavorite} onToggleFavorite={onToggleFavorite}
onPlayFavoriteTrack={onPlayFavoriteTrack} onPlayFavoriteTrack={onPlayFavoriteTrack}
onSwitchToSearch={() => setActiveTab("search")} onSwitchToSearch={() => setActiveTab("search")}
playlists={playlists}
onAddTrackToPlaylist={onAddTrackToPlaylist}
onCreateAndSavePlaylist={onCreateAndSavePlaylist}
/> />
)} )}
@@ -327,6 +337,9 @@ export default function PlayerDrawerSheet({
isResolvingTrack={isResolvingTrack} isResolvingTrack={isResolvingTrack}
onToggleFavorite={onToggleFavorite} onToggleFavorite={onToggleFavorite}
isFavorite={isFavorite} 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 React, { useState } from "react";
import { musicIcons } from "@/icon/music"; import { musicIcons } from "@/icon/music";
import type { TrackDetail } from "@/interface/music"; import type { TrackDetail } from "@/interface/music";
import type { PlaylistFolder } from "@/hooks/usePlayerPlaylists";
import AnimatedList from "../AnimatedList"; import AnimatedList from "../AnimatedList";
import SaveToPlaylistButton from "./SaveToPlaylistButton";
const { const {
heart: HeartIcon, heart: HeartIcon,
@@ -50,6 +52,9 @@ interface DrawerFavoritesTabProps {
onToggleFavorite?: (track: TrackDetail) => void; onToggleFavorite?: (track: TrackDetail) => void;
onPlayFavoriteTrack?: (track: TrackDetail) => void; onPlayFavoriteTrack?: (track: TrackDetail) => void;
onSwitchToSearch: () => void; onSwitchToSearch: () => void;
playlists?: PlaylistFolder[];
onAddTrackToPlaylist?: (playlistId: string, track: TrackDetail) => void;
onCreateAndSavePlaylist?: (name: string, track: TrackDetail) => void;
} }
export default function DrawerFavoritesTab({ export default function DrawerFavoritesTab({
@@ -61,6 +66,9 @@ export default function DrawerFavoritesTab({
onToggleFavorite, onToggleFavorite,
onPlayFavoriteTrack, onPlayFavoriteTrack,
onSwitchToSearch, onSwitchToSearch,
playlists,
onAddTrackToPlaylist,
onCreateAndSavePlaylist,
}: DrawerFavoritesTabProps) { }: DrawerFavoritesTabProps) {
return ( return (
<div className="grow min-h-0 flex flex-col space-y-3 overscroll-contain"> <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" /> <HeartIcon size={15} weight="fill" />
</button> </button>
)} )}
{onAddTrackToPlaylist && playlists && (
<SaveToPlaylistButton
track={track}
playlists={playlists}
onAdd={onAddTrackToPlaylist}
onCreate={onCreateAndSavePlaylist || (() => {})}
/>
)}
</div> </div>
); );
}} }}
@@ -3,7 +3,9 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { musicIcons } from "@/icon/music"; import { musicIcons } from "@/icon/music";
import type { TrackDetail } from "@/interface/music"; import type { TrackDetail } from "@/interface/music";
import type { PlaylistFolder } from "@/hooks/usePlayerPlaylists";
import AnimatedList from "../AnimatedList"; import AnimatedList from "../AnimatedList";
import SaveToPlaylistButton from "./SaveToPlaylistButton";
const { const {
heart: HeartIcon, heart: HeartIcon,
@@ -21,6 +23,9 @@ interface DrawerPlaylistTabProps {
onRemoveTrack?: (index: number) => void; onRemoveTrack?: (index: number) => void;
onToggleFavorite?: (track: TrackDetail) => void; onToggleFavorite?: (track: TrackDetail) => void;
isFavorite?: (track: TrackDetail) => boolean; isFavorite?: (track: TrackDetail) => boolean;
playlists?: PlaylistFolder[];
onAddTrackToPlaylist?: (playlistId: string, track: TrackDetail) => void;
onCreateAndSavePlaylist?: (name: string, track: TrackDetail) => void;
} }
const DefaultVinylCover = () => ( const DefaultVinylCover = () => (
@@ -63,6 +68,9 @@ export default function DrawerPlaylistTab({
onRemoveTrack, onRemoveTrack,
onToggleFavorite, onToggleFavorite,
isFavorite, isFavorite,
playlists,
onAddTrackToPlaylist,
onCreateAndSavePlaylist,
}: DrawerPlaylistTabProps) { }: DrawerPlaylistTabProps) {
const [visibleLimit, setVisibleLimit] = useState(25); const [visibleLimit, setVisibleLimit] = useState(25);
const [showAll, setShowAll] = useState(false); const [showAll, setShowAll] = useState(false);
@@ -185,6 +193,15 @@ export default function DrawerPlaylistTab({
</button> </button>
)} )}
{onAddTrackToPlaylist && playlists && (
<SaveToPlaylistButton
track={track}
playlists={playlists}
onAdd={onAddTrackToPlaylist}
onCreate={onCreateAndSavePlaylist || (() => {})}
/>
)}
{onRemoveTrack && ( {onRemoveTrack && (
<button <button
type="button" type="button"
@@ -3,6 +3,8 @@
import React, { useRef, useState, useEffect } from "react"; import React, { useRef, useState, useEffect } from "react";
import { musicIcons } from "@/icon/music"; import { musicIcons } from "@/icon/music";
import type { ApiSearchResult, MusicSource, TrackDetail } from "@/interface/music"; import type { ApiSearchResult, MusicSource, TrackDetail } from "@/interface/music";
import type { PlaylistFolder } from "@/hooks/usePlayerPlaylists";
import SaveToPlaylistButton from "./SaveToPlaylistButton";
const { const {
caretDown: CaretDownIcon, caretDown: CaretDownIcon,
@@ -33,6 +35,9 @@ interface DrawerSearchTabProps {
isResolvingTrack: boolean; isResolvingTrack: boolean;
onToggleFavorite?: (track: TrackDetail) => void; onToggleFavorite?: (track: TrackDetail) => void;
isFavorite?: (track: TrackDetail) => boolean; isFavorite?: (track: TrackDetail) => boolean;
playlists?: PlaylistFolder[];
onAddTrackToPlaylist?: (playlistId: string, track: TrackDetail) => void;
onCreateAndSavePlaylist?: (name: string, track: TrackDetail) => void;
} }
export default function DrawerSearchTab({ export default function DrawerSearchTab({
@@ -48,6 +53,9 @@ export default function DrawerSearchTab({
isResolvingTrack, isResolvingTrack,
onToggleFavorite, onToggleFavorite,
isFavorite, isFavorite,
playlists,
onAddTrackToPlaylist,
onCreateAndSavePlaylist,
}: DrawerSearchTabProps) { }: DrawerSearchTabProps) {
const [isSelectDropdownOpen, setIsSelectDropdownOpen] = useState(false); const [isSelectDropdownOpen, setIsSelectDropdownOpen] = useState(false);
const [resolvingId, setResolvingId] = useState<string | null>(null); const [resolvingId, setResolvingId] = useState<string | null>(null);
@@ -217,6 +225,15 @@ export default function DrawerSearchTab({
</button> </button>
)} )}
{onAddTrackToPlaylist && playlists && (
<SaveToPlaylistButton
track={searchTrackItem}
playlists={playlists}
onAdd={onAddTrackToPlaylist}
onCreate={onCreateAndSavePlaylist || (() => {})}
/>
)}
<button <button
type="button" type="button"
disabled={isResolvingTrack} disabled={isResolvingTrack}
+135 -104
View File
@@ -50,21 +50,12 @@ interface PlayerCapsuleBarProps {
formatTime: (seconds: number) => string; formatTime: (seconds: number) => string;
} }
const DefaultVinylCover = ({ isPlaying = false }: { isPlaying?: boolean }) => ( /** 播放模式文案 */
<div function modeLabel(mode: PlaybackMode): string {
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" if (mode === "repeat") return "单曲循环";
style={{ animationPlayState: isPlaying ? "running" : "paused", willChange: "transform", transform: "translateZ(0)" }} if (mode === "shuffle") return "随机播放";
> return "顺序播放";
{/* 唱片的同心圆纹路 */} }
<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>
);
export default function PlayerCapsuleBar({ export default function PlayerCapsuleBar({
currentTrack, currentTrack,
@@ -97,7 +88,8 @@ export default function PlayerCapsuleBar({
const [showVolumeSlider, setShowVolumeSlider] = useState(false); const [showVolumeSlider, setShowVolumeSlider] = useState(false);
const [isDraggingVolume, setIsDraggingVolume] = useState(false); const [isDraggingVolume, setIsDraggingVolume] = useState(false);
const [isCollapsed, setIsCollapsed] = useState(false); // 初始即折叠:避免刷新页面时先展开、5 秒后又被自动收起(表现为“弹出又隐藏”)
const [isCollapsed, setIsCollapsed] = useState(true);
const [localCoverFailed, setLocalCoverFailed] = useState(false); const [localCoverFailed, setLocalCoverFailed] = useState(false);
useEffect(() => { useEffect(() => {
@@ -190,6 +182,8 @@ export default function PlayerCapsuleBar({
!localCoverFailed !localCoverFailed
); );
const displayFallbackMessage = playerMessage || currentTrack.album || "等待一段声音开始"; const displayFallbackMessage = playerMessage || currentTrack.album || "等待一段声音开始";
const spinning = isPlaying;
const hasTrack = playlistLength > 0;
return ( return (
<div <div
@@ -198,11 +192,13 @@ export default function PlayerCapsuleBar({
data-player-style="floating-drawer-dock" data-player-style="floating-drawer-dock"
style={{ style={{
transform: isCollapsed transform: isCollapsed
? "translate(-50%, calc(100% - 24px))" ? "translate(-50%, calc(100% - 20px))"
: "translate(-50%, 0)", : "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 ${ 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)/60" : "" isCollapsed
? "cursor-pointer hover:border-(--accent-color)/50"
: "opacity-90 hover:opacity-100"
}`} }`}
onClick={() => { onClick={() => {
if (isCollapsed) { if (isCollapsed) {
@@ -211,24 +207,18 @@ export default function PlayerCapsuleBar({
} }
}} }}
> >
{/* 顶部微型的 Drawer 指示条 */} {/* 顶部手柄:折叠时一条细条,展开时小圆点 */}
<div className="w-full pb-2 flex flex-col items-center shrink-0 cursor-pointer"> <div className="w-full flex flex-col items-center shrink-0 cursor-pointer">
<div className={`h-1 rounded-full transition-all duration-300 ${ {isCollapsed ? (
isCollapsed ? "w-16 bg-(--accent-color) animate-pulse" : "w-10 bg-(--fg-color)/20 group-hover/drawer:bg-(--fg-color)/40" <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> </div>
<PlayerProgressBar {/* 主行:圆形封面 + 歌曲信息 + 播放控制(折叠时整体隐藏) */}
currentTime={currentTime} <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"}`}>
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 <button
type="button" type="button"
onClick={(e) => { onClick={(e) => {
@@ -236,7 +226,7 @@ export default function PlayerCapsuleBar({
e.stopPropagation(); e.stopPropagation();
onOpenExpandedModal(); onOpenExpandedModal();
}} }}
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" 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="打开沉浸式歌词大屏" title="打开沉浸式歌词大屏"
> >
{coverIsAvailable ? ( {coverIsAvailable ? (
@@ -244,34 +234,57 @@ export default function PlayerCapsuleBar({
<img <img
src={currentTrack.cover} src={currentTrack.cover}
alt={`${currentTrack.title} 封面`} alt={`${currentTrack.title} 封面`}
className="size-full object-cover animate-spin-slow" className="absolute inset-0 size-full object-cover animate-spin-slow"
style={{ animationPlayState: isPlaying ? "running" : "paused", willChange: "transform", transform: "translateZ(0)" }} style={{ animationPlayState: spinning ? "running" : "paused", willChange: "transform", transform: "translateZ(0)" }}
onError={() => { onError={() => {
onMarkBrokenCover(currentTrack.id); onMarkBrokenCover(currentTrack.id);
setLocalCoverFailed(true); setLocalCoverFailed(true);
}} }}
/> />
) : ( ) : (
<DefaultVinylCover isPlaying={isPlaying} /> <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 bg-black/30 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-white"> {/* 唱片黑胶外圈与光泽 */}
<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)",
}}
/>
<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" /> <LyricsIcon size={14} weight="bold" />
</div> </div>
</button> </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"> <div className="min-w-0 grow">
<p className="truncate text-xs sm:text-sm font-semibold text-(--fg-color) tracking-tight"> <div className="flex items-center gap-2 min-w-0">
{playlistLength > 0 ? currentTrack.title : "暂无歌曲播放"} <p className="truncate text-sm font-bold text-(--fg-color) tracking-tight">
{hasTrack ? currentTrack.title : "暂无歌曲播放"}
</p> </p>
{playlistLength > 0 && ( {hasTrack && (
<span className="hidden sm:inline text-[10px] text-(--fg-color)/60 truncate"> <span className="hidden sm:inline truncate text-[11px] text-(--fg-color)/60">
• {currentTrack.artist} • {currentTrack.artist}
</span> </span>
)} )}
</div> </div>
<div className="text-[11px] sm:text-xs text-(--fg-color)/70 mt-0.5 truncate"> <div className="flex items-center gap-2 mt-1 min-w-0">
{playlistLength > 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 <RollingLyrics
lyric={currentTrack.lyric} lyric={currentTrack.lyric}
translatedLyric={currentTrack.tlyric} translatedLyric={currentTrack.tlyric}
@@ -279,54 +292,24 @@ export default function PlayerCapsuleBar({
fallback={displayFallbackMessage} fallback={displayFallbackMessage}
/> />
) : ( ) : (
<span className="text-[11px] text-(--fg-color)/40">开启您的音乐生活档案</span> "开启您的音乐生活档案"
)} )}
</div> </span>
</div> </div>
</div> </div>
{/* 中间:播放控制核心组 */} {/* 播放控制:上一首 / 播放 / 下一首 */}
<div className="flex items-center gap-1 sm:gap-2 shrink-0"> <div className="flex items-center gap-1 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>
<button <button
type="button" type="button"
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
onPlayPrev(); 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="上一首" title="上一首"
> >
<PreviousIcon size={18} weight="fill" /> <PreviousIcon size={17} weight="fill" />
</button> </button>
<button <button
@@ -336,7 +319,7 @@ export default function PlayerCapsuleBar({
onTogglePlay(); onTogglePlay();
}} }}
disabled={isResolvingTrack} 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 ? "暂停" : "播放"} title={isPlaying ? "暂停" : "播放"}
> >
{isResolvingTrack ? ( {isResolvingTrack ? (
@@ -344,7 +327,7 @@ export default function PlayerCapsuleBar({
) : isPlaying ? ( ) : isPlaying ? (
<PauseIcon size={18} weight="fill" /> <PauseIcon size={18} weight="fill" />
) : ( ) : (
<PlayIcon size={18} weight="fill" className="translate-x-0.5" /> <PlayIcon size={18} weight="fill" />
)} )}
</button> </button>
@@ -354,22 +337,71 @@ export default function PlayerCapsuleBar({
e.stopPropagation(); e.stopPropagation();
onPlayNext(); 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="下一首" title="下一首"
> >
<NextIcon size={18} weight="fill" /> <NextIcon size={17} weight="fill" />
</button> </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> </span>
</div> </div>
{/* 右侧:音量控制 & 播放队列(采用绝对定位向左连体平滑展开,绝对不挤压左侧操控按钮) */} <div className="flex items-center gap-0.5 sm:gap-1 shrink-0">
<div className="flex items-center gap-1.5 sm:gap-2 shrink-0"> {/* 音量(桌面端悬浮展开) */}
<div <div
ref={volumeContainerRef} ref={volumeContainerRef}
className="relative hidden md:block size-8 sm:size-9" className="relative hidden md:block size-7"
onMouseEnter={() => setShowVolumeSlider(true)} onMouseEnter={() => setShowVolumeSlider(true)}
onMouseLeave={() => { onMouseLeave={() => {
if (!isDraggingVolume) setShowVolumeSlider(false); if (!isDraggingVolume) setShowVolumeSlider(false);
@@ -378,8 +410,8 @@ export default function PlayerCapsuleBar({
<div <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 ${ 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 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-36 sm:w-40 px-2 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-7 px-0 justify-center overflow-hidden"
}`} }`}
> >
<button <button
@@ -396,21 +428,20 @@ export default function PlayerCapsuleBar({
e.stopPropagation(); e.stopPropagation();
onToggleMute(); 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 ? "取消静音" : "调整音量 (双击静音)"} title={isMuted ? "取消静音" : "调整音量 (双击静音)"}
> >
{isMuted || volume === 0 ? <VolumeMutedIcon size={15} /> : <VolumeIcon size={15} />} {isMuted || volume === 0 ? <VolumeMutedIcon size={14} /> : <VolumeIcon size={14} />}
</button> </button>
<div <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" 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)}% {Math.round((isMuted ? 0 : volume) * 100)}%
</span> </span>
<div <div
onPointerDown={handleVolumePointerDown} onPointerDown={handleVolumePointerDown}
onPointerMove={handleVolumePointerMove} onPointerMove={handleVolumePointerMove}
@@ -423,7 +454,7 @@ export default function PlayerCapsuleBar({
className="h-full bg-(--accent-color) rounded-full relative transition-all duration-75" className="h-full bg-(--accent-color) rounded-full relative transition-all duration-75"
style={{ width: `${(isMuted ? 0 : volume) * 100}%` }} 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> </div>
</div> </div>
@@ -438,11 +469,11 @@ export default function PlayerCapsuleBar({
e.stopPropagation(); e.stopPropagation();
onOpenDrawer(); 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="打开播放队列与搜索" title="打开播放队列与搜索"
> >
<PlaylistIcon size={15} weight="bold" /> <PlaylistIcon size={13} weight="bold" />
<span className="hidden sm:inline text-[11px]">队列 ({playlistLength})</span> <span className="hidden sm:inline text-[10px] tabular-nums">{playlistLength}</span>
</button> </button>
</div> </div>
</div> </div>
+15 -15
View File
@@ -10,6 +10,10 @@ interface PlayerProgressBarProps {
hasTrack?: boolean; hasTrack?: boolean;
} }
/**
* 播放进度条:流式布局(非绝对定位),轨道与拖拽圆点垂直居中于同一条线上。
* 高度固定 h-4,方便在 flex 行内与时间标签垂直对齐。
*/
export default function PlayerProgressBar({ export default function PlayerProgressBar({
currentTime, currentTime,
duration, duration,
@@ -22,7 +26,8 @@ export default function PlayerProgressBar({
const [hoverTime, setHoverTime] = useState<number | null>(null); const [hoverTime, setHoverTime] = useState<number | null>(null);
const [hoverPositionRatio, setHoverPositionRatio] = useState(0); 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 calculateRatioFromEvent = (e: React.PointerEvent<HTMLDivElement>) => {
const rect = e.currentTarget.getBoundingClientRect(); const rect = e.currentTarget.getBoundingClientRect();
@@ -68,35 +73,30 @@ export default function PlayerProgressBar({
setIsHovered(false); setIsHovered(false);
setHoverTime(null); 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="点击或拖动调整播放进度" 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="relative w-full h-1.5 bg-(--fg-color)/15 rounded-full transition-all duration-200 group-hover:h-2">
{/* 实际的进度条轨道 */}
<div className="w-full h-1 bg-(--fg-color)/15 transition-all duration-200 group-hover:h-2 relative">
<div <div
className="h-full bg-(--accent-color) transition-all duration-75" className="h-full bg-(--accent-color) rounded-full transition-all duration-75"
style={{ width: `${progressPercent}%` }} style={{ width: `${progressPercent}%` }}
/> />
</div>
</div>
{/* 进度条控制圆点:脱离 overflow-hidden 轨道层放置,以防边界剪裁 */}
{hasTrack && ( {hasTrack && (
<div <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" 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={{ style={{
left: `calc(7px + ${progressPercent} * (100% - 14px) / 100)`, left: `calc(7px + ${progressPercent} * (100% - 14px) / 100)`,
top: isHovered ? "4px" : "2px", transform: "translate(-50%, -50%)",
transform: "translate(-50%, -50%)"
}} }}
/> />
)} )}
</div>
{/* 悬停时间气泡(轨道上方) */}
{isHovered && hoverTime !== null && ( {isHovered && hoverTime !== null && (
<div <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}%` }} style={{ left: `${hoverPositionRatio * 100}%` }}
> >
{formatTime(hoverTime)} {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 { useCallback, useEffect, useRef, useState } from "react";
import type { ApiSearchResult, MusicSource, PlaybackMode, TrackDetail } from "@/interface/music"; 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"; import { mockDefaultTracks } from "@/mock/music";
function formatTime(seconds: number) { function formatTime(seconds: number) {
@@ -109,6 +109,26 @@ export function useAudioPlayer() {
// 页面初始化:从 localStorage 恢复记录、进度与状态 // 页面初始化:从 localStorage 恢复记录、进度与状态
useEffect(() => { 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 { try {
const saved = localStorage.getItem("archive_player_state"); const saved = localStorage.getItem("archive_player_state");
if (saved) { if (saved) {
@@ -121,11 +141,12 @@ export function useAudioPlayer() {
t.id === "uPZirG1+JSxugKvPA7pyJQ==" t.id === "uPZirG1+JSxugKvPA7pyJQ=="
); );
if (hasInvalidCache) { if (hasInvalidCache) {
setPlaylist(mockDefaultTracks); void loadDefaultPlaylist();
setCurrentIndex(0);
} else { } else {
setPlaylist(parsed.playlist); setPlaylist(parsed.playlist);
} }
} else {
void loadDefaultPlaylist();
} }
if (typeof parsed.currentIndex === "number") { if (typeof parsed.currentIndex === "number") {
setCurrentIndex(parsed.currentIndex); setCurrentIndex(parsed.currentIndex);
@@ -143,10 +164,15 @@ export function useAudioPlayer() {
initialPositionRef.current = parsed.currentTime; initialPositionRef.current = parsed.currentTime;
setCurrentTime(parsed.currentTime); setCurrentTime(parsed.currentTime);
} }
} else {
void loadDefaultPlaylist();
} }
} catch { } catch {
// ignore storage error void loadDefaultPlaylist();
} }
return () => {
cancelled = true;
};
}, []); }, []);
// 页面离开/刷新瞬间强行同步写入当前精确播放位置 // 页面离开/刷新瞬间强行同步写入当前精确播放位置
+44
View File
@@ -43,3 +43,47 @@ export function SysConfigProvider({
export function useSysConfig() { export function useSysConfig() {
return useContext(SysConfigContext); 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 { import {
ArrowUpRight, ArrowUpRightIcon as ArrowUpRight,
BracketsCurly, BracketsCurlyIcon as BracketsCurly,
Camera, CameraIcon as Camera,
Compass, CompassIcon as Compass,
Database, DatabaseIcon as Database,
GitBranch, GitBranchIcon as GitBranch,
ImageSquare, ImageSquareIcon as ImageSquare,
Lightning, LightningIcon as Lightning,
MapTrifold, MapTrifoldIcon as MapTrifold,
Notebook, NotebookIcon as Notebook,
Palette, PaletteIcon as Palette,
ShieldCheck, ShieldCheckIcon as ShieldCheck,
} from "@phosphor-icons/react"; } from "@phosphor-icons/react";
import type { Icon } from "@phosphor-icons/react"; import type { Icon } from "@phosphor-icons/react";
import type { AboutIconName } from "@/interface/about"; import type { AboutIconName } from "@/interface/about";
+27 -25
View File
@@ -1,29 +1,30 @@
import { import {
CaretDown, CaretDownIcon as CaretDown,
CaretUp, CaretUpIcon as CaretUp,
CaretLeft, CaretLeftIcon as CaretLeft,
MagnifyingGlass, MagnifyingGlassIcon as MagnifyingGlass,
MusicNotes, MusicNotesIcon as MusicNotes,
Pause, PauseIcon as Pause,
Play, PlayIcon as Play,
Playlist, PlaylistIcon as Playlist,
Radio, RadioIcon as Radio,
Repeat, RepeatIcon as Repeat,
RepeatOnce, RepeatOnceIcon as RepeatOnce,
Shuffle, ShuffleIcon as Shuffle,
SkipBack, SkipBackIcon as SkipBack,
SkipForward, SkipForwardIcon as SkipForward,
SpeakerHigh, SpeakerHighIcon as SpeakerHigh,
SpeakerSlash, SpeakerSlashIcon as SpeakerSlash,
SpinnerGap, SpinnerGapIcon as SpinnerGap,
Trash, TrashIcon as Trash,
Waveform, WaveformIcon as Waveform,
X, XIcon as X,
Article, ArticleIcon as Article,
Heart, HeartIcon as Heart,
Folder, FolderIcon as Folder,
PencilSimple, FolderPlusIcon as FolderPlus,
Plus, PencilSimpleIcon as PencilSimple,
PlusIcon as Plus,
} from '@phosphor-icons/react'; } from '@phosphor-icons/react';
export const musicIcons = { export const musicIcons = {
@@ -50,6 +51,7 @@ export const musicIcons = {
volumeMuted: SpeakerSlash, volumeMuted: SpeakerSlash,
waveform: Waveform, waveform: Waveform,
folder: Folder, folder: Folder,
folderPlus: FolderPlus,
edit: PencilSimple, edit: PencilSimple,
plus: Plus, plus: Plus,
} as const; } as const;