feat: 路由转场+详情页+自定义滚动条+常显网格线+邮箱修复
- 新增 FullscreenTransitionProvider + RouteTransitionOverlay: cover(0.8s b1 遮罩 wipe) → push → reveal 状态机(原 73475/34841 移植), Work 卡片与详情页链接全部走 startNavigation(同路径点击回顶部) - 新增 app/work/[slug] 详情页:content/workArticles.ts 从原站 6 个详情页 1:1 提取(MDX 文章+Metadata+iframe 预览+Links),/2026 锁定时渲染解锁屏 - 新增 CustomScrollbar:桌面右缘 SVG 轨道+拖拽 thumb(188 轨道/min20)、 点击跳转、2s 自动隐藏;移动端底部进度环回顶按钮(原 72443 移植) - BackgroundGrid 重写为原版算法(3 行十字/12px 缺口/12 列内分数纵线, 主页 loading 时隐藏其余时间常显);层叠改为原版结构:canvas z-auto 最前 → grid z-20 → DOM 内容,移除各 section 的 z-30 - 修复 BGM:持久化开启时首次手势自动恢复播放(autoplay 策略被拒后 pointerdown/keydown/touchstart 重试),enabled 闭包改用 ref - 页脚邮箱改为 chenchun@virtheart.com
This commit is contained in:
@@ -1,9 +1,26 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { loadingBus } from '@/lib/loadingBus';
|
||||
|
||||
/**
|
||||
* Background grid — 1:1 port of the original (chunk 2689132c4e070b68.js):
|
||||
*
|
||||
* - Three cross junctions at thirds of the viewport height (y = h/3 - 12,
|
||||
* y = h/3 + 12 + i + 24), i.e. rows at h/3-12 and 2h/3+12, with 12px gaps
|
||||
* around the crosses and 12px notches where lines meet the frame.
|
||||
* - 2 columns (<1280) / 3 columns of vertical lines between the px paddings
|
||||
* (16 mobile / 56 lg), fractions of the inner width.
|
||||
* - Whole overlay hidden while the home loading gate is up
|
||||
* (`"/"===pathname && !readyToLoadHeavy`); visible at all other times —
|
||||
* that is why the original keeps the crosses on screen while scrolling.
|
||||
*/
|
||||
const LINE = 'rgba(255, 255, 255, 0.1)';
|
||||
|
||||
export default function BackgroundGrid() {
|
||||
const [size, setSize] = useState({ w: 375, h: 812 });
|
||||
const pathname = usePathname();
|
||||
const [size, setSize] = useState({ w: 0, h: 0 });
|
||||
|
||||
useEffect(() => {
|
||||
const updateSize = () => {
|
||||
@@ -14,60 +31,71 @@ export default function BackgroundGrid() {
|
||||
return () => window.removeEventListener('resize', updateSize);
|
||||
}, []);
|
||||
|
||||
// useHomeLoadingGate (original module 97839): "/" && !readyToLoadHeavy.
|
||||
// Our equivalent heavy-ready signal is the loading curtain (loadingBus).
|
||||
const [heavyReady, setHeavyReady] = useState(pathname !== '/');
|
||||
useEffect(() => {
|
||||
if (pathname !== '/') {
|
||||
setHeavyReady(true);
|
||||
return;
|
||||
}
|
||||
setHeavyReady(loadingBus.getSnapshot().ready);
|
||||
return loadingBus.subscribe(() => {
|
||||
setHeavyReady(loadingBus.getSnapshot().ready);
|
||||
});
|
||||
}, [pathname]);
|
||||
|
||||
const { w, h } = size;
|
||||
|
||||
// Calculate grid lines
|
||||
// Responsive padding: lg is px-14 (56px), mobile is px-4 (16px)
|
||||
const isDesktop = w >= 1024;
|
||||
const paddingX = isDesktop ? 56 : 16;
|
||||
const edgeOffset = paddingX + 0.5; // +0.5 for crisp SVG rendering
|
||||
const loadingGate = pathname === '/' && !heavyReady;
|
||||
|
||||
const cols = 3; // Left, Center, Right
|
||||
const rows = Math.ceil(h / 450) + 1;
|
||||
|
||||
const vLines = Array.from({ length: cols }).map((_, i) => {
|
||||
if (i === 0) return edgeOffset;
|
||||
if (i === cols - 1) return w - edgeOffset;
|
||||
return w / 2;
|
||||
});
|
||||
|
||||
const hLines = Array.from({ length: rows }).map((_, i) => (i + 1) * 442);
|
||||
const { verticalPath, horizontalPath, crossPath } = useMemo(() => {
|
||||
if (w <= 0 || h <= 0) return { verticalPath: '', horizontalPath: '', crossPath: '' };
|
||||
const n = w < 1024 ? 16 : 56;
|
||||
const innerW = Math.max(0, w - 2 * n);
|
||||
const i = Math.max(0, h / 3 - 12);
|
||||
const s = i + 24;
|
||||
const a = s + i;
|
||||
const cols = w < 1280 ? 2 : 3;
|
||||
const xs = Array.from({ length: cols + 1 }, (_, k) => n + (k / cols) * innerW).map(
|
||||
(x) => Math.round(x) + 0.5
|
||||
);
|
||||
const rows = [
|
||||
{ startY: 0, endY: i },
|
||||
{ startY: s, endY: a },
|
||||
{ startY: a + 24, endY: h },
|
||||
];
|
||||
const u = [i + 12, a + 12];
|
||||
const verticalPath = rows
|
||||
.map(({ startY, endY }) => xs.map((x) => `M${x} ${startY}V${endY}`).join(''))
|
||||
.join('');
|
||||
const horizontalPath = u
|
||||
.map((y) => {
|
||||
if (xs.length < 2) return '';
|
||||
const first = xs[0];
|
||||
const last = xs[xs.length - 1];
|
||||
const mids = xs.slice(0, -1)
|
||||
.map((x, k) => `M${x + 12} ${y}H${xs[k + 1] - 12}`)
|
||||
.join('');
|
||||
return [`M0 ${y}H${first - 12}`, mids, `M${last + 12} ${y}H${w}`].join('');
|
||||
})
|
||||
.join('');
|
||||
const crossPath = xs
|
||||
.flatMap((x) => u.flatMap((y) => [`M${x} ${y - 6}V${y + 6}`, `M${x - 6} ${y}H${x + 6}`]))
|
||||
.join('');
|
||||
return { verticalPath, horizontalPath, crossPath };
|
||||
}, [w, h]);
|
||||
|
||||
// Generate paths
|
||||
let vPath = '';
|
||||
let hPath = '';
|
||||
let crossPath = '';
|
||||
|
||||
const crossSize = 6; // 12px total width/height for the cross
|
||||
|
||||
vLines.forEach(x => {
|
||||
hLines.forEach((y, i) => {
|
||||
const startY = i === 0 ? 0 : hLines[i - 1] + 12;
|
||||
const endY = y - 12;
|
||||
vPath += `M${x} ${startY}V${endY} `;
|
||||
|
||||
crossPath += `M${x} ${y - crossSize}V${y + crossSize} `;
|
||||
crossPath += `M${x - crossSize} ${y}H${x + crossSize} `;
|
||||
});
|
||||
const lastY = hLines[hLines.length - 1] + 12;
|
||||
vPath += `M${x} ${lastY}V${h} `;
|
||||
});
|
||||
|
||||
hLines.forEach(y => {
|
||||
vLines.forEach((x, i) => {
|
||||
const startX = i === 0 ? 0 : vLines[i - 1] + 12;
|
||||
const endX = x - 12;
|
||||
hPath += `M${startX} ${y}H${endX} `;
|
||||
});
|
||||
const lastX = vLines[vLines.length - 1] + 12;
|
||||
hPath += `M${lastX} ${y}H${w} `;
|
||||
});
|
||||
if (loadingGate) return null;
|
||||
|
||||
return (
|
||||
<div className="z-20 fixed inset-0 w-full h-full pointer-events-none mix-blend-difference">
|
||||
<svg viewBox={`0 0 ${w} ${h}`} className="block shape-rendering-crispEdges w-full h-full">
|
||||
<path d={vPath} stroke="rgba(255, 255, 255, 0.1)" strokeWidth="1" fill="none" />
|
||||
<path d={hPath} stroke="rgba(255, 255, 255, 0.1)" strokeWidth="1" fill="none" />
|
||||
<svg
|
||||
viewBox={`0 0 ${w} ${h}`}
|
||||
className="block shape-rendering-crispEdges w-full h-full"
|
||||
>
|
||||
<path d={verticalPath} stroke={LINE} strokeWidth="1" fill="none" />
|
||||
<path d={horizontalPath} stroke={LINE} strokeWidth="1" fill="none" />
|
||||
<path d={crossPath} stroke="#FFFFFF" strokeWidth="1" fill="none" opacity="0.4" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user