diff --git a/frontend/desktop/src/hooks/useDriver.tsx b/frontend/desktop/src/hooks/useDriver.tsx index 9b0d5b4c1c1..ed9b4f65979 100644 --- a/frontend/desktop/src/hooks/useDriver.tsx +++ b/frontend/desktop/src/hooks/useDriver.tsx @@ -4,6 +4,7 @@ import { formatMoney } from '@/utils/format'; import { Box, Button, Flex, FlexProps, Icon, Image, Text } from '@chakra-ui/react'; import { driver } from '@sealos/driver'; import { useTranslation } from 'next-i18next'; +import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; export function DriverStarIcon() { @@ -43,6 +44,7 @@ export default function useDriver({ openDesktopApp }: { openDesktopApp: any }) { const { t, i18n } = useTranslation(); const [showGuide, setShowGuide] = useState(false); const [giftAmount, setGiftAmount] = useState(8); + const router = useRouter(); const handleSkipGuide = () => { console.log('handleSkipGuide'); @@ -65,7 +67,8 @@ export default function useDriver({ openDesktopApp }: { openDesktopApp: any }) { ); setGiftAmount(rewardBalance); } - if (env?.guideEnabled && data?.metadata?.annotations) { + + if (env?.guideEnabled && data?.metadata?.annotations && !router.query?.openapp) { const isGuidedDesktop = !!data.metadata.annotations?.[GUIDE_DESKTOP_INDEX_KEY]; !isGuidedDesktop ? setShowGuide(true) : ''; } @@ -74,6 +77,7 @@ export default function useDriver({ openDesktopApp }: { openDesktopApp: any }) { } }; handleUserGuide(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const PopoverBodyInfo = (props: FlexProps) => ( diff --git a/frontend/providers/template/src/pages/api/updateRepo.ts b/frontend/providers/template/src/pages/api/updateRepo.ts index 880fb35dca6..bb5a1ee069d 100644 --- a/frontend/providers/template/src/pages/api/updateRepo.ts +++ b/frontend/providers/template/src/pages/api/updateRepo.ts @@ -22,7 +22,8 @@ const readFileList = (targetPath: string, fileList: unknown[] = [], handlePath: // ok:path-join-resolve-traversal const filePath = path.join(sanitizePath(targetPath), sanitizePath(item)); const stats = fs.statSync(filePath); - if (stats.isFile() && path.extname(item) === '.yaml' && item !== 'template.yaml') { + const isYamlFile = path.extname(item) === '.yaml' || path.extname(item) === '.yml'; + if (stats.isFile() && isYamlFile && item !== 'template.yaml') { fileList.push(filePath); } else if (stats.isDirectory() && item === handlePath) { readFileList(filePath, fileList, handlePath); diff --git a/service/license/src/pages/api/payment/create.ts b/service/license/src/pages/api/payment/create.ts index a1360165daf..fecd42ba72d 100644 --- a/service/license/src/pages/api/payment/create.ts +++ b/service/license/src/pages/api/payment/create.ts @@ -8,7 +8,8 @@ import type { NextApiRequest, NextApiResponse } from 'next'; export default async function handler(req: NextApiRequest, res: NextApiResponse) { try { - const { amount, currency, payMethod, stripeCallBackUrl } = req.body as PaymentParams; + const { amount, currency, payMethod, stripeSuccessCallBackUrl, stripeErrorCallBackUrl } = + req.body as PaymentParams; const STRIPE_CALLBACK_URL = process.env.STRIPE_CALLBACK_URL; const userInfo = await authSession(req.headers); if (!userInfo) return jsonRes(res, { code: 401, message: 'token verify error' }); @@ -25,8 +26,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) currency: currency, user: userInfo.uid, payMethod: payMethod, - stripeSuccessUrl: `${STRIPE_CALLBACK_URL}${stripeCallBackUrl}`, - stripeCancelUrl: `${STRIPE_CALLBACK_URL}${stripeCallBackUrl}?stripeState=error` + stripeSuccessUrl: `${STRIPE_CALLBACK_URL}${stripeSuccessCallBackUrl}`, + stripeCancelUrl: `${STRIPE_CALLBACK_URL}${stripeErrorCallBackUrl}` }) }).then((res) => res.json()); diff --git a/service/license/src/pages/cluster/components/Recharge.tsx b/service/license/src/pages/cluster/components/Recharge.tsx index 4391b76cf38..f78e998a7f6 100644 --- a/service/license/src/pages/cluster/components/Recharge.tsx +++ b/service/license/src/pages/cluster/components/Recharge.tsx @@ -96,7 +96,8 @@ export default forwardRef(function RechargeComponent(props, ref) { amount: deFormatMoney(selectAmount).toString(), payMethod: payType, currency: 'CNY', - stripeCallBackUrl: `/cluster?clusterId=${clusterDetail?.clusterId}&stripeState=success&tab=license` + stripeSuccessCallBackUrl: `/cluster?clusterId=${clusterDetail?.clusterId}&tab=license&stripeState=success`, + stripeErrorCallBackUrl: `/cluster?clusterId=${clusterDetail?.clusterId}&tab=license&stripeState=error` }), { async onSuccess(data) { @@ -212,6 +213,7 @@ export default forwardRef(function RechargeComponent(props, ref) { }); setClusterDetail(cluster); }; + useEffect(() => { const { stripeState, orderID, clusterId, tab } = router.query; console.log(stripeState, orderID, clusterId); @@ -229,6 +231,7 @@ export default forwardRef(function RechargeComponent(props, ref) { setOrderID(orderID as string); setTimeout(clearQuery, 0); } else if (stripeState === 'error') { + clusterId ? getCluster(clusterId as string) : ''; toast({ status: 'error', duration: 3000, diff --git a/service/license/src/pages/pricing/components/Product.tsx b/service/license/src/pages/pricing/components/Product.tsx index d1b1994d1f7..a334a4da16c 100644 --- a/service/license/src/pages/pricing/components/Product.tsx +++ b/service/license/src/pages/pricing/components/Product.tsx @@ -107,7 +107,8 @@ export default function Product() { amount: amount, payMethod: payType, currency: 'CNY', - stripeCallBackUrl: '/pricing?stripeState=success' + stripeSuccessCallBackUrl: '/pricing?stripeState=success', + stripeErrorCallBackUrl: '/pricing?stripeState=error' }), { async onSuccess(data) { diff --git a/service/license/src/types/payment.ts b/service/license/src/types/payment.ts index c0d16208f19..0f9cf4545f7 100644 --- a/service/license/src/types/payment.ts +++ b/service/license/src/types/payment.ts @@ -29,8 +29,8 @@ export type PaymentParams = { amount: string; currency: 'CNY'; payMethod: TPayMethod; - stripeCallBackUrl: string; - // clusterId: string; + stripeSuccessCallBackUrl: string; + stripeErrorCallBackUrl: string; }; export type PaymentResultParams = {