代码拉取完成,页面将自动刷新
import { Plugin, TFile } from 'obsidian';
export default class ActiveNoteTitlePlugin extends Plugin {
// Get the window title
baseTitle = document.title;
async onload() {
console.log('loading ActiveNoteTitlePlugin plugin');
// When opening, renaming or deleting a file, update the window title
this.registerEvent(this.app.workspace.on('file-open', this.handleOpen));
this.registerEvent(this.app.vault.on('rename', this.handleRename));
this.registerEvent(this.app.vault.on('delete', this.handleDelete));
}
// Restore original title on unload.
onunload() {
document.title = this.baseTitle;
}
private readonly handleRename = async (file: TFile): Promise<void> => {
document.title = this.baseTitle + ' - ' + file.path;
};
private readonly handleDelete = async (file: TFile): Promise<void> => {
document.title = this.baseTitle;
};
private readonly handleOpen = async (file: TFile): Promise<void> => {
if (file instanceof TFile) {
document.title = this.baseTitle + ' - ' + file.path;
} else {
document.title = this.baseTitle;
}
};
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。