@tnotesjs/core 0.0.7 → 0.0.8
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 +6 -3
- package/dist/{chunk-JDVN2QYW.js → chunk-JUMVJKWV.js} +615 -614
- package/dist/cli/index.js +125 -125
- package/dist/vitepress/config/index.js +182 -207
- package/package.json +15 -3
- package/types/shims.d.ts +3 -4
- package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +2 -1
- package/vitepress/components/CodeBlockFullscreen/index.ts +2 -1
- package/vitepress/components/Discussions/Discussions.vue +3 -2
- package/vitepress/components/EnWordList/EnWordList.vue +2 -1
- package/vitepress/components/Layout/AboutModal.vue +1 -1
- package/vitepress/components/Layout/AboutPanel.vue +8 -3
- package/vitepress/components/Layout/ContentCollapse.vue +2 -1
- package/vitepress/components/Layout/CustomSidebar.vue +7 -4
- package/vitepress/components/Layout/DocBeforeControls.vue +4 -4
- package/vitepress/components/Layout/DocFooter.vue +2 -1
- package/vitepress/components/Layout/ImagePreview.vue +2 -1
- package/vitepress/components/Layout/Layout.vue +17 -20
- package/vitepress/components/Layout/NoteStatus.vue +2 -1
- package/vitepress/components/Layout/SidebarItems.vue +7 -2
- package/vitepress/components/Layout/ToggleFullContent.vue +2 -1
- package/vitepress/components/Layout/ToggleSidebar.vue +2 -1
- package/vitepress/components/Layout/composables/useCollapseControl.ts +1 -1
- package/vitepress/components/Layout/composables/useNoteConfig.ts +2 -4
- package/vitepress/components/Layout/composables/useNoteSave.ts +3 -2
- package/vitepress/components/Layout/composables/useRedirect.ts +8 -5
- package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +7 -4
- package/vitepress/components/Layout/homeReadme.data.ts +1 -1
- package/vitepress/components/LoadingPage/LoadingPage.vue +1 -1
- package/vitepress/components/MarkMap/MarkMap.vue +5 -4
- package/vitepress/components/Mermaid/Mermaid.vue +4 -2
- package/vitepress/components/NotesTable/NotesTable.vue +2 -1
- package/vitepress/components/Settings/Settings.vue +2 -1
- package/vitepress/components/SidebarCard/MindMapView.vue +10 -9
- package/vitepress/components/SidebarCard/SidebarCard.vue +4 -6
- package/vitepress/config/index.ts +7 -5
- package/vitepress/configs/head.config.ts +2 -1
- package/vitepress/configs/markdown-it.d.ts +6 -3
- package/vitepress/configs/markdown.config.ts +6 -5
- package/vitepress/configs/theme.config.ts +1 -1
- package/vitepress/plugins/buildProgressPlugin.ts +2 -38
- package/vitepress/plugins/getNoteByConfigIdPlugin.ts +3 -2
- package/vitepress/plugins/renameNotePlugin.ts +2 -1
- package/vitepress/plugins/updateConfigPlugin.ts +2 -1
- package/vitepress/theme/index.ts +5 -3
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
</template>
|
|
57
57
|
|
|
58
58
|
<script setup>
|
|
59
|
+
import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
|
|
60
|
+
|
|
59
61
|
import {
|
|
60
62
|
icon__close,
|
|
61
63
|
icon__next,
|
|
@@ -65,7 +67,6 @@ import {
|
|
|
65
67
|
icon__zoom_out,
|
|
66
68
|
} from '../../assets/icons'
|
|
67
69
|
|
|
68
|
-
import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
|
|
69
70
|
|
|
70
71
|
const preview = ref({
|
|
71
72
|
visible: false,
|
|
@@ -183,34 +183,31 @@
|
|
|
183
183
|
</template>
|
|
184
184
|
|
|
185
185
|
<script setup>
|
|
186
|
-
import Discussions from "../Discussions/Discussions.vue";
|
|
187
|
-
import ImagePreview from "./ImagePreview.vue";
|
|
188
|
-
import Swiper from "./Swiper.vue";
|
|
189
|
-
import ContentCollapse from "./ContentCollapse.vue";
|
|
190
|
-
import AboutModal from "./AboutModal.vue";
|
|
191
|
-
import AboutPanel from "./AboutPanel.vue";
|
|
192
|
-
import DocBeforeControls from "./DocBeforeControls.vue";
|
|
193
|
-
import CustomSidebar from "./CustomSidebar.vue";
|
|
194
|
-
import SidebarNavBefore from "./SidebarNavBefore.vue";
|
|
195
|
-
import DocFooter from "./DocFooter.vue";
|
|
196
|
-
import NoteStatus from "./NoteStatus.vue";
|
|
197
|
-
|
|
198
186
|
import { useData, useRoute, useRouter } from "vitepress";
|
|
199
187
|
import DefaultTheme from "vitepress/theme";
|
|
200
188
|
import { computed, onMounted, ref, watch } from "vue";
|
|
201
189
|
|
|
202
|
-
import {
|
|
203
|
-
import { data as readmeData } from "./homeReadme.data.ts";
|
|
190
|
+
import { useCodeBlockFullscreen } from "../CodeBlockFullscreen";
|
|
204
191
|
import { SIDEBAR_SHOW_NOTE_ID_KEY } from "../constants";
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
import
|
|
192
|
+
import Discussions from "../Discussions/Discussions.vue";
|
|
193
|
+
import { data as allNotesConfig } from "../notesConfig.data.ts";
|
|
194
|
+
import AboutModal from "./AboutModal.vue";
|
|
195
|
+
import AboutPanel from "./AboutPanel.vue";
|
|
196
|
+
import { useCollapseControl } from "./composables/useCollapseControl";
|
|
208
197
|
import { useNoteConfig } from "./composables/useNoteConfig";
|
|
209
|
-
import { useNoteValidation } from "./composables/useNoteValidation";
|
|
210
198
|
import { useNoteSave } from "./composables/useNoteSave";
|
|
211
|
-
import {
|
|
199
|
+
import { useNoteValidation } from "./composables/useNoteValidation";
|
|
200
|
+
import { useRedirect } from "./composables/useRedirect";
|
|
212
201
|
import { useVSCodeIntegration } from "./composables/useVSCodeIntegration";
|
|
213
|
-
import
|
|
202
|
+
import ContentCollapse from "./ContentCollapse.vue";
|
|
203
|
+
import CustomSidebar from "./CustomSidebar.vue";
|
|
204
|
+
import DocBeforeControls from "./DocBeforeControls.vue";
|
|
205
|
+
import DocFooter from "./DocFooter.vue";
|
|
206
|
+
import { data as readmeData } from "./homeReadme.data.ts";
|
|
207
|
+
import ImagePreview from "./ImagePreview.vue";
|
|
208
|
+
import NoteStatus from "./NoteStatus.vue";
|
|
209
|
+
import SidebarNavBefore from "./SidebarNavBefore.vue";
|
|
210
|
+
import Swiper from "./Swiper.vue";
|
|
214
211
|
|
|
215
212
|
const { Layout } = DefaultTheme;
|
|
216
213
|
const vpData = useData();
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
</template>
|
|
17
17
|
|
|
18
18
|
<script setup lang="ts">
|
|
19
|
-
import { computed, toRefs, ref, onMounted, nextTick } from 'vue'
|
|
20
19
|
import { useData } from 'vitepress'
|
|
20
|
+
import { computed, toRefs, ref, onMounted, nextTick } from 'vue'
|
|
21
|
+
|
|
21
22
|
import Tooltip from '../Tooltip/Tooltip.vue'
|
|
22
23
|
|
|
23
24
|
const props = defineProps({
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
<div v-show="!item.collapsed" class="group-items">
|
|
27
27
|
<SidebarItems
|
|
28
|
-
:items="item
|
|
28
|
+
:items="getChildItems(item)"
|
|
29
29
|
:depth="depth + 1"
|
|
30
30
|
:max-depth="maxDepth"
|
|
31
31
|
:show-note-id="showNoteId"
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
</template>
|
|
56
56
|
|
|
57
57
|
<script setup lang="ts">
|
|
58
|
-
import { computed } from 'vue'
|
|
58
|
+
import { computed } from 'vue'
|
|
59
|
+
|
|
59
60
|
import { icon__sidebar_opened, icon__sidebar_collapsed } from '../../assets/icons'
|
|
60
61
|
|
|
61
62
|
interface SidebarItem {
|
|
@@ -92,6 +93,10 @@ function hasChildren(item: SidebarItem): boolean {
|
|
|
92
93
|
return !!(item.items && item.items.length > 0)
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
function getChildItems(item: SidebarItem): SidebarItem[] {
|
|
97
|
+
return item.items ?? []
|
|
98
|
+
}
|
|
99
|
+
|
|
95
100
|
// 获取项的唯一 key
|
|
96
101
|
function getItemKey(item: SidebarItem): string {
|
|
97
102
|
return item.link || item.text
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<img @click="toggle" :class="$style.contentToggleBtn" :aria-pressed="full
|
|
2
|
+
<img @click="toggle" :class="$style.contentToggleBtn" :aria-pressed="full" :title="full ? '退出全屏内容区' : '全屏显示内容区'" :src="full ? icon__fullscreen_exit : icon__fullscreen" alt="" />
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import { onMounted, ref } from 'vue'
|
|
7
|
+
|
|
7
8
|
import { icon__fullscreen, icon__fullscreen_exit } from '../../assets/icons'
|
|
8
9
|
|
|
9
10
|
const KEY = 'vp:content:fullscreen'
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<!-- .vitepress\components\Layout\ToggleSidebar.vue -->
|
|
2
2
|
<template>
|
|
3
|
-
<img @click="toggle" :class="$style.sidebarToggleBtn" :aria-pressed="hidden
|
|
3
|
+
<img @click="toggle" :class="$style.sidebarToggleBtn" :aria-pressed="hidden" :title="hidden ? '显示侧边栏' : '隐藏侧边栏'" :src="hidden ? icon__next : icon__prev" alt="" />
|
|
4
4
|
</template>
|
|
5
5
|
|
|
6
6
|
<script setup lang="ts">
|
|
7
7
|
import { onMounted, ref } from 'vue'
|
|
8
|
+
|
|
8
9
|
import { icon__next, icon__prev } from '../../assets/icons'
|
|
9
10
|
|
|
10
11
|
const KEY = 'vp:sidebar:hidden'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ref, computed, watch } from 'vue'
|
|
2
|
-
|
|
3
|
-
import { useData } from 'vitepress'
|
|
2
|
+
|
|
4
3
|
import type { NoteConfig } from '../../../../types'
|
|
4
|
+
import type { Ref } from 'vue'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* 管理笔记配置状态
|
|
@@ -13,8 +13,6 @@ export function useNoteConfig(
|
|
|
13
13
|
currentNoteTitle: Ref<string>,
|
|
14
14
|
timeModalOpen: Ref<boolean>
|
|
15
15
|
) {
|
|
16
|
-
const vpData = useData()
|
|
17
|
-
|
|
18
16
|
// 可编辑的配置项
|
|
19
17
|
const editableNoteStatus = ref(false)
|
|
20
18
|
const editableDiscussionsEnabled = ref(false)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ref, computed } from 'vue'
|
|
2
|
-
import type { Ref, ComputedRef } from 'vue'
|
|
3
1
|
import { useData } from 'vitepress'
|
|
2
|
+
import { ref, computed } from 'vue'
|
|
3
|
+
|
|
4
4
|
import type { NoteConfig } from '../../../../types'
|
|
5
|
+
import type { Ref, ComputedRef } from 'vue'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* 处理笔记配置的保存和重置逻辑
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ref, watch } from 'vue'
|
|
2
1
|
import { useRoute, useData } from 'vitepress'
|
|
2
|
+
import { ref, watch } from 'vue'
|
|
3
3
|
|
|
4
4
|
import type { NoteConfig } from '../../../../types'
|
|
5
5
|
|
|
@@ -32,11 +32,14 @@ export function useRedirect(allNotesConfig: Record<string, NoteConfig & { redire
|
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
if (match) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const matchedNoteId = match[1]
|
|
36
|
+
if (!matchedNoteId) return false
|
|
37
|
+
|
|
38
|
+
matchedId.value = matchedNoteId
|
|
39
|
+
const targetNote = allNotesConfig[matchedNoteId]
|
|
40
|
+
redirectPath.value = targetNote?.redirect ?? ''
|
|
38
41
|
|
|
39
|
-
if (targetNote
|
|
42
|
+
if (targetNote?.redirect) {
|
|
40
43
|
const base = vpData.site.value.base
|
|
41
44
|
// 构建目标路径(包含基础路径)
|
|
42
45
|
const targetPath = `${base}${targetNote.redirect}`
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { ref } from 'vue'
|
|
2
|
-
import type { Ref, ComputedRef } from 'vue'
|
|
3
1
|
import { useData } from 'vitepress'
|
|
4
|
-
import
|
|
5
|
-
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
import { NOTES_DIR_KEY } from '../../constants'
|
|
5
|
+
|
|
6
|
+
import type { Router } from 'vitepress'
|
|
7
|
+
import type { Ref, ComputedRef } from 'vue'
|
|
8
|
+
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* VSCode 集成和 GitHub 链接拦截
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { scaleOrdinal, schemePastel2, schemeSet3, schemeTableau10 } from 'd3'
|
|
3
3
|
import { Transformer } from 'markmap-lib'
|
|
4
|
-
import { Markmap, IMarkmapOptions } from 'markmap-view'
|
|
5
4
|
import { Toolbar } from 'markmap-toolbar'
|
|
6
5
|
import 'markmap-toolbar/dist/style.css'
|
|
7
|
-
import {
|
|
6
|
+
import { Markmap, IMarkmapOptions } from 'markmap-view'
|
|
7
|
+
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
8
|
+
|
|
8
9
|
import { icon__fullscreen, icon__fullscreen_exit, icon__confirm } from '../../assets/icons'
|
|
10
|
+
import { MARKMAP_THEME_KEY, MARKMAP_EXPAND_LEVEL_KEY } from '../constants'
|
|
9
11
|
|
|
10
12
|
// doc: https://github.com/markmap/markmap/blob/205367a24603dc187f67da1658940c6cade20dce/packages/markmap-view/src/constants.ts#L15
|
|
11
|
-
import { scaleOrdinal, schemePastel2, schemeSet3, schemeTableau10 } from 'd3'
|
|
12
13
|
|
|
13
14
|
const props = defineProps({
|
|
14
15
|
content: { type: String, default: '' },
|
|
@@ -88,7 +88,8 @@
|
|
|
88
88
|
|
|
89
89
|
<script setup lang="ts">
|
|
90
90
|
import mermaid from 'mermaid'
|
|
91
|
-
import { nextTick, onMounted, onBeforeUnmount, ref, watch } from 'vue'
|
|
91
|
+
import { nextTick, onMounted, onBeforeUnmount, ref, watch } from 'vue'
|
|
92
|
+
|
|
92
93
|
import {
|
|
93
94
|
icon__zoom_in,
|
|
94
95
|
icon__zoom_out,
|
|
@@ -293,7 +294,8 @@ const renderDiagram = async () => {
|
|
|
293
294
|
bindFunctions(diagramRef.value)
|
|
294
295
|
}
|
|
295
296
|
} catch (err) {
|
|
296
|
-
|
|
297
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
298
|
+
error.value = `Failed to render diagram: ${message}`
|
|
297
299
|
console.error('Mermaid render error:', err)
|
|
298
300
|
} finally {
|
|
299
301
|
loading.value = false
|
|
@@ -35,8 +35,9 @@
|
|
|
35
35
|
</template>
|
|
36
36
|
|
|
37
37
|
<script setup lang="ts">
|
|
38
|
-
import { computed } from 'vue'
|
|
39
38
|
import { useData } from 'vitepress'
|
|
39
|
+
import { computed } from 'vue'
|
|
40
|
+
|
|
40
41
|
// @ts-expect-error - VitePress data loader exports data at runtime
|
|
41
42
|
import { data as allNotesConfig } from '../notesConfig.data.ts'
|
|
42
43
|
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {
|
|
3
|
-
import { withBase, useData } from 'vitepress'
|
|
2
|
+
import { scaleOrdinal, schemePastel2, schemeSet3, schemeTableau10 } from 'd3'
|
|
4
3
|
import { Transformer } from 'markmap-lib'
|
|
5
|
-
import { Markmap } from 'markmap-view'
|
|
6
4
|
import { Toolbar } from 'markmap-toolbar'
|
|
7
5
|
import 'markmap-toolbar/dist/style.css'
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
REPO_NAME,
|
|
13
|
-
} from '../constants'
|
|
6
|
+
import { Markmap } from 'markmap-view'
|
|
7
|
+
import { withBase, useData } from 'vitepress'
|
|
8
|
+
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
9
|
+
|
|
14
10
|
import {
|
|
15
11
|
icon__fullscreen,
|
|
16
12
|
icon__fullscreen_exit,
|
|
17
13
|
icon__confirm,
|
|
18
14
|
} from '../../assets/icons'
|
|
15
|
+
import {
|
|
16
|
+
MARKMAP_THEME_KEY,
|
|
17
|
+
MARKMAP_EXPAND_LEVEL_KEY,
|
|
18
|
+
REPO_NAME,
|
|
19
|
+
} from '../constants'
|
|
19
20
|
|
|
20
21
|
const props = defineProps({
|
|
21
22
|
sidebarData: {
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { useData } from 'vitepress'
|
|
3
|
-
import { formatDate } from '../utils.ts'
|
|
4
|
-
import { ref, computed, watch } from 'vue'
|
|
5
3
|
import { useRouter } from 'vitepress'
|
|
6
|
-
|
|
7
|
-
import { data as sidebarConfig } from '../sidebar.data'
|
|
4
|
+
import { ref, computed, watch } from 'vue'
|
|
8
5
|
|
|
9
6
|
import { NOTES_DIR_KEY, REPO_NAME, AUTHOR, ROOT_ITEM } from '../constants.ts'
|
|
10
|
-
|
|
7
|
+
import { data as sidebarConfig } from '../sidebar.data'
|
|
8
|
+
import { formatDate } from '../utils.ts'
|
|
9
|
+
// @ts-expect-error - VitePress Data Loader
|
|
11
10
|
import MindMapView from './MindMapView.vue'
|
|
12
11
|
import NotesTrendChart from './NotesTrendChart.vue'
|
|
13
|
-
|
|
14
12
|
import {
|
|
15
13
|
icon__fold,
|
|
16
14
|
icon__github,
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import fs from 'fs'
|
|
11
11
|
import path from 'path'
|
|
12
|
-
import { defineConfig, type UserConfig } from 'vitepress'
|
|
13
|
-
|
|
12
|
+
import { defineConfig, type UserConfig } from 'vitepress'
|
|
13
|
+
|
|
14
14
|
import {
|
|
15
15
|
getIgnoreList,
|
|
16
16
|
getGithubPageUrl,
|
|
@@ -18,10 +18,12 @@ import {
|
|
|
18
18
|
getMarkdownConfig,
|
|
19
19
|
getThemeConfig,
|
|
20
20
|
} from '../configs'
|
|
21
|
-
import {
|
|
22
|
-
import { renameNotePlugin } from '../plugins/renameNotePlugin'
|
|
21
|
+
import { buildProgressPlugin } from '../plugins/buildProgressPlugin'
|
|
23
22
|
import { getNoteByConfigIdPlugin } from '../plugins/getNoteByConfigIdPlugin'
|
|
24
|
-
import {
|
|
23
|
+
import { renameNotePlugin } from '../plugins/renameNotePlugin'
|
|
24
|
+
import { updateConfigPlugin } from '../plugins/updateConfigPlugin'
|
|
25
|
+
|
|
26
|
+
import type { TNotesConfig } from '../../types'
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* 读取 .tnotes.json 配置文件
|
|
@@ -5,19 +5,22 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
declare module 'markdown-it-container' {
|
|
8
|
-
import { PluginWithOptions } from 'markdown-it'
|
|
8
|
+
import { PluginWithOptions } from 'markdown-it'
|
|
9
|
+
|
|
9
10
|
const markdownItContainer: PluginWithOptions<any>
|
|
10
11
|
export default markdownItContainer
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
declare module 'markdown-it-link-attributes' {
|
|
14
|
-
import { PluginWithOptions } from 'markdown-it'
|
|
15
|
+
import { PluginWithOptions } from 'markdown-it'
|
|
16
|
+
|
|
15
17
|
const markdownItLinkAttributes: PluginWithOptions<any>
|
|
16
18
|
export default markdownItLinkAttributes
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
declare module 'markdown-it-task-lists' {
|
|
20
|
-
import { PluginWithOptions } from 'markdown-it'
|
|
22
|
+
import { PluginWithOptions } from 'markdown-it'
|
|
23
|
+
|
|
21
24
|
const markdownItTaskLists: PluginWithOptions<any>
|
|
22
25
|
export default markdownItTaskLists
|
|
23
26
|
}
|
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Markdown 配置
|
|
5
5
|
*/
|
|
6
|
+
import fs from 'fs'
|
|
6
7
|
import MarkdownIt from 'markdown-it'
|
|
7
8
|
import markdownItContainer from 'markdown-it-container'
|
|
8
9
|
import mila from 'markdown-it-link-attributes'
|
|
9
10
|
import markdownItTaskLists from 'markdown-it-task-lists'
|
|
10
|
-
import { MarkdownOptions } from 'vitepress'
|
|
11
|
-
import { generateAnchor } from '../../utils'
|
|
12
|
-
import fs from 'fs'
|
|
13
11
|
import path from 'path'
|
|
12
|
+
import { MarkdownOptions } from 'vitepress'
|
|
13
|
+
|
|
14
|
+
import { generateAnchor } from '../../utils'
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* 辅助函数:HTML 转义
|
|
@@ -105,7 +106,7 @@ function configureMarkMapContainer(md: MarkdownIt) {
|
|
|
105
106
|
const endLine = open.map ? open.map[1] - 1 : null
|
|
106
107
|
|
|
107
108
|
// 1) 从开头 fence 行解析参数(支持 `{a=1 b="x"}`、`a=1 b="x"`,并支持单个数字 shorthand)
|
|
108
|
-
|
|
109
|
+
const params: { [key: string]: any; initialExpandLevel?: number } = {}
|
|
109
110
|
|
|
110
111
|
if (open.map && typeof open.map[0] === 'number') {
|
|
111
112
|
const openLine = (lines[open.map[0]] || '').trim()
|
|
@@ -179,7 +180,7 @@ function configureMarkMapContainer(md: MarkdownIt) {
|
|
|
179
180
|
const refMatch = firstNonEmptyLine.trim().match(/^<<<\s*(.+)$/)
|
|
180
181
|
if (refMatch) {
|
|
181
182
|
// 提取引用路径,支持引号包裹
|
|
182
|
-
|
|
183
|
+
const refRaw = refMatch[1].trim().replace(/^['"]|['"]$/g, '')
|
|
183
184
|
|
|
184
185
|
// 尝试同步读取文件内容(兼容常见 Node 环境)
|
|
185
186
|
try {
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* doc:
|
|
7
7
|
* https://vitepress.dev/reference/default-theme-config
|
|
8
8
|
*/
|
|
9
|
-
import type { DefaultTheme } from 'vitepress'
|
|
10
9
|
import type { TNotesConfig } from '../../types'
|
|
10
|
+
import type { DefaultTheme } from 'vitepress'
|
|
11
11
|
|
|
12
12
|
export function getThemeConfig(config: TNotesConfig): DefaultTheme.Config {
|
|
13
13
|
const themeConfig: DefaultTheme.Config = {
|
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
* https://github.com/jeddygong/vite-plugin-progress
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { Plugin } from 'vite'
|
|
11
10
|
import {
|
|
12
11
|
existsSync,
|
|
13
12
|
readFileSync,
|
|
14
13
|
writeFileSync,
|
|
15
14
|
mkdirSync,
|
|
16
|
-
readdirSync,
|
|
17
15
|
} from 'fs'
|
|
18
16
|
import { join } from 'path'
|
|
19
17
|
|
|
18
|
+
import type { Plugin } from 'vite'
|
|
19
|
+
|
|
20
20
|
/** 缓存目录和文件路径 */
|
|
21
21
|
const CACHE_DIR = join(process.cwd(), 'node_modules', '.tnotes-progress')
|
|
22
22
|
const CACHE_FILE = join(CACHE_DIR, 'build-cache.json')
|
|
@@ -64,37 +64,6 @@ function setCacheData(data: CacheData): void {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
/**
|
|
68
|
-
* 扫描源目录文件数量
|
|
69
|
-
*/
|
|
70
|
-
function countSourceFiles(srcDir: string): number {
|
|
71
|
-
let count = 0
|
|
72
|
-
const extensions = /\.(vue|ts|js|jsx|tsx|css|scss|sass|styl|less|md)$/i
|
|
73
|
-
|
|
74
|
-
const scan = (dir: string) => {
|
|
75
|
-
try {
|
|
76
|
-
const entries = readdirSync(dir, { withFileTypes: true })
|
|
77
|
-
for (const entry of entries) {
|
|
78
|
-
const fullPath = join(dir, entry.name)
|
|
79
|
-
if (
|
|
80
|
-
entry.isDirectory() &&
|
|
81
|
-
!entry.name.startsWith('.') &&
|
|
82
|
-
entry.name !== 'node_modules'
|
|
83
|
-
) {
|
|
84
|
-
scan(fullPath)
|
|
85
|
-
} else if (entry.isFile() && extensions.test(entry.name)) {
|
|
86
|
-
count++
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
} catch {
|
|
90
|
-
// 忽略错误
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
scan(srcDir)
|
|
95
|
-
return count
|
|
96
|
-
}
|
|
97
|
-
|
|
98
67
|
// ============ 全局状态 ============
|
|
99
68
|
let globalStartTime = 0
|
|
100
69
|
let globalTransformCount = 0
|
|
@@ -103,7 +72,6 @@ let globalHasError = false
|
|
|
103
72
|
let globalIsBuilding = false
|
|
104
73
|
let globalOutDir = ''
|
|
105
74
|
let globalLastPercent = 0
|
|
106
|
-
let globalFileCount = 0
|
|
107
75
|
let globalLastLoggedPercent = -1 // 非 TTY 环境下上次输出的百分比区间,初始为 -1 以便第一次输出
|
|
108
76
|
let globalLastOutputTime = 0 // 非 TTY 环境下上次输出时间戳,用于时间节流
|
|
109
77
|
let globalTransformEndTime = 0 // transform 阶段结束时间戳
|
|
@@ -273,10 +241,6 @@ export function buildProgressPlugin(
|
|
|
273
241
|
globalLastHookTime = Date.now()
|
|
274
242
|
globalOutDir = config.build?.outDir || 'dist'
|
|
275
243
|
|
|
276
|
-
if (!hasCache) {
|
|
277
|
-
globalFileCount = countSourceFiles(process.cwd())
|
|
278
|
-
}
|
|
279
|
-
|
|
280
244
|
interceptOutput()
|
|
281
245
|
|
|
282
246
|
// 停滞填充计时器:当 Vite hook 超过 2 秒没触发时(如 VitePress 渲染页面阶段),
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* VitePress 插件 - 根据 configId 查询笔记信息
|
|
5
5
|
*/
|
|
6
|
-
import type { PluginOption } from 'vite'
|
|
7
6
|
import { NoteIndexCache } from '../../core'
|
|
8
|
-
import { logger } from '../../utils'
|
|
7
|
+
import { logger } from '../../utils'
|
|
8
|
+
|
|
9
|
+
import type { PluginOption } from 'vite'
|
|
9
10
|
|
|
10
11
|
export function getNoteByConfigIdPlugin(): PluginOption {
|
|
11
12
|
return {
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Vite 插件 - 处理笔记重命名请求
|
|
5
5
|
*/
|
|
6
|
+
import { RenameNoteCommand } from '../../commands/note/RenameNoteCommand'
|
|
7
|
+
|
|
6
8
|
import type { PluginOption } from 'vite'
|
|
7
|
-
import { RenameNoteCommand } from '../../commands/note/RenameNoteCommand'
|
|
8
9
|
|
|
9
10
|
export function renameNotePlugin(): PluginOption {
|
|
10
11
|
const renameCommand = new RenameNoteCommand()
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* VitePress 插件 - 处理笔记配置更新请求
|
|
5
5
|
*/
|
|
6
|
+
import { UpdateNoteConfigCommand } from '../../commands/note/UpdateNoteConfigCommand'
|
|
7
|
+
|
|
6
8
|
import type { PluginOption } from 'vite'
|
|
7
|
-
import { UpdateNoteConfigCommand } from '../../commands/note/UpdateNoteConfigCommand'
|
|
8
9
|
|
|
9
10
|
export function updateConfigPlugin(): PluginOption {
|
|
10
11
|
let updateCommand: UpdateNoteConfigCommand
|
package/vitepress/theme/index.ts
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* v2 - https://vitepress.dev/zh/guide/custom-theme
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import
|
|
16
|
-
|
|
15
|
+
import DefaultTheme from 'vitepress/theme'
|
|
16
|
+
|
|
17
17
|
import BilibiliOutsidePlayer from '../components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue'
|
|
18
18
|
import Discussions from '../components/Discussions/Discussions.vue'
|
|
19
19
|
import EnWordList from '../components/EnWordList/EnWordList.vue'
|
|
@@ -25,7 +25,9 @@ import Mermaid from '../components/Mermaid/Mermaid.vue'
|
|
|
25
25
|
import NotesTable from '../components/NotesTable/NotesTable.vue'
|
|
26
26
|
import Settings from '../components/Settings/Settings.vue'
|
|
27
27
|
import SidebarCard from '../components/SidebarCard/SidebarCard.vue'
|
|
28
|
-
import Tooltip from '../components/Tooltip/Tooltip.vue'
|
|
28
|
+
import Tooltip from '../components/Tooltip/Tooltip.vue'
|
|
29
|
+
|
|
30
|
+
import type { Theme, EnhanceAppContext } from 'vitepress'
|
|
29
31
|
import './styles/index.scss'
|
|
30
32
|
|
|
31
33
|
/**
|