Skip to content

Commit

Permalink
fix: unable to jump page (#6772)
Browse files Browse the repository at this point in the history
  • Loading branch information
Layouwen authored Oct 29, 2024
1 parent 2a70c91 commit e667fa9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
13 changes: 11 additions & 2 deletions docs/components/components/Main/MainSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Button } from 'antd-mobile'
import React, { useEffect, useState } from 'react'
import Lottie from 'react-lottie'
import { useTrans } from '../../../../hooks/useTrans'
import { openUrl } from '../../../../utils'
import styles from './index.local.less'

export default (props: { isWidthScreen: boolean }) => {
Expand Down Expand Up @@ -39,15 +40,23 @@ export default (props: { isWidthScreen: boolean }) => {
color='primary'
shape='rounded'
className={styles.buttonLeft}
href={trans('/guide/quick-start', '/zh/guide/quick-start')}
onClick={() =>
openUrl({
href: trans('/guide/quick-start', '/zh/guide/quick-start'),
})
}
>
{trans('Get Start', '开始使用')}
</Button>
<Button
color='primary'
shape='rounded'
className={styles.buttonRight}
href={trans('/components', '/zh/components')}
onClick={() =>
openUrl({
href: trans('/components', '/zh/components'),
})
}
>
{trans('Preview Online', '在线体验')}
</Button>
Expand Down
11 changes: 7 additions & 4 deletions docs/components/components/Main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button, Card } from 'antd-mobile'
import React, { useEffect, useRef, useState } from 'react'
import Lottie from 'react-lottie'
import { useTrans } from '../../../hooks/useTrans'
import { openUrl } from '../../../utils'
import MainSection from './MainSection'
import {
getGuides,
Expand Down Expand Up @@ -99,10 +100,12 @@ export default () => {
</div>
<Button
className={styles.productResourceCardButton}
type='primary'
shape='round'
target={resource.target}
href={resource.buttonLink}
onClick={() =>
openUrl({
href: resource.buttonLink,
target: resource.target,
})
}
>
{resource.buttonText}
</Button>
Expand Down
15 changes: 15 additions & 0 deletions docs/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const openUrl = ({
href,
target,
}: {
href: string
target?: string
}) => {
switch (target) {
case '_blank':
window.open(href, target)
break
default:
window.location.href = href
}
}

1 comment on commit e667fa9

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.