From aed0fe4d267ffd8743aba33bb40b6dab52940199 Mon Sep 17 00:00:00 2001 From: class03m15 Date: Thu, 8 Oct 2026 02:32:45 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E5=8E=9F=E7=83=AD=E9=87=8F=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E5=99=A8=E5=9F=BA=E7=A1=80=E4=B8=8A=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BB=8A=E6=97=A5=E9=A5=AE=E9=A3=9F=E8=AE=B0=E5=BD=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在原有身体参数与每日目标计算之外,改为按今日所吃食物输入,输出摄入热量 - 收录常见食物每 100 g 的热量与蛋白质、脂肪、碳水化合物、膳食纤维含量 - 以克数换算每条记录,实时汇总今日摄入热量与四大营养素 - 将摄入汇总与每日目标热量、三大产能营养素目标对比,显示剩余或超出 - 支持未收录食物的自定义每 100 g 数值录入,记录保存在本机浏览器 --- nutrition-calculator.html | 431 +++++++++++++++++++++++++++++++++----- 1 file changed, 378 insertions(+), 53 deletions(-) diff --git a/nutrition-calculator.html b/nutrition-calculator.html index ba971ea..ca850a8 100644 --- a/nutrition-calculator.html +++ b/nutrition-calculator.html @@ -11,7 +11,7 @@ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: #f4f6f8; color: #1f2933; line-height: 1.6; } - .wrap { max-width: 860px; margin: 0 auto; } + .wrap { max-width: 880px; margin: 0 auto; } h1 { font-size: 22px; margin: 0 0 4px; } .sub { color: #6b7280; font-size: 13px; margin-bottom: 20px; } .card { @@ -21,9 +21,9 @@ .card h2 { font-size: 15px; margin: 0 0 14px; color: #0f766e; letter-spacing: .5px; } .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; } label { display: block; font-size: 12px; color: #6b7280; margin-bottom: 4px; } - input[type=number], select { + input[type=number], input[type=text], select { width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; - font-size: 14px; background: #fff; color: #1f2933; + font-size: 14px; background: #fff; color: #1f2933; font-family: inherit; } input:focus, select:focus { outline: 2px solid #0d9488; outline-offset: -1px; border-color: #0d9488; } .radios { display: flex; gap: 16px; padding-top: 4px; } @@ -36,9 +36,7 @@ .hero .unit { font-size: 16px; font-weight: 400; opacity: .9; } .hero .desc { font-size: 13px; opacity: .9; margin-top: 6px; } .chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; } - .chip { - background: rgba(255,255,255,.16); border-radius: 8px; padding: 8px 12px; font-size: 13px; - } + .chip { background: rgba(255,255,255,.16); border-radius: 8px; padding: 8px 12px; font-size: 13px; } .chip b { font-size: 16px; display: block; font-weight: 600; } table { width: 100%; border-collapse: collapse; font-size: 13.5px; } th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid #eef1f4; } @@ -54,15 +52,52 @@ .note { font-size: 12.5px; color: #6b7280; margin-top: 14px; line-height: 1.7; } .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; } @media (max-width: 560px) { .cols { grid-template-columns: 1fr; } } + + /* 饮食记录模块 */ + .food-input { display: grid; grid-template-columns: 1fr 110px 96px; gap: 10px; align-items: end; } + @media (max-width: 560px) { .food-input { grid-template-columns: 1fr; } } + .btn { + padding: 9px 16px; border: none; border-radius: 8px; font-size: 14px; + background: #0d9488; color: #fff; cursor: pointer; font-family: inherit; font-weight: 500; + } + .btn:hover { background: #0f766e; } + .btn-ghost { background: #eef2f3; color: #475b63; } + .btn-ghost:hover { background: #e2e8ea; } + .btn-line { background: none; border: none; color: #b91c1c; cursor: pointer; font-size: 13px; padding: 4px 6px; font-family: inherit; } + .toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; } + .msg { font-size: 12.5px; margin-top: 8px; min-height: 18px; } + .msg-err { color: #b91c1c; } + .msg-ok { color: #0f766e; } + .progress { height: 12px; background: #e8edf0; border-radius: 99px; overflow: hidden; margin: 12px 0 8px; } + .progress i { display: block; height: 100%; background: linear-gradient(90deg, #14b8a6, #0d9488); transition: width .25s; } + .progress i.over { background: linear-gradient(90deg, #f59e0b, #dc2626); } + .prog-label { display: flex; justify-content: space-between; font-size: 12.5px; color: #4b5563; font-variant-numeric: tabular-nums; } + .empty { color: #9aa5ad; font-size: 13px; text-align: center; padding: 18px 0; } + tfoot td { font-weight: 600; background: #fafbfc; border-bottom: none; } + .hint { font-size: 12px; color: #9aa5ad; margin-top: 6px; } + .add-intake { color: #0f766e; } + .over-text { color: #b91c1c; }

