mirror of
https://github.com/morgan9e/chatgpt-web
synced 2026-04-14 00:14:04 +09:00
Changed to file based save
This commit is contained in:
@@ -118,13 +118,33 @@
|
|||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
document.body.removeChild(link);
|
document.body.removeChild(link);
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error dumping localStorage:', error);
|
console.error('Error dumping localStorage:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadLocalStorage() {
|
||||||
|
var fileInput = document.createElement('input');
|
||||||
|
fileInput.type = "file";
|
||||||
|
fileInput.addEventListener('change', function(e) {
|
||||||
|
var file = e.target.files[0];
|
||||||
|
if (file) {
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.onload = function(e) {
|
||||||
|
var data = JSON.parse(e.target.result);
|
||||||
|
Object.keys(data).forEach(function(key) {
|
||||||
|
localStorage.setItem(key, data[key]);
|
||||||
|
});
|
||||||
|
window.location.reload();
|
||||||
|
};
|
||||||
|
reader.readAsText(file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.body.appendChild(fileInput);
|
||||||
|
fileInput.click();
|
||||||
|
fileInput.remove();
|
||||||
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
// console.log('Downloading from server.');
|
// console.log('Downloading from server.');
|
||||||
// fetchLocalStorage();
|
// fetchLocalStorage();
|
||||||
@@ -178,12 +198,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="is-left is-up ml-2">
|
<div class="is-left is-up ml-2">
|
||||||
<button class="button" aria-haspopup="true" on:click|preventDefault|stopPropagation={() => { uploadLocalStorage(); }}>
|
<button class="button" aria-haspopup="true" on:click|preventDefault|stopPropagation={() => { loadLocalStorage(); }}>
|
||||||
<span class="icon"><Fa icon={faUpload}/></span>
|
<span class="icon"><Fa icon={faUpload}/></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="is-left is-up ml-2">
|
<div class="is-left is-up ml-2">
|
||||||
<button class="button" aria-haspopup="true" on:click|preventDefault|stopPropagation={() => { fetchLocalStorage(); }}>
|
<button class="button" aria-haspopup="true" on:click|preventDefault|stopPropagation={() => { dumpLocalStorage(); }}>
|
||||||
<span class="icon"><Fa icon={faDownload}/></span>
|
<span class="icon"><Fa icon={faDownload}/></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user