From f29f408b676d5dff3bef0d16d0eec8da8a6f2d3c Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 31 May 2024 20:35:57 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E7=9B=AE=E5=BD=95=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...diaDirectoryCard.vue => DirectoryCard.vue} | 17 ++++++++++-- .../{DirctoryTreeInput.vue => PathField.vue} | 27 ++++++++++--------- src/main.ts | 2 ++ src/views/setting/AccountSettingDirectory.vue | 7 ++--- 4 files changed, 35 insertions(+), 18 deletions(-) rename src/components/cards/{MediaDirectoryCard.vue => DirectoryCard.vue} (83%) rename src/components/input/{DirctoryTreeInput.vue => PathField.vue} (78%) diff --git a/src/components/cards/MediaDirectoryCard.vue b/src/components/cards/DirectoryCard.vue similarity index 83% rename from src/components/cards/MediaDirectoryCard.vue rename to src/components/cards/DirectoryCard.vue index 4d022b4a..943c7af2 100644 --- a/src/components/cards/MediaDirectoryCard.vue +++ b/src/components/cards/DirectoryCard.vue @@ -17,6 +17,9 @@ const props = defineProps({ height: String, }) +// 路径 +const path = ref('') + // 类型下拉字典 const typeItems = [ { title: '全部', value: '' }, @@ -25,13 +28,19 @@ const typeItems = [ ] // 定义触发的自定义事件 -const emit = defineEmits(['close', 'changed']) +const emit = defineEmits(['close', 'changed', 'update:modelValue']) // 按钮点击 function onClose() { emit('close') } +// 路径更新 +function updatePath(value: string) { + path.value = value + emit('update:modelValue', value) +} + // 根据选中的媒体类型,获取对应的媒体类别 const getCategories = computed(() => { const default_value = [{ title: '全部', value: '' }] @@ -60,7 +69,11 @@ const getCategories = computed(() => { - + + + diff --git a/src/components/input/DirctoryTreeInput.vue b/src/components/input/PathField.vue similarity index 78% rename from src/components/input/DirctoryTreeInput.vue rename to src/components/input/PathField.vue index 11b01a72..a48c826e 100644 --- a/src/components/input/DirctoryTreeInput.vue +++ b/src/components/input/PathField.vue @@ -21,13 +21,10 @@ const activedDirs = ref([]) // 打开的目录 const openedDirs = ref([]) -// 当前选中的目录 -const selectedDir = ref('') - // 目录列表 const treeItems = ref([ { - name: props.root, + name: '/', path: props.root, children: [], type: '', @@ -48,11 +45,18 @@ async function fetchDirs(item: any) { .catch(err => console.warn(err)) } +// 获取选择的目录路径 +const selectedPath = computed(() => { + if (activedDirs.value.length > 0) { + return activedDirs.value[0] + } + return '' +}) + // 监听目录变化 watch(activedDirs, newVal => { if (!newVal.length) return - selectedDir.value = newVal[0] - emit('update:modelValue', newVal[0]) + emit('update:modelValue', selectedPath) }) onMounted(() => { @@ -61,27 +65,24 @@ onMounted(() => {