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 {App} from "../index";
|
||||||
import {saveScroll} from "../protyle/scroll/saveScroll";
|
import {saveScroll} from "../protyle/scroll/saveScroll";
|
||||||
import {isInAndroid, isInIOS} from "../protyle/util/compatibility";
|
import {isInAndroid, isInIOS} from "../protyle/util/compatibility";
|
||||||
|
import {Plugin} from "../plugin";
|
||||||
|
|
||||||
const updateTitle = (rootID: string, tab: Tab) => {
|
const updateTitle = (rootID: string, tab: Tab) => {
|
||||||
fetchPost("/api/block/getDocInfo", {
|
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
|
/// #if MOBILE
|
||||||
const menuSyncUseElement = document.querySelector("#menuSyncNow use");
|
const menuSyncUseElement = document.querySelector("#menuSyncNow use");
|
||||||
const barSyncUseElement = document.querySelector("#toolbarSync use");
|
const barSyncUseElement = document.querySelector("#toolbarSync use");
|
||||||
|
|
@ -467,4 +468,13 @@ export const processSync = (data?: IWebSocketData) => {
|
||||||
useElement.setAttribute("xlink:href", "#iconCloudSucc");
|
useElement.setAttribute("xlink:href", "#iconCloudSucc");
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #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();
|
transactionError();
|
||||||
break;
|
break;
|
||||||
case "syncing":
|
case "syncing":
|
||||||
processSync(data);
|
processSync(data, this.plugins);
|
||||||
break;
|
break;
|
||||||
case "backgroundtask":
|
case "backgroundtask":
|
||||||
progressBackgroundTask(data.data.tasks);
|
progressBackgroundTask(data.data.tasks);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export const onMessage = (app: App, data: IWebSocketData) => {
|
||||||
progressLoading(data);
|
progressLoading(data);
|
||||||
break;
|
break;
|
||||||
case"syncing":
|
case"syncing":
|
||||||
processSync(data);
|
processSync(data, app.plugins);
|
||||||
if (data.code === 1) {
|
if (data.code === 1) {
|
||||||
document.getElementById("toolbarSync").classList.add("fn__none");
|
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"
|
| "sortAttrViewView"
|
||||||
type TBazaarType = "templates" | "icons" | "widgets" | "themes" | "plugins"
|
type TBazaarType = "templates" | "icons" | "widgets" | "themes" | "plugins"
|
||||||
type TCardType = "doc" | "notebook" | "all"
|
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" |
|
"click-blockicon" | "click-editorcontent" | "click-pdf" | "click-editortitleicon" |
|
||||||
"open-noneditableblock" |
|
"open-noneditableblock" |
|
||||||
"open-menu-blockref" | "open-menu-fileannotationref" | "open-menu-tag" | "open-menu-link" | "open-menu-image" |
|
"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 {
|
interface Window {
|
||||||
echarts: {
|
echarts: {
|
||||||
init(element: HTMLElement, theme?: string, options?: { width: number }): {
|
init(element: HTMLElement, theme?: string, options?: {
|
||||||
|
width: number
|
||||||
|
}): {
|
||||||
setOption(option: any): void;
|
setOption(option: any): void;
|
||||||
getZr(): any;
|
getZr(): any;
|
||||||
on(name: string, event: (e: any) => void): any;
|
on(name: string, event: (e: any) => void): any;
|
||||||
|
|
@ -109,15 +111,26 @@ interface Window {
|
||||||
resize(): void;
|
resize(): void;
|
||||||
};
|
};
|
||||||
dispose(element: Element): void;
|
dispose(element: Element): void;
|
||||||
getInstanceById(id: string): { resize: () => void };
|
getInstanceById(id: string): {
|
||||||
|
resize: () => void
|
||||||
|
};
|
||||||
}
|
}
|
||||||
ABCJS: {
|
ABCJS: {
|
||||||
renderAbc(element: Element, text: string, options: { responsive: string }): void;
|
renderAbc(element: Element, text: string, options: {
|
||||||
|
responsive: string
|
||||||
|
}): void;
|
||||||
}
|
}
|
||||||
hljs: {
|
hljs: {
|
||||||
listLanguages(): string[];
|
listLanguages(): string[];
|
||||||
highlight(text: string, options: { language?: string, ignoreIllegals: boolean }): { value: string };
|
highlight(text: string, options: {
|
||||||
getLanguage(text: string): { name: string };
|
language?: string,
|
||||||
|
ignoreIllegals: boolean
|
||||||
|
}): {
|
||||||
|
value: string
|
||||||
|
};
|
||||||
|
getLanguage(text: string): {
|
||||||
|
name: string
|
||||||
|
};
|
||||||
};
|
};
|
||||||
katex: {
|
katex: {
|
||||||
renderToString(math: string, option: {
|
renderToString(math: string, option: {
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ class App {
|
||||||
transactionError();
|
transactionError();
|
||||||
break;
|
break;
|
||||||
case "syncing":
|
case "syncing":
|
||||||
processSync(data);
|
processSync(data, this.plugins);
|
||||||
break;
|
break;
|
||||||
case "backgroundtask":
|
case "backgroundtask":
|
||||||
progressBackgroundTask(data.data.tasks);
|
progressBackgroundTask(data.data.tasks);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue