@tnotesjs/core 0.1.0

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.

Potentially problematic release.


This version of @tnotesjs/core might be problematic. Click here for more details.

Files changed (117) hide show
  1. package/README.md +105 -0
  2. package/dist/chunk-K3X5OP3N.js +1532 -0
  3. package/dist/cli/index.d.ts +2 -0
  4. package/dist/cli/index.js +4199 -0
  5. package/dist/index.d.ts +138 -0
  6. package/dist/index.js +9 -0
  7. package/package.json +74 -0
  8. package/types/config.ts +61 -0
  9. package/types/index.ts +11 -0
  10. package/types/note.ts +33 -0
  11. package/vitepress/assets/icons/icon__check.svg +3 -0
  12. package/vitepress/assets/icons/icon__clipboard.svg +8 -0
  13. package/vitepress/assets/icons/icon__close.svg +1 -0
  14. package/vitepress/assets/icons/icon__collapse.svg +1 -0
  15. package/vitepress/assets/icons/icon__confirm.svg +1 -0
  16. package/vitepress/assets/icons/icon__copy.svg +4 -0
  17. package/vitepress/assets/icons/icon__focus.svg +1 -0
  18. package/vitepress/assets/icons/icon__fold.svg +3 -0
  19. package/vitepress/assets/icons/icon__folder.svg +1 -0
  20. package/vitepress/assets/icons/icon__fullscreen.svg +1 -0
  21. package/vitepress/assets/icons/icon__fullscreen_exit.svg +1 -0
  22. package/vitepress/assets/icons/icon__github.svg +4 -0
  23. package/vitepress/assets/icons/icon__mindmap.svg +1 -0
  24. package/vitepress/assets/icons/icon__next.svg +1 -0
  25. package/vitepress/assets/icons/icon__number_gray.svg +1 -0
  26. package/vitepress/assets/icons/icon__number_purple.svg +1 -0
  27. package/vitepress/assets/icons/icon__prev.svg +1 -0
  28. package/vitepress/assets/icons/icon__restore.svg +1 -0
  29. package/vitepress/assets/icons/icon__rotate.svg +4 -0
  30. package/vitepress/assets/icons/icon__search.svg +1 -0
  31. package/vitepress/assets/icons/icon__sidebar_collapsed.svg +1 -0
  32. package/vitepress/assets/icons/icon__sidebar_opened.svg +1 -0
  33. package/vitepress/assets/icons/icon__totop.svg +6 -0
  34. package/vitepress/assets/icons/icon__vscode.svg +6 -0
  35. package/vitepress/assets/icons/icon__zoom_fit.svg +1 -0
  36. package/vitepress/assets/icons/icon__zoom_in.svg +1 -0
  37. package/vitepress/assets/icons/icon__zoom_out.svg +1 -0
  38. package/vitepress/assets/icons/icon__zoom_reset.svg +1 -0
  39. package/vitepress/assets/icons/index.ts +38 -0
  40. package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +20 -0
  41. package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +373 -0
  42. package/vitepress/components/CodeBlockFullscreen/index.ts +115 -0
  43. package/vitepress/components/CodeBlockFullscreen/styles.css +64 -0
  44. package/vitepress/components/Discussions/Discussions.module.scss +32 -0
  45. package/vitepress/components/Discussions/Discussions.vue +211 -0
  46. package/vitepress/components/EnWordList/EnWordList.module.scss +124 -0
  47. package/vitepress/components/EnWordList/EnWordList.vue +543 -0
  48. package/vitepress/components/EnWordList/RightClickMenu.module.scss +22 -0
  49. package/vitepress/components/EnWordList/RightClickMenu.vue +66 -0
  50. package/vitepress/components/Footprints/Footprints.module.scss +93 -0
  51. package/vitepress/components/Footprints/Footprints.vue +377 -0
  52. package/vitepress/components/Layout/AboutModal.module.scss +233 -0
  53. package/vitepress/components/Layout/AboutModal.vue +105 -0
  54. package/vitepress/components/Layout/AboutPanel.vue +266 -0
  55. package/vitepress/components/Layout/ContentCollapse.vue +603 -0
  56. package/vitepress/components/Layout/CustomSidebar.vue +605 -0
  57. package/vitepress/components/Layout/DocBeforeControls.vue +139 -0
  58. package/vitepress/components/Layout/DocFooter.vue +225 -0
  59. package/vitepress/components/Layout/ImagePreview.module.scss +201 -0
  60. package/vitepress/components/Layout/ImagePreview.vue +281 -0
  61. package/vitepress/components/Layout/Layout.module.scss +661 -0
  62. package/vitepress/components/Layout/Layout.vue +542 -0
  63. package/vitepress/components/Layout/NoteStatus.vue +140 -0
  64. package/vitepress/components/Layout/SidebarItems.vue +263 -0
  65. package/vitepress/components/Layout/SidebarNavBefore.vue +92 -0
  66. package/vitepress/components/Layout/Swiper.vue +167 -0
  67. package/vitepress/components/Layout/ToggleFullContent.module.scss +11 -0
  68. package/vitepress/components/Layout/ToggleFullContent.vue +34 -0
  69. package/vitepress/components/Layout/ToggleSidebar.module.scss +11 -0
  70. package/vitepress/components/Layout/ToggleSidebar.vue +35 -0
  71. package/vitepress/components/Layout/composables/useCollapseControl.ts +88 -0
  72. package/vitepress/components/Layout/composables/useNoteConfig.ts +121 -0
  73. package/vitepress/components/Layout/composables/useNoteSave.ts +173 -0
  74. package/vitepress/components/Layout/composables/useNoteValidation.ts +85 -0
  75. package/vitepress/components/Layout/composables/useRedirect.ts +110 -0
  76. package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +85 -0
  77. package/vitepress/components/Layout/homeReadme.data.ts +124 -0
  78. package/vitepress/components/LoadingPage/LoadingPage.vue +192 -0
  79. package/vitepress/components/MarkMap/MarkMap.module.scss +159 -0
  80. package/vitepress/components/MarkMap/MarkMap.vue +404 -0
  81. package/vitepress/components/Mermaid/Mermaid.module.scss +275 -0
  82. package/vitepress/components/Mermaid/Mermaid.vue +364 -0
  83. package/vitepress/components/NotesTable/NotesTable.module.scss +77 -0
  84. package/vitepress/components/NotesTable/NotesTable.vue +98 -0
  85. package/vitepress/components/NotesTable/README.md +67 -0
  86. package/vitepress/components/Settings/Settings.module.scss +433 -0
  87. package/vitepress/components/Settings/Settings.vue +306 -0
  88. package/vitepress/components/SidebarCard/MindMapView.vue +483 -0
  89. package/vitepress/components/SidebarCard/NotesTrendChart.vue +108 -0
  90. package/vitepress/components/SidebarCard/SidebarCard.vue +948 -0
  91. package/vitepress/components/Tooltip/Tooltip.vue +70 -0
  92. package/vitepress/components/constants.ts +91 -0
  93. package/vitepress/components/notesConfig.data.ts +73 -0
  94. package/vitepress/components/sidebar.data.ts +59 -0
  95. package/vitepress/components/tnotes-config.data.ts +21 -0
  96. package/vitepress/components/utils.ts +26 -0
  97. package/vitepress/config/index.ts +126 -0
  98. package/vitepress/configs/constants.ts +26 -0
  99. package/vitepress/configs/head.config.ts +25 -0
  100. package/vitepress/configs/index.ts +9 -0
  101. package/vitepress/configs/markdown-it.d.ts +23 -0
  102. package/vitepress/configs/markdown.config.ts +366 -0
  103. package/vitepress/configs/theme.config.ts +108 -0
  104. package/vitepress/plugins/buildProgressPlugin.ts +390 -0
  105. package/vitepress/plugins/getNoteByConfigIdPlugin.ts +107 -0
  106. package/vitepress/plugins/renameNotePlugin.ts +60 -0
  107. package/vitepress/plugins/updateConfigPlugin.ts +63 -0
  108. package/vitepress/theme/index.ts +95 -0
  109. package/vitepress/theme/styles/base.scss +50 -0
  110. package/vitepress/theme/styles/components/404.scss +31 -0
  111. package/vitepress/theme/styles/components/collapse.scss +175 -0
  112. package/vitepress/theme/styles/components/markmap.scss +101 -0
  113. package/vitepress/theme/styles/components/swiper.scss +255 -0
  114. package/vitepress/theme/styles/index.scss +25 -0
  115. package/vitepress/theme/styles/layout.scss +62 -0
  116. package/vitepress/theme/styles/utilities.scss +39 -0
  117. package/vitepress/theme/styles/vitepress-override.scss +25 -0
@@ -0,0 +1,211 @@
1
+ <script setup lang="ts">
2
+ import { useData } from 'vitepress/client'
3
+ import { onMounted, onUnmounted, watch, computed } from 'vue'
4
+ import { REPO_NAME, AUTHOR } from '../constants'
5
+ import Tooltip from '../Tooltip/Tooltip.vue'
6
+ import { icon__github } from '../../assets/icons'
7
+
8
+ const props = defineProps({
9
+ /**
10
+ * 留言版 ID
11
+ * 来自于笔记配置文件中的 id 字段的 uuid 值
12
+ */
13
+ id: {
14
+ type: String,
15
+ required: true,
16
+ },
17
+ /**
18
+ * 笔记序号(如 0001)
19
+ */
20
+ noteNumber: {
21
+ type: String,
22
+ default: '',
23
+ },
24
+ /**
25
+ * 笔记标题
26
+ */
27
+ noteTitle: {
28
+ type: String,
29
+ default: '',
30
+ },
31
+ })
32
+
33
+ // 🔍 查阅支持的所有主题 https://giscus.app/zh-CN
34
+ const GISCUS_DARK_THEME = 'noborder_dark'
35
+ const GISCUS_LIGHT_THEME = 'noborder_light'
36
+
37
+ // 获取 VitePress 的数据 - 主题状态
38
+ const { isDark } = useData()
39
+
40
+ // 生成 GitHub Discussions 直接链接
41
+ const githubDiscussionsUrl = computed(() => {
42
+ return `https://github.com/orgs/tnotesjs/discussions?discussions_q=${props.id}`
43
+ })
44
+
45
+ /**
46
+ * 生成 giscus backlink(带有笔记信息的 GitHub 页面链接)
47
+ *
48
+ * giscus 会在创建新 Discussion 时自动添加返回链接。
49
+ * 通过设置 <meta name="giscus:backlink"> 标签,可以自定义这个链接。
50
+ * 这样在 GitHub Discussions 中就能看到对应笔记的直接链接。
51
+ *
52
+ * 📖 官方文档:https://github.com/giscus/giscus/blob/main/ADVANCED-USAGE.md#giscusbacklink
53
+ */
54
+ const giscusBacklink = computed(() => {
55
+ console.log('[Discussions] Props:', {
56
+ noteNumber: props.noteNumber,
57
+ noteTitle: props.noteTitle,
58
+ id: props.id,
59
+ })
60
+
61
+ if (!props.noteNumber || !props.noteTitle) {
62
+ console.log('[Discussions] 使用默认 URL:', window.location.href)
63
+ return window.location.href
64
+ }
65
+
66
+ // 对笔记标题进行 URL 编码(处理中文和特殊字符)
67
+ const encodedTitle = encodeURIComponent(props.noteTitle)
68
+
69
+ // 生成笔记相关链接
70
+ const noteGithubUrl = `https://github.com/${AUTHOR}/${REPO_NAME}/tree/main/notes/${props.noteNumber}.%20${encodedTitle}`
71
+ const notePageUrl = `https://${AUTHOR.toLowerCase()}.github.io/${REPO_NAME}/notes/${
72
+ props.noteNumber
73
+ }.%20${encodedTitle}/README`
74
+
75
+ // 生成知识库相关链接
76
+ const repoGithubUrl = `https://github.com/${AUTHOR}/${REPO_NAME}`
77
+ const repoPageUrl = `https://${AUTHOR.toLowerCase()}.github.io/${REPO_NAME}/`
78
+
79
+ // 生成当前时间字符串
80
+ const now = new Date()
81
+ const year = now.getFullYear()
82
+ const month = String(now.getMonth() + 1).padStart(2, '0')
83
+ const day = String(now.getDate()).padStart(2, '0')
84
+ const weekDays = ['日', '一', '二', '三', '四', '五', '六']
85
+ const weekDay = `周${weekDays[now.getDay()]}`
86
+ const hour = now.getHours()
87
+ const minute = String(now.getMinutes()).padStart(2, '0')
88
+ const second = String(now.getSeconds()).padStart(2, '0')
89
+ const period = hour < 12 ? '上午' : '下午'
90
+ const hour12 = hour % 12 || 12
91
+ const formattedTime = `${year}.${month}.${day} ${weekDay} ${period} ${hour12}:${minute}:${second}`
92
+
93
+ // 构建 Markdown 格式的笔记信息
94
+ const backlink = `
95
+ - **${props.noteNumber}. ${props.noteTitle}**:[GitHub](${noteGithubUrl})、[GitHub Page](${notePageUrl})
96
+ - **${REPO_NAME}**:[GitHub](${repoGithubUrl})、[GitHub Page](${repoPageUrl})
97
+ - **评论创建时间**:${formattedTime}
98
+ `.trim()
99
+
100
+ console.log('[Discussions] 生成的 backlink:', backlink)
101
+ return backlink
102
+ })
103
+
104
+ // 动态注入 giscus backlink meta 标签
105
+ const updateGiscusBacklink = () => {
106
+ // 移除旧的 giscus:backlink meta 标签
107
+ const oldMeta = document.querySelector('meta[name="giscus:backlink"]')
108
+ if (oldMeta) {
109
+ oldMeta.remove()
110
+ }
111
+
112
+ // 添加新的 giscus:backlink meta 标签
113
+ const meta = document.createElement('meta')
114
+ meta.name = 'giscus:backlink'
115
+ meta.content = giscusBacklink.value
116
+ document.head.appendChild(meta)
117
+
118
+ console.log('[Discussions] 已添加 giscus:backlink meta 标签:', meta.content)
119
+ }
120
+
121
+ // 动态注入 giscus 评论脚本
122
+ const loadGiscusScript = () => {
123
+ // 更新 giscus:backlink meta 标签
124
+ updateGiscusBacklink()
125
+
126
+ // 清除旧的 giscus 脚本和 iframe
127
+ const oldScript = document.getElementById('giscus-script')
128
+ const oldIframe = document.querySelector('iframe.giscus-frame')
129
+ if (oldScript) oldScript.remove()
130
+ if (oldIframe) oldIframe.remove()
131
+
132
+ // 创建新的 giscus 脚本
133
+ const giscusScript = document.createElement('script')
134
+ giscusScript.src = 'https://giscus.app/client.js'
135
+ giscusScript.setAttribute('data-repo', 'tnotesjs/TNotes.discussions')
136
+ giscusScript.setAttribute('data-repo-id', 'R_kgDOQauuyw')
137
+ giscusScript.setAttribute('data-category', 'Announcements')
138
+ giscusScript.setAttribute('data-category-id', 'DIC_kwDOQauuy84CyEuQ')
139
+ giscusScript.setAttribute('data-mapping', 'specific')
140
+ giscusScript.setAttribute('data-term', props.id)
141
+ giscusScript.setAttribute('data-strict', '0')
142
+ giscusScript.setAttribute('data-reactions-enabled', '1')
143
+ giscusScript.setAttribute('data-emit-metadata', '0')
144
+ giscusScript.setAttribute('data-input-position', 'top')
145
+ giscusScript.setAttribute('data-lang', 'zh-CN')
146
+ giscusScript.setAttribute('data-loading', 'lazy')
147
+ giscusScript.setAttribute(
148
+ 'data-theme',
149
+ isDark.value ? GISCUS_DARK_THEME : GISCUS_LIGHT_THEME
150
+ )
151
+ giscusScript.setAttribute('crossorigin', 'anonymous')
152
+ giscusScript.async = true
153
+ giscusScript.id = 'giscus-script'
154
+
155
+ document.getElementById('giscus-comments')?.appendChild(giscusScript)
156
+ }
157
+
158
+ onMounted(() => {
159
+ loadGiscusScript()
160
+ })
161
+
162
+ onUnmounted(() => {
163
+ // 组件卸载时移除 giscus:backlink meta 标签
164
+ const meta = document.querySelector('meta[name="giscus:backlink"]')
165
+ if (meta) {
166
+ meta.remove()
167
+ }
168
+ })
169
+
170
+ watch([() => props.id], ([newId]) => {
171
+ loadGiscusScript()
172
+ })
173
+
174
+ // 切换主题的时候,动态修改 giscus 评论主题,不需要重新 loadGiscusScript。
175
+ watch(isDark, (newVal) => {
176
+ const iframe = document.querySelector<HTMLIFrameElement>(
177
+ 'iframe.giscus-frame'
178
+ )
179
+ if (iframe) {
180
+ iframe.contentWindow?.postMessage(
181
+ {
182
+ giscus: {
183
+ setConfig: {
184
+ theme: newVal ? GISCUS_DARK_THEME : GISCUS_LIGHT_THEME,
185
+ },
186
+ },
187
+ },
188
+ 'https://giscus.app'
189
+ )
190
+ }
191
+ })
192
+ </script>
193
+
194
+ <template>
195
+ <h2 :class="$style.h2">
196
+ <Tooltip text="在 GitHub 上发表评论(支持上传图片)">
197
+ <a
198
+ :href="githubDiscussionsUrl"
199
+ target="_blank"
200
+ rel="noopener noreferrer"
201
+ :class="$style.discussionsLink"
202
+ >
203
+ <img :src="icon__github" alt="" :class="$style.githubIcon" />
204
+ Discussions
205
+ </a>
206
+ </Tooltip>
207
+ </h2>
208
+ <div id="giscus-comments"></div>
209
+ </template>
210
+
211
+ <style module src="./Discussions.module.scss"></style>
@@ -0,0 +1,124 @@
1
+ /**
2
+ * .vitepress/components/EnWordList/EnWordList.module.scss
3
+ *
4
+ * EnWordList 组件样式
5
+ */
6
+
7
+ .enWordList {
8
+ // Checkbox 样式
9
+ input[type='checkbox'] {
10
+ margin: 8px;
11
+ transform: scale(1.3);
12
+ cursor: pointer;
13
+ }
14
+
15
+ // 链接样式
16
+ a {
17
+ text-decoration: none;
18
+ color: #4fc3f7;
19
+
20
+ &:hover {
21
+ text-decoration: underline !important;
22
+ }
23
+
24
+ &.lineThrough {
25
+ color: #999;
26
+ text-decoration: line-through;
27
+ }
28
+
29
+ &.textRed {
30
+ color: #f40 !important;
31
+ }
32
+ }
33
+
34
+ // 单词列表样式
35
+ ol {
36
+ list-style-type: decimal;
37
+ padding-left: 20px;
38
+
39
+ li {
40
+ display: flex;
41
+ align-items: center;
42
+ margin-bottom: 8px;
43
+ transition: all 0.3s ease;
44
+
45
+ &.pronounced {
46
+ background-color: rgba(255, 255, 0, 0.1);
47
+ }
48
+ }
49
+ }
50
+
51
+ // 序号样式
52
+ .index {
53
+ margin-right: 10px;
54
+ color: #aaa;
55
+ }
56
+ }
57
+
58
+ // 单词卡片样式(🌑 暗色悬浮卡片)
59
+ .wordCard {
60
+ position: fixed;
61
+ z-index: 9999;
62
+ background: #1e1e1e;
63
+ border: 1px solid #333;
64
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
65
+ padding: 12px 16px;
66
+ max-width: 600px;
67
+ min-width: 200px;
68
+ min-height: 100px;
69
+ font-size: 14px;
70
+ line-height: 1.4;
71
+ border-radius: 8px;
72
+ color: #eee;
73
+ pointer-events: auto;
74
+ font-family: sans-serif;
75
+ cursor: move;
76
+
77
+ // 关闭按钮
78
+ .closeBtn {
79
+ position: absolute;
80
+ right: 5px;
81
+ top: 5px;
82
+ background: none;
83
+ border: none;
84
+ font-size: 16px;
85
+ cursor: pointer;
86
+ color: #ccc;
87
+
88
+ &:hover {
89
+ color: white;
90
+ }
91
+ }
92
+ }
93
+
94
+ // 卡片内容包裹器
95
+ .wordCardContentWrapper {
96
+ width: 100%;
97
+ height: 100%;
98
+ overflow: auto;
99
+ }
100
+
101
+ // 卡片内容样式
102
+ .wordCardContent {
103
+ :deep(ul) {
104
+ margin: 0.5rem 0;
105
+ padding-left: 1rem;
106
+ }
107
+ }
108
+
109
+ // 调整大小手柄
110
+ .resizeHandle {
111
+ position: absolute;
112
+ right: 0;
113
+ bottom: 0;
114
+ width: 12px;
115
+ height: 12px;
116
+ background-color: #666;
117
+ cursor: nwse-resize;
118
+ z-index: 2;
119
+ border-radius: 50%;
120
+
121
+ &:hover {
122
+ background-color: #aaa;
123
+ }
124
+ }