mirror of
https://github.com/patdelphi/suanming.git
synced 2026-02-28 05:33:11 +08:00
Fix TypeScript compilation errors for Koyeb deployment
This commit is contained in:
@@ -10,6 +10,8 @@ interface AnalysisResultDisplayProps {
|
||||
birthDate?: {
|
||||
date: string;
|
||||
time: string;
|
||||
name?: string;
|
||||
gender?: string;
|
||||
};
|
||||
question?: string;
|
||||
userId?: string;
|
||||
|
||||
@@ -188,28 +188,34 @@ const BaziAnalysisDisplay: React.FC<BaziAnalysisDisplayProps> = ({ birthDate })
|
||||
if (wuxingAnalysis) {
|
||||
// 构造五行分析数据
|
||||
const elements = wuxingAnalysis.distribution || {};
|
||||
const total = Object.values(elements).reduce((sum: number, count: any) => sum + (typeof count === 'number' ? count : 0), 0);
|
||||
const total = Object.values(elements).reduce((sum: number, count: any) => sum + (typeof count === 'number' ? count : 0), 0) as number;
|
||||
|
||||
const wuxingData = {
|
||||
bazi: baziChart,
|
||||
wuxingCount: elements,
|
||||
wuxingPercentage: Object.fromEntries(
|
||||
Object.entries(elements).map(([key, value]) => [
|
||||
key,
|
||||
total > 0 ? Math.round(((value as number) / total) * 100) : 0
|
||||
])
|
||||
Object.entries(elements).map(([key, value]) => {
|
||||
const numValue = typeof value === 'number' ? value : 0;
|
||||
return [key, total > 0 ? Math.round((numValue / total) * 100) : 0];
|
||||
})
|
||||
),
|
||||
wuxingWithStrength: Object.entries(elements).map(([element, count]) => ({
|
||||
element,
|
||||
count: count as number,
|
||||
percentage: total > 0 ? Math.round(((count as number) / total) * 100) : 0,
|
||||
strength: (count as number) >= 3 ? '旺' : (count as number) >= 2 ? '中' : '弱'
|
||||
})),
|
||||
radarData: Object.entries(elements).map(([element, count]) => ({
|
||||
element,
|
||||
value: count as number,
|
||||
fullMark: 5
|
||||
})),
|
||||
wuxingWithStrength: Object.entries(elements).map(([element, count]) => {
|
||||
const numCount = typeof count === 'number' ? count : 0;
|
||||
return {
|
||||
element,
|
||||
count: numCount,
|
||||
percentage: total > 0 ? Math.round((numCount / total) * 100) : 0,
|
||||
strength: numCount >= 3 ? '旺' : numCount >= 2 ? '中' : '弱'
|
||||
};
|
||||
}),
|
||||
radarData: Object.entries(elements).map(([element, count]) => {
|
||||
const numCount = typeof count === 'number' ? count : 0;
|
||||
return {
|
||||
element,
|
||||
value: numCount,
|
||||
fullMark: 5
|
||||
};
|
||||
}),
|
||||
balanceAnalysis: wuxingAnalysis.detailed_analysis || '五行分析',
|
||||
suggestions: [wuxingAnalysis.improvement_suggestions || '建议保持平衡'],
|
||||
dominantElement: Object.entries(elements).reduce((a, b) => (elements[a[0]] as number) > (elements[b[0]] as number) ? a : b)[0],
|
||||
|
||||
@@ -233,20 +233,21 @@ const CompleteBaziAnalysis: React.FC<CompleteBaziAnalysisProps> = ({ birthDate,
|
||||
if (!analysisData.wuxing_analysis?.element_distribution) return null;
|
||||
|
||||
const elements = analysisData.wuxing_analysis.element_distribution;
|
||||
const total = Object.values(elements).reduce((sum: number, count: any) => sum + (typeof count === 'number' ? count : 0), 0);
|
||||
const total = Object.values(elements).reduce((sum: number, count: any) => sum + (typeof count === 'number' ? count : 0), 0) as number;
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-5 gap-4">
|
||||
{Object.entries(elements).map(([element, count]) => {
|
||||
const percentage = total > 0 ? Math.round(((count as number) / total) * 100) : 0;
|
||||
const strength = (count as number) >= 3 ? '旺' : (count as number) >= 2 ? '中' : '弱';
|
||||
const numCount = typeof count === 'number' ? count : 0;
|
||||
const percentage = total > 0 ? Math.round((numCount / total) * 100) : 0;
|
||||
const strength = numCount >= 3 ? '旺' : numCount >= 2 ? '中' : '弱';
|
||||
|
||||
return (
|
||||
<Card key={element} className="text-center hover:shadow-xl transition-all duration-300 chinese-card-decoration border-2 border-yellow-400">
|
||||
<CardContent className="p-4">
|
||||
<div className="text-3xl mb-2">{elementSymbols[element]}</div>
|
||||
<h3 className="font-bold text-red-800 text-lg mb-2 chinese-text-shadow">{element}</h3>
|
||||
<div className="text-2xl font-bold text-yellow-600 mb-1">{count}</div>
|
||||
<div className="text-2xl font-bold text-yellow-600 mb-1">{numCount}</div>
|
||||
<div className="text-sm text-gray-600 mb-2">{percentage}%</div>
|
||||
<div className={`text-sm font-medium mb-2 ${
|
||||
strength === '旺' ? 'text-green-600' :
|
||||
|
||||
@@ -358,7 +358,7 @@ const AnalysisPage: React.FC = () => {
|
||||
analysisType={analysisType}
|
||||
birthDate={memoizedBirthDate}
|
||||
question={analysisType === 'yijing' ? formData.question : undefined}
|
||||
userId={user?.id}
|
||||
userId={user?.id?.toString()}
|
||||
divinationMethod="time"
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -21,7 +21,7 @@ const BaziDetailsPage: React.FC = () => {
|
||||
const [birthData, setBirthData] = useState<BirthData>({
|
||||
date: '',
|
||||
time: '12:00',
|
||||
name: user?.name || '',
|
||||
name: '',
|
||||
gender: 'male'
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ const BaziDetailsPage: React.FC = () => {
|
||||
setBirthData({
|
||||
date: '',
|
||||
time: '12:00',
|
||||
name: user?.name || '',
|
||||
name: '',
|
||||
gender: 'male'
|
||||
});
|
||||
setShowAnalysis(false);
|
||||
|
||||
Reference in New Issue
Block a user