🐛 修复封面503

This commit is contained in:
目棃
2024-10-12 15:16:06 +08:00
parent 2e152965df
commit 18507b6273
2 changed files with 17 additions and 5 deletions

View File

@@ -59,7 +59,7 @@
</div>
</template>
<script lang="ts" setup>
import { computed, onBeforeMount, onUnmounted, ref } from "vue";
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
import { generateShareImg, saveImgLocal } from "../../utils/TGShare.js";
import { createPost } from "../../utils/TGWindow.js";
@@ -90,15 +90,26 @@ const selectedList = computed({
},
});
onBeforeMount(async () => {
card.value = getPostCard(props.modelValue);
onMounted(async () => await reload(props.modelValue));
watch(() => props.modelValue, reload);
async function reload(data: TGApp.Plugins.Mys.Post.FullData): Promise<void> {
if (localCover.value) {
URL.revokeObjectURL(localCover.value);
localCover.value = undefined;
}
card.value = getPostCard(data);
if (card.value && card.value.cover !== "") {
localCover.value = await saveImgLocal(card.value.cover);
}
});
}
onUnmounted(() => {
if (localCover.value) URL.revokeObjectURL(localCover.value);
if (localCover.value) {
URL.revokeObjectURL(localCover.value);
localCover.value = undefined;
}
});
/**