diff --git a/app/src/config/repos.ts b/app/src/config/repos.ts
index 43abbeb3c..347d9a618 100644
--- a/app/src/config/repos.ts
+++ b/app/src/config/repos.ts
@@ -64,7 +64,7 @@ const renderProvider = (provider: number) => {
${window.siyuan.languages.syncThirdPartyProviderWebDAVIntro}
@@ -121,7 +132,7 @@ const renderProvider = (provider: number) => {
-
+
`;
+
+
+
+
+
+
+
`;
}
return "";
};
@@ -328,7 +350,7 @@ export const repos = {
@@ -378,6 +400,13 @@ export const repos = {
window.siyuan.config.sync.mode = parseInt(syncModeElement.value, 10);
});
});
+ repos.element.querySelectorAll("#importData").forEach(item => {
+ item.addEventListener("change", (event: InputEvent & { target: HTMLInputElement }) => {
+ const formData = new FormData();
+ formData.append("file", event.target.files[0]);
+ fetchPost(item.getAttribute("data-type") === "s3" ? "/api/sync/importSyncProviderS3" : "/api/sync/importSyncProviderWebDAV", formData);
+ });
+ });
const syncConfigElement = repos.element.querySelector("#reposCloudSyncList");
const syncProviderElement = repos.element.querySelector("#syncProvider") as HTMLSelectElement;
syncProviderElement.addEventListener("change", () => {
@@ -405,21 +434,29 @@ export const repos = {
loadingElement.style.height = repos.element.clientHeight + "px";
bindSyncCloudListEvent(syncConfigElement);
repos.element.firstElementChild.addEventListener("click", (event) => {
- const target = event.target as HTMLElement;
- if (target.getAttribute("data-type") === "config") {
- if (syncConfigElement.classList.contains("fn__none")) {
- getSyncCloudList(syncConfigElement, true);
- syncConfigElement.classList.remove("fn__none");
- } else {
- syncConfigElement.classList.add("fn__none");
+ let target = event.target as HTMLElement;
+ while (target && target !== repos.element) {
+ const action = target.getAttribute("data-action")
+ if (action === "config") {
+ if (syncConfigElement.classList.contains("fn__none")) {
+ getSyncCloudList(syncConfigElement, true);
+ syncConfigElement.classList.remove("fn__none");
+ } else {
+ syncConfigElement.classList.add("fn__none");
+ }
+ break
+ } else if (action === "togglePassword") {
+ const isEye = target.firstElementChild.getAttribute("xlink:href") === "#iconEye";
+ target.firstElementChild.setAttribute("xlink:href", isEye ? "#iconEyeoff" : "#iconEye");
+ target.previousElementSibling.setAttribute("type", isEye ? "text" : "password");
+ break;
+ } else if (action === "exportData") {
+ fetchPost(target.getAttribute("data-type") === "s3" ? "/api/sync/exportSyncProviderS3" : "/api/sync/exportSyncProviderWebDAV", {}, response => {
+ window.location.href = response.data.zip;
+ })
+ break;
}
- return;
- }
- const eyeElement = hasClosestByClassName(target, "b3-form__icona-icon");
- if (eyeElement) {
- const isEye = eyeElement.firstElementChild.getAttribute("xlink:href") === "#iconEye";
- eyeElement.firstElementChild.setAttribute("xlink:href", isEye ? "#iconEyeoff" : "#iconEye");
- eyeElement.previousElementSibling.setAttribute("type", isEye ? "text" : "password");
+ target = target.parentElement
}
});
},