update at 2025-09-22 18:54:59
This commit is contained in:
@@ -44,6 +44,11 @@ export class NMPSettings {
|
||||
isLoaded: boolean = false;
|
||||
enableEmptyLine: boolean = false;
|
||||
enableMarkdownImageToWikilink: boolean = true; // 自动将  转为 ![[file.ext]]
|
||||
// gallery 相关配置:根目录前缀 & 选取图片数量
|
||||
galleryPrePath: string;
|
||||
galleryNumPic: number;
|
||||
// 无图片时的默认封面(wikilink 或 URL 均可)
|
||||
defaultCoverPic: string;
|
||||
|
||||
private static instance: NMPSettings;
|
||||
|
||||
@@ -73,7 +78,12 @@ export class NMPSettings {
|
||||
this.excalidrawToPNG = false;
|
||||
this.expertSettingsNote = '';
|
||||
this.enableEmptyLine = false;
|
||||
this.enableMarkdownImageToWikilink = true;
|
||||
this.enableMarkdownImageToWikilink = true;
|
||||
// 默认值:用户原先硬编码路径 & 前 2 张
|
||||
this.galleryPrePath = '/Users/gavin/myweb/static';
|
||||
this.galleryNumPic = 2;
|
||||
// 默认封面:使用当前笔记同目录下的 cover.png (若存在会被后续流程正常解析;不存在则无效但可被用户覆盖)
|
||||
this.defaultCoverPic = 'cover.png';
|
||||
}
|
||||
|
||||
resetStyelAndHighlight() {
|
||||
@@ -104,6 +114,9 @@ export class NMPSettings {
|
||||
expertSettingsNote,
|
||||
ignoreEmptyLine,
|
||||
enableMarkdownImageToWikilink,
|
||||
galleryPrePath,
|
||||
galleryNumPic,
|
||||
defaultCoverPic,
|
||||
} = data;
|
||||
|
||||
const settings = NMPSettings.getInstance();
|
||||
@@ -161,6 +174,15 @@ export class NMPSettings {
|
||||
if (enableMarkdownImageToWikilink !== undefined) {
|
||||
settings.enableMarkdownImageToWikilink = enableMarkdownImageToWikilink;
|
||||
}
|
||||
if (galleryPrePath) {
|
||||
settings.galleryPrePath = galleryPrePath;
|
||||
}
|
||||
if (galleryNumPic !== undefined && Number.isFinite(galleryNumPic)) {
|
||||
settings.galleryNumPic = Math.max(1, parseInt(galleryNumPic));
|
||||
}
|
||||
if (defaultCoverPic !== undefined) {
|
||||
settings.defaultCoverPic = String(defaultCoverPic).trim();
|
||||
}
|
||||
settings.getExpiredDate();
|
||||
settings.isLoaded = true;
|
||||
}
|
||||
@@ -186,6 +208,9 @@ export class NMPSettings {
|
||||
'expertSettingsNote': settings.expertSettingsNote,
|
||||
'ignoreEmptyLine': settings.enableEmptyLine,
|
||||
'enableMarkdownImageToWikilink': settings.enableMarkdownImageToWikilink,
|
||||
'galleryPrePath': settings.galleryPrePath,
|
||||
'galleryNumPic': settings.galleryNumPic,
|
||||
'defaultCoverPic': settings.defaultCoverPic,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user