diff --git a/app/components/docs/DocsPageHeaderLinks.vue b/app/components/docs/DocsPageHeaderLinks.vue index f00d475..9aa16da 100644 --- a/app/components/docs/DocsPageHeaderLinks.vue +++ b/app/components/docs/DocsPageHeaderLinks.vue @@ -2,6 +2,12 @@ import { useClipboard } from '@vueuse/core' import WxShare from '~/components/shared/wxShare.vue' +const props = defineProps<{ + title?: string + desc?: string + imgUrl?: string +}>() + const route = useRoute() const toast = useToast() const { copy, copied } = useClipboard() @@ -15,8 +21,9 @@ const markdownLink = computed(() => `${origin.value}/raw${decodeURIComponent(rou 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 shareTitle = computed(() => props.title ?? (import.meta.client ? (document.title || 'Estel Docs') : '')) +const shareDesc = computed(() => props.desc ?? (import.meta.client ? (document.title || 'Estel Docs') : '')) +const shareImg = computed(() => props.imgUrl ?? '/images/default-blog.jpg') const items = [ { @@ -106,6 +113,7 @@ const items = [ :url="mdcLink" :title="shareTitle" :desc="shareDesc" + :img-url="shareImg" /> diff --git a/app/pages/blog/[...slug].vue b/app/pages/blog/[...slug].vue index 6a35c77..0bdf774 100644 --- a/app/pages/blog/[...slug].vue +++ b/app/pages/blog/[...slug].vue @@ -98,37 +98,6 @@ const links = computed(() => { return [...links, ...(appConfig.toc?.bottom?.links || [])].filter(Boolean) }) - -// // ===== 微信分享(测试按钮用)===== -// const wxShareActive = ref(false) -// // const contentRoot = ref(null) - -// const shareLink = computed(() => 'https://lijue.me' + decodeURIComponent(path.value)) -// const shareTitle = computed(() => title) -// const shareDesc = computed(() => description || title) -// const shareImg = page?.value?.img -// const shareImg = ref('/images/default-blog.jpg') - -// onMounted(() => { -// // 从正文中抓取第一张图片作为分享图 -// const el = contentRoot.value -// const firstImg = el?.querySelector('img') as HTMLImageElement | null -// if (firstImg?.src) { -// shareImg.value = firstImg.src -// } -// }) - -// // Toast:点击测试分享后给出指引 -// const toast = useToast() -// function handleShareClick() { -// wxShareActive.value = true -// toast.add({ -// title: '已获取分享接口', -// description: '点击右上角分享吧', -// duration: 3000, -// icon: 'i-lucide-share-2' -// }) -// } @@ -192,16 +165,6 @@ const links = computed(() => { > 提交问题 - -