Vanessa 2023-01-20 11:24:11 +08:00
parent c099f3be2e
commit 367c2f4d18
3 changed files with 36 additions and 26 deletions

View file

@ -191,9 +191,12 @@ export const transactionError = (data: { code: number, data: string }) => {
let progressStatusTimeoutId: number;
export const progressStatus = (data: IWebSocketData) => {
const statusElement = document.querySelector("#status") as HTMLElement;
if (!statusElement) {
return;
}
if (isMobile()) {
clearTimeout(progressStatusTimeoutId);
const statusElement = document.querySelector("#status") as HTMLElement;
statusElement.innerHTML = data.msg;
statusElement.classList.remove("status--hide");
if (document.querySelector("#keyboardToolbar").classList.contains("fn__none")) {
@ -206,7 +209,7 @@ export const progressStatus = (data: IWebSocketData) => {
}, 6000);
return;
}
document.querySelector("#status .status__msg").innerHTML = data.msg;
statusElement.querySelector(".status__msg").innerHTML = data.msg;
};
export const progressLoading = (data: IWebSocketData) => {

View file

@ -128,30 +128,6 @@ export const initFramework = () => {
closePanel();
});
initEditorName();
if (getOpenNotebookCount() > 0) {
const openId = getSearch("id");
if (openId) {
openMobileFileById(openId,
getSearch("focus") === "1" ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]);
} else {
const localDoc = window.siyuan.storage[Constants.LOCAL_DOCINFO];
fetchPost("/api/block/checkBlockExist", {id: localDoc.id}, existResponse => {
if (existResponse.data) {
openMobileFileById(localDoc.id, localDoc.action);
} else {
fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => {
if (response.data.length !== 0) {
openMobileFileById(response.data[0].id, [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]);
} else {
setEmpty();
}
});
}
});
}
} else {
setEmpty();
}
if (window.siyuan.config.newbie) {
mountHelp();
}
@ -160,6 +136,36 @@ export const initFramework = () => {
transactionTipElement.querySelector(".b3-button").addEventListener(getEventName(), () => {
syncGuide();
});
if (getOpenNotebookCount() > 0) {
const openURL = window.JSAndroid.getBlockURL();
if (openURL && !/^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(openURL)) {
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]);
return;
}
const openId = getSearch("id");
if (openId) {
openMobileFileById(openId,
getSearch("focus") === "1" ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]);
return;
}
const localDoc = window.siyuan.storage[Constants.LOCAL_DOCINFO];
fetchPost("/api/block/checkBlockExist", {id: localDoc.id}, existResponse => {
if (existResponse.data) {
openMobileFileById(localDoc.id, localDoc.action);
} else {
fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => {
if (response.data.length !== 0) {
openMobileFileById(response.data[0].id, [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]);
} else {
setEmpty();
}
});
}
});
return
}
setEmpty();
};
const initEditorName = () => {

View file

@ -42,6 +42,7 @@ interface Window {
writeClipboard(text: string): void
writeImageClipboard(uri: string): void
readClipboard(): string
getBlockURL(): string
}
goBack(): void