mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-17 20:48:06 +01:00
Improve onDataChanged method (#16472)
* 🐛 Improve onDataChanged method fix https://github.com/siyuan-note/siyuan/pull/16244 重构、修复插件重启逻辑 重构 比如插件在 onload() 中插入了图标,uninstall 会把图标删除,afterLoadPlugin 又不能执行 onload() 把图标加回来 使用 getElementById 先加载插件样式 避免插入重复的样式 改进插件样式插入位置 * reloadPlugin
This commit is contained in:
parent
d620daa530
commit
bcdef64d0f
4 changed files with 60 additions and 37 deletions
|
|
@ -16,8 +16,7 @@ import {BlockPanel} from "../block/Panel";
|
|||
import {Setting} from "./Setting";
|
||||
import {clearOBG} from "../layout/dock/util";
|
||||
import {Constants} from "../constants";
|
||||
import {uninstall} from "./uninstall";
|
||||
import {afterLoadPlugin} from "./loader";
|
||||
import {restartPlugin} from "./loader";
|
||||
|
||||
export class Plugin {
|
||||
private app: App;
|
||||
|
|
@ -103,7 +102,7 @@ export class Plugin {
|
|||
});
|
||||
}
|
||||
|
||||
public onload() {
|
||||
public onload(): Promise<void> | void {
|
||||
// 加载
|
||||
}
|
||||
|
||||
|
|
@ -118,8 +117,7 @@ export class Plugin {
|
|||
public onDataChanged() {
|
||||
// 存储数据变更
|
||||
// 兼容 3.4.1 以前同步数据使用重载插件的问题
|
||||
uninstall(this.app, this.name, false);
|
||||
afterLoadPlugin(this);
|
||||
restartPlugin(this.app, this);
|
||||
}
|
||||
|
||||
public async updateCards(options: ICardData) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue