Files
estel_docs/app/components/docs/DocsPageHeaderLinks.vue
estel be69a51bb2
Some checks failed
CI / lint (push) Has been cancelled
CI / typecheck (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
改回项目内获取md文档
2025-08-08 12:15:35 +08:00

83 lines
2.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup lang="ts">
import { useClipboard } from '@vueuse/core'
const route = useRoute()
const toast = useToast()
const { copy, copied } = useClipboard()
// SSR 安全:不要直接使用 window改用 useRequestURL().origin
const requestURL = useRequestURL()
const origin = computed(() => requestURL.origin)
const mdcLink = computed(() => `${origin.value}${decodeURIComponent(route.path)}`)
const markdownLink = computed(() => `${origin.value}/raw${decodeURIComponent(route.path)}.md`)
const items = [
{
label: '复制链接',
icon: 'lucide-link',
onSelect() {
copy(mdcLink.value)
toast.add({
title: '文档链接已复制到剪贴板',
icon: 'lucide-check-circle',
color: 'success'
})
}
},
{
label: '查看 Markdown',
icon: 'simple-icons:markdown',
target: '_blank',
to: markdownLink.value
},
{
label: '在 ChatGPT 中打开',
icon: 'simple-icons:openai',
target: '_blank',
to: `https://chatgpt.com/?hints=search&q=${encodeURIComponent(`Read ${markdownLink.value} so I can ask questions about it.`)}`
},
{
label: '在 Claude 中打开',
icon: 'simple-icons:anthropic',
target: '_blank',
to: `https://claude.ai/new?q=${encodeURIComponent(`Read ${markdownLink.value} so I can ask questions about it.`)}`
}
]
</script>
<template>
<UButtonGroup size="sm">
<UButton
label="复制链接"
:icon="copied ? 'lucide-copy-check' : 'lucide-copy'"
color="neutral"
variant="outline"
:ui="{
leadingIcon: [copied ? 'text-primary' : 'text-neutral', 'size-3.5']
}"
@click="copy(mdcLink)"
/>
<UDropdownMenu
size="sm"
:items="items"
:content="{
align: 'end',
side: 'bottom',
sideOffset: 8
}"
:ui="{
content: 'w-48'
}"
>
<UButton
icon="lucide-chevron-down"
color="neutral"
variant="outline"
/>
</UDropdownMenu>
</UButtonGroup>
</template>