feat: remember last edited scene path in editor via localStorage
This commit is contained in:
@@ -79,7 +79,23 @@ async function loadDemo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => loadDemo())
|
async function restoreOrLoad() {
|
||||||
|
const lastSource = localStorage.getItem('editor_last_source')
|
||||||
|
if (lastSource) {
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
const resp = await fetch(lastSource)
|
||||||
|
if (resp.ok) {
|
||||||
|
store.loadJSON(await resp.json())
|
||||||
|
store.setSourcePath(lastSource)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
await loadDemo()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => restoreOrLoad())
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ export const useEditorStore = defineStore('editor', () => {
|
|||||||
dirty.value = true
|
dirty.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSourcePath(p: string) { sourcePath.value = p }
|
function setSourcePath(p: string) { sourcePath.value = p; localStorage.setItem('editor_last_source', p) }
|
||||||
|
|
||||||
async function autoSave() {
|
async function autoSave() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user