@tnotesjs/core 0.1.22 → 0.1.24

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.
Files changed (101) hide show
  1. package/README.md +87 -87
  2. package/package.json +1 -1
  3. package/types/config.ts +60 -60
  4. package/types/index.ts +11 -11
  5. package/types/note.ts +33 -33
  6. package/vitepress/assets/icons/icon__check.svg +3 -3
  7. package/vitepress/assets/icons/icon__clipboard.svg +7 -7
  8. package/vitepress/assets/icons/icon__close.svg +1 -1
  9. package/vitepress/assets/icons/icon__collapse.svg +1 -1
  10. package/vitepress/assets/icons/icon__confirm.svg +1 -1
  11. package/vitepress/assets/icons/icon__copy.svg +4 -4
  12. package/vitepress/assets/icons/icon__focus.svg +1 -1
  13. package/vitepress/assets/icons/icon__fold.svg +3 -3
  14. package/vitepress/assets/icons/icon__folder.svg +1 -1
  15. package/vitepress/assets/icons/icon__fullscreen.svg +1 -1
  16. package/vitepress/assets/icons/icon__fullscreen_exit.svg +1 -1
  17. package/vitepress/assets/icons/icon__github.svg +3 -3
  18. package/vitepress/assets/icons/icon__mindmap.svg +1 -1
  19. package/vitepress/assets/icons/icon__next.svg +1 -1
  20. package/vitepress/assets/icons/icon__number_gray.svg +1 -1
  21. package/vitepress/assets/icons/icon__number_purple.svg +1 -1
  22. package/vitepress/assets/icons/icon__prev.svg +1 -1
  23. package/vitepress/assets/icons/icon__restore.svg +1 -1
  24. package/vitepress/assets/icons/icon__rotate.svg +4 -4
  25. package/vitepress/assets/icons/icon__search.svg +1 -1
  26. package/vitepress/assets/icons/icon__sidebar_collapsed.svg +1 -1
  27. package/vitepress/assets/icons/icon__sidebar_opened.svg +1 -1
  28. package/vitepress/assets/icons/icon__totop.svg +5 -5
  29. package/vitepress/assets/icons/icon__vscode.svg +5 -5
  30. package/vitepress/assets/icons/icon__zoom_fit.svg +1 -1
  31. package/vitepress/assets/icons/icon__zoom_in.svg +1 -1
  32. package/vitepress/assets/icons/icon__zoom_out.svg +1 -1
  33. package/vitepress/assets/icons/icon__zoom_reset.svg +1 -1
  34. package/vitepress/assets/icons/index.ts +39 -39
  35. package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +20 -20
  36. package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +369 -369
  37. package/vitepress/components/CodeBlockFullscreen/index.ts +209 -209
  38. package/vitepress/components/CodeBlockFullscreen/styles.css +126 -126
  39. package/vitepress/components/Discussions/Discussions.vue +242 -242
  40. package/vitepress/components/EnWordList/EnWordList.vue +664 -664
  41. package/vitepress/components/EnWordList/RightClickMenu.vue +87 -87
  42. package/vitepress/components/Footprints/Footprints.vue +472 -472
  43. package/vitepress/components/Layout/AboutModal.vue +329 -329
  44. package/vitepress/components/Layout/AboutPanel.vue +485 -485
  45. package/vitepress/components/Layout/ContentCollapse.vue +591 -591
  46. package/vitepress/components/Layout/CustomSidebar.vue +817 -817
  47. package/vitepress/components/Layout/DocBeforeControls.vue +145 -145
  48. package/vitepress/components/Layout/DocFooter.vue +233 -233
  49. package/vitepress/components/Layout/ImagePreview.vue +485 -485
  50. package/vitepress/components/Layout/Layout.vue +744 -744
  51. package/vitepress/components/Layout/NoteStatus.vue +140 -140
  52. package/vitepress/components/Layout/SidebarItems.vue +1083 -1083
  53. package/vitepress/components/Layout/SidebarNavBefore.vue +170 -170
  54. package/vitepress/components/Layout/SidebarResizeHandle.vue +368 -311
  55. package/vitepress/components/Layout/Swiper.vue +167 -167
  56. package/vitepress/components/Layout/ToggleFullContent.vue +45 -45
  57. package/vitepress/components/Layout/ToggleSidebar.vue +35 -35
  58. package/vitepress/components/Layout/composables/useCollapseControl.ts +88 -88
  59. package/vitepress/components/Layout/composables/useNoteConfig.ts +119 -119
  60. package/vitepress/components/Layout/composables/useNoteSave.ts +178 -178
  61. package/vitepress/components/Layout/composables/useNoteValidation.ts +85 -85
  62. package/vitepress/components/Layout/composables/useRedirect.ts +113 -113
  63. package/vitepress/components/Layout/composables/useSidebarLayout.ts +122 -122
  64. package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +85 -85
  65. package/vitepress/components/Layout/homeReadme.data.ts +124 -124
  66. package/vitepress/components/MarkMap/MarkMap.vue +562 -562
  67. package/vitepress/components/Mermaid/Mermaid.vue +644 -644
  68. package/vitepress/components/NotesTable/NotesTable.vue +175 -175
  69. package/vitepress/components/NotesTable/README.md +67 -67
  70. package/vitepress/components/Settings/Settings.vue +711 -711
  71. package/vitepress/components/SidebarCard/MindMapView.vue +484 -484
  72. package/vitepress/components/SidebarCard/NotesTrendChart.vue +108 -108
  73. package/vitepress/components/SidebarCard/SidebarCard.vue +945 -945
  74. package/vitepress/components/Tooltip/Tooltip.vue +70 -70
  75. package/vitepress/components/constants.ts +109 -109
  76. package/vitepress/components/notesConfig.data.ts +73 -73
  77. package/vitepress/components/sidebar.data.ts +59 -59
  78. package/vitepress/components/tnotes-config.data.ts +21 -21
  79. package/vitepress/components/utils.ts +26 -26
  80. package/vitepress/config/index.ts +169 -169
  81. package/vitepress/configs/constants.ts +26 -26
  82. package/vitepress/configs/head.config.ts +25 -25
  83. package/vitepress/configs/index.ts +9 -9
  84. package/vitepress/configs/markdown-it.d.ts +23 -23
  85. package/vitepress/configs/markdown.config.ts +368 -368
  86. package/vitepress/configs/theme.config.ts +108 -108
  87. package/vitepress/plugins/buildProgressPlugin.ts +434 -434
  88. package/vitepress/plugins/getNoteByConfigIdPlugin.ts +107 -107
  89. package/vitepress/plugins/renameNotePlugin.ts +68 -68
  90. package/vitepress/plugins/sidebarStructurePlugin.ts +260 -260
  91. package/vitepress/plugins/updateConfigPlugin.ts +63 -63
  92. package/vitepress/theme/index.ts +137 -137
  93. package/vitepress/theme/styles/base.scss +66 -64
  94. package/vitepress/theme/styles/components/404.scss +31 -31
  95. package/vitepress/theme/styles/components/collapse.scss +172 -172
  96. package/vitepress/theme/styles/components/markmap.scss +101 -101
  97. package/vitepress/theme/styles/components/swiper.scss +255 -255
  98. package/vitepress/theme/styles/index.scss +25 -25
  99. package/vitepress/theme/styles/layout.scss +79 -78
  100. package/vitepress/theme/styles/utilities.scss +39 -39
  101. package/vitepress/theme/styles/vitepress-override.scss +25 -25
