feat: 参考原型图 ui优化提交 个人端-用户中心 相关的页面
This commit is contained in:
@@ -17,257 +17,26 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import { Button, Dropdown } from '@douyinfe/semi-ui';
|
||||
import React from 'react';
|
||||
import { Button, Tooltip } from 'antd';
|
||||
import { Moon, Sun } from 'lucide-react';
|
||||
import { useActualTheme } from '../../../context/Theme';
|
||||
|
||||
// 自定义浅色图标 — 带光芒的太阳
|
||||
const LightIcon = ({ size = 18, color = 'currentColor' }) => (
|
||||
<svg
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox='0 0 24 24'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
>
|
||||
<circle cx='12' cy='12' r='4.5' stroke={color} strokeWidth='1.7' />
|
||||
<line
|
||||
x1='12'
|
||||
y1='2.5'
|
||||
x2='12'
|
||||
y2='5'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<line
|
||||
x1='12'
|
||||
y1='19'
|
||||
x2='12'
|
||||
y2='21.5'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<line
|
||||
x1='21.5'
|
||||
y1='12'
|
||||
x2='19'
|
||||
y2='12'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<line
|
||||
x1='5'
|
||||
y1='12'
|
||||
x2='2.5'
|
||||
y2='12'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<line
|
||||
x1='18.7'
|
||||
y1='5.3'
|
||||
x2='16.9'
|
||||
y2='7.1'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<line
|
||||
x1='7.1'
|
||||
y1='16.9'
|
||||
x2='5.3'
|
||||
y2='18.7'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<line
|
||||
x1='18.7'
|
||||
y1='18.7'
|
||||
x2='16.9'
|
||||
y2='16.9'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<line
|
||||
x1='7.1'
|
||||
y1='7.1'
|
||||
x2='5.3'
|
||||
y2='5.3'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
// 自定义深色图标 — 带星星的弯月
|
||||
const DarkIcon = ({ size = 18, color = 'currentColor' }) => (
|
||||
<svg
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox='0 0 24 24'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
>
|
||||
<path
|
||||
d='M20.5 13.5a8.5 8.5 0 01-10-10A8.5 8.5 0 1020.5 13.5z'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
strokeLinejoin='round'
|
||||
/>
|
||||
<circle cx='18' cy='5' r='0.8' fill={color} />
|
||||
<circle cx='20.5' cy='8' r='0.6' fill={color} />
|
||||
<circle cx='16' cy='3' r='0.5' fill={color} />
|
||||
</svg>
|
||||
);
|
||||
|
||||
// 自定义自动模式图标 — 半日半月
|
||||
const AutoIcon = ({ size = 18, color = 'currentColor' }) => (
|
||||
<svg
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox='0 0 24 24'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
>
|
||||
<circle cx='12' cy='12' r='8.5' stroke={color} strokeWidth='1.7' />
|
||||
<path d='M12 3.5v17a8.5 8.5 0 000-17z' fill={color} fillOpacity='0.2' />
|
||||
<line
|
||||
x1='12'
|
||||
y1='1.5'
|
||||
x2='12'
|
||||
y2='3.5'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<line
|
||||
x1='12'
|
||||
y1='20.5'
|
||||
x2='12'
|
||||
y2='22.5'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<line
|
||||
x1='22.5'
|
||||
y1='12'
|
||||
x2='20.5'
|
||||
y2='12'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<line
|
||||
x1='3.5'
|
||||
y1='12'
|
||||
x2='1.5'
|
||||
y2='12'
|
||||
stroke={color}
|
||||
strokeWidth='1.7'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
const ThemeToggle = ({ theme, onThemeToggle, t }) => {
|
||||
const actualTheme = useActualTheme();
|
||||
|
||||
const themeOptions = useMemo(
|
||||
() => [
|
||||
{
|
||||
key: 'light',
|
||||
icon: <LightIcon />,
|
||||
buttonIcon: <LightIcon />,
|
||||
label: t('浅色模式'),
|
||||
description: t('始终使用浅色主题'),
|
||||
},
|
||||
{
|
||||
key: 'dark',
|
||||
icon: <DarkIcon />,
|
||||
buttonIcon: <DarkIcon />,
|
||||
label: t('深色模式'),
|
||||
description: t('始终使用深色主题'),
|
||||
},
|
||||
{
|
||||
key: 'auto',
|
||||
icon: <AutoIcon />,
|
||||
buttonIcon: <AutoIcon />,
|
||||
label: t('自动模式'),
|
||||
description: t('跟随系统主题设置'),
|
||||
},
|
||||
],
|
||||
[t],
|
||||
);
|
||||
|
||||
const getItemClassName = (isSelected) =>
|
||||
isSelected
|
||||
? '!bg-semi-color-primary-light-default !font-semibold'
|
||||
: 'hover:!bg-semi-color-fill-1';
|
||||
|
||||
const currentButtonIcon = useMemo(() => {
|
||||
const currentOption = themeOptions.find((option) => option.key === theme);
|
||||
return currentOption?.buttonIcon || themeOptions[2].buttonIcon;
|
||||
}, [theme, themeOptions]);
|
||||
const ThemeToggle = ({ onThemeToggle, t }) => {
|
||||
const isDark = useActualTheme() === 'dark';
|
||||
const label = isDark ? t('切换至亮色主题') : t('切换至暗色主题');
|
||||
const Icon = isDark ? Sun : Moon;
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
position='bottomRight'
|
||||
render={
|
||||
<Dropdown.Menu>
|
||||
{themeOptions.map((option) => (
|
||||
<Dropdown.Item
|
||||
key={option.key}
|
||||
icon={option.icon}
|
||||
onClick={() => onThemeToggle(option.key)}
|
||||
className={getItemClassName(theme === option.key)}
|
||||
>
|
||||
<div className='flex flex-col'>
|
||||
<span>{option.label}</span>
|
||||
<span className='text-xs text-semi-color-text-2'>
|
||||
{option.description}
|
||||
</span>
|
||||
</div>
|
||||
</Dropdown.Item>
|
||||
))}
|
||||
|
||||
{theme === 'auto' && (
|
||||
<>
|
||||
<Dropdown.Divider />
|
||||
<div className='px-3 py-2 text-xs text-semi-color-text-2'>
|
||||
{t('当前跟随系统')}:
|
||||
{actualTheme === 'dark' ? t('深色') : t('浅色')}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</Dropdown.Menu>
|
||||
}
|
||||
>
|
||||
{/* Semi can resolve a DOM trigger directly without findDOMNode. */}
|
||||
<span className='inline-flex'>
|
||||
<Button
|
||||
icon={currentButtonIcon}
|
||||
aria-label={t('切换主题')}
|
||||
theme='borderless'
|
||||
type='tertiary'
|
||||
className='!w-8 !h-8 sm:!w-9 sm:!h-9 !flex !items-center !justify-center hover:!bg-brand/10 dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !rounded-full !transition-all !duration-200 hover:!scale-[1.08] active:!scale-95'
|
||||
style={{
|
||||
color:
|
||||
actualTheme === 'dark'
|
||||
? 'rgba(243,244,246,0.9)'
|
||||
: 'rgba(75,85,99,1)',
|
||||
}}
|
||||
/>
|
||||
</span>
|
||||
</Dropdown>
|
||||
<Tooltip title={label}>
|
||||
<Button
|
||||
type='text'
|
||||
icon={<Icon size={16} strokeWidth={1.5} aria-hidden />}
|
||||
aria-label={t('切换主题')}
|
||||
className='ui-header-icon-action'
|
||||
onClick={() => onThemeToggle(isDark ? 'light' : 'dark')}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user