feat(web): 页头滚动信息、移除返回按钮、面包屑左侧可点、侧栏加首页

- 页头中间信息改为无缝滚动 ticker(3 份拼接,24s 线性,尊重 reduced-motion)
- 去掉分区 / 条目 / 文章三处「返回」「返回首页」按钮
- 面包屑移到左侧,中间项可点击并通过 onNavigate 走 SPA 路由
- 侧栏新增「首页」,首页时高亮,点击回首页
This commit is contained in:
stash
2026-10-29 11:26:47 +08:00
parent 2724d6f3ff
commit 22f7853bdd
9 changed files with 221 additions and 130 deletions
+16 -15
View File
@@ -28,7 +28,7 @@ import {
import { useProjects } from './useProjects'
import { useCatalog } from './useCatalog'
import { useViewRoute } from './useViewRoute'
import type { ItemRoute, View } from './data/view'
import { parseViewPath, viewPath, type View } from './data/view'
import './App.css'
export default function App() {
@@ -37,7 +37,7 @@ export default function App() {
const catalog = useCatalog()
const [keyword, setKeyword] = useState('')
// 当前视图由地址栏决定:刷新 / 收藏 / 前进后退都回到同一页(见 useViewRoute.ts)
const { view, go, back } = useViewRoute()
const { view, go } = useViewRoute()
const [scrolled, setScrolled] = useState(false)
const searchRef = useRef<HTMLInputElement>(null)
@@ -169,15 +169,6 @@ export default function App() {
})
}
/**
* 条目详情的「返回」目标:优先回到该条目所在的分组,
* 没有分组(海报 / 图文)时回到分区,走和侧栏一样的展示块规则。
*/
const detailTargetFor = (item: ItemRoute): View =>
item.groupId === undefined
? detailViewFor(item.categoryId)
: { type: 'detail', categoryId: item.categoryId, groupId: item.groupId }
/**
* 侧栏导航:带分组时直接打开那个分组;
* 点分区本身时,交给 openDetail 按展示块落到对应节点。
@@ -193,6 +184,9 @@ export default function App() {
const goHome = () => go({ type: 'home' })
/** 面包屑点击:把 href 解析回视图再跳转(保持 SPA 不刷新) */
const navigateHref = (href: string) => go(parseViewPath(href))
const searching = keyword.trim() !== ''
const viewCategoryId = detailView?.categoryId ?? itemView?.categoryId
@@ -224,8 +218,9 @@ export default function App() {
return (
<ArticleDetailView
article={article}
categoryId={itemCategory.id}
categoryTitle={itemCategory.title}
onBack={() => back(detailTargetFor(itemView))}
onNavigate={navigateHref}
/>
)
}
@@ -236,10 +231,14 @@ export default function App() {
return (
<ItemDetailView
breadcrumb={`${itemCategory.title} / ${detailModel.title}`}
crumbs={[
{ label: '首页', href: '/' },
{ label: itemCategory.title, href: viewPath({ type: 'detail', categoryId: itemCategory.id }) },
{ label: detailModel.title },
]}
model={detailModel}
related={relatedItems}
onBack={() => back(detailTargetFor(itemView))}
onNavigate={navigateHref}
onOpenItem={(itemId) => openItem(itemCategory.id, itemId)}
/>
)
@@ -283,7 +282,9 @@ export default function App() {
onRefresh={refresh}
activeCategoryId={viewCategoryId}
activeGroupId={detailView?.groupId}
homeActive={view.type === 'home'}
onNavigate={navigate}
onHome={goHome}
/>
}
>
@@ -335,7 +336,7 @@ export default function App() {
<DetailView
category={detailCategory}
groupId={detailView.groupId}
onBack={goHome}
onNavigate={navigateHref}
onOpenItem={(itemId) => openItem(detailCategory.id, itemId)}
/>
)}