From 97096f309ce2085439c164608ce51566ee1c5fa9 Mon Sep 17 00:00:00 2001 From: weizwz <1124725517@qq.com> Date: Wed, 19 Nov 2025 11:09:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 6 +++ README.md | 8 ++++ app/globals.css | 37 +++++++++++++++ app/layout.tsx | 1 + app/page.tsx | 25 ++++++---- components/navigation/CategorySidebar.tsx | 58 ++++++++++++----------- 6 files changed, 97 insertions(+), 38 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..14cd765 --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +# 网站 URL(用于生成 Open Graph 和 Twitter 卡片) +# 开发环境 +# NEXT_PUBLIC_SITE_URL=http://localhost:3000 + +# 生产环境 +NEXT_PUBLIC_SITE_URL=https://nav.weizwz.com diff --git a/README.md b/README.md index 2fc0c2c..481b5b0 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,17 @@ Next.js 15 · TypeScript 5 · Tailwind CSS 4 · Ant Design 5 · Redux Toolkit · ## 🚀 快速开始 ```bash +# 克隆项目 +git clone +cd frontend-navigation-site + # 安装依赖 pnpm install +# 配置环境变量(可选) +cp .env.example .env.local +# 编辑 .env.local 设置你的网站 URL + # 启动开发服务器 pnpm dev diff --git a/app/globals.css b/app/globals.css index d8d2673..00b37cc 100644 --- a/app/globals.css +++ b/app/globals.css @@ -397,3 +397,40 @@ select:focus-visible { .install-success { animation: success-bounce 0.5s ease-in-out; } + +/* 固定布局样式 */ +.h-screen { + height: 100vh; + height: 100dvh; /* 动态视口高度,移动端更准确 */ +} + +/* 确保 body 和 html 不会滚动 */ +html, body { + overflow: hidden; + height: 100%; +} + +/* 只允许内容区域滚动 */ +#main-content { + scroll-behavior: smooth; +} + +/* 优化滚动性能 */ +#main-content { + -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */ + overscroll-behavior: contain; /* 防止滚动链 */ +} + +/* 侧边栏滚动优化 */ +aside { + -webkit-overflow-scrolling: touch; + overscroll-behavior: contain; +} + +/* 移动端优化 */ +@media (max-width: 1023px) { + /* 移动端允许整体滚动 */ + html, body { + overflow: auto; + } +} diff --git a/app/layout.tsx b/app/layout.tsx index 7746747..ef2b603 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -5,6 +5,7 @@ import RegisterServiceWorker from './register-sw'; import '@ant-design/v5-patch-for-react-19'; export const metadata: Metadata = { + metadataBase: new URL(process.env.NEXT_PUBLIC_SITE_URL || 'https://nav.weizwz.com'), title: { default: '唯知导航', template: '%s | 唯知导航', diff --git a/app/page.tsx b/app/page.tsx index a348ee4..6a7d883 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -146,19 +146,21 @@ export default function Home() { ); return ( -
- {/* 页头组件 */} -
setDrawerOpen(true)} /> +
+ {/* 固定顶部 Header */} +
+
setDrawerOpen(true)} /> +
- {/* 主内容区域 */} -
+ {/* 主内容区域 - 固定高度,内部滚动 */} +
- {/* 左侧分类导航 - Desktop */} + {/* 左侧分类导航 - Desktop - 固定,内部滚动 */} {/* 移动端抽屉 - 分类导航 */} @@ -169,11 +171,14 @@ export default function Home() { open={drawerOpen} className="lg:hidden" width={280} + styles={{ + body: { padding: 0, height: '100%' } + }} > - + - {/* 右侧内容区域 */} + {/* 右侧内容区域 - 只有这里滚动 */}
= ({ className, style role="navigation" aria-label="分类导航" > -
- {/* 拖拽分类列表 */} - - cat.id)} - strategy={verticalListSortingStrategy} +
+ {/* 拖拽分类列表 - 可滚动区域 */} +
+ -
- {sortedCategories.map((category) => ( - - ))} -
- -
+ cat.id)} + strategy={verticalListSortingStrategy} + > +
+ {sortedCategories.map((category) => ( + + ))} +
+
+ +
- {/* 底部按钮区域 */} -
+ {/* 底部按钮区域 - 固定在底部 */} +
{/* 未分类数据按钮 - 只在有未分类链接时显示 */} {uncategorizedCount > 0 && (