回退图片部分正则表达式, 保留activefile修改

This commit is contained in:
wood chen 2025-03-07 21:54:58 +08:00
parent 836c9d9661
commit 08ad35babe

View File

@ -342,6 +342,12 @@ export default class DiscourseSyncPlugin extends Plugin {
} }
await this.app.vault.modify(activeFile, newContent); await this.app.vault.modify(activeFile, newContent);
// 更新 activeFile 对象,确保它反映最新状态
this.activeFile = {
name: activeFile.basename,
content: newContent,
postId: postId
};
} catch (error) { } catch (error) {
return { return {
message: "Error", message: "Error",
@ -517,23 +523,21 @@ export default class DiscourseSyncPlugin extends Plugin {
} }
private async openCategoryModal() { private async openCategoryModal() {
// 确保activeFile已设置 // 每次都重新获取 activeFile 的最新内容,不使用缓存
if (!this.activeFile) { const activeFile = this.app.workspace.getActiveFile();
const activeFile = this.app.workspace.getActiveFile(); if (!activeFile) {
if (!activeFile) { new NotifyUser(this.app, t('NO_ACTIVE_FILE')).open();
new NotifyUser(this.app, t('NO_ACTIVE_FILE')).open(); return;
return;
}
const content = await this.app.vault.read(activeFile);
const fm = this.getFrontMatter(content);
this.activeFile = {
name: activeFile.basename,
content: content,
postId: fm?.discourse_post_id
};
} }
const content = await this.app.vault.read(activeFile);
const fm = this.getFrontMatter(content);
this.activeFile = {
name: activeFile.basename,
content: content,
postId: fm?.discourse_post_id
};
const [categories, tags] = await Promise.all([ const [categories, tags] = await Promise.all([
this.fetchCategories(), this.fetchCategories(),
this.fetchTags() this.fetchTags()