Preserve cursor and selection across reloads.
This commit is contained in:
parent
8592d462f2
commit
52beedcef0
|
@ -221,7 +221,7 @@ onMounted(() => {
|
|||
updateModified(); modifiedTimer = setInterval(updateModified, 1000)
|
||||
const active = document.querySelector('.cursor') as HTMLElement | null
|
||||
if (active) {
|
||||
active.scrollIntoView({ block: 'center', behavior: 'smooth' })
|
||||
active.scrollIntoView({ block: 'center', behavior: 'instant' })
|
||||
active.focus()
|
||||
}
|
||||
})
|
||||
|
|
|
@ -164,15 +164,10 @@ watchEffect(() => {
|
|||
focusBreadcrumb()
|
||||
}
|
||||
})
|
||||
let nowkey = ref(0)
|
||||
let modifiedTimer: any = null
|
||||
const updateModified = () => {
|
||||
nowkey.value = Math.floor(Date.now() / 1000)
|
||||
}
|
||||
onMounted(() => {
|
||||
const active = document.querySelector('.cursor') as HTMLElement | null
|
||||
if (active) {
|
||||
active.scrollIntoView({ block: 'center', behavior: 'smooth' })
|
||||
active.scrollIntoView({ block: 'center', behavior: 'instant' })
|
||||
active.focus()
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { FileEntry, FUID, SelectedItems } from '@/repositories/Document'
|
||||
import { Doc } from '@/repositories/Document'
|
||||
import { defineStore } from 'pinia'
|
||||
import { defineStore, type StateTree } from 'pinia'
|
||||
import { collator } from '@/utils'
|
||||
import { logoutUser } from '@/repositories/User'
|
||||
import { watchConnect } from '@/repositories/WS'
|
||||
|
@ -11,7 +11,7 @@ export const useMainStore = defineStore({
|
|||
id: 'main',
|
||||
state: () => ({
|
||||
document: shallowRef<Doc[]>([]),
|
||||
selected: new Set<FUID>(),
|
||||
selected: new Set<FUID>([]),
|
||||
query: '' as string,
|
||||
fileExplorer: null as any,
|
||||
error: '' as string,
|
||||
|
@ -31,7 +31,18 @@ export const useMainStore = defineStore({
|
|||
}
|
||||
}),
|
||||
persist: {
|
||||
paths: ['prefs'],
|
||||
paths: ['prefs', 'cursor', 'selected'],
|
||||
serializer: {
|
||||
deserialize: (data: string): StateTree => {
|
||||
const ret = JSON.parse(data)
|
||||
ret.selected = new Set(ret.selected)
|
||||
return ret
|
||||
},
|
||||
serialize: (tree: StateTree): string => {
|
||||
tree.selected = Array.from(tree.selected)
|
||||
return JSON.stringify(tree)
|
||||
}
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
updateRoot(root: FileEntry[]) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user