🐛 Fix: file sort order will not changed after force refresh now

This commit is contained in:
萌萌哒赫萝
2023-08-12 09:16:46 -07:00
parent 083917e34f
commit 52f0fce65a
3 changed files with 80 additions and 109 deletions

View File

@@ -26,6 +26,8 @@ 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(
@@ -46,11 +48,16 @@ const props = defineProps(
)
const createBase64Image = async () => {
const base64 = await fs.readFile(props.localPath, 'base64')
base64Image.value = `data:image/png;base64,${base64}`
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 () => {
await createBase64Image()
try {
await createBase64Image()
} catch (e) {
console.log(e)
}
})
</script>