mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
feat(docs): preview page jumps to github with pr number (#15854)
* feat(docs): preview page jumps to github with pr number * feat: remove return * chore: update * chore: update * chore: use globalThis * feat: update
This commit is contained in:
@@ -1,16 +1,28 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import type { Component } from 'vue'
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
icon: Component
|
||||
link: string
|
||||
text: string
|
||||
}>()
|
||||
|
||||
const targetLink = ref(props.link)
|
||||
onMounted(() => {
|
||||
if (props.text === 'GitHub') {
|
||||
const isPreview = globalThis.location?.host.startsWith('preview')
|
||||
if (isPreview) {
|
||||
const pr = globalThis.location.host.split('-', 2)[1]
|
||||
targetLink.value = `${targetLink.value}/pull/${pr}`
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a
|
||||
:href="link"
|
||||
:href="targetLink"
|
||||
:title="text"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
|
||||
Reference in New Issue
Block a user