限制初始密码强制范围并修复后台图片加载
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { fetchAdminFileBlob, fetchFileBlobByURL } from '@/shared/api/files'
|
||||
import { isAdminPath } from '@/shared/utils/adminPath'
|
||||
|
||||
const props = defineProps<{
|
||||
source: string
|
||||
@@ -9,6 +10,7 @@ const props = defineProps<{
|
||||
|
||||
const objectURL = ref('')
|
||||
const failed = ref(false)
|
||||
const effectiveAdmin = computed(() => props.admin || isAdminPath(window.location.pathname))
|
||||
|
||||
function extractObjectKey(value: string) {
|
||||
try {
|
||||
@@ -35,7 +37,9 @@ async function loadImage() {
|
||||
try {
|
||||
const key = extractObjectKey(props.source)
|
||||
const blob =
|
||||
props.admin && key ? await fetchAdminFileBlob(key) : await fetchFileBlobByURL(props.source)
|
||||
effectiveAdmin.value && key
|
||||
? await fetchAdminFileBlob(key)
|
||||
: await fetchFileBlobByURL(props.source)
|
||||
objectURL.value = URL.createObjectURL(blob)
|
||||
} catch {
|
||||
failed.value = true
|
||||
@@ -47,7 +51,7 @@ function openImage() {
|
||||
window.open(objectURL.value, '_blank')
|
||||
}
|
||||
|
||||
watch(() => [props.source, props.admin] as const, loadImage, { immediate: true })
|
||||
watch(() => [props.source, effectiveAdmin.value] as const, loadImage, { immediate: true })
|
||||
|
||||
onBeforeUnmount(revokeCurrentURL)
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user