Skip to content

Commit 2d0b409

Browse files
committed
🐛 修复图片渲染异常
1 parent 942068f commit 2d0b409

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/components/viewPost/tp-image.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ const showOverlay = ref<boolean>(false);
5555
const localUrl = ref<string>();
5656
const bgColor = ref<string>("transparent");
5757
58-
const oriUrl = computed<string>(() => {
59-
if (typeof props.data.insert.image === "string") return props.data.insert.image;
60-
return props.data.insert.image.url;
61-
});
58+
const oriUrl = ref<string>("");
6259
const imgExt = computed<string>(() => getImageExt());
6360
const showOri = ref<boolean>(imgExt.value === "gif" || imageQualityPercent.value === 100);
6461
@@ -71,6 +68,7 @@ const imgWidth = computed<string>(() => {
7168
console.log("tp-image", props.data.insert.image, props.data.attributes);
7269
7370
onMounted(async () => {
71+
oriUrl.value = miniImgUrl();
7472
const link = appStore.getImageUrl(oriUrl.value, imgExt.value);
7573
localUrl.value = await saveImgLocal(link);
7674
});
@@ -93,6 +91,17 @@ onUnmounted(() => {
9391
if (localUrl.value) URL.revokeObjectURL(localUrl.value);
9492
});
9593
94+
function miniImgUrl(): string {
95+
let url: string;
96+
if (typeof props.data.insert.image === "string") {
97+
url = props.data.insert.image;
98+
} else {
99+
url = props.data.insert.image.url;
100+
}
101+
const link = new URL(url);
102+
return `${link.origin}${link.pathname}`;
103+
}
104+
96105
function getImageTitle(): string {
97106
const res: string[] = [];
98107
if (props.data.attributes) {

0 commit comments

Comments
 (0)