mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
0e0cb97f1b
commit
d2e6198e21
3 changed files with 15 additions and 1 deletions
|
|
@ -143,6 +143,18 @@ export const setLocalStorage = () => {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 复写 localStorage
|
||||||
|
window.__localStorage__setItem = localStorage.setItem
|
||||||
|
window.__localStorage__removeItem = localStorage.removeItem
|
||||||
|
localStorage.setItem = function (key, value) {
|
||||||
|
window.__localStorage__setItem.call(this, key, value)
|
||||||
|
fetchPost("/api/storage/setLocalStorageVal", {key, value});
|
||||||
|
}
|
||||||
|
localStorage.removeItem = function (key) {
|
||||||
|
window.__localStorage__removeItem.call(this, key)
|
||||||
|
fetchPost("/api/storage/removeLocalStorageVal", {key});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const exportLocalStorage = (cb: () => void) => {
|
export const exportLocalStorage = (cb: () => void) => {
|
||||||
|
|
|
||||||
2
app/src/types/index.d.ts
vendored
2
app/src/types/index.d.ts
vendored
|
|
@ -26,6 +26,8 @@ type TBazaarType = "templates" | "icons" | "widgets" | "themes"
|
||||||
declare module "blueimp-md5"
|
declare module "blueimp-md5"
|
||||||
|
|
||||||
interface Window {
|
interface Window {
|
||||||
|
__localStorage__removeItem: (key: string) => void
|
||||||
|
__localStorage__setItem: (key: string, value: string) => void
|
||||||
dataLayer: any[]
|
dataLayer: any[]
|
||||||
siyuan: ISiyuan
|
siyuan: ISiyuan
|
||||||
webkit: any
|
webkit: any
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ export const fetchPost = (url: string, data?: any, cb?: (response: IWebSocketDat
|
||||||
}
|
}
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
if (url === "/api/system/exit" || url === "/api/system/setWorkspaceDir" || (
|
if (url === "/api/system/exit" || url === "/api/system/setWorkspaceDir" || (
|
||||||
url === "/api/system/setUILayout" && data.exit // 内核中断,点关闭处理
|
["/api/system/setUILayout", "/api/storage/setLocalStorage"].includes(url) && data.exit // 内核中断,点关闭处理
|
||||||
)) {
|
)) {
|
||||||
ipcRenderer.send(Constants.SIYUAN_CONFIG_CLOSETRAY);
|
ipcRenderer.send(Constants.SIYUAN_CONFIG_CLOSETRAY);
|
||||||
ipcRenderer.send(Constants.SIYUAN_QUIT);
|
ipcRenderer.send(Constants.SIYUAN_QUIT);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue