@tnotesjs/core 0.0.1
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 +84 -0
- package/dist/chunk-CSSIRO3I.js +4288 -0
- package/dist/chunk-NASIL5FY.js +203 -0
- package/dist/cli/index.js +694 -0
- package/dist/index.js +8 -0
- package/dist/vitepress/config/index.js +904 -0
- package/package.json +77 -0
- package/types/config.ts +61 -0
- package/types/index.ts +11 -0
- package/types/note.ts +33 -0
- package/types/shims.d.ts +10 -0
- package/vitepress/assets/icons/icon__check.svg +3 -0
- package/vitepress/assets/icons/icon__clipboard.svg +8 -0
- package/vitepress/assets/icons/icon__close.svg +1 -0
- package/vitepress/assets/icons/icon__collapse.svg +1 -0
- package/vitepress/assets/icons/icon__confirm.svg +1 -0
- package/vitepress/assets/icons/icon__copy.svg +4 -0
- package/vitepress/assets/icons/icon__focus.svg +1 -0
- package/vitepress/assets/icons/icon__fold.svg +3 -0
- package/vitepress/assets/icons/icon__folder.svg +1 -0
- package/vitepress/assets/icons/icon__fullscreen.svg +1 -0
- package/vitepress/assets/icons/icon__fullscreen_exit.svg +1 -0
- package/vitepress/assets/icons/icon__github.svg +4 -0
- package/vitepress/assets/icons/icon__mindmap.svg +1 -0
- package/vitepress/assets/icons/icon__next.svg +1 -0
- package/vitepress/assets/icons/icon__number_gray.svg +1 -0
- package/vitepress/assets/icons/icon__number_purple.svg +1 -0
- package/vitepress/assets/icons/icon__prev.svg +1 -0
- package/vitepress/assets/icons/icon__restore.svg +1 -0
- package/vitepress/assets/icons/icon__rotate.svg +4 -0
- package/vitepress/assets/icons/icon__search.svg +1 -0
- package/vitepress/assets/icons/icon__sidebar_collapsed.svg +1 -0
- package/vitepress/assets/icons/icon__sidebar_opened.svg +1 -0
- package/vitepress/assets/icons/icon__totop.svg +6 -0
- package/vitepress/assets/icons/icon__vscode.svg +6 -0
- package/vitepress/assets/icons/icon__zoom_fit.svg +1 -0
- package/vitepress/assets/icons/icon__zoom_in.svg +1 -0
- package/vitepress/assets/icons/icon__zoom_out.svg +1 -0
- package/vitepress/assets/icons/icon__zoom_reset.svg +1 -0
- package/vitepress/assets/icons/index.ts +38 -0
- package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +20 -0
- package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +373 -0
- package/vitepress/components/CodeBlockFullscreen/index.ts +115 -0
- package/vitepress/components/CodeBlockFullscreen/styles.css +64 -0
- package/vitepress/components/Discussions/Discussions.module.scss +32 -0
- package/vitepress/components/Discussions/Discussions.vue +211 -0
- package/vitepress/components/EnWordList/EnWordList.module.scss +124 -0
- package/vitepress/components/EnWordList/EnWordList.vue +543 -0
- package/vitepress/components/EnWordList/RightClickMenu.module.scss +22 -0
- package/vitepress/components/EnWordList/RightClickMenu.vue +66 -0
- package/vitepress/components/Footprints/Footprints.module.scss +93 -0
- package/vitepress/components/Footprints/Footprints.vue +377 -0
- package/vitepress/components/Layout/AboutModal.module.scss +233 -0
- package/vitepress/components/Layout/AboutModal.vue +105 -0
- package/vitepress/components/Layout/AboutPanel.vue +266 -0
- package/vitepress/components/Layout/ContentCollapse.vue +603 -0
- package/vitepress/components/Layout/CustomSidebar.vue +605 -0
- package/vitepress/components/Layout/DocBeforeControls.vue +139 -0
- package/vitepress/components/Layout/DocFooter.vue +225 -0
- package/vitepress/components/Layout/ImagePreview.module.scss +201 -0
- package/vitepress/components/Layout/ImagePreview.vue +281 -0
- package/vitepress/components/Layout/Layout.module.scss +661 -0
- package/vitepress/components/Layout/Layout.vue +542 -0
- package/vitepress/components/Layout/NoteStatus.vue +140 -0
- package/vitepress/components/Layout/SidebarItems.vue +263 -0
- package/vitepress/components/Layout/SidebarNavBefore.vue +92 -0
- package/vitepress/components/Layout/Swiper.vue +167 -0
- package/vitepress/components/Layout/ToggleFullContent.module.scss +11 -0
- package/vitepress/components/Layout/ToggleFullContent.vue +34 -0
- package/vitepress/components/Layout/ToggleSidebar.module.scss +11 -0
- package/vitepress/components/Layout/ToggleSidebar.vue +35 -0
- package/vitepress/components/Layout/composables/useCollapseControl.ts +88 -0
- package/vitepress/components/Layout/composables/useNoteConfig.ts +121 -0
- package/vitepress/components/Layout/composables/useNoteSave.ts +173 -0
- package/vitepress/components/Layout/composables/useNoteValidation.ts +85 -0
- package/vitepress/components/Layout/composables/useRedirect.ts +110 -0
- package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +85 -0
- package/vitepress/components/Layout/homeReadme.data.ts +124 -0
- package/vitepress/components/LoadingPage/LoadingPage.vue +192 -0
- package/vitepress/components/MarkMap/MarkMap.module.scss +159 -0
- package/vitepress/components/MarkMap/MarkMap.vue +404 -0
- package/vitepress/components/Mermaid/Mermaid.module.scss +275 -0
- package/vitepress/components/Mermaid/Mermaid.vue +364 -0
- package/vitepress/components/NotesTable/NotesTable.module.scss +77 -0
- package/vitepress/components/NotesTable/NotesTable.vue +98 -0
- package/vitepress/components/NotesTable/README.md +67 -0
- package/vitepress/components/Settings/Settings.module.scss +433 -0
- package/vitepress/components/Settings/Settings.vue +306 -0
- package/vitepress/components/SidebarCard/MindMapView.vue +483 -0
- package/vitepress/components/SidebarCard/NotesTrendChart.vue +108 -0
- package/vitepress/components/SidebarCard/SidebarCard.vue +948 -0
- package/vitepress/components/Tooltip/Tooltip.vue +70 -0
- package/vitepress/components/constants.ts +91 -0
- package/vitepress/components/notesConfig.data.ts +73 -0
- package/vitepress/components/sidebar.data.ts +59 -0
- package/vitepress/components/tnotes-config.data.ts +21 -0
- package/vitepress/components/utils.ts +26 -0
- package/vitepress/config/index.ts +141 -0
- package/vitepress/configs/constants.ts +26 -0
- package/vitepress/configs/head.config.ts +25 -0
- package/vitepress/configs/index.ts +9 -0
- package/vitepress/configs/markdown-it.d.ts +23 -0
- package/vitepress/configs/markdown.config.ts +366 -0
- package/vitepress/configs/theme.config.ts +108 -0
- package/vitepress/plugins/buildProgressPlugin.ts +390 -0
- package/vitepress/plugins/getNoteByConfigIdPlugin.ts +107 -0
- package/vitepress/plugins/renameNotePlugin.ts +60 -0
- package/vitepress/plugins/updateConfigPlugin.ts +63 -0
- package/vitepress/theme/index.ts +95 -0
- package/vitepress/theme/styles/base.scss +50 -0
- package/vitepress/theme/styles/components/404.scss +31 -0
- package/vitepress/theme/styles/components/collapse.scss +175 -0
- package/vitepress/theme/styles/components/markmap.scss +101 -0
- package/vitepress/theme/styles/components/swiper.scss +255 -0
- package/vitepress/theme/styles/index.scss +25 -0
- package/vitepress/theme/styles/layout.scss +62 -0
- package/vitepress/theme/styles/utilities.scss +39 -0
- package/vitepress/theme/styles/vitepress-override.scss +25 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// config/ConfigManager.ts
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
// config/defaultConfig.ts
|
|
6
|
+
function getDefaultConfig(repoName) {
|
|
7
|
+
const name = repoName || "TNotes.default";
|
|
8
|
+
const cleanName = name.replace("TNotes.", "");
|
|
9
|
+
return {
|
|
10
|
+
// 基础信息
|
|
11
|
+
author: "tnotesjs",
|
|
12
|
+
repoName: name,
|
|
13
|
+
keywords: [name],
|
|
14
|
+
id: "",
|
|
15
|
+
// 由外部生成的 UUID
|
|
16
|
+
// Sidebar 配置
|
|
17
|
+
sidebarShowNoteId: true,
|
|
18
|
+
// 忽略目录
|
|
19
|
+
ignore_dirs: [
|
|
20
|
+
".vscode",
|
|
21
|
+
"0000",
|
|
22
|
+
"assets",
|
|
23
|
+
"node_modules",
|
|
24
|
+
"hidden",
|
|
25
|
+
"demos"
|
|
26
|
+
],
|
|
27
|
+
// 根目录项配置
|
|
28
|
+
root_item: {
|
|
29
|
+
icon: {
|
|
30
|
+
src: `https://cdn.jsdelivr.net/gh/tnotesjs/imgs@main/assets/icon--${cleanName}.svg`
|
|
31
|
+
},
|
|
32
|
+
title: cleanName,
|
|
33
|
+
completed_notes_count: {},
|
|
34
|
+
details: `${name} \u77E5\u8BC6\u5E93`,
|
|
35
|
+
link: `https://tnotesjs.github.io/${name}/`,
|
|
36
|
+
created_at: Date.now(),
|
|
37
|
+
updated_at: Date.now(),
|
|
38
|
+
days_since_birth: 0
|
|
39
|
+
},
|
|
40
|
+
// 端口配置(根据仓库名生成)
|
|
41
|
+
port: 8e3,
|
|
42
|
+
// 菜单项
|
|
43
|
+
menuItems: [
|
|
44
|
+
{
|
|
45
|
+
text: "\u{1F3E0} Home",
|
|
46
|
+
link: "/"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
text: "\u2699\uFE0F Settings",
|
|
50
|
+
link: "/Settings"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
text: "\u{1F4D2} TNotes",
|
|
54
|
+
link: "https://tnotesjs.github.io/notes"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
text: "\u{1F4C2} TNotes.yuque",
|
|
58
|
+
link: "https://www.yuque.com/tdahuyou/tnotes.yuque"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
// 社交链接
|
|
62
|
+
socialLinks: [
|
|
63
|
+
{
|
|
64
|
+
ariaLabel: "Tdahuyou \u8BED\u96C0\u4E3B\u9875\u94FE\u63A5",
|
|
65
|
+
link: "https://www.yuque.com/tdahuyou",
|
|
66
|
+
icon: {
|
|
67
|
+
svg: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M17.28 2.955c2.97.203 3.756 2.342 3.84 2.597l1.297.096c.13 0 .169.18.054.236c-1.323.716-1.727 2.17-1.49 3.118c.09.358.254.69.412 1.02c.307.642.651 1.418.707 2.981c.117 3.24-2.51 6.175-5.789 6.593c1.17-1.187 1.815-2.444 2.12-3.375c.606-1.846.508-3.316.055-4.44a4.46 4.46 0 0 0-1.782-2.141c-1.683-1.02-3.22-1.09-4.444-.762c.465-.594.876-1.201 1.2-1.864c.584-1.65-.102-2.848-.704-3.519c-.192-.246-.061-.655.305-.655c1.41 0 2.813.02 4.22.115M3.32 19.107c1.924-2.202 4.712-5.394 7.162-8.15c.559-.63 2.769-2.338 5.748-.533c.878.532 2.43 2.165 1.332 5.51c-.803 2.446-4.408 7.796-15.76 5.844c-.227-.039-.511-.354-.218-.687z"/></svg>'
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
ariaLabel: "Tdahuyou B \u7AD9\u4E3B\u9875\u94FE\u63A5",
|
|
72
|
+
link: "https://space.bilibili.com/407241004",
|
|
73
|
+
icon: {
|
|
74
|
+
svg: '<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024"><g fill="currentColor"><path d="M310.134 596.45c-7.999-4.463-16.498-8.43-24.997-11.9a274 274 0 0 0-26.996-7.438c-2.5-.992-2.5.991-2.5 1.487c0 7.934.5 18.843 1.5 27.768c1 7.438 2 15.372 4 22.81c0 .496 0 .991.5 1.487c.999.992 1.999 1.488 2.999.496c7.999-4.463 15.998-8.43 22.997-13.388c7.499-5.454 15.498-11.9 21.997-18.347c1.5-1.487 0-2.479.5-2.975m323.96-11.9a274 274 0 0 0-26.997-7.438c-2.5-.992-2.5.991-2.5 1.487c0 7.934.5 18.843 1.5 27.768c1 7.438 2 15.372 4 22.81c0 .496 0 .991.5 1.487c1 .992 2 1.488 3 .496c7.999-4.463 15.998-8.43 22.997-13.388c7.499-5.454 15.498-11.9 21.997-18.347c2-1.487.5-2.479.5-2.975c-7.5-4.463-16.498-8.43-24.997-11.9"/><path d="M741.496 112H283c-94.501 0-171 76.5-171 171.5v458c.5 94 77 170.5 170.999 170.5h457.997c94.5 0 171.002-76.5 171.002-170.5v-458c.497-95-76.002-171.5-170.502-171.5m95 343.5h15.5v48h-15.5zm-95.5-1.5l2 43l-13.5 1.5l-5-44.5zm-23.5 0l4 45.5l-14.5 1.5l-6.5-47.5h17zm-230.498 1.5h15v48h-15zm-96-1.5l2 43l-13.5 1.5l-5-44.5zm-23.5 0l4 45.5l-14.5 2l-6-47.5zm-3.5 149C343.498 668.5 216 662.5 204.5 660.5C195.5 499 181.5 464 170 385l54.5-22.5c1 71.5 9 185 9 185s108.5-15.5 132 47c.5 3 0 6-1.5 8.5m20.5 35.5l-23.5-124h35.5l13 123zm44.5-8l-27-235l33.5-1.5l21 236H429zm34-175h17.5v48H467zm41 190h-26.5l-9.5-126h36zm209.998-43C693.496 668 565.997 662 554.497 660c-9-161-23-196-34.5-275l54.5-22.5c1 71.5 9 185 9 185s108.5-15.5 132 46.5c.5 3 0 6-1.5 8.5m19.5 36l-23-124h35.5l13 123zm45.5-8l-27.5-235l33.5-1.5l21 236h-27zm33.5-175h17.5v48h-13zm41 190h-26.5l-9.5-126h36z"/></g></svg>'
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
ariaLabel: `${name} github \u4ED3\u5E93\u94FE\u63A5`,
|
|
79
|
+
link: `https://github.com/tnotesjs/${name}`,
|
|
80
|
+
icon: "github"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function mergeConfig(target, source) {
|
|
86
|
+
const result = { ...target };
|
|
87
|
+
for (const key in source) {
|
|
88
|
+
if (!(key in result)) {
|
|
89
|
+
result[key] = source[key];
|
|
90
|
+
} else if (typeof source[key] === "object" && source[key] !== null && !Array.isArray(source[key])) {
|
|
91
|
+
result[key] = mergeConfig(result[key] || {}, source[key]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
function validateAndCompleteConfig(config) {
|
|
97
|
+
const repoName = config.repoName || "TNotes.default";
|
|
98
|
+
const defaultConfig = getDefaultConfig(repoName);
|
|
99
|
+
const mergedConfig = mergeConfig(config, defaultConfig);
|
|
100
|
+
const modified = JSON.stringify(config) !== JSON.stringify(mergedConfig);
|
|
101
|
+
return {
|
|
102
|
+
config: mergedConfig,
|
|
103
|
+
modified
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// config/ConfigManager.ts
|
|
108
|
+
var ConfigManager = class _ConfigManager {
|
|
109
|
+
static instance;
|
|
110
|
+
config = null;
|
|
111
|
+
configPath;
|
|
112
|
+
rootPath;
|
|
113
|
+
constructor(rootPath) {
|
|
114
|
+
if (rootPath) {
|
|
115
|
+
this.rootPath = rootPath;
|
|
116
|
+
} else {
|
|
117
|
+
this.rootPath = process.cwd();
|
|
118
|
+
}
|
|
119
|
+
this.configPath = path.normalize(
|
|
120
|
+
path.resolve(this.rootPath, ".tnotes.json")
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 使用指定的根路径初始化配置管理器
|
|
125
|
+
*
|
|
126
|
+
* 必须在 getInstance() 之前调用(如果需要指定 rootPath)。
|
|
127
|
+
* 如果已经初始化,则忽略重复调用。
|
|
128
|
+
*/
|
|
129
|
+
static init({ rootPath }) {
|
|
130
|
+
if (!_ConfigManager.instance) {
|
|
131
|
+
_ConfigManager.instance = new _ConfigManager(rootPath);
|
|
132
|
+
}
|
|
133
|
+
return _ConfigManager.instance;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 获取单例实例
|
|
137
|
+
*/
|
|
138
|
+
static getInstance() {
|
|
139
|
+
if (!_ConfigManager.instance) {
|
|
140
|
+
_ConfigManager.instance = new _ConfigManager();
|
|
141
|
+
}
|
|
142
|
+
return _ConfigManager.instance;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 加载配置文件
|
|
146
|
+
*/
|
|
147
|
+
loadConfig(configPath) {
|
|
148
|
+
if (this.config) return this.config;
|
|
149
|
+
const path2 = configPath || this.configPath;
|
|
150
|
+
if (!fs.existsSync(path2)) {
|
|
151
|
+
throw new Error(`\u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728: ${path2}`);
|
|
152
|
+
}
|
|
153
|
+
const configContent = fs.readFileSync(path2, "utf-8");
|
|
154
|
+
const rawConfig = JSON.parse(configContent);
|
|
155
|
+
const { config: validatedConfig, modified } = validateAndCompleteConfig(rawConfig);
|
|
156
|
+
if (modified) {
|
|
157
|
+
console.warn(`[ConfigManager] \u68C0\u6D4B\u5230\u77E5\u8BC6\u5E93\u914D\u7F6E\u7F3A\u5931\u5B57\u6BB5\uFF0C\u5DF2\u81EA\u52A8\u8865\u5168`);
|
|
158
|
+
fs.writeFileSync(path2, JSON.stringify(validatedConfig, null, 2), "utf-8");
|
|
159
|
+
console.log(`[ConfigManager] \u77E5\u8BC6\u5E93\u914D\u7F6E\u6587\u4EF6\u5DF2\u66F4\u65B0`);
|
|
160
|
+
console.log(`[ConfigManager] \u77E5\u8BC6\u5E93\u914D\u7F6E\u6587\u4EF6\u8DEF\u5F84: ${path2}`);
|
|
161
|
+
}
|
|
162
|
+
this.config = validatedConfig;
|
|
163
|
+
return this.config;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 获取配置项
|
|
167
|
+
*/
|
|
168
|
+
get(key) {
|
|
169
|
+
if (!this.config) {
|
|
170
|
+
this.loadConfig();
|
|
171
|
+
}
|
|
172
|
+
return this.config[key];
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 获取所有配置
|
|
176
|
+
*/
|
|
177
|
+
getAll() {
|
|
178
|
+
if (!this.config) {
|
|
179
|
+
this.loadConfig();
|
|
180
|
+
}
|
|
181
|
+
return this.config;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* 获取项目根路径
|
|
185
|
+
*/
|
|
186
|
+
getRootPath() {
|
|
187
|
+
return this.rootPath;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* @deprecated 使用 getRootPath() 替代
|
|
191
|
+
*/
|
|
192
|
+
getDirname() {
|
|
193
|
+
return path.resolve(this.rootPath, ".vitepress", "tnotes", "config");
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
function getConfigManager() {
|
|
197
|
+
return ConfigManager.getInstance();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export {
|
|
201
|
+
ConfigManager,
|
|
202
|
+
getConfigManager
|
|
203
|
+
};
|