限制初始密码强制范围并修复后台图片加载

This commit is contained in:
yml
2026-06-18 15:44:41 +08:00
parent 35f2d93fdf
commit 275663c4ea
6 changed files with 73 additions and 8 deletions
@@ -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>