mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 10:00:13 +01:00
This commit is contained in:
parent
3dcbaf4c37
commit
775f9b39ab
5 changed files with 33 additions and 10 deletions
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ export class App {
|
|||
transactionError();
|
||||
break;
|
||||
case "syncing":
|
||||
processSync(data);
|
||||
processSync(data, this.plugins);
|
||||
break;
|
||||
case "backgroundtask":
|
||||
progressBackgroundTask(data.data.tasks);
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
25
app/src/types/index.d.ts
vendored
25
app/src/types/index.d.ts
vendored
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class App {
|
|||
transactionError();
|
||||
break;
|
||||
case "syncing":
|
||||
processSync(data);
|
||||
processSync(data, this.plugins);
|
||||
break;
|
||||
case "backgroundtask":
|
||||
progressBackgroundTask(data.data.tasks);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue