feat: 添加 FreshImage 组件以动态更新图片链接
This commit is contained in:
parent
f192f4ca6b
commit
49854948be
21
docs/.vitepress/theme/components/FreshImage.vue
Normal file
21
docs/.vitepress/theme/components/FreshImage.vue
Normal 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>
|
@ -6,6 +6,7 @@ import './custom.css'
|
|||||||
|
|
||||||
import HomeStar from './components/HomeStar.vue'
|
import HomeStar from './components/HomeStar.vue'
|
||||||
import NavBarTitleAfter from './components/NavBarTitleAfter.vue'
|
import NavBarTitleAfter from './components/NavBarTitleAfter.vue'
|
||||||
|
import FreshImage from './components/FreshImage.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
extends: DefaultTheme,
|
extends: DefaultTheme,
|
||||||
@ -18,5 +19,6 @@ export default {
|
|||||||
},
|
},
|
||||||
enhanceApp({ app, router, siteData }) {
|
enhanceApp({ app, router, siteData }) {
|
||||||
// ...
|
// ...
|
||||||
|
app.component('FreshImage', FreshImage)
|
||||||
},
|
},
|
||||||
} satisfies Theme
|
} satisfies Theme
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
> 有网友测量过,说要看 `四个小时`,哈哈。
|
> 有网友测量过,说要看 `四个小时`,哈哈。
|
||||||
|
|
||||||

|
<!--  -->
|
||||||
|
<!-- 上面的固定地址的方式会导致刷新后还是旧的图片,所以使用下面这种动态地址的方式。 -->
|
||||||
|
<FreshImage src="https://oss.laf.run/ukw0y1-site/unibest-discussion-group/wechat.jpg" alt="微信群二维码" />
|
||||||
|
|
||||||
> 如果上面的微信群满了,请使用下面的 QQ 群,QQ 群不会过期,长期有效。
|
> 如果上面的微信群满了,请使用下面的 QQ 群,QQ 群不会过期,长期有效。
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user