From 86ecfb11af125f244dae180ba3434b443313faa3 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 10 Mar 2023 10:43:15 +0800 Subject: [PATCH] :iphone: loading --- app/src/dialog/processSystem.ts | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts index c8988a550..bb26b99e9 100644 --- a/app/src/dialog/processSystem.ts +++ b/app/src/dialog/processSystem.ts @@ -338,7 +338,35 @@ export const downloadProgress = (data: { id: string, percent: number }) => { }; export const processSync = (data?: IWebSocketData) => { - const iconElement = document.querySelector(isMobile() ? "#menuSyncNow" : "#barSync"); + /// #if MOBILE + const menuSyncUseElement = document.querySelector("#menuSyncNow use"); + const barSyncUseElement = document.querySelector("#toolbarSync use"); + if (!data) { + if (!window.siyuan.config.sync.enabled || (0 === window.siyuan.config.sync.provider && needSubscribe(""))) { + menuSyncUseElement?.setAttribute("xlink:href", "#iconCloudOff"); + barSyncUseElement.setAttribute("xlink:href", "#iconCloudOff"); + } else { + menuSyncUseElement?.setAttribute("xlink:href", "#iconCloudSucc"); + barSyncUseElement.setAttribute("xlink:href", "#iconCloudSucc"); + } + return; + } + menuSyncUseElement?.parentElement.classList.remove("fn__rotate"); + barSyncUseElement.parentElement.classList.remove("fn__rotate"); + if (data.code === 0) { // syncing + menuSyncUseElement?.parentElement.classList.add("fn__rotate"); + barSyncUseElement.parentElement.classList.add("fn__rotate"); + menuSyncUseElement?.setAttribute("xlink:href", "#iconRefresh"); + barSyncUseElement.setAttribute("xlink:href", "#iconRefresh"); + } else if (data.code === 2) { // error + menuSyncUseElement?.setAttribute("xlink:href", "#iconCloudError"); + barSyncUseElement.setAttribute("xlink:href", "#iconCloudError"); + } else if (data.code === 1) { // success + menuSyncUseElement?.setAttribute("xlink:href", "#iconCloudSucc"); + barSyncUseElement.setAttribute("xlink:href", "#iconCloudSucc"); + } + /// #else + const iconElement = document.querySelector("#barSync"); if (!iconElement) { return; } @@ -366,4 +394,5 @@ export const processSync = (data?: IWebSocketData) => { useElement.setAttribute("xlink:href", "#iconCloudSucc"); } iconElement.setAttribute("aria-label", data.msg); + /// #endif };