@tnotesjs/core 0.0.3 → 0.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tnotesjs/core",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "TNotes 知识库核心框架 —— 基于 VitePress 的笔记管理系统",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,11 +25,21 @@
25
25
  </template>
26
26
 
27
27
  <script setup lang="ts">
28
- import { computed } from 'vue'
28
+ import { computed, ref, onMounted } from 'vue'
29
29
  import { useRoute, useData } from 'vitepress'
30
+ import { SIDEBAR_SHOW_NOTE_ID_KEY } from '../constants'
30
31
  // @ts-expect-error - VitePress Data Loader
31
32
  import { data as sidebarConfig } from '../sidebar.data'
32
33
 
34
+ const showNoteId = ref(false)
35
+
36
+ onMounted(() => {
37
+ const saved = localStorage.getItem(SIDEBAR_SHOW_NOTE_ID_KEY)
38
+ if (saved !== null) {
39
+ showNoteId.value = saved === 'true'
40
+ }
41
+ })
42
+
33
43
  interface NavItem {
34
44
  link: string
35
45
  title: string
@@ -89,13 +99,11 @@ function extractEmojiAndTitle(text: string): { emoji: string; title: string } {
89
99
  if (emojiMatch) {
90
100
  const emoji = emojiMatch[1]
91
101
  const rest = text.slice(emojiMatch[0].length)
92
- // 移除笔记编号(如 "0001. ")
93
- const title = rest.replace(/^\d{4}\.\s*/, '')
102
+ const title = showNoteId.value ? rest : rest.replace(/^\d{4}\.\s*/, '')
94
103
  return { emoji, title }
95
104
  }
96
105
 
97
- // 没有 emoji,只移除编号
98
- const title = text.replace(/^\d{4}\.\s*/, '')
106
+ const title = showNoteId.value ? text : text.replace(/^\d{4}\.\s*/, '')
99
107
  return { emoji: '', title }
100
108
  }
101
109