Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .vitepress/theme/components/EmbeddedSidebarButton.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<template>
<!-- 嵌入式(iframe)模式下导航栏被隐藏,移动端用面包屑同行的目录按钮
<!-- 嵌入式(iframe)模式下导航栏被隐藏,移动端用固定在视口左上角的目录按钮
展开侧边栏。默认隐藏,显隐规则在 custom.css 的 html.embedded 部分,
经 doc-before 插槽渲染(仅文档页存在,首页等无侧边栏页面天然没有) -->
经 doc-top 插槽渲染为 .VPDoc 的直接子节点(仅文档页存在,
首页等无侧边栏页面天然没有) -->
<button
type="button"
class="embedded-sidebar-button"
Expand All @@ -26,9 +27,9 @@ function openSidebar() {
<style scoped>
.embedded-sidebar-button {
display: none;
position: absolute;
top: 10px;
left: 12px;
position: fixed;
top: var(--df-doc-top-space);
left: 16px;
z-index: 21;
width: 34px;
height: 34px;
Expand Down
6 changes: 3 additions & 3 deletions .vitepress/theme/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

/* ===== embedded:全站 chrome 隐藏(参考 eaf3930) =====
<html> 带 embedded 类时隐藏全站导航栏(SiteNavbar)/页脚(SiteFooter)
并清空其占位间距;移动端以面包屑同行的目录按钮
(EmbeddedSidebarButton,doc-before 插槽)展开侧边栏。
并清空其占位间距;移动端以固定在左上角的目录按钮
(EmbeddedSidebarButton,doc-top 插槽,直接挂在 .VPDoc 下)展开侧边栏。
该类由 head 内联脚本标记(见 config.mts):常规构建无条件标记(主站
嵌入形态,始终隐藏);doc-only 变体仅在真实 iframe 环境(产品内嵌
文档)标记,独立访问时不带此类,导航栏/页脚由下方 doc-only 段隐藏 */
Expand Down Expand Up @@ -131,7 +131,7 @@ html.doc-only .sidebar-actions {
padding-top: calc(var(--df-nav-height-mobile) + 16px);
}
html.doc-only .embedded-sidebar-button {
top: calc(var(--df-nav-height-mobile) + 10px);
top: calc(var(--df-nav-height-mobile) + var(--df-doc-top-space));
}
}

Expand Down
12 changes: 1 addition & 11 deletions .vitepress/theme/document-ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
}

.Layout .VPDoc .VPDocAsideOutline .outline-title {
margin-bottom: 8px;
margin-bottom: 2px;
color: var(--df-md-text-1);
font-weight: var(--df-md-font-strong);
}
Expand Down Expand Up @@ -288,7 +288,6 @@
}

.Layout .VPDoc .doc-heading-row {
position: relative;
display: flex;
align-items: center;
gap: 12px;
Expand All @@ -302,15 +301,6 @@
margin: 0;
}

.Layout .VPDoc .doc-heading-row .embedded-sidebar-button {
position: absolute;
top: 50%;
/* Keep the menu at the viewport's left edge beside the centered reading column. */
left: calc((100% - 100vw) / 2 + 12px);
transform: translateY(-50%);
flex: none;
}

@media (max-width: 959px) {
.Layout .VPDoc .doc-heading-row {
min-height: 34px;
Expand Down
6 changes: 4 additions & 2 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ export default {
// 页脚:旧版深色链接矩阵 footer。组件内部按官方 VPFooter 的规则
// 只在无侧边栏的页面(首页/404)渲染,内容页不显示
'layout-bottom': () => h(SiteFooter),
// 将嵌入模式的目录按钮与面包屑放在同一行。
// 嵌入模式的目录按钮:fixed 定位悬浮于视口左上角,经 doc-top
// 插槽直接挂在 .VPDoc 下(仅文档页渲染,首页等无侧边栏页面天然没有)
'doc-top': () => h(EmbeddedSidebarButton),
// 文档顶部的面包屑行
'doc-before': () => h('div', { class: 'doc-heading-row' }, [
h(EmbeddedSidebarButton),
h(DocBreadcrumb)
]),
// 侧边栏菜单上方的搜索 + 语言切换(自 SiteNavbar 迁来):iframe 嵌入
Expand Down
Loading