diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts index 2eb81dd35..86a691906 100644 --- a/app/src/dialog/processSystem.ts +++ b/app/src/dialog/processSystem.ts @@ -22,6 +22,7 @@ import {hideAllElements, hideElements} from "../protyle/ui/hideElements"; import {App} from "../index"; import {saveScroll} from "../protyle/scroll/saveScroll"; import {isInAndroid, isInIOS} from "../protyle/util/compatibility"; +import {Plugin} from "../plugin"; const updateTitle = (rootID: string, tab: Tab) => { fetchPost("/api/block/getDocInfo", { @@ -411,7 +412,7 @@ export const downloadProgress = (data: { id: string, percent: number }) => { } }; -export const processSync = (data?: IWebSocketData) => { +export const processSync = (data?: IWebSocketData, plugins?: Plugin[]) => { /// #if MOBILE const menuSyncUseElement = document.querySelector("#menuSyncNow use"); const barSyncUseElement = document.querySelector("#toolbarSync use"); @@ -467,4 +468,13 @@ export const processSync = (data?: IWebSocketData) => { useElement.setAttribute("xlink:href", "#iconCloudSucc"); } /// #endif + plugins.forEach((item) => { + if (data.code === 0) { + item.eventBus.emit("sync-start", data); + } else if (data.code === 1) { + item.eventBus.emit("sync-end", data); + } else if (data.code === 2) { + item.eventBus.emit("sync-fail", data); + } + }); }; diff --git a/app/src/index.ts b/app/src/index.ts index bda3324da..ad50684bc 100644 --- a/app/src/index.ts +++ b/app/src/index.ts @@ -121,7 +121,7 @@ export class App { transactionError(); break; case "syncing": - processSync(data); + processSync(data, this.plugins); break; case "backgroundtask": progressBackgroundTask(data.data.tasks); diff --git a/app/src/mobile/util/onMessage.ts b/app/src/mobile/util/onMessage.ts index 0ff780166..d55a91860 100644 --- a/app/src/mobile/util/onMessage.ts +++ b/app/src/mobile/util/onMessage.ts @@ -16,7 +16,7 @@ export const onMessage = (app: App, data: IWebSocketData) => { progressLoading(data); break; case"syncing": - processSync(data); + processSync(data, app.plugins); if (data.code === 1) { document.getElementById("toolbarSync").classList.add("fn__none"); } diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index de0c8fa9a..d22950798 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -50,7 +50,7 @@ type TOperation = | "sortAttrViewView" type TBazaarType = "templates" | "icons" | "widgets" | "themes" | "plugins" type TCardType = "doc" | "notebook" | "all" -type TEventBus = "ws-main" | +type TEventBus = "ws-main" | "sync-start" | "sync-end" | "sync-fail" | "click-blockicon" | "click-editorcontent" | "click-pdf" | "click-editortitleicon" | "open-noneditableblock" | "open-menu-blockref" | "open-menu-fileannotationref" | "open-menu-tag" | "open-menu-link" | "open-menu-image" | @@ -101,7 +101,9 @@ declare module "blueimp-md5" interface Window { echarts: { - init(element: HTMLElement, theme?: string, options?: { width: number }): { + init(element: HTMLElement, theme?: string, options?: { + width: number + }): { setOption(option: any): void; getZr(): any; on(name: string, event: (e: any) => void): any; @@ -109,15 +111,26 @@ interface Window { resize(): void; }; dispose(element: Element): void; - getInstanceById(id: string): { resize: () => void }; + getInstanceById(id: string): { + resize: () => void + }; } ABCJS: { - renderAbc(element: Element, text: string, options: { responsive: string }): void; + renderAbc(element: Element, text: string, options: { + responsive: string + }): void; } hljs: { listLanguages(): string[]; - highlight(text: string, options: { language?: string, ignoreIllegals: boolean }): { value: string }; - getLanguage(text: string): { name: string }; + highlight(text: string, options: { + language?: string, + ignoreIllegals: boolean + }): { + value: string + }; + getLanguage(text: string): { + name: string + }; }; katex: { renderToString(math: string, option: { diff --git a/app/src/window/index.ts b/app/src/window/index.ts index 45ce18446..44b37f267 100644 --- a/app/src/window/index.ts +++ b/app/src/window/index.ts @@ -105,7 +105,7 @@ class App { transactionError(); break; case "syncing": - processSync(data); + processSync(data, this.plugins); break; case "backgroundtask": progressBackgroundTask(data.data.tasks);