|
@@ -3,21 +3,21 @@
|
|
|
<div class="flex h-320px overflow-y-auto gap-8px flex-wrap">
|
|
<div class="flex h-320px overflow-y-auto gap-8px flex-wrap">
|
|
|
<div
|
|
<div
|
|
|
class="w-100px h-100px border-solid border-border cursor-pointer flex flex-col"
|
|
class="w-100px h-100px border-solid border-border cursor-pointer flex flex-col"
|
|
|
- v-for="item in videoList"
|
|
|
|
|
|
|
+ v-for="item in fileList"
|
|
|
:key="item.id"
|
|
:key="item.id"
|
|
|
:class="item.id === selected ? 'border-accent-blue!' : ''"
|
|
:class="item.id === selected ? 'border-accent-blue!' : ''"
|
|
|
@click="handleClick(item.id)"
|
|
@click="handleClick(item.id)"
|
|
|
:title="item.fileName"
|
|
:title="item.fileName"
|
|
|
>
|
|
>
|
|
|
<div class="w-100px h-70px flex items-center justify-center">
|
|
<div class="w-100px h-70px flex items-center justify-center">
|
|
|
- <GrDocumentVideo size="45px" />
|
|
|
|
|
|
|
+ <component :is="icon || GrDocumentVideo" size="45px" />
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="h-20px leading-30px text-12px text-text-secondary px-2px truncate">
|
|
<div class="h-20px leading-30px text-12px text-text-secondary px-2px truncate">
|
|
|
{{ item.fileName }}
|
|
{{ item.fileName }}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <el-empty class="mx-auto" v-if="!videoList.length" description="暂无资源" />
|
|
|
|
|
|
|
+ <el-empty class="mx-auto" v-if="!fileList.length" description="暂无资源" />
|
|
|
</div>
|
|
</div>
|
|
|
<template #footer>
|
|
<template #footer>
|
|
|
<el-button @click="handleCancel">取消</el-button>
|
|
<el-button @click="handleCancel">取消</el-button>
|
|
@@ -30,7 +30,12 @@
|
|
|
<LuX v-if="selectedFile" class="cursor-pointer" size="16px" @click="handleClear" />
|
|
<LuX v-if="selectedFile" class="cursor-pointer" size="16px" @click="handleClear" />
|
|
|
</template>
|
|
</template>
|
|
|
<template #append>
|
|
<template #append>
|
|
|
- <GrDocumentVideo size="20px" class="cursor-pointer" @click="visible = true" />
|
|
|
|
|
|
|
+ <component
|
|
|
|
|
+ :is="appendIcon || GrDocumentVideo"
|
|
|
|
|
+ size="20px"
|
|
|
|
|
+ class="cursor-pointer"
|
|
|
|
|
+ @click="visible = true"
|
|
|
|
|
+ />
|
|
|
</template>
|
|
</template>
|
|
|
</el-input>
|
|
</el-input>
|
|
|
</template>
|
|
</template>
|
|
@@ -40,18 +45,35 @@ import { computed, ref } from 'vue'
|
|
|
import { useProjectStore } from '@/store/modules/project'
|
|
import { useProjectStore } from '@/store/modules/project'
|
|
|
import { LuX } from 'vue-icons-plus/lu'
|
|
import { LuX } from 'vue-icons-plus/lu'
|
|
|
import { GrDocumentVideo } from 'vue-icons-plus/gr'
|
|
import { GrDocumentVideo } from 'vue-icons-plus/gr'
|
|
|
|
|
+import { IconType } from 'vue-icons-plus'
|
|
|
|
|
+
|
|
|
|
|
+type FileSelectProps = {
|
|
|
|
|
+ // 扩展名列表
|
|
|
|
|
+ extensionNames: string[]
|
|
|
|
|
+ // input插槽图标
|
|
|
|
|
+ appendIcon?: IconType
|
|
|
|
|
+ // 选择插槽图标
|
|
|
|
|
+ icon?: IconType
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
const modelValue = defineModel('modelValue')
|
|
const modelValue = defineModel('modelValue')
|
|
|
|
|
+
|
|
|
|
|
+const props = defineProps<FileSelectProps>()
|
|
|
|
|
+
|
|
|
const projectStore = useProjectStore()
|
|
const projectStore = useProjectStore()
|
|
|
const visible = ref(false)
|
|
const visible = ref(false)
|
|
|
const selected = ref(modelValue.value)
|
|
const selected = ref(modelValue.value)
|
|
|
// 资源列表
|
|
// 资源列表
|
|
|
-const videoList = computed(() => {
|
|
|
|
|
- return (projectStore.project?.resources.others || []).filter((item) => item.fileType === 'mp4')
|
|
|
|
|
|
|
+const fileList = computed(() => {
|
|
|
|
|
+ // 文件扩展名:['mp4']
|
|
|
|
|
+ const extensionNames = (props.extensionNames || []).map((item) => item.toLowerCase())
|
|
|
|
|
+ return (projectStore.project?.resources.others || []).filter((item) =>
|
|
|
|
|
+ extensionNames.includes((item.fileType || '').toLowerCase())
|
|
|
|
|
+ )
|
|
|
})
|
|
})
|
|
|
// 选中资源
|
|
// 选中资源
|
|
|
const selectedFile = computed(() => {
|
|
const selectedFile = computed(() => {
|
|
|
- return videoList.value.find((item) => item.id === modelValue.value)
|
|
|
|
|
|
|
+ return fileList.value.find((item) => item.id === modelValue.value)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const handleClick = (val: string) => {
|
|
const handleClick = (val: string) => {
|