|
@@ -8,7 +8,10 @@
|
|
|
@click="selectMode ? changeSelects(photo, !selects.includes(photo)) : $emit('update:active', photo)"
|
|
|
>
|
|
|
<div class="img-layout">
|
|
|
- <img :src="useStaticUrl(getURL ? getURL(photo) : photo.url).value" />
|
|
|
+ <div class="occupying" v-if="!urls.get(photo).value">
|
|
|
+ <p>图片加载中</p>
|
|
|
+ </div>
|
|
|
+ <img :src="urls.get(photo).value" v-else />
|
|
|
<ui-input
|
|
|
width="24px"
|
|
|
height="24px"
|
|
@@ -30,6 +33,7 @@
|
|
|
import { useStaticUrl } from '@/hook/useStaticUrl'
|
|
|
import UiInput from "@/components/base/components/input/index.vue";
|
|
|
import Undata from "./undata.vue";
|
|
|
+import {computed, reactive, Ref} from "vue";
|
|
|
|
|
|
type Item = { url: string, id: string }
|
|
|
|
|
@@ -47,6 +51,14 @@ const emit = defineEmits<{
|
|
|
(e: "update:selects", a: Item[]): void,
|
|
|
}>()
|
|
|
|
|
|
+const urls = computed(() => {
|
|
|
+ const urls = reactive(new Map<Item, Ref<string>>())
|
|
|
+ props.data.forEach(item => {
|
|
|
+ urls.set(item, useStaticUrl(props.getURL ? props.getURL(item) : item.url))
|
|
|
+ })
|
|
|
+ return urls
|
|
|
+})
|
|
|
+
|
|
|
const changeSelects = (item: Item, selected: boolean) => {
|
|
|
const olSelected = props.selects.includes(item)
|
|
|
if (selected !== olSelected) {
|
|
@@ -89,12 +101,27 @@ const changeSelects = (item: Item, selected: boolean) => {
|
|
|
position: relative;
|
|
|
height: 100%;
|
|
|
}
|
|
|
+.occupying,
|
|
|
.photo img {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
object-fit: contain;
|
|
|
border-radius: 4px;
|
|
|
}
|
|
|
+
|
|
|
+.occupying {
|
|
|
+ background-color: #ccc;
|
|
|
+ color: #003eff;
|
|
|
+ position: relative;
|
|
|
+ padding-top: 52%;
|
|
|
+
|
|
|
+ p {
|
|
|
+ position: absolute;
|
|
|
+ top: 50%;
|
|
|
+ left: 50%;
|
|
|
+ transform: translate(-50%, -50%);
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|
|
|
|
|
|
<style lang="scss">
|