@@ -1,178 +1,178 @@
1
- import { useData } from 'vitepress'
2
- import { ref, computed } from 'vue'
3
-
4
- import { redirectAfterRename } from './useRenameRedirect'
5
-
6
- import type { NoteConfig } from '../../../../types'
7
- import type { Ref, ComputedRef } from 'vue'
8
-
9
- /**
10
- * 处理笔记配置的保存和重置逻辑
11
- */
12
- export function useNoteSave(
13
- currentNoteId: Ref<string>,
14
- isDev: Ref<boolean> | ComputedRef<boolean>,
15
- hasConfigChanges: ComputedRef<boolean>,
16
- titleError: Ref<string>,
17
- editableNoteTitle: Ref<string>,
18
- originalNoteTitle: Ref<string>,
19
- editableNoteStatus: Ref<boolean>,
20
- originalNoteStatus: Ref<boolean>,
21
- editableDiscussionsEnabled: Ref<boolean>,
22
- originalDiscussionsEnabled: Ref<boolean>,
23
- editableDescription: Ref<string>,
24
- originalDescription: Ref<string>,
25
- allNotesConfig: Record<string, NoteConfig & { redirect?: string }>,
26
- updateOriginalValues: () => void
27
- ) {
28
- const vpData = useData()
29
-
30
- // 保存状态
31
- const isSaving = ref(false)
32
- const showSuccessToast = ref(false)
33
- const savingMessage = ref('') // 保存进度提示
34
-
35
- // 保存按钮文本
36
- const saveButtonText = computed(() => {
37
- if (isSaving.value) return '保存中...'
38
- if (!hasConfigChanges.value) return '无更改'
39
- return '保存配置'
40
- })
41
-
42
- // 保存笔记配置
43
- async function saveNoteConfig() {
44
- if (!currentNoteId.value || !isDev.value || !hasConfigChanges.value) return
45
-
46
- // 验证标题
47
- if (titleError.value) {
48
- alert('❌ 请修正标题错误后再保存')
49
- return
50
- }
51
-
52
- const titleChanged =
53
- editableNoteTitle.value.trim() !== originalNoteTitle.value &&
54
- editableNoteTitle.value.trim()
55
-
56
- isSaving.value = true
57
- savingMessage.value = '正在保存配置...'
58
-
59
- let renameNewUrl: string | null = null
60
-
61
- try {
62
- // 如果标题有变化,先重命名文件夹
63
- if (titleChanged) {
64
- savingMessage.value = '正在重命名文件夹...'
65
-
66
- const renameResponse = await fetch('/__tnotes_rename_note', {
67
- method: 'POST',
68
- headers: {
69
- 'Content-Type': 'application/json',
70
- },
71
- body: JSON.stringify({
72
- noteIndex: currentNoteId.value,
73
- newTitle: editableNoteTitle.value.trim(),
74
- }),
75
- })
76
-
77
- if (!renameResponse.ok) {
78
- const error = await renameResponse.text()
79
- throw new Error(`重命名失败: ${error}`)
80
- }
81
-
82
- // 后端已经完成所有更新(含文件系统、根 README、sidebar)
83
- const result = (await renameResponse.json()) as {
84
- success: boolean
85
- newUrl?: string
86
- }
87
-
88
- if (!result?.newUrl) {
89
- throw new Error('重命名响应缺少 newUrl 字段')
90
- }
91
-
92
- renameNewUrl = result.newUrl
93
- savingMessage.value = '文件已同步,准备跳转...'
94
- }
95
-
96
- // 检查是否需要更新配置(无论标题是否改变)
97
- const needConfigUpdate =
98
- editableNoteStatus.value !== originalNoteStatus.value ||
99
- editableDiscussionsEnabled.value !== originalDiscussionsEnabled.value ||
100
- editableDescription.value.trim() !== originalDescription.value
101
-
102
- if (needConfigUpdate) {
103
- savingMessage.value = '正在更新笔记配置...'
104
-
105
- const response = await fetch('/__tnotes_update_config', {
106
- method: 'POST',
107
- headers: {
108
- 'Content-Type': 'application/json',
109
- },
110
- body: JSON.stringify({
111
- noteIndex: currentNoteId.value,
112
- config: {
113
- done: editableNoteStatus.value,
114
- enableDiscussions: editableDiscussionsEnabled.value,
115
- description: editableDescription.value.trim(),
116
- },
117
- }),
118
- })
119
-
120
- if (!response.ok) {
121
- const error = await response.text()
122
- throw new Error(error || '保存失败')
123
- }
124
- }
125
-
126
- // 更新原始值
127
- updateOriginalValues()
128
-
129
- // 更新本地配置(立即反映在页面上)
130
- if (allNotesConfig[currentNoteId.value]) {
131
- allNotesConfig[currentNoteId.value].done = editableNoteStatus.value
132
- allNotesConfig[currentNoteId.value].enableDiscussions =
133
- editableDiscussionsEnabled.value
134
- allNotesConfig[currentNoteId.value].description =
135
- editableDescription.value.trim()
136
- }
137
-
138
- savingMessage.value = '保存成功!'
139
-
140
- // 显示成功提示
141
- showSuccessToast.value = true
142
- setTimeout(() => {
143
- showSuccessToast.value = false
144
- }, 3000)
145
-
146
- // 如果标题改变了, 显示遮罩并整页跳到新 URL
147
- if (titleChanged && renameNewUrl) {
148
- // 提前结束「保存中」状态,避免遮罩退出后按钮文案残留
149
- isSaving.value = false
150
- savingMessage.value = ''
151
-
152
- const base = vpData.site.value.base || '/'
153
- await redirectAfterRename(renameNewUrl, { base })
154
- }
155
- } catch (error) {
156
- console.error('保存配置失败:', error)
157
- savingMessage.value = ''
158
-
159
- alert(
160
- '❌ 保存失败: ' +
161
- (error instanceof Error ? error.message : String(error))
162
- )
163
- } finally {
164
- if (!titleChanged) {
165
- isSaving.value = false
166
- savingMessage.value = ''
167
- }
168
- }
169
- }
170
-
171
- return {
172
- isSaving,
173
- showSuccessToast,
174
- savingMessage,
175
- saveButtonText,
176
- saveNoteConfig,
177
- }
178
- }
1
+ import { useData } from 'vitepress'
2
+ import { ref, computed } from 'vue'
3
+
4
+ import { redirectAfterRename } from './useRenameRedirect'
5
+
6
+ import type { NoteConfig } from '../../../../types'
7
+ import type { Ref, ComputedRef } from 'vue'
8
+
9
+ /**
10
+ * 处理笔记配置的保存和重置逻辑
11
+ */
12
+ export function useNoteSave(
13
+ currentNoteId: Ref<string>,
14
+ isDev: Ref<boolean> | ComputedRef<boolean>,
15
+ hasConfigChanges: ComputedRef<boolean>,
16
+ titleError: Ref<string>,
17
+ editableNoteTitle: Ref<string>,
18
+ originalNoteTitle: Ref<string>,
19
+ editableNoteStatus: Ref<boolean>,
20
+ originalNoteStatus: Ref<boolean>,
21
+ editableDiscussionsEnabled: Ref<boolean>,
22
+ originalDiscussionsEnabled: Ref<boolean>,
23
+ editableDescription: Ref<string>,
24
+ originalDescription: Ref<string>,
25
+ allNotesConfig: Record<string, NoteConfig & { redirect?: string }>,
26
+ updateOriginalValues: () => void
27
+ ) {
28
+ const vpData = useData()
29
+
30
+ // 保存状态
31
+ const isSaving = ref(false)
32
+ const showSuccessToast = ref(false)
33
+ const savingMessage = ref('') // 保存进度提示
34
+
35
+ // 保存按钮文本
36
+ const saveButtonText = computed(() => {
37
+ if (isSaving.value) return '保存中...'
38
+ if (!hasConfigChanges.value) return '无更改'
39
+ return '保存配置'
40
+ })
41
+
42
+ // 保存笔记配置
43
+ async function saveNoteConfig() {
44
+ if (!currentNoteId.value || !isDev.value || !hasConfigChanges.value) return
45
+
46
+ // 验证标题
47
+ if (titleError.value) {
48
+ alert('❌ 请修正标题错误后再保存')
49
+ return
50
+ }
51
+
52
+ const titleChanged =
53
+ editableNoteTitle.value.trim() !== originalNoteTitle.value &&
54
+ editableNoteTitle.value.trim()
55
+
56
+ isSaving.value = true
57
+ savingMessage.value = '正在保存配置...'
58
+
59
+ let renameNewUrl: string | null = null
60
+
61
+ try {
62
+ // 如果标题有变化,先重命名文件夹
63
+ if (titleChanged) {
64
+ savingMessage.value = '正在重命名文件夹...'
65
+
66
+ const renameResponse = await fetch('/__tnotes_rename_note', {
67
+ method: 'POST',
68
+ headers: {
69
+ 'Content-Type': 'application/json',
70
+ },
71
+ body: JSON.stringify({
72
+ noteIndex: currentNoteId.value,
73
+ newTitle: editableNoteTitle.value.trim(),
74
+ }),
75
+ })
76
+
77
+ if (!renameResponse.ok) {
78
+ const error = await renameResponse.text()
79
+ throw new Error(`重命名失败: ${error}`)
80
+ }
81
+
82
+ // 后端已经完成所有更新(含文件系统、根 README、sidebar)
83
+ const result = (await renameResponse.json()) as {
84
+ success: boolean
85
+ newUrl?: string
86
+ }
87
+
88
+ if (!result?.newUrl) {
89
+ throw new Error('重命名响应缺少 newUrl 字段')
90
+ }
91
+
92
+ renameNewUrl = result.newUrl
93
+ savingMessage.value = '文件已同步,准备跳转...'
94
+ }
95
+
96
+ // 检查是否需要更新配置(无论标题是否改变)
97
+ const needConfigUpdate =
98
+ editableNoteStatus.value !== originalNoteStatus.value ||
99
+ editableDiscussionsEnabled.value !== originalDiscussionsEnabled.value ||
100
+ editableDescription.value.trim() !== originalDescription.value
101
+
102
+ if (needConfigUpdate) {
103
+ savingMessage.value = '正在更新笔记配置...'
104
+
105
+ const response = await fetch('/__tnotes_update_config', {
106
+ method: 'POST',
107
+ headers: {
108
+ 'Content-Type': 'application/json',
109
+ },
110
+ body: JSON.stringify({
111
+ noteIndex: currentNoteId.value,
112
+ config: {
113
+ done: editableNoteStatus.value,
114
+ enableDiscussions: editableDiscussionsEnabled.value,
115
+ description: editableDescription.value.trim(),
116
+ },
117
+ }),
118
+ })
119
+
120
+ if (!response.ok) {
121
+ const error = await response.text()
122
+ throw new Error(error || '保存失败')
123
+ }
124
+ }
125
+
126
+ // 更新原始值
127
+ updateOriginalValues()
128
+
129
+ // 更新本地配置(立即反映在页面上)
130
+ if (allNotesConfig[currentNoteId.value]) {
131
+ allNotesConfig[currentNoteId.value].done = editableNoteStatus.value
132
+ allNotesConfig[currentNoteId.value].enableDiscussions =
133
+ editableDiscussionsEnabled.value
134
+ allNotesConfig[currentNoteId.value].description =
135
+ editableDescription.value.trim()
136
+ }
137
+
138
+ savingMessage.value = '保存成功!'
139
+
140
+ // 显示成功提示
141
+ showSuccessToast.value = true
142
+ setTimeout(() => {
143
+ showSuccessToast.value = false
144
+ }, 3000)
145
+
146
+ // 如果标题改变了, 显示遮罩并整页跳到新 URL
147
+ if (titleChanged && renameNewUrl) {
148
+ // 提前结束「保存中」状态,避免遮罩退出后按钮文案残留
149
+ isSaving.value = false
150
+ savingMessage.value = ''
151
+
152
+ const base = vpData.site.value.base || '/'
153
+ await redirectAfterRename(renameNewUrl, { base })
154
+ }
155
+ } catch (error) {
156
+ console.error('保存配置失败:', error)
157
+ savingMessage.value = ''
158
+
159
+ alert(
160
+ '❌ 保存失败: ' +
161
+ (error instanceof Error ? error.message : String(error))
162
+ )
163
+ } finally {
164
+ if (!titleChanged) {
165
+ isSaving.value = false
166
+ savingMessage.value = ''
167
+ }
168
+ }
169
+ }
170
+
171
+ return {
172
+ isSaving,
173
+ showSuccessToast,
174
+ savingMessage,
175
+ saveButtonText,
176
+ saveNoteConfig,
177
+ }
178
+ }
@@ -1,85 +1,85 @@
1
- import type { Ref } from 'vue'
2
-
3
- /**
4
- * 笔记标题验证
5
- */
6
- export function useNoteValidation() {
7
- // 标题验证函数
8
- function validateTitle(title: string): string | null {
9
- // 非法字符正则
10
- const invalidChars = /[<>:"/\\|?*\x00-\x1F]/
11
- const windowsReservedNames = new Set([
12
- 'CON',
13
- 'PRN',
14
- 'AUX',
15
- 'NUL',
16
- 'COM1',
17
- 'COM2',
18
- 'COM3',
19
- 'COM4',
20
- 'COM5',
21
- 'COM6',
22
- 'COM7',
23
- 'COM8',
24
- 'COM9',
25
- 'LPT1',
26
- 'LPT2',
27
- 'LPT3',
28
- 'LPT4',
29
- 'LPT5',
30
- 'LPT6',
31
- 'LPT7',
32
- 'LPT8',
33
- 'LPT9',
34
- ])
35
-
36
- if (!title || title.trim().length === 0) {
37
- return '标题不能为空'
38
- }
39
-
40
- const trimmedTitle = title.trim()
41
-
42
- if (trimmedTitle.length > 200) {
43
- return '标题过长(最多200个字符)'
44
- }
45
-
46
- if (invalidChars.test(trimmedTitle)) {
47
- return '标题包含非法字符(不允许: < > : " / \\ | ? *)'
48
- }
49
-
50
- if (/^[.\s]|[.\s]$/.test(trimmedTitle)) {
51
- return '标题不能以点或空格开头/结尾'
52
- }
53
-
54
- const upperTitle = trimmedTitle.toUpperCase()
55
- if (windowsReservedNames.has(upperTitle)) {
56
- return `"${trimmedTitle}" 是 Windows 系统保留名称`
57
- }
58
-
59
- const baseName = trimmedTitle.split('.')[0].toUpperCase()
60
- if (windowsReservedNames.has(baseName)) {
61
- return `"${trimmedTitle}" 包含 Windows 系统保留名称`
62
- }
63
-
64
- return null
65
- }
66
-
67
- // 标题输入事件处理器
68
- function onTitleInput(editableNoteTitle: Ref<string>, titleError: Ref<string>) {
69
- const error = validateTitle(editableNoteTitle.value)
70
- titleError.value = error || ''
71
- }
72
-
73
- // 标题失焦事件处理器
74
- function onTitleBlur(editableNoteTitle: Ref<string>, titleError: Ref<string>) {
75
- // 去除首尾空格
76
- editableNoteTitle.value = editableNoteTitle.value.trim()
77
- onTitleInput(editableNoteTitle, titleError)
78
- }
79
-
80
- return {
81
- validateTitle,
82
- onTitleInput,
83
- onTitleBlur,
84
- }
85
- }
1
+ import type { Ref } from 'vue'
2
+
3
+ /**
4
+ * 笔记标题验证
5
+ */
6
+ export function useNoteValidation() {
7
+ // 标题验证函数
8
+ function validateTitle(title: string): string | null {
9
+ // 非法字符正则
10
+ const invalidChars = /[<>:"/\\|?*\x00-\x1F]/
11
+ const windowsReservedNames = new Set([
12
+ 'CON',
13
+ 'PRN',
14
+ 'AUX',
15
+ 'NUL',
16
+ 'COM1',
17
+ 'COM2',
18
+ 'COM3',
19
+ 'COM4',
20
+ 'COM5',
21
+ 'COM6',
22
+ 'COM7',
23
+ 'COM8',
24
+ 'COM9',
25
+ 'LPT1',
26
+ 'LPT2',
27
+ 'LPT3',
28
+ 'LPT4',
29
+ 'LPT5',
30
+ 'LPT6',
31
+ 'LPT7',
32
+ 'LPT8',
33
+ 'LPT9',
34
+ ])
35
+
36
+ if (!title || title.trim().length === 0) {
37
+ return '标题不能为空'
38
+ }
39
+
40
+ const trimmedTitle = title.trim()
41
+
42
+ if (trimmedTitle.length > 200) {
43
+ return '标题过长(最多200个字符)'
44
+ }
45
+
46
+ if (invalidChars.test(trimmedTitle)) {
47
+ return '标题包含非法字符(不允许: < > : " / \\ | ? *)'
48
+ }
49
+
50
+ if (/^[.\s]|[.\s]$/.test(trimmedTitle)) {
51
+ return '标题不能以点或空格开头/结尾'
52
+ }
53
+
54
+ const upperTitle = trimmedTitle.toUpperCase()
55
+ if (windowsReservedNames.has(upperTitle)) {
56
+ return `"${trimmedTitle}" 是 Windows 系统保留名称`
57
+ }
58
+
59
+ const baseName = trimmedTitle.split('.')[0].toUpperCase()
60
+ if (windowsReservedNames.has(baseName)) {
61
+ return `"${trimmedTitle}" 包含 Windows 系统保留名称`
62
+ }
63
+
64
+ return null
65
+ }
66
+
67
+ // 标题输入事件处理器
68
+ function onTitleInput(editableNoteTitle: Ref<string>, titleError: Ref<string>) {
69
+ const error = validateTitle(editableNoteTitle.value)
70
+ titleError.value = error || ''
71
+ }
72
+
73
+ // 标题失焦事件处理器
74
+ function onTitleBlur(editableNoteTitle: Ref<string>, titleError: Ref<string>) {
75
+ // 去除首尾空格
76
+ editableNoteTitle.value = editableNoteTitle.value.trim()
77
+ onTitleInput(editableNoteTitle, titleError)
78
+ }
79
+
80
+ return {
81
+ validateTitle,
82
+ onTitleInput,
83
+ onTitleBlur,
84
+ }
85
+ }