This commit is contained in:
YasinOnm08 2024-10-07 11:16:51 +02:00
parent 2e67f911c1
commit 0f610d3c18
11 changed files with 408 additions and 288 deletions

View file

@ -5,11 +5,13 @@ export function exportSettings(): string {
const settings: { [key: string]: string } = {};
// Loop through all keys in localStorage and add them to the settings object
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
if (key) {
if (key !== "accountName" && key !== "accountPassword" && key !== "accountEmail") {
settings[key] = localStorage.getItem(key) || "";
if (typeof localStorage !== 'undefined') {
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
if (key) {
if (key !== "accountName" && key !== "accountPassword" && key !== "accountEmail") {
settings[key] = localStorage.getItem(key) || "";
}
}
}
}
@ -24,9 +26,11 @@ export function importSettings(jsonData: string): void {
const parsedSettings = JSON.parse(jsonData);
// Loop through parsed settings and save them in localStorage
Object.keys(parsedSettings).forEach((key) => {
localStorage.setItem(key, parsedSettings[key]);
});
if (typeof localStorage !== 'undefined') {
Object.keys(parsedSettings).forEach((key) => {
localStorage.setItem(key, parsedSettings[key]);
});
}
console.log("Settings imported successfully!");
} catch (error) {