-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Description
我的插件需要 await fetchSyncPost 获取数据之后才能判断是否应该添加选项,但是只要使用了异步操作就无法正常 addItem
import {
Plugin,
Menu,
} from "siyuan";
export default class PluginSample extends Plugin {
async onload() {
this.eventBus.on('open-menu-doctree', this.openMenuDoctree);
}
openMenuDoctree = async (event: CustomEvent) => {
const type = event.detail.type;
const menu = event.detail.menu as Menu;
if (type === "doc") {
console.log("单个文档", menu);
// 异步操作
await new Promise(resolve => setTimeout(resolve, 1));
menu.addItem({
id: "test",
label: "测试",
click: () => {
console.log("点击");
}
});
}
};
}video.webm
Metadata
Metadata
Assignees
Labels
No labels