mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
459b700e26
commit
c33e9429cd
8 changed files with 38 additions and 25 deletions
|
|
@ -119,11 +119,11 @@ export const initBar = (app: App) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (targetId === "barExit") {
|
} else if (targetId === "barExit") {
|
||||||
|
event.stopPropagation();
|
||||||
exportLayout({
|
exportLayout({
|
||||||
errorExit: true,
|
errorExit: true,
|
||||||
cb: exitSiYuan,
|
cb: exitSiYuan,
|
||||||
});
|
});
|
||||||
event.stopPropagation();
|
|
||||||
break;
|
break;
|
||||||
} else if (targetId === "barMode") {
|
} else if (targetId === "barMode") {
|
||||||
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
|
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
|
||||||
|
|
|
||||||
|
|
@ -225,18 +225,19 @@ export const saveLayout = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const exportLayout = (options: {
|
export const exportLayout = async (options: {
|
||||||
cb: () => void,
|
cb: () => void,
|
||||||
errorExit: boolean
|
errorExit: boolean
|
||||||
}) => {
|
}) => {
|
||||||
|
const editors = getAllModels().editor
|
||||||
|
for (let i = 0; i < editors.length; i++) {
|
||||||
|
await saveScroll(editors[i].editor.protyle);
|
||||||
|
}
|
||||||
if (isWindow()) {
|
if (isWindow()) {
|
||||||
const layoutJSON: any = {
|
const layoutJSON: any = {
|
||||||
layout: {},
|
layout: {},
|
||||||
};
|
};
|
||||||
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
||||||
getAllModels().editor.forEach(item => {
|
|
||||||
saveScroll(item.editor.protyle);
|
|
||||||
});
|
|
||||||
sessionStorage.setItem("layout", JSON.stringify(layoutJSON));
|
sessionStorage.setItem("layout", JSON.stringify(layoutJSON));
|
||||||
options.cb();
|
options.cb();
|
||||||
return;
|
return;
|
||||||
|
|
@ -253,10 +254,6 @@ export const exportLayout = (options: {
|
||||||
right: dockToJSON(window.siyuan.layout.rightDock),
|
right: dockToJSON(window.siyuan.layout.rightDock),
|
||||||
};
|
};
|
||||||
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
||||||
getAllModels().editor.forEach(item => {
|
|
||||||
saveScroll(item.editor.protyle);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (window.siyuan.config.readonly) {
|
if (window.siyuan.config.readonly) {
|
||||||
options.cb();
|
options.cb();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -170,9 +170,9 @@ export const initRightMenu = (app: App) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (target.id === "menuSafeQuit") {
|
} else if (target.id === "menuSafeQuit") {
|
||||||
exitSiYuan();
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
exitSiYuan();
|
||||||
break;
|
break;
|
||||||
} else if (target.id === "menuAbout") {
|
} else if (target.id === "menuAbout") {
|
||||||
initAbout();
|
initAbout();
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,13 @@ export const saveScroll = (protyle: IProtyle, getObject = false) => {
|
||||||
if (getObject) {
|
if (getObject) {
|
||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.siyuan.storage[Constants.LOCAL_FILEPOSITION][protyle.block.rootID] = attr;
|
window.siyuan.storage[Constants.LOCAL_FILEPOSITION][protyle.block.rootID] = attr;
|
||||||
setStorageVal(Constants.LOCAL_FILEPOSITION, window.siyuan.storage[Constants.LOCAL_FILEPOSITION]);
|
return new Promise(resolve => {
|
||||||
|
setStorageVal(Constants.LOCAL_FILEPOSITION, window.siyuan.storage[Constants.LOCAL_FILEPOSITION], () => {
|
||||||
|
resolve(true);
|
||||||
|
});
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDocByScroll = (options: {
|
export const getDocByScroll = (options: {
|
||||||
|
|
|
||||||
|
|
@ -300,7 +300,6 @@ export const setStorageVal = (key: string, val: any, cb?: () => void) => {
|
||||||
if (window.siyuan.config.readonly) {
|
if (window.siyuan.config.readonly) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchPost("/api/storage/setLocalStorageVal", {
|
fetchPost("/api/storage/setLocalStorageVal", {
|
||||||
app: Constants.SIYUAN_APPID,
|
app: Constants.SIYUAN_APPID,
|
||||||
key,
|
key,
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ export const reloadProtyle = (protyle: IProtyle, focus: boolean, updateReadonly?
|
||||||
getDocByScroll({
|
getDocByScroll({
|
||||||
protyle,
|
protyle,
|
||||||
focus,
|
focus,
|
||||||
scrollAttr: saveScroll(protyle, true),
|
scrollAttr: saveScroll(protyle, true) as IScrollAttr,
|
||||||
updateReadonly
|
updateReadonly
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ const focusStack = async (app: App, stack: IBackStack) => {
|
||||||
title: info.data.rootTitle,
|
title: info.data.rootTitle,
|
||||||
docIcon: info.data.rootIcon,
|
docIcon: info.data.rootIcon,
|
||||||
callback(tab) {
|
callback(tab) {
|
||||||
const scrollAttr = saveScroll(stack.protyle, true);
|
const scrollAttr = saveScroll(stack.protyle, true) as IScrollAttr;
|
||||||
scrollAttr.rootId = stack.protyle.block.rootID;
|
scrollAttr.rootId = stack.protyle.block.rootID;
|
||||||
scrollAttr.focusId = stack.id;
|
scrollAttr.focusId = stack.id;
|
||||||
scrollAttr.focusStart = stack.position.start;
|
scrollAttr.focusStart = stack.position.start;
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,30 @@ export const processMessage = (response: IWebSocketData) => {
|
||||||
if ("reloadui" === response.cmd) {
|
if ("reloadui" === response.cmd) {
|
||||||
if (response.data?.resetScroll) {
|
if (response.data?.resetScroll) {
|
||||||
window.siyuan.storage[Constants.LOCAL_FILEPOSITION] = {};
|
window.siyuan.storage[Constants.LOCAL_FILEPOSITION] = {};
|
||||||
setStorageVal(Constants.LOCAL_FILEPOSITION, window.siyuan.storage[Constants.LOCAL_FILEPOSITION]);
|
setStorageVal(Constants.LOCAL_FILEPOSITION, window.siyuan.storage[Constants.LOCAL_FILEPOSITION], () => {
|
||||||
}
|
/// #if MOBILE
|
||||||
/// #if MOBILE
|
|
||||||
window.location.reload();
|
|
||||||
/// #else
|
|
||||||
exportLayout({
|
|
||||||
cb() {
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
},
|
/// #else
|
||||||
errorExit: false,
|
exportLayout({
|
||||||
});
|
cb() {
|
||||||
/// #endif
|
window.location.reload();
|
||||||
|
},
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
|
/// #endif
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
/// #if MOBILE
|
||||||
|
window.location.reload();
|
||||||
|
/// #else
|
||||||
|
exportLayout({
|
||||||
|
cb() {
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
errorExit: false,
|
||||||
|
});
|
||||||
|
/// #endif
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue