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>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, onBeforeMount } from 'vue'
|
import { ref, onBeforeMount, watch } from 'vue'
|
||||||
import { getFileIconPath } from '@/manage/utils/common'
|
import { getFileIconPath } from '@/manage/utils/common'
|
||||||
import { Loading } from '@element-plus/icons-vue'
|
import { Loading } from '@element-plus/icons-vue'
|
||||||
import fs from 'fs-extra'
|
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 createBase64Image = async () => {
|
||||||
const filePath = path.normalize(props.localPath)
|
const filePath = path.normalize(props.localPath)
|
||||||
const base64 = await fs.readFile(filePath, 'base64')
|
const base64 = await fs.readFile(filePath, 'base64')
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, onBeforeMount } from 'vue'
|
import { ref, onMounted, watch } from 'vue'
|
||||||
import { getFileIconPath } from '@/manage/utils/common'
|
import { getFileIconPath } from '@/manage/utils/common'
|
||||||
import { Loading } from '@element-plus/icons-vue'
|
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 () => {
|
const urlCreateObjectURL = async () => {
|
||||||
await fetch(props.url, {
|
await fetch(props.url, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@ -59,7 +73,7 @@ const urlCreateObjectURL = async () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onMounted(async () => {
|
||||||
await urlCreateObjectURL()
|
await urlCreateObjectURL()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -2199,12 +2199,11 @@ async function resetParam (force: boolean = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
watch(route, async (newRoute) => {
|
watch(route, async (newRoute) => {
|
||||||
if (newRoute.query.configMap) {
|
const queryConfigMap = newRoute.query.configMap as string
|
||||||
|
if (queryConfigMap) {
|
||||||
isShowLoadingPage.value = true
|
isShowLoadingPage.value = true
|
||||||
const query = newRoute.query.configMap as string
|
const parsedConfigMap = JSON.parse(queryConfigMap)
|
||||||
for (const key in JSON.parse(query)) {
|
Object.assign(configMap, parsedConfigMap)
|
||||||
configMap[key] = JSON.parse(query)[key]
|
|
||||||
}
|
|
||||||
await initCustomDomainList()
|
await initCustomDomainList()
|
||||||
await resetParam(false)
|
await resetParam(false)
|
||||||
isShowLoadingPage.value = false
|
isShowLoadingPage.value = false
|
||||||
@ -2227,7 +2226,7 @@ async function forceRefreshFileList () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
watch(currentPageNumber, () => {
|
watch(currentPageNumber, () => {
|
||||||
if (typeof currentPageNumber.value !== 'number' || currentPageNumber.value === null) {
|
if (typeof currentPageNumber.value !== 'number') {
|
||||||
currentPageNumber.value = 1
|
currentPageNumber.value = 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -2898,8 +2897,7 @@ async function getBucketFileList () {
|
|||||||
customUrl: currentCustomDomain.value,
|
customUrl: currentCustomDomain.value,
|
||||||
currentPage: currentPageNumber.value
|
currentPage: currentPageNumber.value
|
||||||
}
|
}
|
||||||
const res = await ipcRenderer.invoke('getBucketFileList', configMap.alias, param)
|
return await ipcRenderer.invoke('getBucketFileList', configMap.alias, param)
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleBatchDeleteInfo () {
|
function handleBatchDeleteInfo () {
|
||||||
@ -3137,8 +3135,7 @@ function getTableKeyOfDb () {
|
|||||||
|
|
||||||
async function searchExistFileList () {
|
async function searchExistFileList () {
|
||||||
const table = fileCacheDbInstance.table(currentPicBedName.value)
|
const table = fileCacheDbInstance.table(currentPicBedName.value)
|
||||||
const res = await table.where('key').equals(getTableKeyOfDb()).toArray()
|
return await table.where('key').equals(getTableKeyOfDb()).toArray()
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDetectShiftKey (event: KeyboardEvent) {
|
function handleDetectShiftKey (event: KeyboardEvent) {
|
||||||
|
Loading…
Reference in New Issue
Block a user