Skip to content

Commit

Permalink
✨ Feature: add grid view for file explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuingsmile committed Feb 24, 2023
1 parent d533f6f commit 69e1b48
Show file tree
Hide file tree
Showing 6 changed files with 349 additions and 50 deletions.
63 changes: 63 additions & 0 deletions src/renderer/components/ImageWebdav.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<template>
<el-image
:src="isShowThumbnail && item.isImage ?
base64Url
: require(`../manage/pages/assets/icons/${getFileIconPath(item.fileName ?? '')}`)"
fit="contain"
style="height: 100px;width: 100%;margin: 0 auto;"
>
<template #placeholder>
<el-icon>
<Loading />
</el-icon>
</template>
<template #error>
<el-image
:src="require(`../manage/pages/assets/icons/${getFileIconPath(item.fileName ?? '')}`)"
fit="contain"
style="height: 100px;width: 100%;margin: 0 auto;"
/>
</template>
</el-image>
</template>

<script lang="ts" setup>
import { ref, onBeforeMount } from 'vue'
import { getFileIconPath } from '@/manage/utils/common'
import { Loading } from '@element-plus/icons-vue'
const base64Url = ref('')
const props = defineProps(
{
isShowThumbnail: {
type: Boolean,
required: true
},
item: {
type: Object,
required: true
},
url: {
type: String,
required: true
},
headers: {
type: Object,
required: true
}
}
)
const urlCreateObjectURL = async () => {
await fetch(props.url, {
method: 'GET',
headers: props.headers
}).then(res => res.blob()).then(blob => {
base64Url.value = URL.createObjectURL(blob)
})
}
onBeforeMount(async () => {
await urlCreateObjectURL()
})
</script>
Loading

0 comments on commit 69e1b48

Please sign in to comment.