11<script setup lang="ts">
2- import { useData } from ' vitepress'
2+ import { useData , Content } from ' vitepress'
33import NavBar from ' ./components/NavBar.vue'
44import Footer from ' ./components/Footer.vue'
5+ import Sidebar from ' ./components/Sidebar.vue'
6+ import Toc from ' ./components/Toc.vue'
7+ import Hero from ' ./components/Hero.vue'
58
69const { frontmatter } = useData ()
10+
11+ const isHome = frontmatter .value ?.home === true
712 </script >
813
914<template >
1015 <div class =" layout" >
1116 <!-- 导航栏 -->
1217 <NavBar />
1318
14- <!-- 主要内容区 -->
15- <main class =" main-content" >
16- <!-- 首页布局 -->
17- <div v-if =" frontmatter.home" class =" home" >
18- <Content />
19- </div >
20-
21- <!-- 文档页面布局 -->
22- <div v-else class =" page" >
23- <Content />
24- </div >
19+ <!-- 首页布局 -->
20+ <main v-if =" isHome" class =" home-layout" >
21+ <Hero />
22+ <Content />
2523 </main >
2624
25+ <!-- 文档页面布局 -->
26+ <div v-else class =" doc-layout" >
27+ <!-- 侧边栏 -->
28+ <Sidebar />
29+
30+ <!-- 主内容区 -->
31+ <main class =" main-content" >
32+ <div class =" content-wrapper" >
33+ <Content />
34+ </div >
35+ </main >
36+
37+ <!-- 目录 -->
38+ <Toc />
39+ </div >
40+
2741 <!-- 页脚 -->
2842 <Footer />
2943 </div >
@@ -36,75 +50,143 @@ const { frontmatter } = useData()
3650 flex-direction : column ;
3751}
3852
39- .main-content {
53+ /* 首页布局 */
54+ .home-layout {
4055 flex : 1 ;
4156 padding : 2rem ;
4257 max-width : 1200px ;
4358 margin : 0 auto ;
4459 width : 100% ;
4560}
4661
47- /* 首页样式 - 居中布局 */
48- .home {
49- text-align : center ;
62+ /* 文档页面布局 */
63+ .doc-layout {
64+ flex : 1 ;
65+ display : flex ;
66+ max-width : 1400px ;
67+ margin : 0 auto ;
68+ width : 100% ;
5069}
5170
52- .home :deep(h1 ) {
53- font-size : 3rem ;
54- font-weight : 700 ;
55- margin-bottom : 1rem ;
56- background : linear-gradient (120deg , #3b82f6 , #10b981 );
57- -webkit-background-clip : text ;
58- -webkit-text-fill-color : transparent ;
71+ .main-content {
72+ flex : 1 ;
73+ min-width : 0 ;
74+ padding : 2rem ;
5975}
6076
61- .home :deep(p ) {
62- font-size : 1.25rem ;
63- color : #666 ;
64- margin-bottom : 2rem ;
77+ .content-wrapper {
78+ max-width : 800px ;
79+ margin : 0 auto ;
6580}
6681
6782/* 文档页面样式 - 左对齐 */
68- .page {
69- text-align : left ;
70- }
71-
72- .page :deep(h1 ) {
83+ .content-wrapper :deep(h1 ) {
7384 font-size : 2rem ;
7485 margin-bottom : 1rem ;
7586 border-bottom : 1px solid #e5e7eb ;
7687 padding-bottom : 0.5rem ;
7788}
7889
79- .page :deep(h2 ) {
90+ .content-wrapper :deep(h2 ) {
8091 font-size : 1.5rem ;
8192 margin-top : 2rem ;
8293 margin-bottom : 1rem ;
8394}
8495
85- .page :deep(p ) {
96+ .content-wrapper :deep(h3 ) {
97+ font-size : 1.25rem ;
98+ margin-top : 1.5rem ;
99+ margin-bottom : 0.75rem ;
100+ }
101+
102+ .content-wrapper :deep(p ) {
86103 line-height : 1.8 ;
87104 margin-bottom : 1rem ;
88105}
89106
90- .page :deep(pre ) {
107+ .content-wrapper :deep(pre ) {
91108 background : #1e1e1e ;
92109 color : #d4d4d4 ;
93110 padding : 1rem ;
94111 border-radius : 0.5rem ;
95112 overflow-x : auto ;
96113}
97114
98- .page :deep(code ) {
115+ .content-wrapper :deep(code ) {
99116 font-family : ' JetBrains Mono' , monospace ;
100117 background : #f3f4f6 ;
101118 padding : 0.2em 0.4em ;
102119 border-radius : 0.25rem ;
103120 font-size : 0.875em ;
104121}
105122
106- .page :deep(pre code ) {
123+ .content-wrapper :deep(pre code ) {
107124 background : transparent ;
108125 padding : 0 ;
109126}
127+
128+ .content-wrapper :deep(table ) {
129+ width : 100% ;
130+ border-collapse : collapse ;
131+ margin : 1rem 0 ;
132+ }
133+
134+ .content-wrapper :deep(th ),
135+ .content-wrapper :deep(td ) {
136+ border : 1px solid #e5e7eb ;
137+ padding : 0.5rem 0.75rem ;
138+ text-align : left ;
139+ }
140+
141+ .content-wrapper :deep(th ) {
142+ background : #f9fafb ;
143+ font-weight : 600 ;
144+ }
145+
146+ .content-wrapper :deep(ul ),
147+ .content-wrapper :deep(ol ) {
148+ padding-left : 1.5rem ;
149+ margin-bottom : 1rem ;
150+ }
151+
152+ .content-wrapper :deep(li ) {
153+ margin : 0.5rem 0 ;
154+ }
155+
156+ .content-wrapper :deep(a ) {
157+ color : #3b82f6 ;
158+ text-decoration : none ;
159+ }
160+
161+ .content-wrapper :deep(a :hover ) {
162+ text-decoration : underline ;
163+ }
164+
165+ .content-wrapper :deep(blockquote ) {
166+ border-left : 4px solid #3b82f6 ;
167+ padding-left : 1rem ;
168+ margin : 1rem 0 ;
169+ color : #4b5563 ;
170+ }
171+
172+ /* 响应式布局 */
173+ @media (max-width : 1024px ) {
174+ .doc-layout {
175+ flex-direction : column ;
176+ }
177+
178+ .main-content {
179+ padding : 1.5rem ;
180+ }
181+ }
182+
183+ @media (max-width : 640px ) {
184+ .home-layout {
185+ padding : 1rem ;
186+ }
187+
188+ .main-content {
189+ padding : 1rem ;
190+ }
191+ }
110192 </style >
0 commit comments