|
@ -14,7 +14,7 @@ |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
<script lang="ts" setup> |
|
|
<script lang="ts" setup> |
|
|
import { provide, ref, renderSlot, useSlots, getCurrentInstance } from "vue" |
|
|
import { provide, ref, renderSlot, useSlots, getCurrentInstance, watch } from "vue" |
|
|
import node from './node.vue' |
|
|
import node from './node.vue' |
|
|
import type { INiuTreeData, INiuTreeKey } from './type' |
|
|
import type { INiuTreeData, INiuTreeKey } from './type' |
|
|
import { ENiuTreeStatus } from './type' |
|
|
import { ENiuTreeStatus } from './type' |
|
@ -30,19 +30,7 @@ import { |
|
|
} from './util' |
|
|
} from './util' |
|
|
|
|
|
|
|
|
import { betterDirectorySort } from "./better-directory-sort" |
|
|
import { betterDirectorySort } from "./better-directory-sort" |
|
|
import { computed } from "@vue/reactivity" |
|
|
import { cloneDeep } from "lodash" |
|
|
|
|
|
|
|
|
const sortedList = computed(() => { |
|
|
|
|
|
if (props.sort) { |
|
|
|
|
|
return props.list.sort((a, b) => { |
|
|
|
|
|
return betterDirectorySort( |
|
|
|
|
|
{ name: a.title, isDirectory: a.isFolder }, |
|
|
|
|
|
{ name: b.title, isDirectory: b.isFolder }, |
|
|
|
|
|
); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
return props.list |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const isDrag = ref(false) |
|
|
const isDrag = ref(false) |
|
|
function onDragover2() { |
|
|
function onDragover2() { |
|
@ -102,6 +90,21 @@ provide("tree:data", { |
|
|
parentKey: ref<INiuTreeKey>() |
|
|
parentKey: ref<INiuTreeKey>() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const sortedList = ref([]) |
|
|
|
|
|
watch(()=>props.list, ()=>{ |
|
|
|
|
|
if (props.sort) { |
|
|
|
|
|
sortedList.value = props.list.sort((a, b) => { |
|
|
|
|
|
return betterDirectorySort( |
|
|
|
|
|
{ name: a.title, isDirectory: a.isFolder }, |
|
|
|
|
|
{ name: b.title, isDirectory: b.isFolder }, |
|
|
|
|
|
); |
|
|
|
|
|
}) |
|
|
|
|
|
}else{ |
|
|
|
|
|
sortedList.value = props.list |
|
|
|
|
|
} |
|
|
|
|
|
}, { deep: true, immediate: true }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onExpand(item: INiuTreeData) { |
|
|
function onExpand(item: INiuTreeData) { |
|
|
emit("expand", item) |
|
|
emit("expand", item) |
|
|
} |
|
|
} |
|
|