修改分享传递参数,清理注释
This commit is contained in:
@@ -2,6 +2,12 @@
|
|||||||
import { useClipboard } from '@vueuse/core'
|
import { useClipboard } from '@vueuse/core'
|
||||||
import WxShare from '~/components/shared/wxShare.vue'
|
import WxShare from '~/components/shared/wxShare.vue'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
title?: string
|
||||||
|
desc?: string
|
||||||
|
imgUrl?: string
|
||||||
|
}>()
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const { copy, copied } = useClipboard()
|
const { copy, copied } = useClipboard()
|
||||||
@@ -15,8 +21,9 @@ const markdownLink = computed(() => `${origin.value}/raw${decodeURIComponent(rou
|
|||||||
|
|
||||||
const enableWxShare = ref(false)
|
const enableWxShare = ref(false)
|
||||||
|
|
||||||
const shareTitle = computed(() => (import.meta.client ? (document.title || 'Estel Docs') : ''))
|
const shareTitle = computed(() => props.title ?? (import.meta.client ? (document.title || 'Estel Docs') : ''))
|
||||||
const shareDesc = computed(() => (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 = [
|
const items = [
|
||||||
{
|
{
|
||||||
@@ -106,6 +113,7 @@ const items = [
|
|||||||
:url="mdcLink"
|
:url="mdcLink"
|
||||||
:title="shareTitle"
|
:title="shareTitle"
|
||||||
:desc="shareDesc"
|
:desc="shareDesc"
|
||||||
|
:img-url="shareImg"
|
||||||
/>
|
/>
|
||||||
</ClientOnly>
|
</ClientOnly>
|
||||||
</template>
|
</template>
|
||||||
|
@@ -98,37 +98,6 @@ const links = computed(() => {
|
|||||||
|
|
||||||
return [...links, ...(appConfig.toc?.bottom?.links || [])].filter(Boolean)
|
return [...links, ...(appConfig.toc?.bottom?.links || [])].filter(Boolean)
|
||||||
})
|
})
|
||||||
|
|
||||||
// // ===== 微信分享(测试按钮用)=====
|
|
||||||
// const wxShareActive = ref(false)
|
|
||||||
// // const contentRoot = ref<HTMLElement | null>(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<string>('/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'
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -156,7 +125,11 @@ const links = computed(() => {
|
|||||||
v-bind="link"
|
v-bind="link"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DocsPageHeaderLinks />
|
<DocsPageHeaderLinks
|
||||||
|
:title="page.title"
|
||||||
|
:desc="page.description || page.seo?.description || page.title"
|
||||||
|
:img-url="page.img || '/images/default-blog.jpg'"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</UPageHeader>
|
</UPageHeader>
|
||||||
|
|
||||||
@@ -192,16 +165,6 @@ const links = computed(() => {
|
|||||||
>
|
>
|
||||||
提交问题
|
提交问题
|
||||||
</UButton>
|
</UButton>
|
||||||
|
|
||||||
<!-- <UButton
|
|
||||||
variant="link"
|
|
||||||
color="neutral"
|
|
||||||
icon="lucide-share-2"
|
|
||||||
:ui="{ leadingIcon: 'size-4' }"
|
|
||||||
@click="handleShareClick()"
|
|
||||||
>
|
|
||||||
微信分享
|
|
||||||
</UButton> -->
|
|
||||||
</div>
|
</div>
|
||||||
</USeparator>
|
</USeparator>
|
||||||
<UContentSurround :surround="surround" />
|
<UContentSurround :surround="surround" />
|
||||||
|
Reference in New Issue
Block a user