mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-03-13 00:18:13 -04:00
🐛 Fix: fix a bug of webdav image preview component
This commit is contained in:
parent
52f0fce65a
commit
f6c9a789d1
@ -22,7 +22,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onBeforeMount } from 'vue'
|
||||
import { ref, onBeforeMount, watch } from 'vue'
|
||||
import { getFileIconPath } from '@/manage/utils/common'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
import fs from 'fs-extra'
|
||||
@ -47,6 +47,19 @@ const props = defineProps(
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.localPath,
|
||||
async (newLocalPath, oldLocalPath) => {
|
||||
if (newLocalPath !== oldLocalPath) {
|
||||
try {
|
||||
await createBase64Image()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const createBase64Image = async () => {
|
||||
const filePath = path.normalize(props.localPath)
|
||||
const base64 = await fs.readFile(filePath, 'base64')
|
||||
|
@ -22,7 +22,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onBeforeMount } from 'vue'
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import { getFileIconPath } from '@/manage/utils/common'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
|
||||
@ -48,6 +48,20 @@ const props = defineProps(
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => [props.url, props.headers],
|
||||
async (newValues, oldValues) => {
|
||||
if (newValues[0] !== oldValues[0] || newValues[1] !== oldValues[1]) {
|
||||
try {
|
||||
await urlCreateObjectURL()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const urlCreateObjectURL = async () => {
|
||||
await fetch(props.url, {
|
||||
method: 'GET',
|
||||
@ -59,7 +73,7 @@ const urlCreateObjectURL = async () => {
|
||||
})
|
||||
}
|
||||
|
||||
onBeforeMount(async () => {
|
||||
onMounted(async () => {
|
||||
await urlCreateObjectURL()
|
||||
})
|
||||
</script>
|
||||
|
@ -2199,12 +2199,11 @@ async function resetParam (force: boolean = false) {
|
||||
}
|
||||
|
||||
watch(route, async (newRoute) => {
|
||||
if (newRoute.query.configMap) {
|
||||
const queryConfigMap = newRoute.query.configMap as string
|
||||
if (queryConfigMap) {
|
||||
isShowLoadingPage.value = true
|
||||
const query = newRoute.query.configMap as string
|
||||
for (const key in JSON.parse(query)) {
|
||||
configMap[key] = JSON.parse(query)[key]
|
||||
}
|
||||
const parsedConfigMap = JSON.parse(queryConfigMap)
|
||||
Object.assign(configMap, parsedConfigMap)
|
||||
await initCustomDomainList()
|
||||
await resetParam(false)
|
||||
isShowLoadingPage.value = false
|
||||
@ -2227,7 +2226,7 @@ async function forceRefreshFileList () {
|
||||
}
|
||||
|
||||
watch(currentPageNumber, () => {
|
||||
if (typeof currentPageNumber.value !== 'number' || currentPageNumber.value === null) {
|
||||
if (typeof currentPageNumber.value !== 'number') {
|
||||
currentPageNumber.value = 1
|
||||
}
|
||||
})
|
||||
@ -2898,8 +2897,7 @@ async function getBucketFileList () {
|
||||
customUrl: currentCustomDomain.value,
|
||||
currentPage: currentPageNumber.value
|
||||
}
|
||||
const res = await ipcRenderer.invoke('getBucketFileList', configMap.alias, param)
|
||||
return res
|
||||
return await ipcRenderer.invoke('getBucketFileList', configMap.alias, param)
|
||||
}
|
||||
|
||||
function handleBatchDeleteInfo () {
|
||||
@ -3137,8 +3135,7 @@ function getTableKeyOfDb () {
|
||||
|
||||
async function searchExistFileList () {
|
||||
const table = fileCacheDbInstance.table(currentPicBedName.value)
|
||||
const res = await table.where('key').equals(getTableKeyOfDb()).toArray()
|
||||
return res
|
||||
return await table.where('key').equals(getTableKeyOfDb()).toArray()
|
||||
}
|
||||
|
||||
function handleDetectShiftKey (event: KeyboardEvent) {
|
||||
|
Loading…
Reference in New Issue
Block a user