feat: 添加 FreshImage 组件以动态更新图片链接

This commit is contained in:
feige996 2025-05-19 18:31:27 +08:00
parent f192f4ca6b
commit 49854948be
3 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,21 @@
<template>
<img :src="freshUrl" :alt="alt" />
</template>
<script setup>
import { computed } from 'vue'
const props = defineProps({
src: {
type: String,
required: true,
},
alt: {
type: String,
default: '',
},
})
const freshUrl = computed(() => {
return `${props.src}?t=${Date.now()}`
})
</script>

View File

@ -6,6 +6,7 @@ import './custom.css'
import HomeStar from './components/HomeStar.vue'
import NavBarTitleAfter from './components/NavBarTitleAfter.vue'
import FreshImage from './components/FreshImage.vue'
export default {
extends: DefaultTheme,
@ -18,5 +19,6 @@ export default {
},
enhanceApp({ app, router, siteData }) {
// ...
app.component('FreshImage', FreshImage)
},
} satisfies Theme

View File

@ -10,7 +10,9 @@
> 有网友测量过,说要看 `四个小时`,哈哈。
![alt text](https://oss.laf.run/ukw0y1-site/unibest-discussion-group/wechat.jpg)
<!-- ![alt text](https://oss.laf.run/ukw0y1-site/unibest-discussion-group/wechat.jpg) -->
<!-- 上面的固定地址的方式会导致刷新后还是旧的图片,所以使用下面这种动态地址的方式。 -->
<FreshImage src="https://oss.laf.run/ukw0y1-site/unibest-discussion-group/wechat.jpg" alt="微信群二维码" />
> 如果上面的微信群满了,请使用下面的 QQ 群QQ 群不会过期,长期有效。