mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-03 07:18:49 +01:00
This commit is contained in:
parent
b11e0af08d
commit
7154879ddc
3 changed files with 13 additions and 7 deletions
|
|
@ -846,7 +846,7 @@ export const bazaar = {
|
|||
bazaar.element.querySelectorAll("#configBazaarDownloaded .b3-card").forEach(item => {
|
||||
item.classList.remove("b3-card--disabled");
|
||||
});
|
||||
loadPlugins(app).then(() => {
|
||||
loadPlugins(app, null, false).then(() => {
|
||||
app.plugins.forEach(item => {
|
||||
afterLoadPlugin(item);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ export class Plugin {
|
|||
// 存储数据变更
|
||||
// 兼容 3.4.1 以前同步数据使用重载插件的问题
|
||||
uninstall(this.app, this.name, false);
|
||||
loadPlugins(this.app, [this.name]).then(() => {
|
||||
loadPlugins(this.app, [this.name], false).then(() => {
|
||||
afterLoadPlugin(this);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,15 +27,21 @@ const runCode = (code: string, sourceURL: string) => {
|
|||
return window.eval("(function anonymous(require, module, exports){".concat(code, "\n})\n//# sourceURL=").concat(sourceURL, "\n"));
|
||||
};
|
||||
|
||||
export const loadPlugins = async (app: App, names?: string[]) => {
|
||||
export const loadPlugins = async (app: App, names?: string[], init = true) => {
|
||||
const response = await fetchSyncPost("/api/petal/loadPetals", {frontend: getFrontend()});
|
||||
const pluginsStyle = getPluginsStyle();
|
||||
response.data.forEach((item: IPluginData) => {
|
||||
for (let i = 0; i < response.data.length; i++) {
|
||||
const item = response.data[i] as IPluginData;
|
||||
if (!names || (names && names.includes(item.name))) {
|
||||
loadPluginJS(app, item);
|
||||
if (init) {
|
||||
// 初始化时为加快启动速度,已特殊处理,不进行 await
|
||||
loadPluginJS(app, item);
|
||||
} else {
|
||||
await loadPluginJS(app, item);
|
||||
}
|
||||
insertPluginCSS(item, pluginsStyle);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const loadPluginJS = async (app: App, item: IPluginData) => {
|
||||
|
|
@ -228,7 +234,7 @@ export const reloadPlugin = async (app: App, data: {
|
|||
upsertCodePlugins.forEach((item) => {
|
||||
uninstall(app, item, false);
|
||||
});
|
||||
loadPlugins(app, upsertCodePlugins).then(() => {
|
||||
loadPlugins(app, upsertCodePlugins, false).then(() => {
|
||||
app.plugins.forEach(item => {
|
||||
if (upsertCodePlugins.includes(item.name)) {
|
||||
afterLoadPlugin(item);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue