fix: socket CreateFolder folder doubly
This commit is contained in:
parent
db23b90a02
commit
eb40d098ff
1 changed files with 20 additions and 6 deletions
|
|
@ -2,6 +2,7 @@ import { computed, reactive, ref } from 'vue'
|
|||
import { defineStore } from 'pinia'
|
||||
import { io } from 'socket.io-client'
|
||||
import axios from 'axios'
|
||||
import { useErrorStore } from '@/stores/error'
|
||||
|
||||
import api from '@/services/HttpService'
|
||||
|
||||
|
|
@ -69,6 +70,7 @@ function consistantPath(path: string | string[]) {
|
|||
}
|
||||
|
||||
const useStorage = defineStore('storageStore', () => {
|
||||
const error = useErrorStore()
|
||||
const loader = useLoader()
|
||||
const init = ref<boolean>(false)
|
||||
const folder = ref<Record<Path, StorageFolder[]>>({})
|
||||
|
|
@ -201,12 +203,19 @@ const useStorage = defineStore('storageStore', () => {
|
|||
const path = consistantPath(arr.slice(0, -1))
|
||||
|
||||
if (folder.value[path]) {
|
||||
folder.value[path].push({
|
||||
pathname: data.pathname,
|
||||
name: data.name,
|
||||
createdAt: data.createdAt,
|
||||
createdBy: data.createdBy,
|
||||
})
|
||||
const idx = folder.value[path].findIndex(
|
||||
(v) => v.pathname === currentInfo.path,
|
||||
)
|
||||
|
||||
if (idx !== -1) {
|
||||
folder.value[path].push({
|
||||
pathname: data.pathname,
|
||||
name: data.name,
|
||||
createdAt: data.createdAt,
|
||||
createdBy: data.createdBy,
|
||||
})
|
||||
}
|
||||
|
||||
folder.value[path].sort((a, b) => a.pathname.localeCompare(b.pathname))
|
||||
}
|
||||
},
|
||||
|
|
@ -271,6 +280,11 @@ const useStorage = defineStore('storageStore', () => {
|
|||
(v) => v.pathname !== data.pathname,
|
||||
)
|
||||
}
|
||||
|
||||
const idx = folder.value[path].findIndex(
|
||||
(v) => v.pathname === currentInfo.path,
|
||||
)
|
||||
console.log(idx)
|
||||
})
|
||||
socket.on('FileUpload', (data: StorageFile) => {
|
||||
const arr = data.pathname.split('/').filter(Boolean)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue