Skip to content

Commit 358b44a

Browse files
committed
refactor: support multiple version docs
1 parent 48ab055 commit 358b44a

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

.dumi/components/Redirect.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ import { Spin } from 'antd';
22
import { useLocale } from 'dumi';
33
import { useEffect } from 'react';
44

5-
export const Redirect = ({ url }: { url: string }) => {
5+
export const Redirect = ({ url, target, text }: { url: string; target?: string; text?: string; }) => {
66
const { id: lang } = useLocale();
7+
const loading = target !== '_blank';
78

89
useEffect(() => {
9-
window.location.replace(url);
10+
if (target === '_blank') {
11+
window.open(url);
12+
}
13+
else window.location.replace(url);
1014
}, []);
1115

1216
return (
1317
<div style={{ display: 'flex', justifyContent: 'center', gap: 15 }}>
14-
<Spin />
15-
{lang === 'zh-CN' ? '跳转中...' : 'Redirecting...'}
18+
<Spin spinning={loading} />
19+
{text ? text : lang === 'zh-CN' ? '跳转中...' : 'Redirecting...'}
1620
</div>
1721
);
1822
};

.dumi/pages/guide.en-US.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* order: 2
55
*/
66

7-
import { Redirect } from '../components/Redirect';
7+
import Guide from './guide';
88

9-
export default () => {
10-
return <Redirect url="https://openspg.yuque.com/ndx6g9/ns5nw2" />;
11-
};
9+
export default Guide;

.dumi/pages/guide.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@
44
* order: 2
55
*/
66
import { Redirect } from '../components/Redirect';
7+
import { Button, Typography, Flex } from 'antd';
8+
import { useLocale } from 'dumi';
9+
10+
const { Title } = Typography;
711

812
export default () => {
9-
return <Redirect url="https://openspg.yuque.com/ndx6g9/ooil9x" />;
13+
const { id: locale } = useLocale();
14+
const intl = (zh: string, en: string) => (locale === 'zh-CN' ? zh : en);
15+
16+
return <div>
17+
<Title level={4}>{intl('版本', 'Version')}</Title>
18+
<Redirect url={intl('https://openspg.yuque.com/ndx6g9/nmwkzz', 'https://openspg.yuque.com/ndx6g9/ps5q6b')} target='_blank' text=" " />
19+
<Flex vertical align={'flex-start'}>
20+
<Button type="link" target="_blank" href={intl('https://openspg.yuque.com/ndx6g9/ooil9x', 'https://openspg.yuque.com/ndx6g9/ns5nw2')}>0.0.2</Button>
21+
<Button type="link" target="_blank" href={intl('https://openspg.yuque.com/ndx6g9/nmwkzz', 'https://openspg.yuque.com/ndx6g9/ps5q6b')}>0.0.3</Button>
22+
</Flex>
23+
</div>;
1024
};

0 commit comments

Comments
 (0)