mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
🎨
This commit is contained in:
parent
b3a2db861a
commit
d12d25993a
1 changed files with 17 additions and 5 deletions
|
|
@ -73,13 +73,15 @@ export const bindSyncCloudListEvent = (cloudPanelElement: Element) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getSyncCloudList = (cloudPanelElement: Element, reload = false) => {
|
export const getSyncCloudList = (cloudPanelElement: Element, reload = false, cb?:() =>void) => {
|
||||||
if (!reload && cloudPanelElement.firstElementChild.tagName !== "IMG") {
|
if (!reload && cloudPanelElement.firstElementChild.tagName !== "IMG") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fetchPost("/api/sync/listCloudSyncDir", {}, (response) => {
|
fetchPost("/api/sync/listCloudSyncDir", {}, (response) => {
|
||||||
let syncListHTML = `<div class="fn__hr"></div><ul><li style="padding: 0 16px" class="b3-list--empty">${window.siyuan.languages.emptyCloudSyncList}</li></ul>`;
|
let syncListHTML = `<div class="fn__hr"></div><ul><li style="padding: 0 16px" class="b3-list--empty">${window.siyuan.languages.emptyCloudSyncList}</li></ul>`;
|
||||||
if (response.code !== 1) {
|
if (response.code === 1) {
|
||||||
|
syncListHTML = `<div class="fn__hr"></div><ul><li style="padding: 0 16px" class="b3-list--empty ft__error">${response.msg}</li></ul>`;
|
||||||
|
} else if (response.code !== 1) {
|
||||||
syncListHTML = '<div class="fn__hr"></div><ul class="b3-list b3-list--background fn__flex-1" style="overflow: auto;">';
|
syncListHTML = '<div class="fn__hr"></div><ul class="b3-list b3-list--background fn__flex-1" style="overflow: auto;">';
|
||||||
response.data.syncDirs.forEach((item: { hSize: string, cloudName: string, updated: string }) => {
|
response.data.syncDirs.forEach((item: { hSize: string, cloudName: string, updated: string }) => {
|
||||||
syncListHTML += `<li data-type="selectCloud" data-name="${item.cloudName}" class="b3-list-item${isMobile() ? "" : " b3-list-item--hide-action"}">
|
syncListHTML += `<li data-type="selectCloud" data-name="${item.cloudName}" class="b3-list-item${isMobile() ? "" : " b3-list-item--hide-action"}">
|
||||||
|
|
@ -102,6 +104,9 @@ export const getSyncCloudList = (cloudPanelElement: Element, reload = false) =>
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
cloudPanelElement.innerHTML = syncListHTML;
|
cloudPanelElement.innerHTML = syncListHTML;
|
||||||
|
if (cb) {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -132,7 +137,7 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="b3-dialog__action">
|
<div class="b3-dialog__action">
|
||||||
<button class="b3-button">${window.siyuan.languages.openSyncTip1}</button>
|
<button class="b3-button" disabled="disabled">${window.siyuan.languages.openSyncTip1}</button>
|
||||||
</div>`;
|
</div>`;
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
dialog.element.querySelector(".b3-dialog__header").innerHTML = window.siyuan.languages.cloudSyncDir;
|
dialog.element.querySelector(".b3-dialog__header").innerHTML = window.siyuan.languages.cloudSyncDir;
|
||||||
|
|
@ -146,8 +151,15 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
||||||
}
|
}
|
||||||
const contentElement = dialog.element.querySelector(".b3-dialog__content").lastElementChild;
|
const contentElement = dialog.element.querySelector(".b3-dialog__content").lastElementChild;
|
||||||
bindSyncCloudListEvent(contentElement);
|
bindSyncCloudListEvent(contentElement);
|
||||||
getSyncCloudList(contentElement);
|
const btnElement = dialog.element.querySelector(".b3-button");
|
||||||
dialog.element.querySelector(".b3-button").addEventListener("click", () => {
|
getSyncCloudList(contentElement, false, () => {
|
||||||
|
if (contentElement.querySelector("input[checked]")) {
|
||||||
|
btnElement.removeAttribute("disabled");
|
||||||
|
} else {
|
||||||
|
btnElement.setAttribute("disabled", "disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
btnElement.addEventListener("click", () => {
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
fetchPost("/api/sync/setSyncEnable", {enabled: true}, (response) => {
|
fetchPost("/api/sync/setSyncEnable", {enabled: true}, (response) => {
|
||||||
if (response.code === 1) {
|
if (response.code === 1) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue