♻️ 动态获取版块

This commit is contained in:
目棃
2025-01-16 15:51:03 +08:00
parent e8a79fb409
commit 8ecaed05ea
10 changed files with 297 additions and 135 deletions

View File

@@ -10,7 +10,7 @@
<v-progress-circular v-else indeterminate color="primary" size="25" />
</template>
<script lang="ts" setup>
import { onMounted, onUnmounted, ref } from "vue";
import { onMounted, onUnmounted, ref, watch } from "vue";
import { useAppStore } from "@/store/modules/app.js";
import { saveImgLocal } from "@/utils/TGShare.js";
@@ -32,10 +32,21 @@ const appStore = useAppStore();
const localUrl = ref<string>();
onMounted(async () => {
if (!props.src) return;
const link = props.ori ? props.src : appStore.getImageUrl(props.src);
localUrl.value = await saveImgLocal(link);
});
watch(
() => props.src,
async () => {
if (!props.src) return;
if (localUrl.value) URL.revokeObjectURL(localUrl.value);
const link = props.ori ? props.src : appStore.getImageUrl(props.src);
localUrl.value = await saveImgLocal(link);
},
);
onUnmounted(() => {
if (localUrl.value) URL.revokeObjectURL(localUrl.value);
});