4444 </div >
4545 </section >
4646
47+ <!-- 内容宽度配置 -->
48+ <section :class =" $style.section" >
49+ <div :class =" $style.sectionHeader" >
50+ <h2 :class =" $style.sectionTitle" >
51+ <span :class =" $style.icon" >📏</span >
52+ 内容区宽度
53+ <span
54+ :class =" $style.infoIcon"
55+ @mouseenter =" showTooltip('contentWidth')"
56+ @mouseleave =" hideTooltip"
57+ @click =" toggleTooltip('contentWidth')"
58+ >ℹ️
59+ <span
60+ v-if =" activeTooltip === 'contentWidth'"
61+ :class =" $style.tooltip"
62+ >
63+ 调整文章内容区域的最大宽度(全屏模式下不限制宽度)
64+ </span >
65+ </span >
66+ </h2 >
67+ <span :class =" $style.badge" >{{ contentWidth }}</span >
68+ </div >
69+
70+ <div :class =" $style.widthOptions" >
71+ <button
72+ :class =" [
73+ $style.widthBtn,
74+ contentWidth === '688px' ? $style.active : '',
75+ ]"
76+ @click =" setContentWidth('688px')"
77+ title =" 标准宽度 688px(VitePress 默认)"
78+ >
79+ 标准 (688px)
80+ </button >
81+ <button
82+ :class =" [
83+ $style.widthBtn,
84+ contentWidth === '755px' ? $style.active : '',
85+ ]"
86+ @click =" setContentWidth('755px')"
87+ title =" 较大宽度 755px(适合宽屏)"
88+ >
89+ 较大 (755px)
90+ </button >
91+ </div >
92+ </section >
93+
4794 <!-- MarkMap 配置 -->
4895 <section :class =" $style.section" >
4996 <div :class =" $style.sectionHeader" >
@@ -152,6 +199,8 @@ import {
152199 MARKMAP_EXPAND_LEVEL_KEY ,
153200} from ' ../constants'
154201
202+ const CONTENT_WIDTH_KEY = ' tnotes-content-width'
203+
155204// ===================================
156205// #region 响应式数据
157206// ===================================
@@ -161,6 +210,7 @@ const markmapTheme = ref('default')
161210const originalMarkmapTheme = ref (' default' )
162211const markmapExpandLevel = ref (5 )
163212const originalMarkmapExpandLevel = ref (5 )
213+ const contentWidth = ref (' 688px' )
164214const showSuccessToast = ref (false )
165215const activeTooltip = ref <string | null >(null )
166216// #endregion
@@ -197,6 +247,10 @@ onMounted(() => {
197247 const savedLevel = localStorage .getItem (MARKMAP_EXPAND_LEVEL_KEY ) || ' 5'
198248 markmapExpandLevel .value = parseInt (savedLevel )
199249 originalMarkmapExpandLevel .value = parseInt (savedLevel )
250+
251+ const savedWidth = localStorage .getItem (CONTENT_WIDTH_KEY ) || ' 688px'
252+ contentWidth .value = savedWidth
253+ applyContentWidth ()
200254 }
201255})
202256// #endregion
@@ -255,6 +309,22 @@ function hideTooltip() {
255309function toggleTooltip(id : string ) {
256310 activeTooltip .value = activeTooltip .value === id ? null : id
257311}
312+
313+ // 应用内容宽度(通过 CSS 变量)
314+ function applyContentWidth() {
315+ if (typeof document === ' undefined' ) return
316+ document .documentElement .style .setProperty (
317+ ' --tn-content-width' ,
318+ contentWidth .value
319+ )
320+ }
321+
322+ // 设置内容宽度
323+ function setContentWidth(width : string ) {
324+ contentWidth .value = width
325+ localStorage .setItem (CONTENT_WIDTH_KEY , width )
326+ applyContentWidth ()
327+ }
258328// #endregion
259329 </script >
260330
0 commit comments