-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Tutorial.tsx
195 lines (189 loc) · 6.36 KB
/
Tutorial.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import { findClusterById } from '@/api/cluster';
import { getFileByName } from '@/api/oos';
import CodeBlock from '@/components/CodeBlock';
import { CheckListIcon, DownloadIcon, OfflineIcon, OnlineComputerIcon } from '@/components/Icon';
import { useCopyData } from '@/hooks/useCopyData';
import { ClusterType } from '@/types';
import { downloadFromURL } from '@/utils/downloadFIle';
import {
Accordion,
AccordionButton,
AccordionIcon,
AccordionItem,
AccordionPanel,
Box,
Center,
Divider,
Text
} from '@chakra-ui/react';
import { useQuery } from '@tanstack/react-query';
import { useTranslation } from 'next-i18next';
import { useMemo, useState } from 'react';
import ReadMe from './ReadMe';
export default function Tutorial({
clusterId,
ossFileUrl
}: {
clusterId: string;
ossFileUrl: string;
}) {
let { fileNameParams, bashParams, ossVersion } = useMemo(() => {
if (ossFileUrl) {
let match = /cloud-(.*?)\.tar/g.exec(ossFileUrl);
return {
fileNameParams: ossFileUrl.replace('/cloud/', ''),
bashParams: match ? `--cloud-version=${match[1]}` : '--cloud-version v5.0.0-beta1',
ossVersion: match ? `${match[1]}` : 'v5.0.0-beta1'
};
} else {
return {
fileNameParams: '',
bashParams: '',
ossVersion: ''
};
}
}, [ossFileUrl]);
const { t } = useTranslation();
const { copyData } = useCopyData();
const [ossLink, setOssLink] = useState('');
const { data } = useQuery(
['findClusterByIds', clusterId],
() =>
findClusterById({
clusterId
}),
{
async onSuccess(data) {
if (data?.orderID && data.type === ClusterType.Enterprise) {
const _link = await getFileByName(ossFileUrl);
setOssLink(_link);
}
}
}
);
return (
<Box
flex={1}
pt="64px"
pb="40px"
px={{
base: '56px',
xl: '130px'
}}
bg="#F4F6F8"
overflow="scroll"
>
<Text mb="20px" color={'#262A32'} fontSize={'28px'} fontWeight={600} alignSelf={'flex-start'}>
集群安装教程
</Text>
<Accordion color={'#24282C'} allowMultiple>
<AccordionItem bg="#fff" border={'none'} p="10px 32px" mb="8px" borderRadius={'12px'}>
<AccordionButton px="0px" _hover={{ bg: '#fff' }}>
<CheckListIcon w="20px" h="20px" />
<Text ml="16px" fontSize={'18px'} fontWeight={600}>
准备工作
</Text>
<AccordionIcon ml="auto" w="24px" h="24px" />
</AccordionButton>
<AccordionPanel py="20px" pl="40px" gap={'12px'}>
<ReadMe />
<Center
borderRadius={'4px'}
cursor={'pointer'}
mt="20px"
w="218px"
h="44px"
color={'#FFF'}
bg="#24282C"
fontSize={'14px'}
fontWeight={600}
onClick={() =>
window.open('https://sealos.io/zh-Hans/docs/self-hosting/sealos/installation')
}
>
详细文档
</Center>
</AccordionPanel>
</AccordionItem>
{data?.type === ClusterType.Enterprise && (
<AccordionItem bg="#fff" border={'none'} p="10px 32px" mb="8px" borderRadius={'12px'}>
<AccordionButton px="0px" _hover={{ bg: '#fff' }}>
<OfflineIcon w="20px" h="20px" />
<Text ml="16px" fontSize={'18px'} fontWeight={600}>
离线安装
</Text>
<AccordionIcon ml="auto" w="24px" h="24px" />
</AccordionButton>
<AccordionPanel py="20px" pl="40px" gap={'12px'}>
<Text fontSize={'16px'} fontWeight={600}>
下载离线包
</Text>
<Center
borderRadius={'4px'}
cursor={'pointer'}
mt="12px"
w="218px"
h="44px"
color={'#FFF'}
bg="#24282C"
fontSize={'14px'}
fontWeight={600}
onClick={() => downloadFromURL(ossLink)}
>
<DownloadIcon fill={'#fff'} mr="8px" />
<Text>点击下载</Text>
</Center>
<Text mt="24px" fontSize={'16px'} fontWeight={600} mb="12px">
服务器上下载
</Text>
<CodeBlock
language="bash"
code={`wget '${ossLink}' -O ${fileNameParams}`}
></CodeBlock>
<Divider my="20px" />
<Text mt="12px" fontSize={'16px'} fontWeight={600} mb="12px">
部署集群
</Text>
<CodeBlock
language="bash"
code={`tar xzvf ${fileNameParams} \n && cd sealos-cloud && bash install.sh`}
copyValue={`tar xzvf ${fileNameParams} && cd sealos-cloud && bash install.sh`}
></CodeBlock>
</AccordionPanel>
</AccordionItem>
)}
<AccordionItem bg="#fff" border={'none'} p="10px 32px" mb="8px" borderRadius={'12px'}>
<AccordionButton px="0px" _hover={{ bg: '#fff' }}>
<OnlineComputerIcon w="20px" h="20px" />
<Text ml="16px" fontSize={'18px'} fontWeight={600}>
在线安装
</Text>
<AccordionIcon ml="auto" w="24px" h="24px" />
</AccordionButton>
<AccordionPanel py="20px" pl="40px" gap={'12px'}>
<CodeBlock
language="bash"
code={`curl -sfL https://gh-proxy.com/https://raw.githubusercontent.com/labring/sealos/main/scripts/cloud/install.sh -o /tmp/install.sh && bash /tmp/install.sh \ --image-registry=registry.cn-shanghai.aliyuncs.com --zh \ --proxy-prefix=https://gh-proxy.com`}
></CodeBlock>
<Center
borderRadius={'4px'}
cursor={'pointer'}
mt="20px"
w="218px"
h="44px"
color={'#FFF'}
bg="#24282C"
fontSize={'14px'}
fontWeight={600}
onClick={() =>
window.open('https://sealos.io/zh-Hans/docs/self-hosting/sealos/installation')
}
>
详细文档
</Center>
</AccordionPanel>
</AccordionItem>
</Accordion>
</Box>
);
}