mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 08:00:13 +01:00
🚨
This commit is contained in:
parent
c8b05a6b96
commit
ac8748d161
13 changed files with 36 additions and 36 deletions
|
|
@ -203,7 +203,7 @@ ${window.siyuan.languages.account8}`;
|
||||||
account.bindEvent(element);
|
account.bindEvent(element);
|
||||||
showMessage(window.siyuan.languages.refreshUser, 3000);
|
showMessage(window.siyuan.languages.refreshUser, 3000);
|
||||||
account.onSetaccount();
|
account.onSetaccount();
|
||||||
processSync()
|
processSync();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
element.querySelector("#logout").addEventListener("click", () => {
|
element.querySelector("#logout").addEventListener("click", () => {
|
||||||
|
|
@ -213,7 +213,7 @@ ${window.siyuan.languages.account8}`;
|
||||||
element.innerHTML = account.genHTML();
|
element.innerHTML = account.genHTML();
|
||||||
account.bindEvent(element);
|
account.bindEvent(element);
|
||||||
account.onSetaccount();
|
account.onSetaccount();
|
||||||
processSync()
|
processSync();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -224,7 +224,7 @@ ${window.siyuan.languages.account8}`;
|
||||||
element.innerHTML = account.genHTML();
|
element.innerHTML = account.genHTML();
|
||||||
account.bindEvent(element);
|
account.bindEvent(element);
|
||||||
account.onSetaccount();
|
account.onSetaccount();
|
||||||
processSync()
|
processSync();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -372,7 +372,7 @@ ${window.siyuan.languages.account8}`;
|
||||||
},
|
},
|
||||||
_afterLogin(userResponse: IWebSocketData, element: Element) {
|
_afterLogin(userResponse: IWebSocketData, element: Element) {
|
||||||
window.siyuan.user = userResponse.data;
|
window.siyuan.user = userResponse.data;
|
||||||
processSync()
|
processSync();
|
||||||
if (element.classList.contains("account") && !needSubscribe("")) {
|
if (element.classList.contains("account") && !needSubscribe("")) {
|
||||||
const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
|
const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
|
||||||
if (dialogElement) {
|
if (dialogElement) {
|
||||||
|
|
|
||||||
|
|
@ -328,7 +328,7 @@ export const repos = {
|
||||||
showMessage(window.siyuan.languages._kernel[123]);
|
showMessage(window.siyuan.languages._kernel[123]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fetchPost("/api/sync/setSyncEnable", {enabled: switchElement.checked}, (response) => {
|
fetchPost("/api/sync/setSyncEnable", {enabled: switchElement.checked}, () => {
|
||||||
window.siyuan.config.sync.enabled = switchElement.checked;
|
window.siyuan.config.sync.enabled = switchElement.checked;
|
||||||
processSync();
|
processSync();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ export const progressBackgroundTask = (tasks:{action:string}[]) => {
|
||||||
backgroundTaskElement.setAttribute("data-tasks", JSON.stringify(tasks));
|
backgroundTaskElement.setAttribute("data-tasks", JSON.stringify(tasks));
|
||||||
backgroundTaskElement.innerHTML = tasks[0].action + "<div><div></div></div>";
|
backgroundTaskElement.innerHTML = tasks[0].action + "<div><div></div></div>";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
export const bootSync = () => {
|
export const bootSync = () => {
|
||||||
fetchPost("/api/sync/getBootSync", {}, response => {
|
fetchPost("/api/sync/getBootSync", {}, response => {
|
||||||
|
|
@ -335,31 +335,31 @@ export const downloadProgress = (data: { id: string, percent: number }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const processSync = (data?: IWebSocketData) => {
|
export const processSync = (data?: IWebSocketData) => {
|
||||||
const iconElement = document.querySelector(isMobile()?"#menuSyncNow" : "#barSync")
|
const iconElement = document.querySelector(isMobile()?"#menuSyncNow" : "#barSync");
|
||||||
if (!iconElement) {
|
if (!iconElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const useElement = iconElement.querySelector("use")
|
const useElement = iconElement.querySelector("use");
|
||||||
if (!data) {
|
if (!data) {
|
||||||
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.classList.add("toolbar__item--active");
|
iconElement.classList.add("toolbar__item--active");
|
||||||
iconElement.setAttribute("aria-label", window.siyuan.languages["_kernel"]["53"]);
|
iconElement.setAttribute("aria-label", window.siyuan.languages["_kernel"]["53"]);
|
||||||
useElement.setAttribute("xlink:href", "#iconCloudOff")
|
useElement.setAttribute("xlink:href", "#iconCloudOff");
|
||||||
} else {
|
} else {
|
||||||
iconElement.classList.remove("toolbar__item--active");
|
iconElement.classList.remove("toolbar__item--active");
|
||||||
useElement.setAttribute("xlink:href", "#iconCloudSucc")
|
useElement.setAttribute("xlink:href", "#iconCloudSucc");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.code === 0) { // syncing
|
if (data.code === 0) { // syncing
|
||||||
iconElement.classList.add("toolbar__item--active");
|
iconElement.classList.add("toolbar__item--active");
|
||||||
useElement.setAttribute("xlink:href", "#iconCloudSync")
|
useElement.setAttribute("xlink:href", "#iconCloudSync");
|
||||||
} else if (data.code === 2) { // error
|
} else if (data.code === 2) { // error
|
||||||
iconElement.classList.remove("toolbar__item--active");
|
iconElement.classList.remove("toolbar__item--active");
|
||||||
useElement.setAttribute("xlink:href", "#iconCloudError")
|
useElement.setAttribute("xlink:href", "#iconCloudError");
|
||||||
} else if (data.code === 1) { // success
|
} else if (data.code === 1) { // success
|
||||||
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);
|
iconElement.setAttribute("aria-label", data.msg);
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ export const initStatus = () => {
|
||||||
iconHTML: Constants.ZWSP,
|
iconHTML: Constants.ZWSP,
|
||||||
label: item.action
|
label: item.action
|
||||||
}).element);
|
}).element);
|
||||||
})
|
});
|
||||||
const rect = target.getBoundingClientRect();
|
const rect = target.getBoundingClientRect();
|
||||||
window.siyuan.menus.menu.popup({x: rect.right, y: rect.top}, true);
|
window.siyuan.menus.menu.popup({x: rect.right, y: rect.top}, true);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
|
||||||
|
|
@ -388,13 +388,13 @@ const genImportMenu = (notebookId: string, pathString: string) => {
|
||||||
formData.append("notebook", notebookId);
|
formData.append("notebook", notebookId);
|
||||||
formData.append("toPath", pathString);
|
formData.append("toPath", pathString);
|
||||||
fetchPost("/api/import/importSY", formData, () => {
|
fetchPost("/api/import/importSY", formData, () => {
|
||||||
let files
|
let files;
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
files = window.siyuan.mobile.files
|
files = window.siyuan.mobile.files;
|
||||||
/// #else
|
/// #else
|
||||||
files = (getDockByType("file").data["file"] as Files);
|
files = (getDockByType("file").data["file"] as Files);
|
||||||
/// #endif
|
/// #endif
|
||||||
const liElement = files.element.querySelector(`[data-path="${pathString}"]`)
|
const liElement = files.element.querySelector(`[data-path="${pathString}"]`);
|
||||||
const toggleElement = liElement.querySelector(".b3-list-item__arrow--open");
|
const toggleElement = liElement.querySelector(".b3-list-item__arrow--open");
|
||||||
if (toggleElement) {
|
if (toggleElement) {
|
||||||
toggleElement.classList.remove("b3-list-item__arrow--open");
|
toggleElement.classList.remove("b3-list-item__arrow--open");
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ window.openFileByURL = (openURL) => {
|
||||||
if (openURL && /^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(openURL)) {
|
if (openURL && /^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(openURL)) {
|
||||||
openMobileFileById(openURL.substr(16, 22),
|
openMobileFileById(openURL.substr(16, 22),
|
||||||
getSearch("focus", openURL) === "1" ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]);
|
getSearch("focus", openURL) === "1" ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]);
|
||||||
return true
|
return true;
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ export const initFramework = () => {
|
||||||
mountHelp();
|
mountHelp();
|
||||||
}
|
}
|
||||||
const transactionTipElement = document.getElementById("transactionTip");
|
const transactionTipElement = document.getElementById("transactionTip");
|
||||||
transactionTipElement.innerHTML = `${window.siyuan.languages.waitSync} <button class="b3-button">${window.siyuan.languages.syncNow}</button>`
|
transactionTipElement.innerHTML = `${window.siyuan.languages.waitSync} <button class="b3-button">${window.siyuan.languages.syncNow}</button>`;
|
||||||
transactionTipElement.querySelector(".b3-button").addEventListener(getEventName(), () => {
|
transactionTipElement.querySelector(".b3-button").addEventListener(getEventName(), () => {
|
||||||
syncGuide();
|
syncGuide();
|
||||||
});
|
});
|
||||||
|
|
@ -162,7 +162,7 @@ export const initFramework = () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
setEmpty();
|
setEmpty();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ const showAccountInfo = (modelElement: HTMLElement, modelMainElement: Element) =
|
||||||
window.siyuan.user = null;
|
window.siyuan.user = null;
|
||||||
closePanel();
|
closePanel();
|
||||||
document.getElementById("menuAccount").innerHTML = `<svg class="b3-list-item__graphic"><use xlink:href="#iconAccount"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.login}</span>`;
|
document.getElementById("menuAccount").innerHTML = `<svg class="b3-list-item__graphic"><use xlink:href="#iconAccount"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.login}</span>`;
|
||||||
processSync()
|
processSync();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
modelMainElement.querySelector("#deactivateUser").addEventListener(getEventName(), () => {
|
modelMainElement.querySelector("#deactivateUser").addEventListener(getEventName(), () => {
|
||||||
|
|
@ -71,7 +71,7 @@ const showAccountInfo = (modelElement: HTMLElement, modelMainElement: Element) =
|
||||||
window.siyuan.user = null;
|
window.siyuan.user = null;
|
||||||
closePanel();
|
closePanel();
|
||||||
document.getElementById("menuAccount").innerHTML = `<svg class="b3-list-item__graphic"><use xlink:href="#iconAccount"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.login}</span>`;
|
document.getElementById("menuAccount").innerHTML = `<svg class="b3-list-item__graphic"><use xlink:href="#iconAccount"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.login}</span>`;
|
||||||
processSync()
|
processSync();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -94,7 +94,7 @@ const showAccountInfo = (modelElement: HTMLElement, modelMainElement: Element) =
|
||||||
} else {
|
} else {
|
||||||
menuAccountElement.innerHTML = `<svg class="b3-list-item__graphic"><use xlink:href="#iconAccount"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.login}</span>`;
|
menuAccountElement.innerHTML = `<svg class="b3-list-item__graphic"><use xlink:href="#iconAccount"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.login}</span>`;
|
||||||
}
|
}
|
||||||
processSync()
|
processSync();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -174,7 +174,7 @@ ${accountHTML}
|
||||||
<svg class="b3-list-item__graphic"><use xlink:href="#iconQuit"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.safeQuit}</span>
|
<svg class="b3-list-item__graphic"><use xlink:href="#iconQuit"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.safeQuit}</span>
|
||||||
</div>`;
|
</div>`;
|
||||||
// 只能用 click,否则无法上下滚动 https://github.com/siyuan-note/siyuan/issues/6628
|
// 只能用 click,否则无法上下滚动 https://github.com/siyuan-note/siyuan/issues/6628
|
||||||
processSync()
|
processSync();
|
||||||
menuElement.addEventListener("click", (event) => {
|
menuElement.addEventListener("click", (event) => {
|
||||||
let target = event.target as HTMLElement;
|
let target = event.target as HTMLElement;
|
||||||
while (target && !target.isEqualNode(menuElement)) {
|
while (target && !target.isEqualNode(menuElement)) {
|
||||||
|
|
@ -669,7 +669,7 @@ ${accountHTML}
|
||||||
closePanel();
|
closePanel();
|
||||||
document.getElementById("menuAccount").innerHTML = `<img class="b3-list-item__graphic" src="${window.siyuan.user.userAvatarURL}"/>
|
document.getElementById("menuAccount").innerHTML = `<img class="b3-list-item__graphic" src="${window.siyuan.user.userAvatarURL}"/>
|
||||||
<span class="b3-list-item__text">${window.siyuan.user.userName}</span>`;
|
<span class="b3-list-item__text">${window.siyuan.user.userName}</span>`;
|
||||||
processSync()
|
processSync();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -686,7 +686,7 @@ ${accountHTML}
|
||||||
closePanel();
|
closePanel();
|
||||||
document.getElementById("menuAccount").innerHTML = `<img class="b3-list-item__graphic" src="${window.siyuan.user.userAvatarURL}"/>
|
document.getElementById("menuAccount").innerHTML = `<img class="b3-list-item__graphic" src="${window.siyuan.user.userAvatarURL}"/>
|
||||||
<span class="b3-list-item__text">${window.siyuan.user.userName}</span>`;
|
<span class="b3-list-item__text">${window.siyuan.user.userName}</span>`;
|
||||||
processSync()
|
processSync();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export const onMessage = (data: IWebSocketData) => {
|
||||||
case"syncing":
|
case"syncing":
|
||||||
processSync(data);
|
processSync(data);
|
||||||
if (data.code !== 0) {
|
if (data.code !== 0) {
|
||||||
document.getElementById("transactionTip").classList.add("fn__none")
|
document.getElementById("transactionTip").classList.add("fn__none");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "create":
|
case "create":
|
||||||
|
|
|
||||||
|
|
@ -76,11 +76,11 @@ export const exportImage = (id: string) => {
|
||||||
}, Constants.TIMEOUT_TRANSITION);
|
}, Constants.TIMEOUT_TRANSITION);
|
||||||
});
|
});
|
||||||
const previewElement = exportDialog.element.querySelector("#preview") as HTMLElement;
|
const previewElement = exportDialog.element.querySelector("#preview") as HTMLElement;
|
||||||
const foldElement = (exportDialog.element.querySelector("#keepFold") as HTMLInputElement)
|
const foldElement = (exportDialog.element.querySelector("#keepFold") as HTMLInputElement);
|
||||||
foldElement.addEventListener("change", () => {
|
foldElement.addEventListener("change", () => {
|
||||||
btnsElement[0].setAttribute("disabled", "disabled");
|
btnsElement[0].setAttribute("disabled", "disabled");
|
||||||
btnsElement[1].setAttribute("disabled", "disabled");
|
btnsElement[1].setAttribute("disabled", "disabled");
|
||||||
btnsElement[1].parentElement.insertAdjacentHTML("afterend", `<div class="fn__loading"><img height="128px" width="128px" src="stage/loading-pure.svg"></div>`)
|
btnsElement[1].parentElement.insertAdjacentHTML("afterend", "<div class=\"fn__loading\"><img height=\"128px\" width=\"128px\" src=\"stage/loading-pure.svg\"></div>");
|
||||||
window.siyuan.storage[Constants.LOCAL_EXPORTIMG].keepFold = foldElement.checked;
|
window.siyuan.storage[Constants.LOCAL_EXPORTIMG].keepFold = foldElement.checked;
|
||||||
fetchPost("/api/export/exportPreviewHTML", {
|
fetchPost("/api/export/exportPreviewHTML", {
|
||||||
id,
|
id,
|
||||||
|
|
@ -88,7 +88,7 @@ export const exportImage = (id: string) => {
|
||||||
image: true,
|
image: true,
|
||||||
}, (response) => {
|
}, (response) => {
|
||||||
refreshPreview(response);
|
refreshPreview(response);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
const refreshPreview = (response: IWebSocketData) => {
|
const refreshPreview = (response: IWebSocketData) => {
|
||||||
previewElement.innerHTML = response.data.content;
|
previewElement.innerHTML = response.data.content;
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ const promiseTransaction = () => {
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
if ((0 !== window.siyuan.config.sync.provider || (0 === window.siyuan.config.sync.provider && !needSubscribe(""))) &&
|
if ((0 !== window.siyuan.config.sync.provider || (0 === window.siyuan.config.sync.provider && !needSubscribe(""))) &&
|
||||||
window.siyuan.config.repo.key && window.siyuan.config.sync.enabled) {
|
window.siyuan.config.repo.key && window.siyuan.config.sync.enabled) {
|
||||||
document.getElementById("transactionTip").classList.remove("fn__none")
|
document.getElementById("transactionTip").classList.remove("fn__none");
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
if (response.data[0].doOperations[0].action === "setAttrs") {
|
if (response.data[0].doOperations[0].action === "setAttrs") {
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ const setSync = (key?: string, dialog?: Dialog) => {
|
||||||
});
|
});
|
||||||
btnElement.addEventListener("click", () => {
|
btnElement.addEventListener("click", () => {
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
fetchPost("/api/sync/setSyncEnable", {enabled: true}, (response) => {
|
fetchPost("/api/sync/setSyncEnable", {enabled: true}, () => {
|
||||||
window.siyuan.config.sync.enabled = true;
|
window.siyuan.config.sync.enabled = true;
|
||||||
processSync();
|
processSync();
|
||||||
confirmDialog(window.siyuan.languages.syncConfGuide4, window.siyuan.languages.syncConfGuide5, () => {
|
confirmDialog(window.siyuan.languages.syncConfGuide4, window.siyuan.languages.syncConfGuide5, () => {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import {addGA, initAssets, setInlineStyle, setMode} from "./assets";
|
||||||
import {renderSnippet} from "../config/util/snippets";
|
import {renderSnippet} from "../config/util/snippets";
|
||||||
import {openFileById} from "../editor/util";
|
import {openFileById} from "../editor/util";
|
||||||
import {focusByRange} from "../protyle/util/selection";
|
import {focusByRange} from "../protyle/util/selection";
|
||||||
import {exitSiYuan, processSync, progressLoading} from "../dialog/processSystem";
|
import {exitSiYuan, processSync} from "../dialog/processSystem";
|
||||||
import {openSetting} from "../config";
|
import {openSetting} from "../config";
|
||||||
import {getSearch} from "./functions";
|
import {getSearch} from "./functions";
|
||||||
import {initStatus} from "../layout/status";
|
import {initStatus} from "../layout/status";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue