Compare commits

..

No commits in common. "797e0c033d9dce25a7836d89c9f16f3a3e525943" and "d3502e105a55bc58f7ddcf3e19026b31e57de7a4" have entirely different histories.

2 changed files with 16 additions and 64 deletions

View File

@ -1,7 +1,7 @@
import { VersionInfoMap } from '@/constant/version';
import { useVersionInfo } from '@/hooks';
import { ConstsLicenseEdition } from '@/request/types';
import { styled, SxProps, Tooltip } from '@mui/material';
import { styled, SxProps } from '@mui/material';
import React from 'react';
const StyledMaskWrapper = styled('div')(({ theme }) => ({
@ -95,48 +95,24 @@ export const VersionCanUse = ({
ConstsLicenseEdition.LicenseEditionEnterprise,
],
sx,
mode = 'text',
}: {
permission?: ConstsLicenseEdition[];
sx?: SxProps;
mode?: 'icon' | 'text';
}) => {
const versionInfo = useVersionInfo();
const hasPermission = permission.includes(versionInfo.permission);
if (hasPermission) return null;
const nextVersionInfo = VersionInfoMap[permission[0]];
return (
<StyledMaskContent
sx={{
width: 'auto',
ml: mode === 'icon' ? 0.5 : 1,
// 允许 Tooltip 在 disabled 的父元素中正常工作
pointerEvents: 'auto',
...sx,
}}
onClick={e => {
e.stopPropagation();
e.preventDefault();
}}
>
{mode === 'icon' ? (
<Tooltip title={nextVersionInfo.label + '可用'} placement='top' arrow>
<img
src={nextVersionInfo.image}
style={{ width: 14, objectFit: 'contain' }}
alt={nextVersionInfo.label}
/>
</Tooltip>
) : (
<StyledMaskVersion sx={{ backgroundColor: nextVersionInfo.bgColor }}>
<img
src={nextVersionInfo.image}
style={{ width: 12, objectFit: 'contain', marginTop: 1 }}
alt={nextVersionInfo.label}
/>
{nextVersionInfo?.label}
</StyledMaskVersion>
)}
<StyledMaskContent sx={{ width: 'auto', ml: 1, ...sx }}>
<StyledMaskVersion sx={{ backgroundColor: nextVersionInfo.bgColor }}>
<img
src={nextVersionInfo.image}
style={{ width: 12, objectFit: 'contain', marginTop: 1 }}
alt={nextVersionInfo.label}
/>
{nextVersionInfo?.label}
</StyledMaskVersion>
</StyledMaskContent>
);
};

View File

@ -36,17 +36,9 @@ const Statistic = () => {
{ label: '近 24 小时', value: 1, disabled: false },
{
label: (
<Stack
direction={'row'}
alignItems={'center'}
gap={0.5}
sx={{ lineHeight: 1 }}
>
<Stack direction={'row'} alignItems={'center'} gap={0.5}>
<span> 7 </span>
<VersionCanUse
permission={PROFESSION_VERSION_PERMISSION}
mode='icon'
/>
<VersionCanUse permission={PROFESSION_VERSION_PERMISSION} />
</Stack>
),
value: 7,
@ -54,17 +46,9 @@ const Statistic = () => {
},
{
label: (
<Stack
direction={'row'}
alignItems={'center'}
gap={0.5}
sx={{ lineHeight: 1 }}
>
<Stack direction={'row'} alignItems={'center'} gap={0.5}>
<span> 30 </span>
<VersionCanUse
permission={BUSINESS_VERSION_PERMISSION}
mode='icon'
/>
<VersionCanUse permission={BUSINESS_VERSION_PERMISSION} />
</Stack>
),
value: 30,
@ -72,17 +56,9 @@ const Statistic = () => {
},
{
label: (
<Stack
direction={'row'}
alignItems={'center'}
gap={0.5}
sx={{ lineHeight: 1 }}
>
<Stack direction={'row'} alignItems={'center'} gap={0.5}>
<span> 90 </span>
<VersionCanUse
permission={BUSINESS_VERSION_PERMISSION}
mode='icon'
/>
<VersionCanUse permission={BUSINESS_VERSION_PERMISSION} />
</Stack>
),
value: 90,