Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix user avator && url #4218

Merged
merged 7 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/website/src/pages/pricing/plan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ export default function Plan() {
{select === 'month' && (
<div className="my-5 text-lg lg:text-xs font-medium text-white/80">
如集群中运行一个容器,配额是 CPU 1核 x 内存1G x 存储卷 100G x 网络 10G,
则一年消耗的费用为 1.61 + 0.80 + 0 + 0 = 2.41元
则一月消耗的费用为 1.61 + 0.80 + 0 + 0 = 2.41元
</div>
)}

{select === 'day' && (
<div className="my-5 text-lg lg:text-xs font-medium text-white/80">
如集群中运行一个容器,配额是 CPU 1核 x 内存1G x 存储卷 100G x 网络 10G,
则一年消耗的费用为 0.05 + 0.03 + 0 + 0 = 0.08元
则一天消耗的费用为 0.05 + 0.03 + 0 + 0 = 0.08元
</div>
)}
<div
Expand Down
2 changes: 1 addition & 1 deletion docs/website/src/pages/pricing/product/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function Product() {
];

return (
<main className="self-center flex w-full max-w-[1280px] flex-col px-10">
<main className="self-center flex w-full max-w-[1280px] flex-col px-10 z-10">
<div className="mt-24 text-white text-6xl font-semibold leading-[140%] self-center max-md:text-4xl lg:text-3xl">
Sealos 私有云
</div>
Expand Down
4 changes: 4 additions & 0 deletions service/license/public/images/avatar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 10 additions & 18 deletions service/license/src/components/Account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,15 @@ export default function Account() {
position={'relative'}
onClick={accountDisclosure.onOpen}
>
{userInfo?.user?.avatar ? (
<Image
width={'36px'}
height={'36px'}
borderRadius="full"
src={userInfo?.user?.avatar || ''}
alt="user avator"
/>
) : (
<Avatar
name={userInfo?.user?.name || ''}
width={'36px'}
height={'36px'}
borderRadius="full"
bg="#36ADEF"
></Avatar>
)}
<Image
opacity={'0.9'}
width={'36px'}
height={'36px'}
borderRadius="full"
src={userInfo?.user?.avatar || ''}
fallbackSrc={'/images/avatar.svg'}
alt="user avator"
/>

{accountDisclosure.isOpen && (
<>
Expand Down Expand Up @@ -75,7 +67,7 @@ export default function Account() {
height={'36px'}
borderRadius="full"
src={userInfo?.user?.avatar || ''}
fallbackSrc="/images/sealos.svg"
fallbackSrc={'/images/avatar.svg'}
alt="user avator"
/>
<Text ml="12px">{userInfo?.user?.name}</Text>
Expand Down
17 changes: 12 additions & 5 deletions service/license/src/components/CodeBlock/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import { useCopyData } from '@/hooks/useCopyData';
import { Center, Flex, FlexProps, Text } from '@chakra-ui/react';
import { Box, Center, Flex, FlexProps, Text } from '@chakra-ui/react';
import { CSSProperties } from 'react';
import { PrismAsyncLight as SyntaxHighlighter } from 'react-syntax-highlighter';
import { CopyIcon } from '@/components/Icon';

type CodeBlockProps = {
code: string;
copyValue?: string;
language: string;
customStyle?: CSSProperties | undefined;
flexStyle?: FlexProps;
};

export default function CodeBlock({ code, language, customStyle, flexStyle }: CodeBlockProps) {
export default function CodeBlock({
code,
language,
customStyle,
flexStyle,
copyValue
}: CodeBlockProps) {
const { copyData } = useCopyData();

return (
Expand All @@ -25,14 +32,14 @@ export default function CodeBlock({ code, language, customStyle, flexStyle }: Co
px="20px"
fontSize={'14px'}
>
<Text mr="10px" color={'#c99bdf'}>
<Box mr="10px" color={'#c99bdf'} alignSelf={'self-start'}>
$
</Text>
</Box>
<SyntaxHighlighter language={language} customStyle={customStyle}>
{code}
</SyntaxHighlighter>
</Flex>
<Center mx="20px" onClick={() => copyData(code)}>
<Center mx="20px" onClick={() => copyData(copyValue ? copyValue : code)}>
<CopyIcon _hover={{ fill: '#219BF4' }} />
</Center>
</Flex>
Expand Down
15 changes: 7 additions & 8 deletions service/license/src/components/Signin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ export default function SigninComponent() {
isLoading: passwordLoading
} = usePassword({ showError });
const isLoading = useMemo(() => passwordLoading || smsLoading, [passwordLoading, smsLoading]);
const isSignIn = useSessionStore((s) => s.isUserLogin);
const router = useRouter();

useEffect(() => {
if (isSignIn()) {
router.push('/pricing');
}
}, [isSignIn, router]);
// const isSignIn = useSessionStore((s) => s.isUserLogin);
// const router = useRouter();
// useEffect(() => {
// if (isSignIn()) {
// router.push('/pricing');
// }
// }, [isSignIn, router]);

const { AuthList } = useAuthList();

Expand Down
28 changes: 10 additions & 18 deletions service/license/src/components/account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,15 @@ export default function Account() {
position={'relative'}
onClick={accountDisclosure.onOpen}
>
{userInfo?.user?.avatar ? (
<Image
width={'36px'}
height={'36px'}
borderRadius="full"
src={userInfo?.user?.avatar || ''}
alt="user avator"
/>
) : (
<Avatar
name={userInfo?.user?.name || ''}
width={'36px'}
height={'36px'}
borderRadius="full"
bg="#36ADEF"
></Avatar>
)}
<Image
opacity={'0.9'}
width={'36px'}
height={'36px'}
borderRadius="full"
src={userInfo?.user?.avatar || ''}
fallbackSrc={'/images/avatar.svg'}
alt="user avator"
/>

{accountDisclosure.isOpen && (
<>
Expand Down Expand Up @@ -75,7 +67,7 @@ export default function Account() {
height={'36px'}
borderRadius="full"
src={userInfo?.user?.avatar || ''}
fallbackSrc="/images/sealos.svg"
fallbackSrc={'/images/avatar.svg'}
alt="user avator"
/>
<Text ml="12px">{userInfo?.user?.name}</Text>
Expand Down
15 changes: 7 additions & 8 deletions service/license/src/components/signin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ export default function SigninComponent() {
isLoading: passwordLoading
} = usePassword({ showError });
const isLoading = useMemo(() => passwordLoading || smsLoading, [passwordLoading, smsLoading]);
const isSignIn = useSessionStore((s) => s.isUserLogin);
const router = useRouter();

useEffect(() => {
if (isSignIn()) {
router.push('/pricing');
}
}, [isSignIn, router]);
// const isSignIn = useSessionStore((s) => s.isUserLogin);
// const router = useRouter();
// useEffect(() => {
// if (isSignIn()) {
// router.push('/pricing');
// }
// }, [isSignIn, router]);

const { AuthList } = useAuthList();

Expand Down
1 change: 1 addition & 0 deletions service/license/src/pages/api/payment/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { authSession } from '@/services/backend/auth';
import { generateLicenseToken } from '@/services/backend/db/license';
import { createPaymentRecord } from '@/services/backend/db/payment';
import { jsonRes } from '@/services/backend/response';
import { getSealosPay } from '@/services/pay';
Expand Down
24 changes: 20 additions & 4 deletions service/license/src/pages/cluster/components/Tutorial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,22 @@ export default function Tutorial({
clusterId: string;
ossFileName: string;
}) {
let fileName = useMemo(() => ossFileName.replace('/cloud/', ''), [ossFileName]);
let { fileNameParams, bashParams } = useMemo(() => {
if (ossFileName) {
let match = /cloud-(.*?)\.tar/g.exec(ossFileName);
return {
fileNameParams: ossFileName?.replace('/cloud/', ''),
bashParams: match ? `--cloud-version=${match[1]}` : '--cloud-version v5.0.0-beta1'
};
} else {
return {
fileNameParams: '',
bashParams: ''
};
}
}, [ossFileName]);
// console.log(ossFileName, fileNameParams, bashParams);

const { t } = useTranslation();
const { copyData } = useCopyData();
const [ossLink, setOssLink] = useState('');
Expand Down Expand Up @@ -239,14 +254,15 @@ export default function Tutorial({
<Text mt="24px" fontSize={'16px'} fontWeight={600} mb="12px">
服务器上下载
</Text>
<CodeBlock language="bash" code={`wget ${ossLink}`}></CodeBlock>
<CodeBlock language="bash" code={`wget '${ossLink}' -O ${ossFileName}`}></CodeBlock>
<Divider my="20px" />
<Text mt="12px" fontSize={'16px'} fontWeight={600} mb="12px">
部署集群
</Text>
<CodeBlock
language="bash"
code={`tar xzf ${fileName} && cd sealos-cloud && bash install.sh`}
code={`tar xzvf ${fileNameParams} \n && cd sealos-cloud && bash install.sh`}
copyValue={`tar xzvf ${fileNameParams} && cd sealos-cloud && bash install.sh`}
></CodeBlock>
</AccordionPanel>
</AccordionItem>
Expand All @@ -263,7 +279,7 @@ export default function Tutorial({
<AccordionPanel py="20px" pl="40px" gap={'12px'}>
<CodeBlock
language="bash"
code={`curl -sfL https://raw.githubusercontent.com/labring/sealos/main/scripts/cloud/install.sh -o /tmp/install.sh && bash /tmp/install.sh`}
code={`curl -sfL https://raw.githubusercontent.com/labring/sealos/main/scripts/cloud/install.sh -o /tmp/install.sh && bash /tmp/install.sh ${bashParams}`}
></CodeBlock>
</AccordionPanel>
</AccordionItem>
Expand Down
2 changes: 1 addition & 1 deletion service/license/src/pages/license/components/Recharge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function RechargeComponent() {
const queryClient = useQueryClient();
const toast = useToast({ position: 'top', duration: 2000 });
const { t } = useTranslation();
const [isAgree, setIsAgree] = useState(true);
const [isAgree, setIsAgree] = useState(false);
const [isInvalid, setIsInvalid] = useState(false);
const { BonusBox, selectAmount } = useBonusBox();
const { isOpen, onOpen, onClose } = useDisclosure();
Expand Down
21 changes: 7 additions & 14 deletions service/license/src/pages/pricing/components/Product.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function Product() {
const [orderID, setOrderID] = useState('');
const [wechatData, setWechatData] = useState<WechatPaymentData>();
const { data: platformEnv } = useQuery(['getPlatformEnv'], getSystemEnv);
const [remainingSeconds, setRemainingSeconds] = useState(2); // 初始值为2秒
const [remainingSeconds, setRemainingSeconds] = useState(1); // 初始值为2秒
const { data: routeParams, setRouteParams, clearRouteParams } = useRouteParamsStore();
const { isUserLogin } = useSessionStore();
const { paymentData, setPaymentData, deletePaymentData, isExpired } = usePaymentDataStore();
Expand Down Expand Up @@ -221,7 +221,7 @@ export default function Product() {
status: 'success',
title: t('Checking Payment Results'), // 这里改为license 签发成功
isClosable: true,
duration: 9000,
duration: 3500,
position: 'top'
});
setComplete(2);
Expand Down Expand Up @@ -262,27 +262,20 @@ export default function Product() {

// handle Jump link
useEffect(() => {
const { clusterType, external } = router.query;
const isLogin = isUserLogin();
console.log(clusterType, external);

if (!isLogin) {
setRouteParams(external as string, clusterType as ClusterType);
} else if (routeParams.clusterType) {
const { clusterType, external } = routeParams;
console.log(clusterType, external, 'pricing');
if (clusterType && external) {
handleProductByType(routeParams.clusterType as ClusterType);
clearRouteParams();
} else {
console.log(11);
handleProductByType(clusterType as ClusterType);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<Box flex={1} overflow={'scroll'} backgroundColor="#f2f5f7">
<Flex
minW={'1280px'}
// flexWrap={'wrap'}
// minW={'1280px'}
flexWrap={'wrap'}
h="100%"
pt="30px"
pb="15px"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function ServicePackage({ items, children }: ServicePackageProps)
pt="48px"
flexDirection={'column'}
maxW="400px"
minH={'676px'}
>
{children}
<Divider my="28px" color={'rgba(0, 0, 0, 0.10)'} />
Expand Down
21 changes: 21 additions & 0 deletions service/license/src/pages/signin.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
import SigninComponent from '@/components/Signin';
import useRouteParamsStore from '@/stores/routeParams';
import useSessionStore from '@/stores/session';
import { ClusterType } from '@/types';
import { compareFirstLanguages } from '@/utils/tools';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { useRouter } from 'next/router';
import { useEffect } from 'react';

export default function SigninPage() {
const router = useRouter();
const { data: routeParams, setRouteParams, clearRouteParams } = useRouteParamsStore();
const { isUserLogin } = useSessionStore();

useEffect(() => {
const { clusterType, external } = router.query;
console.log(clusterType, external, '--------');
if (external && clusterType) {
setRouteParams(external as string, clusterType as ClusterType);
}
if (isUserLogin()) {
router.push('/pricing');
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return <SigninComponent />;
}

Expand Down
Loading
Loading