Vanessa 2024-01-20 23:01:41 +08:00
parent db690c51b6
commit 09e5828ffe
4 changed files with 22 additions and 11 deletions

View file

@ -25,8 +25,7 @@ import {getAllTabs} from "./layout/getAll";
import {getLocalStorage} from "./protyle/util/compatibility";
import {getSearch} from "./util/functions";
import {hideAllElements} from "./protyle/ui/hideElements";
import {afterLoadPlugin, loadPlugins} from "./plugin/loader";
import {uninstall} from "./plugin/uninstall";
import {loadPlugins, reloadPlugin} from "./plugin/loader";
import "./assets/scss/base.scss";
export class App {
@ -61,14 +60,7 @@ export class App {
if (data) {
switch (data.cmd) {
case "reloadPlugin":
this.plugins.forEach((plugin) => {
uninstall(this, plugin.name);
});
loadPlugins(this).then(() => {
this.plugins.forEach(item => {
afterLoadPlugin(item);
});
});
reloadPlugin(this);
break;
case "syncMergeResult":
reloadSync(this, data.data);

View file

@ -2,10 +2,14 @@ import {openMobileFileById} from "../editor";
import {processSync, progressLoading, progressStatus, reloadSync, transactionError} from "../../dialog/processSystem";
import {Constants} from "../../constants";
import {App} from "../../index";
import {reloadPlugin} from "../../plugin/loader";
export const onMessage = (app: App, data: IWebSocketData) => {
if (data) {
switch (data.cmd) {
case "reloadPlugin":
reloadPlugin(app);
break;
case "syncMergeResult":
reloadSync(app, data.data);
break;

View file

@ -7,6 +7,7 @@ import {resizeTopBar, saveLayout} from "../layout/util";
import {API} from "./API";
import {getFrontend, isMobile, isWindow} from "../util/functions";
import {Constants} from "../constants";
import {uninstall} from "./uninstall";
const requireFunc = (key: string) => {
const modules = {
@ -231,3 +232,14 @@ export const afterLoadPlugin = (plugin: Plugin) => {
saveLayout();
/// #endif
};
export const reloadPlugin = (app: App) => {
app.plugins.forEach((item) => {
uninstall(this, item.name);
});
loadPlugins(this).then(() => {
app.plugins.forEach(item => {
afterLoadPlugin(item);
});
});
};

View file

@ -19,7 +19,7 @@ import {initMessage} from "../dialog/message";
import {getAllTabs} from "../layout/getAll";
import {getLocalStorage} from "../protyle/util/compatibility";
import {init} from "../window/init";
import {loadPlugins} from "../plugin/loader";
import {loadPlugins, reloadPlugin} from "../plugin/loader";
import {hideAllElements} from "../protyle/ui/hideElements";
class App {
@ -51,6 +51,9 @@ class App {
});
if (data) {
switch (data.cmd) {
case "reloadPlugin":
reloadPlugin(this);
break;
case "syncMergeResult":
reloadSync(this, data.data);
break;