mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
♻️ 动态获取版块
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user