Vanessa 2023-06-12 11:50:37 +08:00
parent d138e5c04c
commit 250bb3839d
3 changed files with 30 additions and 3 deletions

View File

@ -441,7 +441,6 @@ export const processSync = (data?: IWebSocketData) => {
if (!data) { if (!data) {
iconElement.classList.remove("toolbar__item--active"); iconElement.classList.remove("toolbar__item--active");
if (!window.siyuan.config.sync.enabled || (0 === window.siyuan.config.sync.provider && needSubscribe(""))) { if (!window.siyuan.config.sync.enabled || (0 === window.siyuan.config.sync.provider && needSubscribe(""))) {
iconElement.setAttribute("aria-label", window.siyuan.languages["_kernel"]["53"]);
useElement.setAttribute("xlink:href", "#iconCloudOff"); useElement.setAttribute("xlink:href", "#iconCloudOff");
} else { } else {
useElement.setAttribute("xlink:href", "#iconCloudSucc"); useElement.setAttribute("xlink:href", "#iconCloudSucc");
@ -460,6 +459,5 @@ export const processSync = (data?: IWebSocketData) => {
iconElement.classList.remove("toolbar__item--active"); iconElement.classList.remove("toolbar__item--active");
useElement.setAttribute("xlink:href", "#iconCloudSucc"); useElement.setAttribute("xlink:href", "#iconCloudSucc");
} }
iconElement.setAttribute("aria-label", data.msg);
/// #endif /// #endif
}; };

View File

@ -16,6 +16,10 @@ import {webFrame} from "electron";
import {Constants} from "../constants"; import {Constants} from "../constants";
import {isBrowser, isWindow} from "../util/functions"; import {isBrowser, isWindow} from "../util/functions";
import {Menu} from "../plugin/Meun"; import {Menu} from "../plugin/Meun";
import {fetchPost} from "../util/fetch";
import {escapeAttr} from "../util/escape";
import {needSubscribe} from "../util/needSubscribe";
import * as dayjs from "dayjs";
export const updateEditModeElement = () => { export const updateEditModeElement = () => {
const target = document.querySelector("#barReadonly"); const target = document.querySelector("#barReadonly");
@ -227,6 +231,32 @@ export const initBar = (app: App) => {
target = target.parentElement; target = target.parentElement;
} }
}); });
const barSyncElement = toolbarElement.querySelector("#barSync");
barSyncElement.addEventListener("mouseenter", (event) => {
event.stopPropagation();
event.preventDefault();
fetchPost("/api/sync/getSyncInfo", {}, (response) => {
let html = ""
if (!window.siyuan.config.sync.enabled || (0 === window.siyuan.config.sync.provider && needSubscribe(""))) {
html = response.data.stat;
} else {
html = window.siyuan.languages._kernel[82].replace("%s", dayjs(response.data.synced).format("YYYY-MM-DD HH:mm")) + "\n\n"
response.data.kernels.forEach((item: {
os: string;
ver: string;
hostname: string;
id: string;
}) => {
html += `${item.os}-${item.ver} ${item.hostname} ${item.id}\n`
})
if (response.data.kernels.length > 0) {
html += "\n"
}
html += response.data.stat;
}
barSyncElement.setAttribute("aria-label", escapeAttr(html));
})
})
}; };
export const setZoom = (type: "zoomIn" | "zoomOut" | "restore") => { export const setZoom = (type: "zoomIn" | "zoomOut" | "restore") => {

View File

@ -101,4 +101,3 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
}); });
} }
}; };