Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: local storage

Vanessa722f71803e19
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts
index 48c2788ab0..fdd0fb075e 100644
--- a/app/src/protyle/util/compatibility.ts
+++ b/app/src/protyle/util/compatibility.ts
@@ -135,11 +135,15 @@ export const hotKey2Electron = (key: string) => {
export const setLocalStorage = () => {
fetchPost("/api/storage/getLocalStorage", undefined, (response) => {
- localStorage.clear();
if (response.data) {
+ localStorage.clear();
Object.keys(response.data).forEach(item => {
- localStorage.setItem(item, response.data[item]);
+ if (item !== "setItem" && item !== "removeItem") {
+ localStorage.setItem(item, response.data[item]);
+ }
});
+ } else {
+ exportLocalStorage();
}
});
@@ -156,8 +160,10 @@ export const setLocalStorage = () => {
};
};
-export const exportLocalStorage = (cb: () => void) => {
+export const exportLocalStorage = (cb?: () => void) => {
fetchPost("/api/storage/setLocalStorage", {val: localStorage}, () => {
- cb();
+ if (cb) {
+ cb();
+ }
});
};