chore: call only once useRoute

This commit is contained in:
userquin 2023-01-09 12:55:15 +01:00
parent 531392f967
commit fcf712ef42

View file

@ -16,7 +16,8 @@ export default defineNuxtPlugin(() => {
return !!lastStatus.value[path] return !!lastStatus.value[path]
}, },
restoreScrollPosition: () => { restoreScrollPosition: () => {
const restore = lastStatus.value[useRoute().fullPath] const fullPath = useRoute().fullPath
const restore = lastStatus.value[fullPath]
if (restore) { if (restore) {
const el = restore.type === 'status' const el = restore.type === 'status'
? document.getElementById(`status-${restore.id}`) ? document.getElementById(`status-${restore.id}`)
@ -28,7 +29,7 @@ export default defineNuxtPlugin(() => {
window.scrollTo(0, restore.position) window.scrollTo(0, restore.position)
} }
else { else {
delete lastStatus.value[useRoute().fullPath] delete lastStatus.value[fullPath]
} }
} }
}, },