feat: 修复宽屏下正文+TOC整体偏右、顶栏与TOC错位的问题
- 新增 TOC_BREAKPOINT 常量替代硬编码 1536,通过 define:vars 注入客户端脚本 - MainGridLayout 平移正文/TOC 容器让整体视觉居中,并用 margin 计算修复 Navbar 与 TOC 右边缘的 1rem 错位 - data-has-toc 同时判断 siteConfig.toc.enable 与 headings.length,避免 toc 关闭时仍触发平移 - 新增 adaptive-width-for-fuwari.md 教程文档
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
DEFAULT_THEME,
|
||||
LIGHT_MODE,
|
||||
PAGE_WIDTH,
|
||||
TOC_BREAKPOINT,
|
||||
} from "../constants/constants";
|
||||
import { defaultFavicons } from "../constants/icon";
|
||||
import type { Favicon } from "../types/config";
|
||||
@@ -572,10 +573,10 @@ if (window.swup) {
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
<script is:inline define:vars={{ TOC_BREAKPOINT }}>
|
||||
function adjustTocLayout() {
|
||||
const hasToc = !!document.querySelector('[data-has-toc]');
|
||||
const isWide = window.innerWidth >= 1536;
|
||||
const isWide = window.innerWidth >= TOC_BREAKPOINT;
|
||||
if (hasToc && isWide) {
|
||||
document.body.classList.add('toc-offset');
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user