💄 优化图片加载显示

This commit is contained in:
目棃
2024-09-02 13:45:49 +08:00
parent e7b176f9f4
commit 49a9060212

View File

@@ -1,7 +1,11 @@
<template> <template>
<div class="tp-image-box" @click="showOverlay = true"> <div class="tp-image-box" @click="showOverlay = true" v-if="localUrl !== undefined">
<img :src="localUrl" :alt="props.data.insert.image" :title="getImageTitle()" /> <img :src="localUrl" :alt="props.data.insert.image" :title="getImageTitle()" />
</div> </div>
<div v-else class="tp-image-load" :title="getImageUrl()">
<v-progress-circular indeterminate color="primary" size="small" />
<span>加载中...</span>
</div>
<TpoImage :image="props.data" v-model="showOverlay" /> <TpoImage :image="props.data" v-model="showOverlay" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@@ -31,7 +35,7 @@ interface TpImageProps {
const props = defineProps<TpImageProps>(); const props = defineProps<TpImageProps>();
const showOverlay = ref(false); const showOverlay = ref(false);
const localUrl = ref<string>(); const localUrl = ref<string | undefined>(undefined);
console.log("tp-image", props.data.insert.image, props.data.attributes); console.log("tp-image", props.data.insert.image, props.data.attributes);
@@ -80,4 +84,12 @@ function getImageUrl(): string {
border-radius: 10px; border-radius: 10px;
cursor: pointer; cursor: pointer;
} }
.tp-image-load {
display: flex;
align-items: center;
justify-content: center;
margin: 10px auto;
column-gap: 5px;
}
</style> </style>