Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: launchpad multiple port (#3871)
* feat: launchpad multiple port * perf: ui
- Loading branch information
Showing
29 changed files
with
9,178 additions
and
6,475 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type AuthCnamePrams = { | ||
publicDomain: string; | ||
customDomain: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
frontend/providers/applaunchpad/src/components/MyModal/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import { | ||
Modal, | ||
ModalOverlay, | ||
ModalContent, | ||
ModalHeader, | ||
ModalCloseButton, | ||
ModalContentProps, | ||
Box | ||
} from '@chakra-ui/react'; | ||
|
||
interface Props extends ModalContentProps { | ||
showCloseBtn?: boolean; | ||
title?: any; | ||
isCentered?: boolean; | ||
isOpen: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
const MyModal = ({ | ||
isOpen, | ||
onClose, | ||
title, | ||
children, | ||
showCloseBtn = true, | ||
isCentered, | ||
w = 'auto', | ||
maxW = ['90vw', '600px'], | ||
...props | ||
}: Props) => { | ||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose} autoFocus={false} isCentered={isCentered}> | ||
<ModalOverlay /> | ||
<ModalContent | ||
display={'flex'} | ||
flexDirection={'column'} | ||
w={w} | ||
minW={['90vw', '400px']} | ||
maxW={maxW} | ||
position={'relative'} | ||
maxH={'90vh'} | ||
{...props} | ||
> | ||
{!!title && <ModalHeader>{title}</ModalHeader>} | ||
<Box overflow={'overlay'} h={'100%'}> | ||
{showCloseBtn && <ModalCloseButton />} | ||
{children} | ||
</Box> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default MyModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useToast } from '@/hooks/useToast'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import type { UseMutationOptions } from '@tanstack/react-query'; | ||
import { getErrText } from '@/utils/tools'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
interface Props extends UseMutationOptions<any, any, any, any> { | ||
successToast?: string | null; | ||
errorToast?: string | null; | ||
} | ||
|
||
export const useRequest = ({ successToast, errorToast, onSuccess, onError, ...props }: Props) => { | ||
const { toast } = useToast(); | ||
const { t } = useTranslation(); | ||
const mutation = useMutation<unknown, unknown, any, unknown>({ | ||
...props, | ||
onSuccess(res, variables: void, context: unknown) { | ||
onSuccess?.(res, variables, context); | ||
successToast && | ||
toast({ | ||
title: successToast, | ||
status: 'success' | ||
}); | ||
}, | ||
onError(err: any, variables: void, context: unknown) { | ||
onError?.(err, variables, context); | ||
errorToast && | ||
toast({ | ||
title: t(getErrText(err, errorToast)), | ||
status: 'error' | ||
}); | ||
} | ||
}); | ||
|
||
return mutation; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
frontend/providers/applaunchpad/src/pages/api/platform/authCname.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
import { jsonRes } from '@/services/backend/response'; | ||
import dns from 'dns'; | ||
import type { AuthCnamePrams } from '@/api/params'; | ||
import { getErrText } from '@/utils/tools'; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
try { | ||
const { publicDomain, customDomain } = req.body as AuthCnamePrams; | ||
|
||
await (async () => | ||
new Promise((resolve, reject) => { | ||
dns.resolveCname(customDomain, (err, address) => { | ||
if (err) return reject(err); | ||
|
||
if (address[0] !== publicDomain) | ||
return reject("Cname auth error: customDomain's cname is not equal to publicDomain"); | ||
resolve(''); | ||
}); | ||
}))(); | ||
|
||
jsonRes(res); | ||
} catch (error) { | ||
jsonRes(res, { | ||
code: 500, | ||
error | ||
}); | ||
} | ||
} |
Oops, something went wrong.