@tnotesjs/core 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -87
- package/package.json +1 -1
- package/types/config.ts +61 -61
- package/types/index.ts +11 -11
- package/types/note.ts +33 -33
- package/vitepress/assets/icons/icon__check.svg +3 -3
- package/vitepress/assets/icons/icon__clipboard.svg +7 -7
- package/vitepress/assets/icons/icon__close.svg +1 -1
- package/vitepress/assets/icons/icon__collapse.svg +1 -1
- package/vitepress/assets/icons/icon__confirm.svg +1 -1
- package/vitepress/assets/icons/icon__copy.svg +4 -4
- package/vitepress/assets/icons/icon__focus.svg +1 -1
- package/vitepress/assets/icons/icon__fold.svg +3 -3
- package/vitepress/assets/icons/icon__folder.svg +1 -1
- package/vitepress/assets/icons/icon__fullscreen.svg +1 -1
- package/vitepress/assets/icons/icon__fullscreen_exit.svg +1 -1
- package/vitepress/assets/icons/icon__github.svg +3 -3
- package/vitepress/assets/icons/icon__mindmap.svg +1 -1
- package/vitepress/assets/icons/icon__next.svg +1 -1
- package/vitepress/assets/icons/icon__number_gray.svg +1 -1
- package/vitepress/assets/icons/icon__number_purple.svg +1 -1
- package/vitepress/assets/icons/icon__prev.svg +1 -1
- package/vitepress/assets/icons/icon__restore.svg +1 -1
- package/vitepress/assets/icons/icon__rotate.svg +4 -4
- package/vitepress/assets/icons/icon__search.svg +1 -1
- package/vitepress/assets/icons/icon__sidebar_collapsed.svg +1 -1
- package/vitepress/assets/icons/icon__sidebar_opened.svg +1 -1
- package/vitepress/assets/icons/icon__totop.svg +5 -5
- package/vitepress/assets/icons/icon__vscode.svg +5 -5
- package/vitepress/assets/icons/icon__zoom_fit.svg +1 -1
- package/vitepress/assets/icons/icon__zoom_in.svg +1 -1
- package/vitepress/assets/icons/icon__zoom_out.svg +1 -1
- package/vitepress/assets/icons/icon__zoom_reset.svg +1 -1
- package/vitepress/assets/icons/index.ts +39 -39
- package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +20 -20
- package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +369 -369
- package/vitepress/components/CodeBlockFullscreen/index.ts +213 -213
- package/vitepress/components/CodeBlockFullscreen/styles.css +126 -126
- package/vitepress/components/Discussions/Discussions.module.scss +32 -32
- package/vitepress/components/Discussions/Discussions.vue +211 -211
- package/vitepress/components/EnWordList/EnWordList.module.scss +124 -124
- package/vitepress/components/EnWordList/EnWordList.vue +543 -543
- package/vitepress/components/EnWordList/RightClickMenu.module.scss +22 -22
- package/vitepress/components/EnWordList/RightClickMenu.vue +66 -66
- package/vitepress/components/Footprints/Footprints.module.scss +93 -93
- package/vitepress/components/Footprints/Footprints.vue +377 -377
- package/vitepress/components/Layout/AboutModal.module.scss +233 -233
- package/vitepress/components/Layout/AboutModal.vue +105 -105
- package/vitepress/components/Layout/AboutPanel.vue +270 -270
- package/vitepress/components/Layout/ContentCollapse.vue +603 -603
- package/vitepress/components/Layout/CustomSidebar.vue +817 -817
- package/vitepress/components/Layout/DocBeforeControls.vue +149 -149
- package/vitepress/components/Layout/DocFooter.vue +233 -233
- package/vitepress/components/Layout/ImagePreview.module.scss +201 -201
- package/vitepress/components/Layout/ImagePreview.vue +281 -281
- package/vitepress/components/Layout/Layout.module.scss +661 -661
- package/vitepress/components/Layout/Layout.vue +621 -621
- package/vitepress/components/Layout/NoteStatus.vue +140 -140
- package/vitepress/components/Layout/SidebarItems.vue +1083 -1083
- package/vitepress/components/Layout/SidebarNavBefore.vue +171 -171
- package/vitepress/components/Layout/SidebarResizeHandle.vue +319 -319
- package/vitepress/components/Layout/Swiper.vue +167 -167
- package/vitepress/components/Layout/ToggleFullContent.module.scss +11 -11
- package/vitepress/components/Layout/ToggleFullContent.vue +35 -35
- package/vitepress/components/Layout/ToggleSidebar.module.scss +11 -11
- package/vitepress/components/Layout/ToggleSidebar.vue +26 -26
- package/vitepress/components/Layout/composables/useCollapseControl.ts +88 -88
- package/vitepress/components/Layout/composables/useNoteConfig.ts +119 -119
- package/vitepress/components/Layout/composables/useNoteSave.ts +178 -178
- package/vitepress/components/Layout/composables/useNoteValidation.ts +85 -85
- package/vitepress/components/Layout/composables/useRedirect.ts +113 -113
- package/vitepress/components/Layout/composables/useSidebarLayout.ts +122 -122
- package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +85 -85
- package/vitepress/components/Layout/homeReadme.data.ts +124 -124
- package/vitepress/components/MarkMap/MarkMap.module.scss +159 -159
- package/vitepress/components/MarkMap/MarkMap.vue +405 -405
- package/vitepress/components/Mermaid/Mermaid.module.scss +275 -275
- package/vitepress/components/Mermaid/Mermaid.vue +365 -365
- package/vitepress/components/NotesTable/NotesTable.module.scss +77 -77
- package/vitepress/components/NotesTable/NotesTable.vue +98 -98
- package/vitepress/components/NotesTable/README.md +67 -67
- package/vitepress/components/Settings/Settings.module.scss +375 -375
- package/vitepress/components/Settings/Settings.vue +334 -334
- package/vitepress/components/SidebarCard/MindMapView.vue +484 -484
- package/vitepress/components/SidebarCard/NotesTrendChart.vue +108 -108
- package/vitepress/components/SidebarCard/SidebarCard.vue +946 -946
- package/vitepress/components/Tooltip/Tooltip.vue +70 -70
- package/vitepress/components/constants.ts +109 -109
- package/vitepress/components/notesConfig.data.ts +73 -73
- package/vitepress/components/sidebar.data.ts +59 -59
- package/vitepress/components/tnotes-config.data.ts +21 -21
- package/vitepress/components/utils.ts +26 -26
- package/vitepress/config/index.ts +169 -169
- package/vitepress/configs/constants.ts +26 -26
- package/vitepress/configs/head.config.ts +25 -25
- package/vitepress/configs/index.ts +9 -9
- package/vitepress/configs/markdown-it.d.ts +23 -23
- package/vitepress/configs/markdown.config.ts +366 -366
- package/vitepress/configs/theme.config.ts +108 -108
- package/vitepress/plugins/buildProgressPlugin.ts +434 -434
- package/vitepress/plugins/getNoteByConfigIdPlugin.ts +107 -107
- package/vitepress/plugins/renameNotePlugin.ts +68 -68
- package/vitepress/plugins/sidebarStructurePlugin.ts +260 -260
- package/vitepress/plugins/updateConfigPlugin.ts +63 -63
- package/vitepress/theme/index.ts +137 -137
- package/vitepress/theme/styles/base.scss +64 -59
- package/vitepress/theme/styles/components/404.scss +31 -31
- package/vitepress/theme/styles/components/collapse.scss +172 -172
- package/vitepress/theme/styles/components/markmap.scss +101 -101
- package/vitepress/theme/styles/components/swiper.scss +255 -255
- package/vitepress/theme/styles/index.scss +25 -25
- package/vitepress/theme/styles/layout.scss +78 -78
- package/vitepress/theme/styles/utilities.scss +39 -39
- package/vitepress/theme/styles/vitepress-override.scss +25 -25
|
@@ -1,621 +1,621 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Layout>
|
|
3
|
-
<template v-if="showNotFound" #not-found>
|
|
4
|
-
<div class="not-found-container">
|
|
5
|
-
<h1>404</h1>
|
|
6
|
-
<p>Page not found</p>
|
|
7
|
-
<!-- <div class="debug-info">
|
|
8
|
-
<p>Current path: {{ decodedCurrentPath }}</p>
|
|
9
|
-
<p>Matched ID: {{ matchedId }}</p>
|
|
10
|
-
<p>Redirect path: {{ redirectPath }}</p>
|
|
11
|
-
</div> -->layout
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
<template #doc-top>
|
|
15
|
-
<!-- <pre>vscodesNoteDir: {{ vscodeNotesDir }}</pre> -->
|
|
16
|
-
<!-- <pre>vpData.page.value: {{ vpData.page.value }}</pre>
|
|
17
|
-
<pre>currentNoteConfig: {{ currentNoteConfig }}</pre> -->
|
|
18
|
-
<!-- <button @click="copyRawFile" title="Copy raw file">raw</button> -->
|
|
19
|
-
<!-- <pre>{{ tocData }}</pre> -->
|
|
20
|
-
<ImagePreview />
|
|
21
|
-
<Swiper />
|
|
22
|
-
<ContentCollapse />
|
|
23
|
-
</template>
|
|
24
|
-
<!-- <template #doc-bottom>doc-bottom</template> -->
|
|
25
|
-
<template #doc-before>
|
|
26
|
-
<DocBeforeControls
|
|
27
|
-
:is-full-content-mode="isFullContentMode"
|
|
28
|
-
:vscode-notes-dir="vscodeNotesDir"
|
|
29
|
-
:is-home-readme="isHomeReadme"
|
|
30
|
-
:current-note-id="currentNoteId"
|
|
31
|
-
:created_at="created_at"
|
|
32
|
-
:updated_at="updated_at"
|
|
33
|
-
:home-readme-created-at="homeReadmeCreatedAt"
|
|
34
|
-
:home-readme-updated-at="homeReadmeUpdatedAt"
|
|
35
|
-
:time-modal-open="timeModalOpen"
|
|
36
|
-
:all-collapsed="allCollapsed"
|
|
37
|
-
@open-time-modal="openTimeModal"
|
|
38
|
-
@toggle-all-collapse="toggleAllCollapse"
|
|
39
|
-
/>
|
|
40
|
-
<!-- 笔记状态标题 -->
|
|
41
|
-
<NoteStatus
|
|
42
|
-
:note-config="currentNoteConfig"
|
|
43
|
-
:is-notes-page="isNotesPage"
|
|
44
|
-
/>
|
|
45
|
-
|
|
46
|
-
<AboutModal
|
|
47
|
-
v-model="timeModalOpen"
|
|
48
|
-
@close="onTimeModalClose"
|
|
49
|
-
:title="modalTitle"
|
|
50
|
-
>
|
|
51
|
-
<template #title>
|
|
52
|
-
{{ modalTitle }}
|
|
53
|
-
</template>
|
|
54
|
-
|
|
55
|
-
<AboutPanel
|
|
56
|
-
:is-home-readme="modalIsHomeReadme"
|
|
57
|
-
:current-note-id="modalNoteId"
|
|
58
|
-
:is-dev="isDev"
|
|
59
|
-
v-model:editable-note-title="editableNoteTitle"
|
|
60
|
-
v-model:editable-description="editableDescription"
|
|
61
|
-
v-model:editable-note-status="editableNoteStatus"
|
|
62
|
-
v-model:editable-discussions-enabled="editableDiscussionsEnabled"
|
|
63
|
-
v-model:title-error="titleError"
|
|
64
|
-
:modal-created-at="modalCreatedAt"
|
|
65
|
-
:modal-updated-at="modalUpdatedAt"
|
|
66
|
-
:modal-github-url="modalGithubUrl"
|
|
67
|
-
:modal-github-page-url="modalGithubPageUrl"
|
|
68
|
-
:completion-percentage="completionPercentage"
|
|
69
|
-
:done-notes-len="doneNotesLen"
|
|
70
|
-
:total-notes-len="totalNotesLen"
|
|
71
|
-
@title-input="onTitleInput"
|
|
72
|
-
@title-blur="onTitleBlur"
|
|
73
|
-
@description-input="onDescriptionInput"
|
|
74
|
-
@config-change="onConfigChange"
|
|
75
|
-
/>
|
|
76
|
-
|
|
77
|
-
<!-- 操作按钮(仅开发环境且非首页显示) -->
|
|
78
|
-
<template #footer v-if="isDev && !modalIsHomeReadme">
|
|
79
|
-
<div :class="$style.actionBar">
|
|
80
|
-
<button
|
|
81
|
-
:class="[
|
|
82
|
-
$style.saveButton,
|
|
83
|
-
{ [$style.disabled]: !hasConfigChanges },
|
|
84
|
-
]"
|
|
85
|
-
@click="saveNoteConfig"
|
|
86
|
-
:disabled="!hasConfigChanges || isSaving"
|
|
87
|
-
type="button"
|
|
88
|
-
>
|
|
89
|
-
{{ saveButtonText }}
|
|
90
|
-
</button>
|
|
91
|
-
<button
|
|
92
|
-
v-if="hasConfigChanges"
|
|
93
|
-
@click="resetNoteConfig"
|
|
94
|
-
:class="$style.resetButton"
|
|
95
|
-
type="button"
|
|
96
|
-
>
|
|
97
|
-
重置
|
|
98
|
-
</button>
|
|
99
|
-
</div>
|
|
100
|
-
|
|
101
|
-
<!-- 保存进度提示 -->
|
|
102
|
-
<Transition name="toast">
|
|
103
|
-
<div v-if="isSaving && savingMessage" :class="$style.loadingToast">
|
|
104
|
-
<div :class="$style.loadingSpinner"></div>
|
|
105
|
-
<span>{{ savingMessage }}</span>
|
|
106
|
-
</div>
|
|
107
|
-
</Transition>
|
|
108
|
-
|
|
109
|
-
<!-- 保存成功提示 -->
|
|
110
|
-
<Transition name="toast">
|
|
111
|
-
<div v-if="showSuccessToast" :class="$style.toast">✓ 保存成功</div>
|
|
112
|
-
</Transition>
|
|
113
|
-
</template>
|
|
114
|
-
</AboutModal>
|
|
115
|
-
</template>
|
|
116
|
-
<template #doc-footer-before>
|
|
117
|
-
<!-- <div class="footer-time-info">
|
|
118
|
-
<p title="首次提交时间">首次提交时间:{{ formatDate(created_at) }}</p>
|
|
119
|
-
<p title="最近提交时间">最近提交时间:{{ formatDate(updated_at) }}</p>
|
|
120
|
-
</div> -->
|
|
121
|
-
</template>
|
|
122
|
-
<template #doc-after>
|
|
123
|
-
<!-- 自定义 DocFooter -->
|
|
124
|
-
<DocFooter />
|
|
125
|
-
<!-- {{ REPO_NAME + '.' + currentNoteId }} -->
|
|
126
|
-
<Discussions
|
|
127
|
-
v-if="isDiscussionsVisible"
|
|
128
|
-
:id="currentNoteConfig.id"
|
|
129
|
-
:note-number="currentNoteId || ''"
|
|
130
|
-
:note-title="currentNoteTitle"
|
|
131
|
-
/>
|
|
132
|
-
</template>
|
|
133
|
-
<!-- <template #doc-bottom>
|
|
134
|
-
<Discussions id="TNotes.template.0003" />
|
|
135
|
-
</template> -->
|
|
136
|
-
|
|
137
|
-
<template #aside-top>
|
|
138
|
-
<!-- aside-top -->
|
|
139
|
-
<!-- {{ vpData.page.value.title }} -->
|
|
140
|
-
</template>
|
|
141
|
-
<!-- <template #aside-outline-before>
|
|
142
|
-
<span
|
|
143
|
-
@click="scrollToTop"
|
|
144
|
-
style="cursor: pointer; height: 1em; width: 1em"
|
|
145
|
-
title="回到顶部"
|
|
146
|
-
>
|
|
147
|
-
<img :src="icon__totop" alt="to top" />
|
|
148
|
-
</span>
|
|
149
|
-
</template> -->
|
|
150
|
-
|
|
151
|
-
<!-- 使用 sidebar-nav-before 插槽插入控制按钮 -->
|
|
152
|
-
<template #sidebar-nav-before>
|
|
153
|
-
<SidebarNavBefore
|
|
154
|
-
:is-expanded="allSidebarExpanded"
|
|
155
|
-
:show-note-id="showNoteId"
|
|
156
|
-
@toggle-expand="toggleSidebarSections"
|
|
157
|
-
@toggle-note-id="toggleNoteId"
|
|
158
|
-
@focus-current="focusCurrentNote"
|
|
159
|
-
/>
|
|
160
|
-
</template>
|
|
161
|
-
|
|
162
|
-
<!-- 使用 sidebar-nav-after 插槽插入自定义 Sidebar -->
|
|
163
|
-
<template #sidebar-nav-after>
|
|
164
|
-
<CustomSidebar
|
|
165
|
-
ref="customSidebarRef"
|
|
166
|
-
@open-note-about="openSidebarNoteAbout"
|
|
167
|
-
/>
|
|
168
|
-
</template>
|
|
169
|
-
<!-- <template #sidebar-nav-after>sidebar-nav-after</template> -->
|
|
170
|
-
|
|
171
|
-
<!-- <template #aside-outline-after>aside-outline-after</template> -->
|
|
172
|
-
<!-- <template #aside-bottom>aside-bottom</template> -->
|
|
173
|
-
<!-- <template #aside-ads-before>aside-ads-before</template> -->
|
|
174
|
-
<!-- <template #aside-ads-after>aside-ads-after</template> -->
|
|
175
|
-
<!-- <template #layout-top>layout-top</template> -->
|
|
176
|
-
<!-- <template #layout-bottom>layout-bottom</template> -->
|
|
177
|
-
<!-- <template #nav-bar-title-before>nav-bar-title-before</template> -->
|
|
178
|
-
<!-- <template #nav-bar-title-after>nav-bar-title-after</template> -->
|
|
179
|
-
<!-- <template #nav-bar-content-before>nav-bar-content-before</template> -->
|
|
180
|
-
<!-- 设置入口:固定在 VPNav 右侧(social-links / appearance 之后,extra 之前) -->
|
|
181
|
-
<template #nav-bar-content-after>
|
|
182
|
-
<NavBarSettingsTrigger />
|
|
183
|
-
</template>
|
|
184
|
-
|
|
185
|
-
<!-- !NOTE 不清楚下面的插槽所对应的位置 -->
|
|
186
|
-
<!-- <template #nav-screen-content-before>nav-screen-content-before</template> -->
|
|
187
|
-
<!-- <template #nav-screen-content-after>nav-screen-content-after</template> -->
|
|
188
|
-
</Layout>
|
|
189
|
-
|
|
190
|
-
<SidebarResizeHandle />
|
|
191
|
-
|
|
192
|
-
<!-- 全局重命名遮罩:关于面板保存或文件系统重命名时由 useRenameOverlay 控制 -->
|
|
193
|
-
<LoadingPage
|
|
194
|
-
:visible="renameOverlayState.visible"
|
|
195
|
-
:message="renameOverlayState.message"
|
|
196
|
-
:tip="renameOverlayState.tip"
|
|
197
|
-
/>
|
|
198
|
-
|
|
199
|
-
<!-- 全局设置 Dialog:由 useSettingsDialog 控制显隐 -->
|
|
200
|
-
<SettingsDialog />
|
|
201
|
-
</template>
|
|
202
|
-
|
|
203
|
-
<script setup>
|
|
204
|
-
import { useData, useRoute, useRouter } from "vitepress";
|
|
205
|
-
import DefaultTheme from "vitepress/theme";
|
|
206
|
-
import { computed, onMounted, ref, watch } from "vue";
|
|
207
|
-
|
|
208
|
-
import { useCodeBlockFullscreen } from "../CodeBlockFullscreen";
|
|
209
|
-
import { SIDEBAR_SHOW_NOTE_ID_KEY } from "../constants";
|
|
210
|
-
import { data as allNotesConfig } from "../notesConfig.data.ts";
|
|
211
|
-
import AboutModal from "./AboutModal.vue";
|
|
212
|
-
import AboutPanel from "./AboutPanel.vue";
|
|
213
|
-
import Discussions from "../Discussions/Discussions.vue";
|
|
214
|
-
import LoadingPage from "../LoadingPage/LoadingPage.vue";
|
|
215
|
-
import { useCollapseControl } from "./composables/useCollapseControl";
|
|
216
|
-
import { useNoteConfig } from "./composables/useNoteConfig";
|
|
217
|
-
import { useNoteSave } from "./composables/useNoteSave";
|
|
218
|
-
import { useNoteValidation } from "./composables/useNoteValidation";
|
|
219
|
-
import { useRedirect } from "./composables/useRedirect";
|
|
220
|
-
import { useRenameOverlay } from "./composables/useRenameOverlay";
|
|
221
|
-
import { useVSCodeIntegration } from "./composables/useVSCodeIntegration";
|
|
222
|
-
import ContentCollapse from "./ContentCollapse.vue";
|
|
223
|
-
import CustomSidebar from "./CustomSidebar.vue";
|
|
224
|
-
import DocBeforeControls from "./DocBeforeControls.vue";
|
|
225
|
-
import DocFooter from "./DocFooter.vue";
|
|
226
|
-
import { data as readmeData } from "./homeReadme.data.ts";
|
|
227
|
-
import ImagePreview from "./ImagePreview.vue";
|
|
228
|
-
import NavBarSettingsTrigger from "./NavBarSettingsTrigger.vue";
|
|
229
|
-
import NoteStatus from "./NoteStatus.vue";
|
|
230
|
-
import SidebarNavBefore from "./SidebarNavBefore.vue";
|
|
231
|
-
import SidebarResizeHandle from "./SidebarResizeHandle.vue";
|
|
232
|
-
import Swiper from "./Swiper.vue";
|
|
233
|
-
import SettingsDialog from "../Settings/SettingsDialog.vue";
|
|
234
|
-
|
|
235
|
-
const { Layout } = DefaultTheme;
|
|
236
|
-
const vpData = useData();
|
|
237
|
-
const router = useRouter();
|
|
238
|
-
const route = useRoute();
|
|
239
|
-
|
|
240
|
-
// 启用代码块全屏功能
|
|
241
|
-
useCodeBlockFullscreen();
|
|
242
|
-
|
|
243
|
-
// 全局重命名遮罩状态(由 useRenameRedirect 控制 show/hide)
|
|
244
|
-
const { state: renameOverlayState } = useRenameOverlay();
|
|
245
|
-
|
|
246
|
-
// 自定义侧边栏引用
|
|
247
|
-
const customSidebarRef = ref(null);
|
|
248
|
-
const showNoteId = ref(false);
|
|
249
|
-
|
|
250
|
-
// 计算是否有展开的一级章节
|
|
251
|
-
const allSidebarExpanded = computed(() => {
|
|
252
|
-
if (!customSidebarRef.value) return false;
|
|
253
|
-
return customSidebarRef.value.hasAnyFirstLevelExpanded();
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
// 初始化笔记编号显示状态
|
|
257
|
-
if (typeof window !== "undefined") {
|
|
258
|
-
const savedShowNoteId = localStorage.getItem(SIDEBAR_SHOW_NOTE_ID_KEY);
|
|
259
|
-
showNoteId.value = savedShowNoteId === "true";
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// 切换侧边栏展开/折叠状态(智能切换)
|
|
263
|
-
function toggleSidebarSections() {
|
|
264
|
-
if (customSidebarRef.value) {
|
|
265
|
-
customSidebarRef.value.toggleExpandCollapse();
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// 切换笔记编号显示状态
|
|
270
|
-
function toggleNoteId() {
|
|
271
|
-
showNoteId.value = !showNoteId.value;
|
|
272
|
-
if (typeof window !== "undefined") {
|
|
273
|
-
localStorage.setItem(SIDEBAR_SHOW_NOTE_ID_KEY, showNoteId.value.toString());
|
|
274
|
-
// 刷新页面以应用变化
|
|
275
|
-
window.location.reload();
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// 聚焦到当前笔记
|
|
280
|
-
function focusCurrentNote() {
|
|
281
|
-
if (customSidebarRef.value) {
|
|
282
|
-
customSidebarRef.value.focusCurrentNote();
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// 提取当前笔记的 ID(前 4 个数字)
|
|
287
|
-
const currentNoteId = computed(() => {
|
|
288
|
-
const relativePath = vpData.page.value.relativePath;
|
|
289
|
-
// relativePath 格式: notes/0001. 标题/README.md
|
|
290
|
-
const match = relativePath.match(/notes\/(\d{4})/);
|
|
291
|
-
const id = match ? match[1] : null;
|
|
292
|
-
|
|
293
|
-
return id;
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
// 判断是否是笔记页面(notes 目录下)
|
|
297
|
-
const isNotesPage = computed(() => {
|
|
298
|
-
return vpData.page.value.relativePath.startsWith("notes/");
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
// 提取当前笔记的标题(从 relativePath)
|
|
302
|
-
const currentNoteTitle = computed(() => {
|
|
303
|
-
const relativePath = vpData.page.value.relativePath;
|
|
304
|
-
// relativePath 格式: notes/0001. 标题/README.md
|
|
305
|
-
const match = relativePath.match(/notes\/\d{4}\.\s+([^/]+)\//);
|
|
306
|
-
const title = match ? match[1] : "";
|
|
307
|
-
|
|
308
|
-
return title;
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
// 根据当前笔记 ID 获取配置数据
|
|
312
|
-
const currentNoteConfig = computed(() => {
|
|
313
|
-
return currentNoteId.value && allNotesConfig[currentNoteId.value]
|
|
314
|
-
? allNotesConfig[currentNoteId.value]
|
|
315
|
-
: {
|
|
316
|
-
bilibili: [],
|
|
317
|
-
done: false,
|
|
318
|
-
enableDiscussions: false,
|
|
319
|
-
};
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
function getEmptyNoteConfig() {
|
|
323
|
-
return {
|
|
324
|
-
bilibili: [],
|
|
325
|
-
done: false,
|
|
326
|
-
enableDiscussions: false,
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
const isDiscussionsVisible = computed(
|
|
331
|
-
() => currentNoteConfig.value.enableDiscussions,
|
|
332
|
-
);
|
|
333
|
-
const updated_at = computed(() => currentNoteConfig.value.updated_at);
|
|
334
|
-
const created_at = computed(() => currentNoteConfig.value.created_at);
|
|
335
|
-
|
|
336
|
-
// 判断是否为首页 README.md
|
|
337
|
-
const isHomeReadme = computed(() => vpData.page.value.filePath === "README.md");
|
|
338
|
-
const doneNotesLen = computed(() => readmeData?.doneNotesLen || 0);
|
|
339
|
-
const totalNotesLen = computed(() => readmeData?.totalNotesLen || 0);
|
|
340
|
-
|
|
341
|
-
// 完成进度百分比
|
|
342
|
-
const completionPercentage = computed(() => {
|
|
343
|
-
if (!totalNotesLen.value || totalNotesLen.value === 0) return null;
|
|
344
|
-
return Math.round((doneNotesLen.value / totalNotesLen.value) * 100);
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
// 首页 README.md 的时间戳
|
|
348
|
-
const homeReadmeCreatedAt = computed(() => readmeData?.created_at);
|
|
349
|
-
const homeReadmeUpdatedAt = computed(() => readmeData?.updated_at);
|
|
350
|
-
|
|
351
|
-
// #region - Composables
|
|
352
|
-
// 404 重定向
|
|
353
|
-
const { showNotFound, decodedCurrentPath, initRedirectCheck } =
|
|
354
|
-
useRedirect(allNotesConfig);
|
|
355
|
-
|
|
356
|
-
// modal 控制
|
|
357
|
-
const timeModalOpen = ref(false);
|
|
358
|
-
const sidebarAboutNoteId = ref(null);
|
|
359
|
-
|
|
360
|
-
const modalIsHomeReadme = computed(
|
|
361
|
-
() => !sidebarAboutNoteId.value && isHomeReadme.value,
|
|
362
|
-
);
|
|
363
|
-
|
|
364
|
-
const modalNoteId = computed(() => sidebarAboutNoteId.value || currentNoteId.value);
|
|
365
|
-
|
|
366
|
-
function safeDecode(value) {
|
|
367
|
-
try {
|
|
368
|
-
return decodeURIComponent(value);
|
|
369
|
-
} catch {
|
|
370
|
-
return value;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
function getNoteFolderSegment(noteId) {
|
|
375
|
-
if (!noteId) return "";
|
|
376
|
-
|
|
377
|
-
const source =
|
|
378
|
-
noteId === currentNoteId.value
|
|
379
|
-
? vpData.page.value.relativePath
|
|
380
|
-
: allNotesConfig[noteId]?.redirect || "";
|
|
381
|
-
const match = source.match(/notes\/([^/]+)\/README/);
|
|
382
|
-
|
|
383
|
-
return match ? match[1] : "";
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
function getNoteTitleById(noteId) {
|
|
387
|
-
const folderSegment = getNoteFolderSegment(noteId);
|
|
388
|
-
const match = folderSegment.match(/^\d{4}\.\s+(.+)$/);
|
|
389
|
-
|
|
390
|
-
return match ? safeDecode(match[1]) : "";
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
const modalNoteTitle = computed(() => {
|
|
394
|
-
if (!sidebarAboutNoteId.value) return currentNoteTitle.value;
|
|
395
|
-
return getNoteTitleById(sidebarAboutNoteId.value);
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
const modalNoteConfig = computed(() => {
|
|
399
|
-
return modalNoteId.value && allNotesConfig[modalNoteId.value]
|
|
400
|
-
? allNotesConfig[modalNoteId.value]
|
|
401
|
-
: getEmptyNoteConfig();
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
// 笔记配置管理
|
|
405
|
-
const {
|
|
406
|
-
editableNoteStatus,
|
|
407
|
-
editableDiscussionsEnabled,
|
|
408
|
-
editableNoteTitle,
|
|
409
|
-
editableDescription,
|
|
410
|
-
titleError,
|
|
411
|
-
hasConfigChanges,
|
|
412
|
-
resetNoteConfig,
|
|
413
|
-
updateOriginalValues,
|
|
414
|
-
} = useNoteConfig(
|
|
415
|
-
modalNoteId,
|
|
416
|
-
modalNoteConfig,
|
|
417
|
-
modalNoteTitle,
|
|
418
|
-
timeModalOpen,
|
|
419
|
-
);
|
|
420
|
-
|
|
421
|
-
// 标题验证
|
|
422
|
-
const { onTitleInput: validateTitleInput, onTitleBlur: validateTitleBlur } =
|
|
423
|
-
useNoteValidation();
|
|
424
|
-
|
|
425
|
-
// 保存逻辑
|
|
426
|
-
const {
|
|
427
|
-
isSaving,
|
|
428
|
-
showSuccessToast,
|
|
429
|
-
savingMessage,
|
|
430
|
-
saveButtonText,
|
|
431
|
-
saveNoteConfig,
|
|
432
|
-
} = useNoteSave(
|
|
433
|
-
modalNoteId,
|
|
434
|
-
computed(() => {
|
|
435
|
-
if (typeof window === "undefined") return false;
|
|
436
|
-
return (
|
|
437
|
-
window.location.hostname === "localhost" ||
|
|
438
|
-
window.location.hostname === "127.0.0.1"
|
|
439
|
-
);
|
|
440
|
-
}),
|
|
441
|
-
hasConfigChanges,
|
|
442
|
-
titleError,
|
|
443
|
-
editableNoteTitle,
|
|
444
|
-
computed(() => modalNoteTitle.value),
|
|
445
|
-
editableNoteStatus,
|
|
446
|
-
computed(() => modalNoteConfig.value.done || false),
|
|
447
|
-
editableDiscussionsEnabled,
|
|
448
|
-
computed(() => modalNoteConfig.value.enableDiscussions || false),
|
|
449
|
-
editableDescription,
|
|
450
|
-
computed(() => modalNoteConfig.value.description || ""),
|
|
451
|
-
allNotesConfig,
|
|
452
|
-
updateOriginalValues,
|
|
453
|
-
);
|
|
454
|
-
|
|
455
|
-
// 折叠控制
|
|
456
|
-
const { allCollapsed, toggleAllCollapse } = useCollapseControl();
|
|
457
|
-
|
|
458
|
-
// VSCode 集成
|
|
459
|
-
const { vscodeNotesDir, updateVscodeNoteDir, interceptHomeReadmeLinks } =
|
|
460
|
-
useVSCodeIntegration();
|
|
461
|
-
|
|
462
|
-
// 判断是否为开发环境
|
|
463
|
-
const isDev = computed(() => {
|
|
464
|
-
if (typeof window === "undefined") return false;
|
|
465
|
-
return (
|
|
466
|
-
window.location.hostname === "localhost" ||
|
|
467
|
-
window.location.hostname === "127.0.0.1"
|
|
468
|
-
);
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
// #endregion
|
|
472
|
-
|
|
473
|
-
// modal 标题
|
|
474
|
-
const modalTitle = computed(() => {
|
|
475
|
-
return modalIsHomeReadme.value ? "关于这个知识库" : "关于这篇笔记";
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
// modal 中显示的 GitHub 链接
|
|
479
|
-
const modalGithubUrl = computed(() => {
|
|
480
|
-
if (modalIsHomeReadme.value) {
|
|
481
|
-
const repoName = vpData.site.value.title.toLowerCase();
|
|
482
|
-
return `https://github.com/tnotesjs/${repoName}`;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
const folderSegment = getNoteFolderSegment(modalNoteId.value);
|
|
486
|
-
if (!folderSegment) return "";
|
|
487
|
-
|
|
488
|
-
const repoName = vpData.site.value.title.toLowerCase();
|
|
489
|
-
return `https://github.com/tnotesjs/${repoName}/tree/main/notes/${encodeURIComponent(folderSegment)}`;
|
|
490
|
-
});
|
|
491
|
-
|
|
492
|
-
// modal 中显示的 GitHub Page 链接
|
|
493
|
-
const modalGithubPageUrl = computed(() => {
|
|
494
|
-
if (modalIsHomeReadme.value) {
|
|
495
|
-
const repoName = vpData.site.value.title; // 保持原始大小写
|
|
496
|
-
return `https://tnotesjs.github.io/${repoName}/`;
|
|
497
|
-
}
|
|
498
|
-
// 笔记页面的 GitHub Page 链接
|
|
499
|
-
const folderSegment = getNoteFolderSegment(modalNoteId.value);
|
|
500
|
-
if (modalNoteId.value && folderSegment) {
|
|
501
|
-
const repoName = vpData.site.value.title; // 保持原始大小写
|
|
502
|
-
return `https://tnotesjs.github.io/${repoName}/notes/${encodeURIComponent(folderSegment)}/README`;
|
|
503
|
-
}
|
|
504
|
-
return "";
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
// modal 中显示的创建时间
|
|
508
|
-
const modalCreatedAt = computed(() => {
|
|
509
|
-
return modalIsHomeReadme.value
|
|
510
|
-
? homeReadmeCreatedAt.value
|
|
511
|
-
: modalNoteConfig.value.created_at;
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
// modal 中显示的更新时间
|
|
515
|
-
const modalUpdatedAt = computed(() => {
|
|
516
|
-
return modalIsHomeReadme.value
|
|
517
|
-
? homeReadmeUpdatedAt.value
|
|
518
|
-
: modalNoteConfig.value.updated_at;
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
function openTimeModal() {
|
|
522
|
-
sidebarAboutNoteId.value = null;
|
|
523
|
-
timeModalOpen.value = true;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
function onTimeModalClose() {
|
|
527
|
-
timeModalOpen.value = false;
|
|
528
|
-
sidebarAboutNoteId.value = null;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
function openSidebarNoteAbout(noteIndex) {
|
|
532
|
-
sidebarAboutNoteId.value = noteIndex;
|
|
533
|
-
timeModalOpen.value = true;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// 配置变更时的回调
|
|
537
|
-
function onConfigChange() {
|
|
538
|
-
// 配置变更时不需要做额外操作,只需要触发 hasConfigChanges 计算
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
// 标题输入事件
|
|
542
|
-
function onTitleInput() {
|
|
543
|
-
validateTitleInput(editableNoteTitle, titleError);
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
// 标题失焦事件
|
|
547
|
-
function onTitleBlur() {
|
|
548
|
-
validateTitleBlur(editableNoteTitle, titleError);
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
// 简介输入事件
|
|
552
|
-
function onDescriptionInput() {
|
|
553
|
-
// 简介没有特殊验证,只需要触发变更检测
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
// #region - 全屏状态检测
|
|
557
|
-
const isFullContentMode = ref(false);
|
|
558
|
-
|
|
559
|
-
function checkFullContentMode() {
|
|
560
|
-
if (typeof document === "undefined") return;
|
|
561
|
-
|
|
562
|
-
const vpApp = document.querySelector(".VPContent");
|
|
563
|
-
if (vpApp) {
|
|
564
|
-
const sidebar = document.querySelector(".VPSidebar");
|
|
565
|
-
if (sidebar) {
|
|
566
|
-
const sidebarDisplay = window.getComputedStyle(sidebar).display;
|
|
567
|
-
isFullContentMode.value = sidebarDisplay === "none";
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
// #endregion
|
|
572
|
-
|
|
573
|
-
// 生命周期钩子
|
|
574
|
-
onMounted(() => {
|
|
575
|
-
updateVscodeNoteDir();
|
|
576
|
-
interceptHomeReadmeLinks(isHomeReadme, router);
|
|
577
|
-
initRedirectCheck();
|
|
578
|
-
|
|
579
|
-
if (typeof window !== "undefined") {
|
|
580
|
-
checkFullContentMode();
|
|
581
|
-
window.addEventListener("resize", checkFullContentMode);
|
|
582
|
-
|
|
583
|
-
// 监听 VitePress 的侧边栏切换事件
|
|
584
|
-
const observer = new MutationObserver(checkFullContentMode);
|
|
585
|
-
const vpLayout = document.querySelector(".Layout");
|
|
586
|
-
if (vpLayout) {
|
|
587
|
-
observer.observe(vpLayout, {
|
|
588
|
-
attributes: true,
|
|
589
|
-
childList: true,
|
|
590
|
-
subtree: true,
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
// 监听路由变化
|
|
597
|
-
watch(
|
|
598
|
-
() => vpData.page.value.relativePath,
|
|
599
|
-
() => {
|
|
600
|
-
updateVscodeNoteDir();
|
|
601
|
-
interceptHomeReadmeLinks(isHomeReadme, router);
|
|
602
|
-
},
|
|
603
|
-
);
|
|
604
|
-
|
|
605
|
-
watch(
|
|
606
|
-
() => route.path,
|
|
607
|
-
() => {
|
|
608
|
-
setTimeout(checkFullContentMode, 100);
|
|
609
|
-
},
|
|
610
|
-
);
|
|
611
|
-
</script>
|
|
612
|
-
|
|
613
|
-
<style>
|
|
614
|
-
@import "../CodeBlockFullscreen/styles.css";
|
|
615
|
-
|
|
616
|
-
#VPSidebarNav > .group {
|
|
617
|
-
display: none;
|
|
618
|
-
}
|
|
619
|
-
</style>
|
|
620
|
-
|
|
621
|
-
<style module src="./Layout.module.scss" scoped></style>
|
|
1
|
+
<template>
|
|
2
|
+
<Layout>
|
|
3
|
+
<template v-if="showNotFound" #not-found>
|
|
4
|
+
<div class="not-found-container">
|
|
5
|
+
<h1>404</h1>
|
|
6
|
+
<p>Page not found</p>
|
|
7
|
+
<!-- <div class="debug-info">
|
|
8
|
+
<p>Current path: {{ decodedCurrentPath }}</p>
|
|
9
|
+
<p>Matched ID: {{ matchedId }}</p>
|
|
10
|
+
<p>Redirect path: {{ redirectPath }}</p>
|
|
11
|
+
</div> -->layout
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
<template #doc-top>
|
|
15
|
+
<!-- <pre>vscodesNoteDir: {{ vscodeNotesDir }}</pre> -->
|
|
16
|
+
<!-- <pre>vpData.page.value: {{ vpData.page.value }}</pre>
|
|
17
|
+
<pre>currentNoteConfig: {{ currentNoteConfig }}</pre> -->
|
|
18
|
+
<!-- <button @click="copyRawFile" title="Copy raw file">raw</button> -->
|
|
19
|
+
<!-- <pre>{{ tocData }}</pre> -->
|
|
20
|
+
<ImagePreview />
|
|
21
|
+
<Swiper />
|
|
22
|
+
<ContentCollapse />
|
|
23
|
+
</template>
|
|
24
|
+
<!-- <template #doc-bottom>doc-bottom</template> -->
|
|
25
|
+
<template #doc-before>
|
|
26
|
+
<DocBeforeControls
|
|
27
|
+
:is-full-content-mode="isFullContentMode"
|
|
28
|
+
:vscode-notes-dir="vscodeNotesDir"
|
|
29
|
+
:is-home-readme="isHomeReadme"
|
|
30
|
+
:current-note-id="currentNoteId"
|
|
31
|
+
:created_at="created_at"
|
|
32
|
+
:updated_at="updated_at"
|
|
33
|
+
:home-readme-created-at="homeReadmeCreatedAt"
|
|
34
|
+
:home-readme-updated-at="homeReadmeUpdatedAt"
|
|
35
|
+
:time-modal-open="timeModalOpen"
|
|
36
|
+
:all-collapsed="allCollapsed"
|
|
37
|
+
@open-time-modal="openTimeModal"
|
|
38
|
+
@toggle-all-collapse="toggleAllCollapse"
|
|
39
|
+
/>
|
|
40
|
+
<!-- 笔记状态标题 -->
|
|
41
|
+
<NoteStatus
|
|
42
|
+
:note-config="currentNoteConfig"
|
|
43
|
+
:is-notes-page="isNotesPage"
|
|
44
|
+
/>
|
|
45
|
+
|
|
46
|
+
<AboutModal
|
|
47
|
+
v-model="timeModalOpen"
|
|
48
|
+
@close="onTimeModalClose"
|
|
49
|
+
:title="modalTitle"
|
|
50
|
+
>
|
|
51
|
+
<template #title>
|
|
52
|
+
{{ modalTitle }}
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<AboutPanel
|
|
56
|
+
:is-home-readme="modalIsHomeReadme"
|
|
57
|
+
:current-note-id="modalNoteId"
|
|
58
|
+
:is-dev="isDev"
|
|
59
|
+
v-model:editable-note-title="editableNoteTitle"
|
|
60
|
+
v-model:editable-description="editableDescription"
|
|
61
|
+
v-model:editable-note-status="editableNoteStatus"
|
|
62
|
+
v-model:editable-discussions-enabled="editableDiscussionsEnabled"
|
|
63
|
+
v-model:title-error="titleError"
|
|
64
|
+
:modal-created-at="modalCreatedAt"
|
|
65
|
+
:modal-updated-at="modalUpdatedAt"
|
|
66
|
+
:modal-github-url="modalGithubUrl"
|
|
67
|
+
:modal-github-page-url="modalGithubPageUrl"
|
|
68
|
+
:completion-percentage="completionPercentage"
|
|
69
|
+
:done-notes-len="doneNotesLen"
|
|
70
|
+
:total-notes-len="totalNotesLen"
|
|
71
|
+
@title-input="onTitleInput"
|
|
72
|
+
@title-blur="onTitleBlur"
|
|
73
|
+
@description-input="onDescriptionInput"
|
|
74
|
+
@config-change="onConfigChange"
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
<!-- 操作按钮(仅开发环境且非首页显示) -->
|
|
78
|
+
<template #footer v-if="isDev && !modalIsHomeReadme">
|
|
79
|
+
<div :class="$style.actionBar">
|
|
80
|
+
<button
|
|
81
|
+
:class="[
|
|
82
|
+
$style.saveButton,
|
|
83
|
+
{ [$style.disabled]: !hasConfigChanges },
|
|
84
|
+
]"
|
|
85
|
+
@click="saveNoteConfig"
|
|
86
|
+
:disabled="!hasConfigChanges || isSaving"
|
|
87
|
+
type="button"
|
|
88
|
+
>
|
|
89
|
+
{{ saveButtonText }}
|
|
90
|
+
</button>
|
|
91
|
+
<button
|
|
92
|
+
v-if="hasConfigChanges"
|
|
93
|
+
@click="resetNoteConfig"
|
|
94
|
+
:class="$style.resetButton"
|
|
95
|
+
type="button"
|
|
96
|
+
>
|
|
97
|
+
重置
|
|
98
|
+
</button>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<!-- 保存进度提示 -->
|
|
102
|
+
<Transition name="toast">
|
|
103
|
+
<div v-if="isSaving && savingMessage" :class="$style.loadingToast">
|
|
104
|
+
<div :class="$style.loadingSpinner"></div>
|
|
105
|
+
<span>{{ savingMessage }}</span>
|
|
106
|
+
</div>
|
|
107
|
+
</Transition>
|
|
108
|
+
|
|
109
|
+
<!-- 保存成功提示 -->
|
|
110
|
+
<Transition name="toast">
|
|
111
|
+
<div v-if="showSuccessToast" :class="$style.toast">✓ 保存成功</div>
|
|
112
|
+
</Transition>
|
|
113
|
+
</template>
|
|
114
|
+
</AboutModal>
|
|
115
|
+
</template>
|
|
116
|
+
<template #doc-footer-before>
|
|
117
|
+
<!-- <div class="footer-time-info">
|
|
118
|
+
<p title="首次提交时间">首次提交时间:{{ formatDate(created_at) }}</p>
|
|
119
|
+
<p title="最近提交时间">最近提交时间:{{ formatDate(updated_at) }}</p>
|
|
120
|
+
</div> -->
|
|
121
|
+
</template>
|
|
122
|
+
<template #doc-after>
|
|
123
|
+
<!-- 自定义 DocFooter -->
|
|
124
|
+
<DocFooter />
|
|
125
|
+
<!-- {{ REPO_NAME + '.' + currentNoteId }} -->
|
|
126
|
+
<Discussions
|
|
127
|
+
v-if="isDiscussionsVisible"
|
|
128
|
+
:id="currentNoteConfig.id"
|
|
129
|
+
:note-number="currentNoteId || ''"
|
|
130
|
+
:note-title="currentNoteTitle"
|
|
131
|
+
/>
|
|
132
|
+
</template>
|
|
133
|
+
<!-- <template #doc-bottom>
|
|
134
|
+
<Discussions id="TNotes.template.0003" />
|
|
135
|
+
</template> -->
|
|
136
|
+
|
|
137
|
+
<template #aside-top>
|
|
138
|
+
<!-- aside-top -->
|
|
139
|
+
<!-- {{ vpData.page.value.title }} -->
|
|
140
|
+
</template>
|
|
141
|
+
<!-- <template #aside-outline-before>
|
|
142
|
+
<span
|
|
143
|
+
@click="scrollToTop"
|
|
144
|
+
style="cursor: pointer; height: 1em; width: 1em"
|
|
145
|
+
title="回到顶部"
|
|
146
|
+
>
|
|
147
|
+
<img :src="icon__totop" alt="to top" />
|
|
148
|
+
</span>
|
|
149
|
+
</template> -->
|
|
150
|
+
|
|
151
|
+
<!-- 使用 sidebar-nav-before 插槽插入控制按钮 -->
|
|
152
|
+
<template #sidebar-nav-before>
|
|
153
|
+
<SidebarNavBefore
|
|
154
|
+
:is-expanded="allSidebarExpanded"
|
|
155
|
+
:show-note-id="showNoteId"
|
|
156
|
+
@toggle-expand="toggleSidebarSections"
|
|
157
|
+
@toggle-note-id="toggleNoteId"
|
|
158
|
+
@focus-current="focusCurrentNote"
|
|
159
|
+
/>
|
|
160
|
+
</template>
|
|
161
|
+
|
|
162
|
+
<!-- 使用 sidebar-nav-after 插槽插入自定义 Sidebar -->
|
|
163
|
+
<template #sidebar-nav-after>
|
|
164
|
+
<CustomSidebar
|
|
165
|
+
ref="customSidebarRef"
|
|
166
|
+
@open-note-about="openSidebarNoteAbout"
|
|
167
|
+
/>
|
|
168
|
+
</template>
|
|
169
|
+
<!-- <template #sidebar-nav-after>sidebar-nav-after</template> -->
|
|
170
|
+
|
|
171
|
+
<!-- <template #aside-outline-after>aside-outline-after</template> -->
|
|
172
|
+
<!-- <template #aside-bottom>aside-bottom</template> -->
|
|
173
|
+
<!-- <template #aside-ads-before>aside-ads-before</template> -->
|
|
174
|
+
<!-- <template #aside-ads-after>aside-ads-after</template> -->
|
|
175
|
+
<!-- <template #layout-top>layout-top</template> -->
|
|
176
|
+
<!-- <template #layout-bottom>layout-bottom</template> -->
|
|
177
|
+
<!-- <template #nav-bar-title-before>nav-bar-title-before</template> -->
|
|
178
|
+
<!-- <template #nav-bar-title-after>nav-bar-title-after</template> -->
|
|
179
|
+
<!-- <template #nav-bar-content-before>nav-bar-content-before</template> -->
|
|
180
|
+
<!-- 设置入口:固定在 VPNav 右侧(social-links / appearance 之后,extra 之前) -->
|
|
181
|
+
<template #nav-bar-content-after>
|
|
182
|
+
<NavBarSettingsTrigger />
|
|
183
|
+
</template>
|
|
184
|
+
|
|
185
|
+
<!-- !NOTE 不清楚下面的插槽所对应的位置 -->
|
|
186
|
+
<!-- <template #nav-screen-content-before>nav-screen-content-before</template> -->
|
|
187
|
+
<!-- <template #nav-screen-content-after>nav-screen-content-after</template> -->
|
|
188
|
+
</Layout>
|
|
189
|
+
|
|
190
|
+
<SidebarResizeHandle />
|
|
191
|
+
|
|
192
|
+
<!-- 全局重命名遮罩:关于面板保存或文件系统重命名时由 useRenameOverlay 控制 -->
|
|
193
|
+
<LoadingPage
|
|
194
|
+
:visible="renameOverlayState.visible"
|
|
195
|
+
:message="renameOverlayState.message"
|
|
196
|
+
:tip="renameOverlayState.tip"
|
|
197
|
+
/>
|
|
198
|
+
|
|
199
|
+
<!-- 全局设置 Dialog:由 useSettingsDialog 控制显隐 -->
|
|
200
|
+
<SettingsDialog />
|
|
201
|
+
</template>
|
|
202
|
+
|
|
203
|
+
<script setup>
|
|
204
|
+
import { useData, useRoute, useRouter } from "vitepress";
|
|
205
|
+
import DefaultTheme from "vitepress/theme";
|
|
206
|
+
import { computed, onMounted, ref, watch } from "vue";
|
|
207
|
+
|
|
208
|
+
import { useCodeBlockFullscreen } from "../CodeBlockFullscreen";
|
|
209
|
+
import { SIDEBAR_SHOW_NOTE_ID_KEY } from "../constants";
|
|
210
|
+
import { data as allNotesConfig } from "../notesConfig.data.ts";
|
|
211
|
+
import AboutModal from "./AboutModal.vue";
|
|
212
|
+
import AboutPanel from "./AboutPanel.vue";
|
|
213
|
+
import Discussions from "../Discussions/Discussions.vue";
|
|
214
|
+
import LoadingPage from "../LoadingPage/LoadingPage.vue";
|
|
215
|
+
import { useCollapseControl } from "./composables/useCollapseControl";
|
|
216
|
+
import { useNoteConfig } from "./composables/useNoteConfig";
|
|
217
|
+
import { useNoteSave } from "./composables/useNoteSave";
|
|
218
|
+
import { useNoteValidation } from "./composables/useNoteValidation";
|
|
219
|
+
import { useRedirect } from "./composables/useRedirect";
|
|
220
|
+
import { useRenameOverlay } from "./composables/useRenameOverlay";
|
|
221
|
+
import { useVSCodeIntegration } from "./composables/useVSCodeIntegration";
|
|
222
|
+
import ContentCollapse from "./ContentCollapse.vue";
|
|
223
|
+
import CustomSidebar from "./CustomSidebar.vue";
|
|
224
|
+
import DocBeforeControls from "./DocBeforeControls.vue";
|
|
225
|
+
import DocFooter from "./DocFooter.vue";
|
|
226
|
+
import { data as readmeData } from "./homeReadme.data.ts";
|
|
227
|
+
import ImagePreview from "./ImagePreview.vue";
|
|
228
|
+
import NavBarSettingsTrigger from "./NavBarSettingsTrigger.vue";
|
|
229
|
+
import NoteStatus from "./NoteStatus.vue";
|
|
230
|
+
import SidebarNavBefore from "./SidebarNavBefore.vue";
|
|
231
|
+
import SidebarResizeHandle from "./SidebarResizeHandle.vue";
|
|
232
|
+
import Swiper from "./Swiper.vue";
|
|
233
|
+
import SettingsDialog from "../Settings/SettingsDialog.vue";
|
|
234
|
+
|
|
235
|
+
const { Layout } = DefaultTheme;
|
|
236
|
+
const vpData = useData();
|
|
237
|
+
const router = useRouter();
|
|
238
|
+
const route = useRoute();
|
|
239
|
+
|
|
240
|
+
// 启用代码块全屏功能
|
|
241
|
+
useCodeBlockFullscreen();
|
|
242
|
+
|
|
243
|
+
// 全局重命名遮罩状态(由 useRenameRedirect 控制 show/hide)
|
|
244
|
+
const { state: renameOverlayState } = useRenameOverlay();
|
|
245
|
+
|
|
246
|
+
// 自定义侧边栏引用
|
|
247
|
+
const customSidebarRef = ref(null);
|
|
248
|
+
const showNoteId = ref(false);
|
|
249
|
+
|
|
250
|
+
// 计算是否有展开的一级章节
|
|
251
|
+
const allSidebarExpanded = computed(() => {
|
|
252
|
+
if (!customSidebarRef.value) return false;
|
|
253
|
+
return customSidebarRef.value.hasAnyFirstLevelExpanded();
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// 初始化笔记编号显示状态
|
|
257
|
+
if (typeof window !== "undefined") {
|
|
258
|
+
const savedShowNoteId = localStorage.getItem(SIDEBAR_SHOW_NOTE_ID_KEY);
|
|
259
|
+
showNoteId.value = savedShowNoteId === "true";
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// 切换侧边栏展开/折叠状态(智能切换)
|
|
263
|
+
function toggleSidebarSections() {
|
|
264
|
+
if (customSidebarRef.value) {
|
|
265
|
+
customSidebarRef.value.toggleExpandCollapse();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// 切换笔记编号显示状态
|
|
270
|
+
function toggleNoteId() {
|
|
271
|
+
showNoteId.value = !showNoteId.value;
|
|
272
|
+
if (typeof window !== "undefined") {
|
|
273
|
+
localStorage.setItem(SIDEBAR_SHOW_NOTE_ID_KEY, showNoteId.value.toString());
|
|
274
|
+
// 刷新页面以应用变化
|
|
275
|
+
window.location.reload();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// 聚焦到当前笔记
|
|
280
|
+
function focusCurrentNote() {
|
|
281
|
+
if (customSidebarRef.value) {
|
|
282
|
+
customSidebarRef.value.focusCurrentNote();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// 提取当前笔记的 ID(前 4 个数字)
|
|
287
|
+
const currentNoteId = computed(() => {
|
|
288
|
+
const relativePath = vpData.page.value.relativePath;
|
|
289
|
+
// relativePath 格式: notes/0001. 标题/README.md
|
|
290
|
+
const match = relativePath.match(/notes\/(\d{4})/);
|
|
291
|
+
const id = match ? match[1] : null;
|
|
292
|
+
|
|
293
|
+
return id;
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// 判断是否是笔记页面(notes 目录下)
|
|
297
|
+
const isNotesPage = computed(() => {
|
|
298
|
+
return vpData.page.value.relativePath.startsWith("notes/");
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// 提取当前笔记的标题(从 relativePath)
|
|
302
|
+
const currentNoteTitle = computed(() => {
|
|
303
|
+
const relativePath = vpData.page.value.relativePath;
|
|
304
|
+
// relativePath 格式: notes/0001. 标题/README.md
|
|
305
|
+
const match = relativePath.match(/notes\/\d{4}\.\s+([^/]+)\//);
|
|
306
|
+
const title = match ? match[1] : "";
|
|
307
|
+
|
|
308
|
+
return title;
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
// 根据当前笔记 ID 获取配置数据
|
|
312
|
+
const currentNoteConfig = computed(() => {
|
|
313
|
+
return currentNoteId.value && allNotesConfig[currentNoteId.value]
|
|
314
|
+
? allNotesConfig[currentNoteId.value]
|
|
315
|
+
: {
|
|
316
|
+
bilibili: [],
|
|
317
|
+
done: false,
|
|
318
|
+
enableDiscussions: false,
|
|
319
|
+
};
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
function getEmptyNoteConfig() {
|
|
323
|
+
return {
|
|
324
|
+
bilibili: [],
|
|
325
|
+
done: false,
|
|
326
|
+
enableDiscussions: false,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const isDiscussionsVisible = computed(
|
|
331
|
+
() => currentNoteConfig.value.enableDiscussions,
|
|
332
|
+
);
|
|
333
|
+
const updated_at = computed(() => currentNoteConfig.value.updated_at);
|
|
334
|
+
const created_at = computed(() => currentNoteConfig.value.created_at);
|
|
335
|
+
|
|
336
|
+
// 判断是否为首页 README.md
|
|
337
|
+
const isHomeReadme = computed(() => vpData.page.value.filePath === "README.md");
|
|
338
|
+
const doneNotesLen = computed(() => readmeData?.doneNotesLen || 0);
|
|
339
|
+
const totalNotesLen = computed(() => readmeData?.totalNotesLen || 0);
|
|
340
|
+
|
|
341
|
+
// 完成进度百分比
|
|
342
|
+
const completionPercentage = computed(() => {
|
|
343
|
+
if (!totalNotesLen.value || totalNotesLen.value === 0) return null;
|
|
344
|
+
return Math.round((doneNotesLen.value / totalNotesLen.value) * 100);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
// 首页 README.md 的时间戳
|
|
348
|
+
const homeReadmeCreatedAt = computed(() => readmeData?.created_at);
|
|
349
|
+
const homeReadmeUpdatedAt = computed(() => readmeData?.updated_at);
|
|
350
|
+
|
|
351
|
+
// #region - Composables
|
|
352
|
+
// 404 重定向
|
|
353
|
+
const { showNotFound, decodedCurrentPath, initRedirectCheck } =
|
|
354
|
+
useRedirect(allNotesConfig);
|
|
355
|
+
|
|
356
|
+
// modal 控制
|
|
357
|
+
const timeModalOpen = ref(false);
|
|
358
|
+
const sidebarAboutNoteId = ref(null);
|
|
359
|
+
|
|
360
|
+
const modalIsHomeReadme = computed(
|
|
361
|
+
() => !sidebarAboutNoteId.value && isHomeReadme.value,
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
const modalNoteId = computed(() => sidebarAboutNoteId.value || currentNoteId.value);
|
|
365
|
+
|
|
366
|
+
function safeDecode(value) {
|
|
367
|
+
try {
|
|
368
|
+
return decodeURIComponent(value);
|
|
369
|
+
} catch {
|
|
370
|
+
return value;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function getNoteFolderSegment(noteId) {
|
|
375
|
+
if (!noteId) return "";
|
|
376
|
+
|
|
377
|
+
const source =
|
|
378
|
+
noteId === currentNoteId.value
|
|
379
|
+
? vpData.page.value.relativePath
|
|
380
|
+
: allNotesConfig[noteId]?.redirect || "";
|
|
381
|
+
const match = source.match(/notes\/([^/]+)\/README/);
|
|
382
|
+
|
|
383
|
+
return match ? match[1] : "";
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function getNoteTitleById(noteId) {
|
|
387
|
+
const folderSegment = getNoteFolderSegment(noteId);
|
|
388
|
+
const match = folderSegment.match(/^\d{4}\.\s+(.+)$/);
|
|
389
|
+
|
|
390
|
+
return match ? safeDecode(match[1]) : "";
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const modalNoteTitle = computed(() => {
|
|
394
|
+
if (!sidebarAboutNoteId.value) return currentNoteTitle.value;
|
|
395
|
+
return getNoteTitleById(sidebarAboutNoteId.value);
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
const modalNoteConfig = computed(() => {
|
|
399
|
+
return modalNoteId.value && allNotesConfig[modalNoteId.value]
|
|
400
|
+
? allNotesConfig[modalNoteId.value]
|
|
401
|
+
: getEmptyNoteConfig();
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
// 笔记配置管理
|
|
405
|
+
const {
|
|
406
|
+
editableNoteStatus,
|
|
407
|
+
editableDiscussionsEnabled,
|
|
408
|
+
editableNoteTitle,
|
|
409
|
+
editableDescription,
|
|
410
|
+
titleError,
|
|
411
|
+
hasConfigChanges,
|
|
412
|
+
resetNoteConfig,
|
|
413
|
+
updateOriginalValues,
|
|
414
|
+
} = useNoteConfig(
|
|
415
|
+
modalNoteId,
|
|
416
|
+
modalNoteConfig,
|
|
417
|
+
modalNoteTitle,
|
|
418
|
+
timeModalOpen,
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
// 标题验证
|
|
422
|
+
const { onTitleInput: validateTitleInput, onTitleBlur: validateTitleBlur } =
|
|
423
|
+
useNoteValidation();
|
|
424
|
+
|
|
425
|
+
// 保存逻辑
|
|
426
|
+
const {
|
|
427
|
+
isSaving,
|
|
428
|
+
showSuccessToast,
|
|
429
|
+
savingMessage,
|
|
430
|
+
saveButtonText,
|
|
431
|
+
saveNoteConfig,
|
|
432
|
+
} = useNoteSave(
|
|
433
|
+
modalNoteId,
|
|
434
|
+
computed(() => {
|
|
435
|
+
if (typeof window === "undefined") return false;
|
|
436
|
+
return (
|
|
437
|
+
window.location.hostname === "localhost" ||
|
|
438
|
+
window.location.hostname === "127.0.0.1"
|
|
439
|
+
);
|
|
440
|
+
}),
|
|
441
|
+
hasConfigChanges,
|
|
442
|
+
titleError,
|
|
443
|
+
editableNoteTitle,
|
|
444
|
+
computed(() => modalNoteTitle.value),
|
|
445
|
+
editableNoteStatus,
|
|
446
|
+
computed(() => modalNoteConfig.value.done || false),
|
|
447
|
+
editableDiscussionsEnabled,
|
|
448
|
+
computed(() => modalNoteConfig.value.enableDiscussions || false),
|
|
449
|
+
editableDescription,
|
|
450
|
+
computed(() => modalNoteConfig.value.description || ""),
|
|
451
|
+
allNotesConfig,
|
|
452
|
+
updateOriginalValues,
|
|
453
|
+
);
|
|
454
|
+
|
|
455
|
+
// 折叠控制
|
|
456
|
+
const { allCollapsed, toggleAllCollapse } = useCollapseControl();
|
|
457
|
+
|
|
458
|
+
// VSCode 集成
|
|
459
|
+
const { vscodeNotesDir, updateVscodeNoteDir, interceptHomeReadmeLinks } =
|
|
460
|
+
useVSCodeIntegration();
|
|
461
|
+
|
|
462
|
+
// 判断是否为开发环境
|
|
463
|
+
const isDev = computed(() => {
|
|
464
|
+
if (typeof window === "undefined") return false;
|
|
465
|
+
return (
|
|
466
|
+
window.location.hostname === "localhost" ||
|
|
467
|
+
window.location.hostname === "127.0.0.1"
|
|
468
|
+
);
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
// #endregion
|
|
472
|
+
|
|
473
|
+
// modal 标题
|
|
474
|
+
const modalTitle = computed(() => {
|
|
475
|
+
return modalIsHomeReadme.value ? "关于这个知识库" : "关于这篇笔记";
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// modal 中显示的 GitHub 链接
|
|
479
|
+
const modalGithubUrl = computed(() => {
|
|
480
|
+
if (modalIsHomeReadme.value) {
|
|
481
|
+
const repoName = vpData.site.value.title.toLowerCase();
|
|
482
|
+
return `https://github.com/tnotesjs/${repoName}`;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
const folderSegment = getNoteFolderSegment(modalNoteId.value);
|
|
486
|
+
if (!folderSegment) return "";
|
|
487
|
+
|
|
488
|
+
const repoName = vpData.site.value.title.toLowerCase();
|
|
489
|
+
return `https://github.com/tnotesjs/${repoName}/tree/main/notes/${encodeURIComponent(folderSegment)}`;
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
// modal 中显示的 GitHub Page 链接
|
|
493
|
+
const modalGithubPageUrl = computed(() => {
|
|
494
|
+
if (modalIsHomeReadme.value) {
|
|
495
|
+
const repoName = vpData.site.value.title; // 保持原始大小写
|
|
496
|
+
return `https://tnotesjs.github.io/${repoName}/`;
|
|
497
|
+
}
|
|
498
|
+
// 笔记页面的 GitHub Page 链接
|
|
499
|
+
const folderSegment = getNoteFolderSegment(modalNoteId.value);
|
|
500
|
+
if (modalNoteId.value && folderSegment) {
|
|
501
|
+
const repoName = vpData.site.value.title; // 保持原始大小写
|
|
502
|
+
return `https://tnotesjs.github.io/${repoName}/notes/${encodeURIComponent(folderSegment)}/README`;
|
|
503
|
+
}
|
|
504
|
+
return "";
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
// modal 中显示的创建时间
|
|
508
|
+
const modalCreatedAt = computed(() => {
|
|
509
|
+
return modalIsHomeReadme.value
|
|
510
|
+
? homeReadmeCreatedAt.value
|
|
511
|
+
: modalNoteConfig.value.created_at;
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
// modal 中显示的更新时间
|
|
515
|
+
const modalUpdatedAt = computed(() => {
|
|
516
|
+
return modalIsHomeReadme.value
|
|
517
|
+
? homeReadmeUpdatedAt.value
|
|
518
|
+
: modalNoteConfig.value.updated_at;
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
function openTimeModal() {
|
|
522
|
+
sidebarAboutNoteId.value = null;
|
|
523
|
+
timeModalOpen.value = true;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function onTimeModalClose() {
|
|
527
|
+
timeModalOpen.value = false;
|
|
528
|
+
sidebarAboutNoteId.value = null;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
function openSidebarNoteAbout(noteIndex) {
|
|
532
|
+
sidebarAboutNoteId.value = noteIndex;
|
|
533
|
+
timeModalOpen.value = true;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// 配置变更时的回调
|
|
537
|
+
function onConfigChange() {
|
|
538
|
+
// 配置变更时不需要做额外操作,只需要触发 hasConfigChanges 计算
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// 标题输入事件
|
|
542
|
+
function onTitleInput() {
|
|
543
|
+
validateTitleInput(editableNoteTitle, titleError);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// 标题失焦事件
|
|
547
|
+
function onTitleBlur() {
|
|
548
|
+
validateTitleBlur(editableNoteTitle, titleError);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// 简介输入事件
|
|
552
|
+
function onDescriptionInput() {
|
|
553
|
+
// 简介没有特殊验证,只需要触发变更检测
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// #region - 全屏状态检测
|
|
557
|
+
const isFullContentMode = ref(false);
|
|
558
|
+
|
|
559
|
+
function checkFullContentMode() {
|
|
560
|
+
if (typeof document === "undefined") return;
|
|
561
|
+
|
|
562
|
+
const vpApp = document.querySelector(".VPContent");
|
|
563
|
+
if (vpApp) {
|
|
564
|
+
const sidebar = document.querySelector(".VPSidebar");
|
|
565
|
+
if (sidebar) {
|
|
566
|
+
const sidebarDisplay = window.getComputedStyle(sidebar).display;
|
|
567
|
+
isFullContentMode.value = sidebarDisplay === "none";
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
// #endregion
|
|
572
|
+
|
|
573
|
+
// 生命周期钩子
|
|
574
|
+
onMounted(() => {
|
|
575
|
+
updateVscodeNoteDir();
|
|
576
|
+
interceptHomeReadmeLinks(isHomeReadme, router);
|
|
577
|
+
initRedirectCheck();
|
|
578
|
+
|
|
579
|
+
if (typeof window !== "undefined") {
|
|
580
|
+
checkFullContentMode();
|
|
581
|
+
window.addEventListener("resize", checkFullContentMode);
|
|
582
|
+
|
|
583
|
+
// 监听 VitePress 的侧边栏切换事件
|
|
584
|
+
const observer = new MutationObserver(checkFullContentMode);
|
|
585
|
+
const vpLayout = document.querySelector(".Layout");
|
|
586
|
+
if (vpLayout) {
|
|
587
|
+
observer.observe(vpLayout, {
|
|
588
|
+
attributes: true,
|
|
589
|
+
childList: true,
|
|
590
|
+
subtree: true,
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
// 监听路由变化
|
|
597
|
+
watch(
|
|
598
|
+
() => vpData.page.value.relativePath,
|
|
599
|
+
() => {
|
|
600
|
+
updateVscodeNoteDir();
|
|
601
|
+
interceptHomeReadmeLinks(isHomeReadme, router);
|
|
602
|
+
},
|
|
603
|
+
);
|
|
604
|
+
|
|
605
|
+
watch(
|
|
606
|
+
() => route.path,
|
|
607
|
+
() => {
|
|
608
|
+
setTimeout(checkFullContentMode, 100);
|
|
609
|
+
},
|
|
610
|
+
);
|
|
611
|
+
</script>
|
|
612
|
+
|
|
613
|
+
<style>
|
|
614
|
+
@import "../CodeBlockFullscreen/styles.css";
|
|
615
|
+
|
|
616
|
+
#VPSidebarNav > .group {
|
|
617
|
+
display: none;
|
|
618
|
+
}
|
|
619
|
+
</style>
|
|
620
|
+
|
|
621
|
+
<style module src="./Layout.module.scss" scoped></style>
|