mirror of
https://github.com/patdelphi/suanming.git
synced 2026-02-28 05:33:11 +08:00
✨ 首页优化:
- 丰富项目介绍内容,增加平台特色说明
- 新增平台优势展示区域(AI智能分析、专业可靠、高效便捷、趋势对比)
- 添加平台数据统计展示(10+核心算法、99%准确率、24/7服务、100%隐私保护)
- 新增技术特色介绍(AI智能优化、算法精进)
- 优化CTA区域,提供更清晰的行动引导
- 改进功能描述,突出技术优势
� 回到顶部功能:
- 创建BackToTop通用组件,支持半透明浮动设计
- 集成到所有分析结果页面(八字、紫微、易经)
- 智能显示/隐藏机制(滚动300px后显示)
- 平滑滚动动画和悬停效果
- 中国风配色方案,与整体设计保持一致
� 用户体验提升:
- 首页内容更加丰富专业,提升用户信任度
- 长页面导航体验优化,便于用户快速返回顶部
- 保持设计风格一致性,提升整体视觉效果
75 lines
1.7 KiB
TypeScript
75 lines
1.7 KiB
TypeScript
import React, { useState, useEffect } from 'react';
|
|
import { ChevronUp } from 'lucide-react';
|
|
import { cn } from '../../lib/utils';
|
|
|
|
interface BackToTopProps {
|
|
className?: string;
|
|
threshold?: number; // 滚动多少像素后显示按钮
|
|
}
|
|
|
|
const BackToTop: React.FC<BackToTopProps> = ({
|
|
className,
|
|
threshold = 300
|
|
}) => {
|
|
const [isVisible, setIsVisible] = useState(false);
|
|
|
|
// 监听滚动事件
|
|
useEffect(() => {
|
|
const toggleVisibility = () => {
|
|
if (window.pageYOffset > threshold) {
|
|
setIsVisible(true);
|
|
} else {
|
|
setIsVisible(false);
|
|
}
|
|
};
|
|
|
|
window.addEventListener('scroll', toggleVisibility);
|
|
|
|
return () => {
|
|
window.removeEventListener('scroll', toggleVisibility);
|
|
};
|
|
}, [threshold]);
|
|
|
|
// 滚动到顶部
|
|
const scrollToTop = () => {
|
|
window.scrollTo({
|
|
top: 0,
|
|
behavior: 'smooth'
|
|
});
|
|
};
|
|
|
|
if (!isVisible) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<button
|
|
onClick={scrollToTop}
|
|
className={cn(
|
|
// 基础样式
|
|
'fixed bottom-6 right-6 z-50',
|
|
'w-12 h-12 rounded-full',
|
|
'flex items-center justify-center',
|
|
'transition-all duration-300 ease-in-out',
|
|
'shadow-lg hover:shadow-xl',
|
|
// 中国风配色
|
|
'bg-red-600/80 hover:bg-red-700/90',
|
|
'border-2 border-yellow-400/50 hover:border-yellow-300/70',
|
|
'backdrop-blur-sm',
|
|
// 动画效果
|
|
'transform hover:scale-110 active:scale-95',
|
|
'hover:-translate-y-1',
|
|
className
|
|
)}
|
|
aria-label="回到顶部"
|
|
title="回到顶部"
|
|
>
|
|
<ChevronUp
|
|
className="w-6 h-6 text-yellow-100 hover:text-yellow-50 transition-colors"
|
|
/>
|
|
</button>
|
|
);
|
|
};
|
|
|
|
export default BackToTop;
|
|
export { BackToTop }; |