import { useState } from 'react'; import { Flame, Scale, Footprints, Activity } from 'lucide-react'; const stepBands = [ { min: 0, max: 5000, factor: 1.2, label: '久坐(<5,000 步)' }, { min: 5000, max: 7500, factor: 1.375, label: '轻度活动(5,000–7,499 步)' }, { min: 7500, max: 10000, factor: 1.55, label: '中度活动(7,500–9,999 步)' }, { min: 10000, max: 12500, factor: 1.65, label: '高度活动(10,000–12,499 步)' }, { min: 12500, max: Infinity, factor: 1.8, label: '非常活跃(≥12,500 步)' }, ]; function bandFor(steps) { return stepBands.find(b => steps >= b.min && steps < b.max) || stepBands[stepBands.length - 1]; } function bmiCategory(bmi) { if (bmi < 18.5) return { text: '偏瘦', color: 'text-amber-600' }; if (bmi < 24) return { text: '正常', color: 'text-emerald-600' }; if (bmi < 28) return { text: '超重', color: 'text-orange-600' }; return { text: '肥胖', color: 'text-red-600' }; } export default function CalorieCalculator() { const [sex, setSex] = useState('female'); const [age, setAge] = useState(30); const [height, setHeight] = useState(164); const [weight, setWeight] = useState(51); const [steps, setSteps] = useState(10000); const hM = height / 100; const bmi = hM > 0 ? weight / (hM * hM) : 0; const cat = bmiCategory(bmi); const bmr = sex === 'male' ? 10 * weight + 6.25 * height - 5 * age + 5 : 10 * weight + 6.25 * height - 5 * age - 161; const band = bandFor(steps); const tdee = bmr * band.factor; const round = n => Math.round(n); const inputCls = 'w-full px-3 py-2 rounded-lg border border-slate-200 focus:outline-none focus:ring-2 focus:ring-sky-400'; return (
Mifflin-St Jeor 公式 + 步数活动系数
* 结果仅供参考,个体肌肉量、代谢与食物热效应等会影响实际需求。