refactor(layout): 统一页面边距管理,移除 Container 限制
- layoutConfig.js: 新增 LAYOUT_PADDING 常量 { base: 4, md: 6, lg: '80px' }
- MainLayout.js: 在 Outlet 容器上统一应用 px={LAYOUT_PADDING.x}
- HomeNavbar.js: 边距从 lg:8 改为 lg:'80px',与内容区对齐
- AppFooter.js: 移除 Container,边距改为 lg:'80px'
页面组件清理(移除冗余的 px/Container):
- Company, Community, Center, Profile, Settings
- ValueForum, DataBrowser, LimitAnalyse, StockOverview, Concept
特殊处理:
- CompanyHeader: 使用负边距实现全宽背景
- Concept Hero: 使用负边距实现全宽背景
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Box, Container, VStack, HStack, Text, Link, useColorModeValue } from '@chakra-ui/react';
|
||||
import { Box, VStack, HStack, Text, Link, useColorModeValue } from '@chakra-ui/react';
|
||||
import RiskDisclaimer from '../components/RiskDisclaimer';
|
||||
|
||||
/**
|
||||
@@ -8,8 +8,7 @@ import RiskDisclaimer from '../components/RiskDisclaimer';
|
||||
*/
|
||||
const AppFooter = () => {
|
||||
return (
|
||||
<Box bg={useColorModeValue('gray.100', 'gray.800')} py={2}>
|
||||
<Container maxW="container.xl">
|
||||
<Box bg={useColorModeValue('gray.100', 'gray.800')} py={2} px={{ base: 4, md: 6, lg: '80px' }}>
|
||||
<VStack spacing={1}>
|
||||
<RiskDisclaimer />
|
||||
<Text color="gray.500" fontSize="sm">
|
||||
@@ -32,7 +31,6 @@ const AppFooter = () => {
|
||||
</Link>
|
||||
</HStack>
|
||||
</VStack>
|
||||
</Container>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ import BackToTopButton from "./components/BackToTopButton";
|
||||
import ErrorBoundary from "../components/ErrorBoundary";
|
||||
import PageLoader from "../components/Loading/PageLoader";
|
||||
import GlobalSidebar from "../components/GlobalSidebar";
|
||||
import { BACK_TO_TOP_CONFIG, LAYOUT_SIZE } from "./config/layoutConfig";
|
||||
import { BACK_TO_TOP_CONFIG, LAYOUT_SIZE, LAYOUT_PADDING } from "./config/layoutConfig";
|
||||
|
||||
// ✅ P0 性能优化:缓存静态组件,避免路由切换时不必要的重新渲染
|
||||
// HomeNavbar (1623行) 和 AppFooter 不依赖路由参数,使用 memo 可大幅减少渲染次数
|
||||
@@ -40,7 +40,7 @@ export default function MainLayout() {
|
||||
<Box flex="1" bg="#1A202C" position="relative" overflow="hidden">
|
||||
{/* 页面内容区域 - 全宽度,与导航栏对齐 */}
|
||||
<Box h="100%" overflowY="auto" display="flex" flexDirection="column">
|
||||
<Box flex="1" pt={LAYOUT_SIZE.navbarHeight}>
|
||||
<Box flex="1" pt={LAYOUT_SIZE.navbarHeight} px={LAYOUT_PADDING.x}>
|
||||
<ErrorBoundary>
|
||||
<Suspense fallback={<PageLoader message="页面加载中..." />}>
|
||||
<Outlet />
|
||||
|
||||
@@ -170,6 +170,15 @@ export const LAYOUT_SIZE = {
|
||||
contentMinHeight: 'calc(100vh - 60px)', // 100vh - navbar高度
|
||||
};
|
||||
|
||||
/**
|
||||
* 布局内边距配置
|
||||
* 统一控制页面内容的水平内边距
|
||||
* 右侧预留空间给 GlobalSidebar(收起宽度 72px)
|
||||
*/
|
||||
export const LAYOUT_PADDING = {
|
||||
x: { base: 4, md: 6, lg: '80px' }, // 移动端 16px,中屏 24px,大屏 80px(容纳工具栏)
|
||||
};
|
||||
|
||||
/**
|
||||
* 响应式断点
|
||||
* 与 Chakra UI 断点保持一致
|
||||
@@ -189,5 +198,6 @@ export default {
|
||||
BACK_TO_TOP_CONFIG,
|
||||
PAGE_LOADER_CONFIG,
|
||||
LAYOUT_SIZE,
|
||||
LAYOUT_PADDING,
|
||||
BREAKPOINTS
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user