修改分享到微信按钮至HeaderLinks

组件.  并修改博客文章头样式,加入日期显示
This commit is contained in:
2025-08-10 16:01:03 +08:00
parent 85863cb249
commit c557e6980c
5 changed files with 117 additions and 40 deletions

View File

@@ -1,5 +1,6 @@
<script setup lang="ts">
import { useClipboard } from '@vueuse/core'
import WxShare from '~/components/shared/wxShare.vue'
const route = useRoute()
const toast = useToast()
@@ -12,6 +13,11 @@ const origin = computed(() => requestURL.origin)
const mdcLink = computed(() => `${origin.value}${decodeURIComponent(route.path)}`)
const markdownLink = computed(() => `${origin.value}/raw${decodeURIComponent(route.path)}.md`)
const enableWxShare = ref(false)
const shareTitle = computed(() => (import.meta.client ? (document.title || 'Estel Docs') : ''))
const shareDesc = computed(() => (import.meta.client ? (document.title || 'Estel Docs') : ''))
const items = [
{
label: '复制链接',
@@ -26,6 +32,19 @@ const items = [
})
}
},
{
label: '分享到微信',
icon: 'simple-icons:wechat',
onSelect() {
enableWxShare.value = true
toast.add({
title: '已为本页配置微信分享,请在微信内点击右上角分享',
icon: 'lucide-check-circle',
color: 'success'
})
}
},
{
label: '查看 Markdown',
icon: 'simple-icons:markdown',
@@ -79,4 +98,14 @@ const items = [
/>
</UDropdownMenu>
</UButtonGroup>
<!-- 懒加载式挂载微信分享逻辑避免在非微信环境造成无谓请求 -->
<ClientOnly>
<WxShare
v-if="enableWxShare"
:url="mdcLink"
:title="shareTitle"
:desc="shareDesc"
/>
</ClientOnly>
</template>