Skip to content

Commit cf38081

Browse files
committed
feat: improve Ulink component
1 parent 8f784ca commit cf38081

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/components/common/ulink.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
* @author Surmon <https://github.com/surmon-china>
55
*/
66

7-
import { AnchorHTMLAttributes, defineComponent, h } from 'vue'
7+
import { AnchorHTMLAttributes, PropType, defineComponent, h } from 'vue'
88
import { RouterLink, RouterLinkProps } from 'vue-router'
99

1010
export default defineComponent({
1111
name: 'Ulink',
1212
props: {
13-
// @ts-ignore
14-
...RouterLink.props,
1513
to: {
1614
type: String,
1715
required: false
@@ -27,31 +25,33 @@ export default defineComponent({
2725
blank: {
2826
type: Boolean,
2927
default: true
28+
},
29+
routerLink: {
30+
type: Object as PropType<RouterLinkProps>
3031
}
3132
},
3233
setup(props, context) {
3334
return () => {
34-
const { to, href, external, blank, ...routerLinkProps } = props
3535
const customAttrs: AnchorHTMLAttributes = { ...context.attrs }
3636

3737
// <router-link>
38-
if (to && !to.startsWith('http')) {
39-
const ps: RouterLinkProps = {
40-
to: to,
41-
...routerLinkProps
38+
if (props.to && !props.to.startsWith('http')) {
39+
const linkProps: RouterLinkProps = {
40+
to: props.to,
41+
...(props.routerLink ?? {})
4242
}
43-
return h(RouterLink, ps, context.slots.default)
43+
return h(RouterLink, linkProps, context.slots.default)
4444
}
4545

4646
// <a>
47-
if (external) {
47+
if (props.external) {
4848
customAttrs.rel = 'external nofollow noopener'
4949
}
50-
if (blank) {
50+
if (props.blank) {
5151
customAttrs.target = '_blank'
5252
}
5353

54-
return h('a', { ...customAttrs, href }, context.slots.default?.())
54+
return h('a', { ...customAttrs, href: props.href }, context.slots.default?.())
5555
}
5656
}
5757
})

src/components/widget/sponsor/provider.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@
9595
</ulink>
9696
<ulink
9797
class="more-link"
98-
v-if="allGitHubSponsors.length > maxSponsors"
9998
:href="VALUABLE_LINKS.GITHUB_SPONSORS"
99+
v-if="allGitHubSponsors.length > maxSponsors"
100100
>
101101
+ {{ allGitHubSponsors.length - maxSponsors }}
102102
</ulink>

src/pages/index/twitter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<template>
3838
<div class="twitter">
39-
<placeholder :data="profile" :loading="fetching">
39+
<placeholder :data="profile ?? void 0" :loading="fetching">
4040
<template #placeholder>
4141
<empty class="twitter-empty" bold key="empty" />
4242
</template>

0 commit comments

Comments
 (0)