tokenFactory/web/src/components/dashboard/Hero.jsx

56 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
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';
const getGreeting = () => {
const h = new Date().getHours();
if (h < 5) return '深夜好';
if (h < 12) return '早上好';
if (h < 14) return '中午好';
if (h < 18) return '下午好';
return '晚上好';
};
const Hero = ({ user }) => {
const dateStr = useMemo(() => {
const now = new Date();
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
return `${now.getFullYear()}${now.getMonth() + 1}${now.getDate()}日 · ${weekdays[now.getDay()]}`;
}, []);
return (
<div className='flex flex-wrap items-center justify-between gap-4'>
<div className='min-w-0'>
<div className='mb-1.5 flex items-center gap-2'>
<span className='flex h-1.5 w-1.5 rounded-full bg-emerald-500' />
<span className='text-xs text-slate-500 dark:text-white/50'>{dateStr}</span>
</div>
<h1 className='text-2xl font-semibold leading-tight tracking-tight md:text-3xl'>
<span className='text-slate-500 dark:text-white/60'>{getGreeting()}</span>
<span className='text-slate-900 dark:text-white'>
{user?.username || '访客'}
</span>
</h1>
</div>
</div>
);
};
export default Hero;