Better special handling for root Document. Restore live updates of relative modified times.
This commit is contained in:
parent
540e825cc3
commit
2978e0c968
|
@ -4,6 +4,7 @@ import { defineStore } from 'pinia'
|
||||||
import { collator } from '@/utils'
|
import { collator } from '@/utils'
|
||||||
import { logoutUser } from '@/repositories/User'
|
import { logoutUser } from '@/repositories/User'
|
||||||
import { watchConnect } from '@/repositories/WS'
|
import { watchConnect } from '@/repositories/WS'
|
||||||
|
import { format } from 'path'
|
||||||
|
|
||||||
type FileData = { id: string; mtime: number; size: number; dir: DirectoryData }
|
type FileData = { id: string; mtime: number; size: number; dir: DirectoryData }
|
||||||
type DirectoryData = {
|
type DirectoryData = {
|
||||||
|
@ -39,11 +40,10 @@ export const useDocumentStore = defineStore({
|
||||||
const docs = []
|
const docs = []
|
||||||
let loc = [] as string[]
|
let loc = [] as string[]
|
||||||
for (const [level, name, key, mtime, size, isfile] of root) {
|
for (const [level, name, key, mtime, size, isfile] of root) {
|
||||||
if (level === 0) continue
|
|
||||||
loc = loc.slice(0, level - 1)
|
loc = loc.slice(0, level - 1)
|
||||||
docs.push({
|
docs.push({
|
||||||
name,
|
name,
|
||||||
loc: loc.join('/'),
|
loc: level ? loc.join('/') : '/',
|
||||||
key,
|
key,
|
||||||
size,
|
size,
|
||||||
sizedisp: formatSize(size),
|
sizedisp: formatSize(size),
|
||||||
|
@ -57,6 +57,9 @@ export const useDocumentStore = defineStore({
|
||||||
console.log("Documents", docs)
|
console.log("Documents", docs)
|
||||||
this.document = docs as Document[]
|
this.document = docs as Document[]
|
||||||
},
|
},
|
||||||
|
updateModified() {
|
||||||
|
for (const doc of this.document) doc.modified = formatUnixDate(doc.mtime)
|
||||||
|
},
|
||||||
login(username: string, privileged: boolean) {
|
login(username: string, privileged: boolean) {
|
||||||
this.user.username = username
|
this.user.username = username
|
||||||
this.user.privileged = privileged
|
this.user.privileged = privileged
|
||||||
|
|
Loading…
Reference in New Issue
Block a user