From 2cf42c3fd93ce253edb2970bf8ae431b39197f98 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 28 Sep 2026 00:35:02 -0500 Subject: [PATCH] =?UTF-8?q?feat(web):=20PC=20=E5=93=8D=E5=BA=94=E5=BC=8F?= =?UTF-8?q?=E4=BE=A7=E6=A0=8F=E4=B8=8E=E5=8A=A0=E5=AE=BD=E7=BD=91=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- README.md | 4 +- src/App.tsx | 137 ++++++++++++++------- src/styles/global.css | 270 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 364 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index ab4e756..bcad4be 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,8 @@ npm run preview ## 能力 -- 整页长滚动浏览全部入口(图标 + 标题 + 简介) -- 左侧抽屉可快速跳到某一分类 +- **移动端**:整页长滚动 + 左侧抽屉跳转分类 +- **PC(≥960px)**:左侧常驻分类栏、加宽内容区、4~5 列入口网格 - 顶栏随滚动显示当前分类 - 浅色 / 深色主题记忆 - 回到顶部 diff --git a/src/App.tsx b/src/App.tsx index 81449b3..abc034a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { CategoryPanel } from './components/CategoryPanel' import { SideDrawer } from './components/SideDrawer' import config from './data/links.json' -import type { NavConfig, NavLink } from './types' +import type { NavCategory, NavConfig, NavLink } from './types' const nav = config as NavConfig @@ -16,6 +16,10 @@ function readTheme(): Theme { : 'light' } +function countLinks(cat: NavCategory) { + return cat.groups.reduce((s, g) => s + g.links.length, 0) +} + function IconMenu({ open }: { open: boolean }) { return ( window.clearTimeout(id) }, [toast]) + useEffect(() => { + const mq = window.matchMedia('(min-width: 960px)') + const onChange = () => { + if (mq.matches) setDrawerOpen(false) + } + onChange() + mq.addEventListener('change', onChange) + return () => mq.removeEventListener('change', onChange) + }, []) + useEffect(() => { const sections = nav.categories .map((c) => document.getElementById(`cat-${c.id}`)) @@ -173,45 +187,85 @@ export default function App() { -
-
- - -
- -
-

{nav.brand}

-

- {activeCategory.title} -

-
+
+ + + +
+
+
+ + +
+ +
+

{nav.brand}

+

+ {activeCategory.title} +

+
+
+ + +
+
+ +
+ {nav.categories.map((cat) => ( + + ))} +
{nav.footer}
+
+
-
- {nav.categories.map((cat) => ( - - ))} - -
-