update at 2025-09-23 18:52:50
This commit is contained in:
@@ -440,6 +440,24 @@ export class NotePreview extends ItemView {
|
||||
return;
|
||||
}
|
||||
this.currentFile = af;
|
||||
// 如果关闭了样式 UI,则在渲染前强制使用全局默认样式/高亮(忽略 frontmatter 中的 theme/highlight)
|
||||
if (!this.settings.showStyleUI) {
|
||||
const globalStyle = this.settings.defaultStyle;
|
||||
const globalHighlight = this.settings.defaultHighlight;
|
||||
// 仅当变更时更新当前与 articleRender 中的值,避免不必要的刷新
|
||||
if (this.currentTheme !== globalStyle) {
|
||||
this.currentTheme = globalStyle;
|
||||
if (this._articleRender) {
|
||||
this._articleRender.currentTheme = globalStyle;
|
||||
}
|
||||
}
|
||||
if (this.currentHighlight !== globalHighlight) {
|
||||
this.currentHighlight = globalHighlight;
|
||||
if (this._articleRender) {
|
||||
this._articleRender.currentHighlight = globalHighlight;
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.render.renderMarkdown(af);
|
||||
const metadata = this.render.getMetadata();
|
||||
if (metadata.appid) {
|
||||
@@ -448,23 +466,27 @@ export class NotePreview extends ItemView {
|
||||
else {
|
||||
this.wechatSelect.value = this.currentAppId;
|
||||
}
|
||||
// 仅当 UI 开启时才允许 frontmatter 覆盖与下拉同步;关闭时忽略 frontmatter 的 theme/highlight
|
||||
if (this.settings.showStyleUI) {
|
||||
if (metadata.theme) {
|
||||
this.assetsManager.themes.forEach(theme => {
|
||||
if (theme.name === metadata.theme) {
|
||||
this.currentTheme = theme.className;
|
||||
if (this.themeSelect) this.themeSelect.value = theme.className;
|
||||
if (this._articleRender) this._articleRender.currentTheme = theme.className;
|
||||
}
|
||||
});
|
||||
} else if (this.themeSelect) {
|
||||
this.themeSelect.value = this.currentTheme;
|
||||
}
|
||||
|
||||
if (metadata.theme) {
|
||||
this.assetsManager.themes.forEach(theme => {
|
||||
if (theme.name === metadata.theme) {
|
||||
this.themeSelect.value = theme.className;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.themeSelect.value = this.currentTheme;
|
||||
}
|
||||
|
||||
if (metadata.highlight) {
|
||||
this.highlightSelect.value = this.render.currentHighlight;
|
||||
}
|
||||
else {
|
||||
this.highlightSelect.value = this.currentHighlight;
|
||||
if (metadata.highlight) {
|
||||
this.currentHighlight = metadata.highlight;
|
||||
if (this.highlightSelect) this.highlightSelect.value = metadata.highlight;
|
||||
if (this._articleRender) this._articleRender.currentHighlight = metadata.highlight;
|
||||
} else if (this.highlightSelect) {
|
||||
this.highlightSelect.value = this.currentHighlight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user