mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-07 08:26:57 +08:00
✨ Feature: add imagelocal component
This commit is contained in:
@@ -0,0 +1,63 @@
|
|||||||
|
<template>
|
||||||
|
<el-image
|
||||||
|
:src="isShowThumbnail && item.isImage ?
|
||||||
|
base64Image
|
||||||
|
: 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'
|
||||||
|
import fs from 'fs-extra'
|
||||||
|
import mime from 'mime-types'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
const base64Image = ref('')
|
||||||
|
const props = defineProps(
|
||||||
|
{
|
||||||
|
isShowThumbnail: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
item: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
localPath: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const createBase64Image = async () => {
|
||||||
|
const filePath = path.normalize(props.localPath)
|
||||||
|
const base64 = await fs.readFile(filePath, 'base64')
|
||||||
|
base64Image.value = `data:${mime.lookup(filePath) || 'image/png'};base64,${base64}`
|
||||||
|
}
|
||||||
|
|
||||||
|
onBeforeMount(async () => {
|
||||||
|
try {
|
||||||
|
await createBase64Image()
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -497,7 +497,7 @@ https://www.baidu.com/img/bd_logo1.png"
|
|||||||
shadow="hover"
|
shadow="hover"
|
||||||
>
|
>
|
||||||
<el-image
|
<el-image
|
||||||
v-if="!item.isDir && currentPicBedName !== 'webdavplist' && currentPicBedName !== 'sftp'"
|
v-if="!item.isDir && currentPicBedName !== 'webdavplist' && currentPicBedName !== 'sftp' && currentPicBedName !== 'local'"
|
||||||
:src="isShowThumbnail && item.isImage ?
|
:src="isShowThumbnail && item.isImage ?
|
||||||
item.url
|
item.url
|
||||||
: require(`./assets/icons/${getFileIconPath(item.fileName ?? '')}`)"
|
: require(`./assets/icons/${getFileIconPath(item.fileName ?? '')}`)"
|
||||||
@@ -526,6 +526,13 @@ https://www.baidu.com/img/bd_logo1.png"
|
|||||||
:url="item.url"
|
:url="item.url"
|
||||||
@click="handleClickFile(item)"
|
@click="handleClickFile(item)"
|
||||||
/>
|
/>
|
||||||
|
<ImageLocal
|
||||||
|
v-else-if="!item.isDir && currentPicBedName === 'local' && item.isImage"
|
||||||
|
:is-show-thumbnail="isShowThumbnail"
|
||||||
|
:item="item"
|
||||||
|
:local-path="item.key"
|
||||||
|
@click="handleClickFile(item)"
|
||||||
|
/>
|
||||||
<el-image
|
<el-image
|
||||||
v-else-if="!item.isDir"
|
v-else-if="!item.isDir"
|
||||||
:src="require(`./assets/icons/${getFileIconPath(item.fileName ?? '')}`)"
|
:src="require(`./assets/icons/${getFileIconPath(item.fileName ?? '')}`)"
|
||||||
@@ -1492,6 +1499,7 @@ import { videoExt } from '../utils/videofile'
|
|||||||
|
|
||||||
// 组件
|
// 组件
|
||||||
import ImageWebdav from '@/components/ImageWebdav.vue'
|
import ImageWebdav from '@/components/ImageWebdav.vue'
|
||||||
|
import ImageLocal from '@/components/ImageLocal.vue'
|
||||||
|
|
||||||
// 国际化函数
|
// 国际化函数
|
||||||
import { T as $T } from '@/i18n'
|
import { T as $T } from '@/i18n'
|
||||||
|
|||||||
Reference in New Issue
Block a user