每日热量与七大营养素计算器

-
算法:Mifflin-St Jeor 基础代谢 + MET 法步行能耗 + DRIs 2023 供能比
+
算法:Mifflin-St Jeor 基础代谢 + MET 法步行能耗 + DRIs 2023 供能比 + 食物成分表折算
+ +
+
每日建议摄入热量
+
1800 kcal / 天
+
+
BMI18.7
+
基础代谢 BMR1230
+
步行能耗300
+
总消耗 TDEE1776
+
今日已摄入0
+
+
-

① 输入参数

+

① 身体参数与每日目标

@@ -79,7 +114,7 @@ @@ -87,19 +122,63 @@
-
-
每日建议摄入热量
-
1800 kcal / 天
-
-
BMI18.7
-
基础代谢 BMR1230
-
步行能耗300
-
总消耗 TDEE1776
+
+

② 今日饮食记录 —— 输入你吃了什么,输出热量

+ +
+
+ + + +
+
+ + +
+
+
参考分量:一碗米饭约 150 g,一个鸡蛋约 50 g,一个苹果约 200 g,一杯牛奶约 250 g,一勺植物油约 10 g。
+
+ + + + + + + + + + +
食物分量(g)热量蛋白脂肪碳水纤维
+ +
+
+ 已摄入 0 kcal / 目标 1800 kcal + 剩余 1800 kcal +
+ +
+ 记录自动保存在本机浏览器中,刷新不丢失。 + +
+ +
+ 食物库没有我要的?点这里自定义添加 +
+
+
+
+
+
+
+
+
+
+
-

② 三大产能营养素分配

+

③ 三大产能营养素:目标 / 已摄入 / 剩余

@@ -112,14 +191,14 @@
- +
营养素每日推荐能量系数提供能量供能比
营养素目标能量系数目标能量已摄入剩余
-

③ 七大营养素全景

+

④ 七大营养素全景

@@ -128,12 +207,12 @@
#营养素是否产能每日推荐量能量
蛋白质/脂肪/碳水为产能营养素;膳食纤维 25–30 g 建议量,能量按 2 kcal/g 计(通常并入碳水账目);
- 维生素、矿物质、水不产能,其参考摄入量见下表。 + 维生素、矿物质、水不产能,其参考摄入量见下。
-

④ 微量营养素参考摄入量

+

⑤ 微量营养素参考摄入量

@@ -168,12 +247,82 @@
维生素每日量
-
以上为成年女性 18–49 岁、轻身体活动水平参考值;男性或孕期/哺乳期需上调。公式仅算存在 ±10%~15% 个体差异,建议以 2–4 周体重变化实测校准。
+
以上为成年女性 18–49 岁、轻身体活动水平参考值;男性或孕期/哺乳期需上调。公式估算存在 ±10%~15% 个体差异,建议以 2–4 周体重变化实测校准。