fix: duplicate name on create with same name
This commit is contained in:
parent
66e33a9c7b
commit
1d956be783
1 changed files with 16 additions and 9 deletions
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue