mirror of
https://github.com/patdelphi/suanming.git
synced 2026-03-11 19:04:42 +08:00
feat: 优化首页设计并添加回到顶部按钮
✨ 首页优化:
- 丰富项目介绍内容,增加平台特色说明
- 新增平台优势展示区域(AI智能分析、专业可靠、高效便捷、趋势对比)
- 添加平台数据统计展示(10+核心算法、99%准确率、24/7服务、100%隐私保护)
- 新增技术特色介绍(AI智能优化、算法精进)
- 优化CTA区域,提供更清晰的行动引导
- 改进功能描述,突出技术优势
� 回到顶部功能:
- 创建BackToTop通用组件,支持半透明浮动设计
- 集成到所有分析结果页面(八字、紫微、易经)
- 智能显示/隐藏机制(滚动300px后显示)
- 平滑滚动动画和悬停效果
- 中国风配色方案,与整体设计保持一致
� 用户体验提升:
- 首页内容更加丰富专业,提升用户信任度
- 长页面导航体验优化,便于用户快速返回顶部
- 保持设计风格一致性,提升整体视觉效果
This commit is contained in:
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
|
||||
import { Radar, RadarChart, PolarGrid, PolarAngleAxis, PolarRadiusAxis, ResponsiveContainer } from 'recharts';
|
||||
import { Calendar, Star, BookOpen, Sparkles, User, BarChart3, Zap, TrendingUp, Loader2, Clock, Target, Heart, DollarSign, Activity } from 'lucide-react';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from './ui/Card';
|
||||
import { BackToTop } from './ui/BackToTop';
|
||||
import { localApi } from '../lib/localApi';
|
||||
|
||||
interface CompleteBaziAnalysisProps {
|
||||
@@ -1031,6 +1032,9 @@ const CompleteBaziAnalysis: React.FC<CompleteBaziAnalysisProps> = ({ birthDate,
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* 回到顶部按钮 */}
|
||||
<BackToTop />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Calendar, Star, BookOpen, Sparkles, User, BarChart3, Zap, TrendingUp, Loader2, Clock, Target, Heart, DollarSign, Activity, Crown, Compass, Moon, Sun, Hexagon, Layers, Eye, Shuffle } from 'lucide-react';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from './ui/Card';
|
||||
import { BackToTop } from './ui/BackToTop';
|
||||
import { localApi } from '../lib/localApi';
|
||||
|
||||
interface CompleteYijingAnalysisProps {
|
||||
@@ -734,6 +735,9 @@ const CompleteYijingAnalysis: React.FC<CompleteYijingAnalysisProps> = ({
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* 返回顶部按钮 */}
|
||||
<BackToTop />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Calendar, Star, BookOpen, Sparkles, User, BarChart3, Zap, TrendingUp, L
|
||||
import { Card, CardContent, CardHeader, CardTitle } from './ui/Card';
|
||||
import { ChineseCard, ChineseCardContent, ChineseCardHeader, ChineseCardTitle } from './ui/ChineseCard';
|
||||
import { ChineseLoading } from './ui/ChineseLoading';
|
||||
import { BackToTop } from './ui/BackToTop';
|
||||
import { localApi } from '../lib/localApi';
|
||||
import { cn } from '../lib/utils';
|
||||
|
||||
@@ -1550,6 +1551,9 @@ const CompleteZiweiAnalysis: React.FC<CompleteZiweiAnalysisProps> = ({ birthDate
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* 回到顶部按钮 */}
|
||||
<BackToTop />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
75
src/components/ui/BackToTop.tsx
Normal file
75
src/components/ui/BackToTop.tsx
Normal file
@@ -0,0 +1,75 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user