Преглед на файлове

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

feige996 преди 11 месеца
родител
ревизия
49854948be
променени са 3 файла, в които са добавени 26 реда и са изтрити 1 реда
  1. 21 0
      docs/.vitepress/theme/components/FreshImage.vue
  2. 2 0
      docs/.vitepress/theme/index.ts
  3. 3 1
      docs/advanced/wechat/wechat.md

+ 21 - 0
docs/.vitepress/theme/components/FreshImage.vue

@@ -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>

+ 2 - 0
docs/.vitepress/theme/index.ts

@@ -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

+ 3 - 1
docs/advanced/wechat/wechat.md

@@ -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 群不会过期,长期有效。