mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
db690c51b6
commit
09e5828ffe
4 changed files with 22 additions and 11 deletions
|
|
@ -25,8 +25,7 @@ import {getAllTabs} from "./layout/getAll";
|
||||||
import {getLocalStorage} from "./protyle/util/compatibility";
|
import {getLocalStorage} from "./protyle/util/compatibility";
|
||||||
import {getSearch} from "./util/functions";
|
import {getSearch} from "./util/functions";
|
||||||
import {hideAllElements} from "./protyle/ui/hideElements";
|
import {hideAllElements} from "./protyle/ui/hideElements";
|
||||||
import {afterLoadPlugin, loadPlugins} from "./plugin/loader";
|
import {loadPlugins, reloadPlugin} from "./plugin/loader";
|
||||||
import {uninstall} from "./plugin/uninstall";
|
|
||||||
import "./assets/scss/base.scss";
|
import "./assets/scss/base.scss";
|
||||||
|
|
||||||
export class App {
|
export class App {
|
||||||
|
|
@ -61,14 +60,7 @@ export class App {
|
||||||
if (data) {
|
if (data) {
|
||||||
switch (data.cmd) {
|
switch (data.cmd) {
|
||||||
case "reloadPlugin":
|
case "reloadPlugin":
|
||||||
this.plugins.forEach((plugin) => {
|
reloadPlugin(this);
|
||||||
uninstall(this, plugin.name);
|
|
||||||
});
|
|
||||||
loadPlugins(this).then(() => {
|
|
||||||
this.plugins.forEach(item => {
|
|
||||||
afterLoadPlugin(item);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case "syncMergeResult":
|
case "syncMergeResult":
|
||||||
reloadSync(this, data.data);
|
reloadSync(this, data.data);
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,14 @@ import {openMobileFileById} from "../editor";
|
||||||
import {processSync, progressLoading, progressStatus, reloadSync, transactionError} from "../../dialog/processSystem";
|
import {processSync, progressLoading, progressStatus, reloadSync, transactionError} from "../../dialog/processSystem";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
|
import {reloadPlugin} from "../../plugin/loader";
|
||||||
|
|
||||||
export const onMessage = (app: App, data: IWebSocketData) => {
|
export const onMessage = (app: App, data: IWebSocketData) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
switch (data.cmd) {
|
switch (data.cmd) {
|
||||||
|
case "reloadPlugin":
|
||||||
|
reloadPlugin(app);
|
||||||
|
break;
|
||||||
case "syncMergeResult":
|
case "syncMergeResult":
|
||||||
reloadSync(app, data.data);
|
reloadSync(app, data.data);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import {resizeTopBar, saveLayout} from "../layout/util";
|
||||||
import {API} from "./API";
|
import {API} from "./API";
|
||||||
import {getFrontend, isMobile, isWindow} from "../util/functions";
|
import {getFrontend, isMobile, isWindow} from "../util/functions";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
|
import {uninstall} from "./uninstall";
|
||||||
|
|
||||||
const requireFunc = (key: string) => {
|
const requireFunc = (key: string) => {
|
||||||
const modules = {
|
const modules = {
|
||||||
|
|
@ -231,3 +232,14 @@ export const afterLoadPlugin = (plugin: Plugin) => {
|
||||||
saveLayout();
|
saveLayout();
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const reloadPlugin = (app: App) => {
|
||||||
|
app.plugins.forEach((item) => {
|
||||||
|
uninstall(this, item.name);
|
||||||
|
});
|
||||||
|
loadPlugins(this).then(() => {
|
||||||
|
app.plugins.forEach(item => {
|
||||||
|
afterLoadPlugin(item);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import {initMessage} from "../dialog/message";
|
||||||
import {getAllTabs} from "../layout/getAll";
|
import {getAllTabs} from "../layout/getAll";
|
||||||
import {getLocalStorage} from "../protyle/util/compatibility";
|
import {getLocalStorage} from "../protyle/util/compatibility";
|
||||||
import {init} from "../window/init";
|
import {init} from "../window/init";
|
||||||
import {loadPlugins} from "../plugin/loader";
|
import {loadPlugins, reloadPlugin} from "../plugin/loader";
|
||||||
import {hideAllElements} from "../protyle/ui/hideElements";
|
import {hideAllElements} from "../protyle/ui/hideElements";
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
|
|
@ -51,6 +51,9 @@ class App {
|
||||||
});
|
});
|
||||||
if (data) {
|
if (data) {
|
||||||
switch (data.cmd) {
|
switch (data.cmd) {
|
||||||
|
case "reloadPlugin":
|
||||||
|
reloadPlugin(this);
|
||||||
|
break;
|
||||||
case "syncMergeResult":
|
case "syncMergeResult":
|
||||||
reloadSync(this, data.data);
|
reloadSync(this, data.data);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue