fix: duplicate name on create with same name

This commit is contained in:
Methapon2001 2023-12-09 12:09:19 +07:00
parent 66e33a9c7b
commit 1d956be783
No known key found for this signature in database
GPG key ID: 849924FEF46BD132

View file

@ -1,6 +1,5 @@
import { defineStore } from 'pinia'
import { reactive } from 'vue'
import { useFileInfoStore } from '@/stores/file-info-data'
import { io } from 'socket.io-client'
import { useTreeDataStore } from '@/stores/tree-data'
import { storeToRefs } from 'pinia'
@ -53,15 +52,23 @@ export const useSocketStore = defineStore('socket', () => {
},
)
currentFolder.value.push({
pathname: pathname,
name: pathArray[pathArray.length - 1],
status: true,
folder: [],
file: [],
})
if (
currentFolder.value.findIndex(
(v) => v.name === pathArray[pathArray.length - 1],
) === -1
) {
currentFolder.value.push({
pathname: pathname,
name: pathArray[pathArray.length - 1],
status: true,
folder: [],
file: [],
})
}
listDataFolder.value = currentFolder.value
currentFolder.value.sort((a, b) => {
return a.name.localeCompare(b.name)
})
}
})