From c762fb0a55b3287fbc5667d7079dc78d3a3e0d39 Mon Sep 17 00:00:00 2001 From: class07f17 Date: Thu, 24 Sep 2026 00:28:54 +0000 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E9=A3=9F=E8=B0=B1=E4=B8=8E?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E8=90=A5=E5=85=BB=EF=BC=9A=E5=9C=A8=E6=AF=8F?= =?UTF-8?q?=E6=97=A5=E7=83=AD=E9=87=8F=E7=9B=AE=E6=A0=87=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E4=B8=8A=EF=BC=8C=E6=8C=89=E6=97=A9=E9=A4=90=2025%=E3=80=81?= =?UTF-8?q?=E5=8D=88=E9=A4=90=2035%=E3=80=81=E6=99=9A=E9=A4=90=2030%?= =?UTF-8?q?=E3=80=81=E5=8A=A0=E9=A4=90=2010%=20=E5=88=86=E9=85=8D=E5=85=A8?= =?UTF-8?q?=E5=A4=A9=E7=83=AD=E9=87=8F=EF=BC=8C=E7=BB=99=E5=87=BA=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E4=B8=80=E6=97=A5=E9=A3=9F=E8=B0=B1=E5=B9=B6=E6=A0=87?= =?UTF-8?q?=E6=B3=A8=E6=AF=8F=E9=A4=90=E4=B8=8E=E5=85=A8=E5=A4=A9=E7=9A=84?= =?UTF-8?q?=E7=83=AD=E9=87=8F=E5=8F=8A=E8=9B=8B=E7=99=BD=E8=B4=A8/?= =?UTF-8?q?=E8=84=82=E8=82=AA/=E7=A2=B3=E6=B0=B4=EF=BC=8C=E4=BF=9D?= =?UTF-8?q?=E8=AF=81=E8=90=A5=E5=85=BB=E5=9D=87=E8=A1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tdee_calculator.py | 127 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 110 insertions(+), 17 deletions(-) diff --git a/tdee_calculator.py b/tdee_calculator.py index 7001e14..5a0af93 100644 --- a/tdee_calculator.py +++ b/tdee_calculator.py @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { Flame, Scale, Footprints, Activity } from 'lucide-react'; +import { Flame, Scale, Footprints, Activity, Target, Utensils, Coffee, Sun, Moon, Cookie } from 'lucide-react'; const stepBands = [ { min: 0, max: 5000, factor: 1.2, label: '久坐(<5,000 步)' }, @@ -20,6 +20,53 @@ function bmiCategory(bmi) { return { text: '肥胖', color: 'text-red-600' }; } +// 一日食谱模板:全天约 2,176 千卡,蛋白/脂肪/碳水约 104/64/300 g(约 19% / 26% / 55%) +const menu = [ + { + key: 'breakfast', meal: '早餐', icon: Coffee, ratio: '约 25%', + items: [ + { name: '燕麦(干重)', amount: '60 g', kcal: 230, p: 8, f: 4, c: 40 }, + { name: '牛奶', amount: '250 ml', kcal: 160, p: 8, f: 8, c: 12 }, + { name: '鸡蛋', amount: '1 个', kcal: 70, p: 6, f: 5, c: 0 }, + { name: '香蕉', amount: '1 根(约 120 g)', kcal: 105, p: 1, f: 0, c: 27 }, + ], + }, + { + key: 'lunch', meal: '午餐', icon: Sun, ratio: '约 35%', + items: [ + { name: '米饭', amount: '2 碗(约 300 g 熟)', kcal: 350, p: 7, f: 1, c: 77 }, + { name: '鸡胸肉', amount: '100 g', kcal: 140, p: 26, f: 3, c: 0 }, + { name: '清炒时蔬(含油 10 g)', amount: '200 g', kcal: 160, p: 5, f: 10, c: 12 }, + { name: '苹果', amount: '1 个(约 200 g)', kcal: 104, p: 1, f: 0, c: 28 }, + ], + }, + { + key: 'dinner', meal: '晚餐', icon: Moon, ratio: '约 30%', + items: [ + { name: '杂粮饭', amount: '1.5 碗(约 225 g 熟)', kcal: 255, p: 6, f: 2, c: 54 }, + { name: '三文鱼', amount: '100 g', kcal: 200, p: 20, f: 13, c: 0 }, + { name: '白灼蔬菜(含橄榄油 5 g)', amount: '200 g', kcal: 95, p: 5, f: 6, c: 8 }, + { name: '无糖酸奶', amount: '100 g', kcal: 70, p: 4, f: 3, c: 8 }, + ], + }, + { + key: 'snack', meal: '加餐', icon: Cookie, ratio: '约 10%', + items: [ + { name: '混合坚果', amount: '15 g', kcal: 90, p: 3, f: 8, c: 3 }, + { name: '全麦面包', amount: '1 片', kcal: 90, p: 3, f: 1, c: 17 }, + { name: '蓝莓', amount: '100 g', kcal: 57, p: 1, f: 0, c: 14 }, + ], + }, +]; + +const sumMacros = items => + items.reduce((a, it) => ({ kcal: a.kcal + it.kcal, p: a.p + it.p, f: a.f + it.f, c: a.c + it.c }), { kcal: 0, p: 0, f: 0, c: 0 }); + +const menuTotals = menu.reduce((a, m) => { + const t = sumMacros(m.items); + return { kcal: a.kcal + t.kcal, p: a.p + t.p, f: a.f + t.f, c: a.c + t.c }; +}, { kcal: 0, p: 0, f: 0, c: 0 }); + export default function CalorieCalculator() { const [sex, setSex] = useState('female'); const [age, setAge] = useState(30); @@ -39,12 +86,17 @@ export default function CalorieCalculator() { const tdee = bmr * band.factor; const round = n => Math.round(n); + const target = round(tdee + 300); + const proteinG = round(weight * 1.6); + const fatG = round((target * 0.25) / 9); + const carbG = Math.max(round((target - proteinG * 4 - fatG * 9) / 4), 0); + 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 公式 + 步数活动系数

+
+

每日热量需求与食谱计算器

+

Mifflin-St Jeor 公式 + 步数活动系数 + 营养均衡一日食谱

@@ -79,45 +131,86 @@ export default function CalorieCalculator() {
-
+
BMI
{bmi.toFixed(1)}
{cat.text}
-
基础代谢 BMR
{round(bmr)}
千卡 / 天
-
活动系数
× {band.factor}
{band.label}
-
每日总消耗 TDEE
{round(tdee)}
千卡 / 天(维持体重)
+
-
-
建议目标热量
-
- 增重(每周 +0.3 kg 左右) - {round(tdee + 300)} 千卡 +
+
目标营养素(增重 {target} 千卡 / 天)
+
+
+
蛋白质(约 20%)
+
{proteinG} g
+
{weight} kg × 1.6 g
-
- 维持体重 - {round(tdee)} 千卡 +
+
脂肪(约 25%)
+
{fatG} g
+
总热量 × 25% ÷ 9
+
+
+
碳水(约 55%)
+
{carbG} g
+
剩余热量 ÷ 4
-

* 结果仅供参考,个体肌肉量、代谢与食物热效应等会影响实际需求。

+
一日食谱(示例,全天约 {menuTotals.kcal} 千卡)
+
+ {menu.map(m => { + const t = sumMacros(m.items); + const Icon = m.icon; + return ( +
+
+
{m.meal}
+ 占全天 {m.ratio} +
+
+ {m.items.map((it, i) => ( +
+ {it.name} {it.amount} + {it.kcal} 千卡 +
+ ))} +
+
+ 小计 {t.kcal} 千卡 + 蛋白 {t.p} g | 脂肪 {t.f} g | 碳水 {t.c} g +
+
+ ); + })} +
+ +
+
全天合计
+
{menuTotals.kcal} 千卡
+
蛋白 {menuTotals.p} g | 脂肪 {menuTotals.f} g | 碳水 {menuTotals.c} g
+
对照目标:{target} 千卡 · 蛋白 {proteinG} g · 脂肪 {fatG} g · 碳水 {carbG} g;份量可按需等比例增减。
+
+ +

* 示例食谱仅供参考,可同类替换(鸡胸肉 ↔ 鱼虾 ↔ 豆制品,米饭 ↔ 杂粮/薯类),保证每餐有主食、优质蛋白和蔬菜水果即可。

); }