816 lines
40 KiB
HTML
816 lines
40 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
<title>✧ 每日热量需求与膳食计算器 ✧ 减重 / 维持 / 增重 · 千禧闪亮版</title>
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.3.1/umd/react.production.min.js" crossorigin></script>
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.3.1/umd/react-dom.production.min.js" crossorigin></script>
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.26.4/babel.min.js"></script>
|
||
<style>
|
||
*{box-sizing:border-box}
|
||
html,body{margin:0;padding:0}
|
||
body{
|
||
min-height:100vh;overflow-x:hidden;color:#fff;
|
||
font-family:"Comic Sans MS","Chalkboard SE","PingFang SC","Microsoft YaHei",cursive,sans-serif;
|
||
background:
|
||
radial-gradient(1200px 600px at 15% -10%,#64179e 0%,transparent 55%),
|
||
radial-gradient(900px 500px at 90% 0%,#b3129a 0%,transparent 50%),
|
||
radial-gradient(900px 700px at 50% 110%,#0b4e78 0%,transparent 55%),
|
||
linear-gradient(165deg,#1c0038 0%,#2b0552 45%,#120026 100%);
|
||
background-attachment:fixed;
|
||
cursor:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26'%3E%3Cpath d='M13 2l3 8 8 .5-6.2 5 2 7.9L13 19l-6.8 4.4 2-7.9L2 10.5 10 10z' fill='%23ffe94d' stroke='%23ff2fb9' stroke-width='1.4'/%3E%3C/svg%3E") 13 13,auto;
|
||
}
|
||
|
||
/* ===== 星空 / 閃爍 ===== */
|
||
.stars,.stars2{position:fixed;inset:0;pointer-events:none;z-index:0}
|
||
.stars{
|
||
background-image:
|
||
radial-gradient(2px 2px at 20px 30px,#fff,transparent),
|
||
radial-gradient(2px 2px at 130px 90px,#ffe94d,transparent),
|
||
radial-gradient(1.5px 1.5px at 210px 45px,#00e5ff,transparent),
|
||
radial-gradient(1.5px 1.5px at 80px 160px,#ff9de0,transparent),
|
||
radial-gradient(2px 2px at 250px 200px,#c8ff3d,transparent);
|
||
background-size:280px 240px;opacity:.9;animation:twk 3s steps(2,end) infinite;
|
||
}
|
||
.stars2{
|
||
background-image:
|
||
radial-gradient(1.5px 1.5px at 60px 60px,#fff,transparent),
|
||
radial-gradient(2px 2px at 180px 140px,#a64bff,transparent),
|
||
radial-gradient(1.5px 1.5px at 300px 30px,#fff,transparent);
|
||
background-size:220px 200px;opacity:.6;animation:twk 4.5s steps(2,end) infinite reverse;
|
||
}
|
||
@keyframes twk{50%{opacity:.22}}
|
||
.sparkle{position:fixed;z-index:1;pointer-events:none;font-size:22px;opacity:.9;
|
||
filter:drop-shadow(0 0 8px #ff9de0);animation:float 6s ease-in-out infinite}
|
||
@keyframes float{0%,100%{transform:translateY(0) rotate(-8deg)}50%{transform:translateY(-26px) rotate(8deg)}}
|
||
|
||
/* ===== 流星雨 ===== */
|
||
.shower{position:fixed;inset:0;z-index:1;pointer-events:none;overflow:hidden}
|
||
.meteor{position:absolute;height:2px;border-radius:999px;opacity:0;
|
||
transform:rotate(135deg);
|
||
filter:drop-shadow(0 0 6px var(--glow)) drop-shadow(0 0 14px var(--glow));
|
||
animation-name:meteor;animation-timing-function:linear;animation-iteration-count:infinite}
|
||
.meteor::after{content:"";position:absolute;right:0;top:-2px;width:6px;height:6px;border-radius:50%;
|
||
background:#fff;box-shadow:0 0 10px 3px var(--glow)}
|
||
@keyframes meteor{
|
||
0%{opacity:0;transform:translate3d(0,0,0) rotate(135deg) scaleX(.25)}
|
||
6%{opacity:1}
|
||
55%{opacity:1}
|
||
78%{opacity:0;transform:translate3d(-85vw,85vh,0) rotate(135deg) scaleX(1.15)}
|
||
100%{opacity:0;transform:translate3d(-85vw,85vh,0) rotate(135deg) scaleX(1.15)}
|
||
}
|
||
|
||
/* ===== 跑馬燈 ===== */
|
||
.marquee{position:relative;z-index:3;overflow:hidden;border-bottom:2px solid #fff;
|
||
background:linear-gradient(90deg,#ff2fb9,#a64bff,#00e5ff,#c8ff3d,#ff2fb9);
|
||
background-size:200% 100%;box-shadow:0 0 18px #ff2fb9;animation:flow 6s linear infinite}
|
||
.marquee-track{display:inline-block;white-space:nowrap;padding:8px 0;font-weight:900;
|
||
font-size:14px;letter-spacing:1px;color:#1a0030;
|
||
text-shadow:0 1px 0 rgba(255,255,255,.65);animation:slide 22s linear infinite}
|
||
@keyframes slide{from{transform:translateX(0)}to{transform:translateX(-50%)}}
|
||
@keyframes flow{to{background-position:300% 0}}
|
||
|
||
/* ===== 版面 ===== */
|
||
.wrap{position:relative;z-index:2;max-width:1020px;margin:0 auto;padding:22px 16px 60px}
|
||
.hero{text-align:center;margin:12px 0 18px}
|
||
.hero h1{margin:0;font-size:clamp(21px,4.6vw,38px);letter-spacing:1px;
|
||
background:linear-gradient(90deg,#ffe94d,#ff2fb9,#00e5ff,#c8ff3d,#ffe94d);
|
||
background-size:300% 100%;-webkit-background-clip:text;background-clip:text;color:transparent;
|
||
animation:flow 5s linear infinite;filter:drop-shadow(0 0 10px rgba(255,47,185,.85))}
|
||
.sub{color:#ffe94d;font-size:13px;margin-top:6px;text-shadow:0 0 8px #ff2fb9}
|
||
.badge{display:inline-block;margin:8px 4px 0;padding:3px 10px;border-radius:999px;font-size:12px;
|
||
font-weight:900;color:#1a0030;background:linear-gradient(90deg,#ffe94d,#c8ff3d);
|
||
border:2px solid #fff;box-shadow:0 0 12px #c8ff3d;animation:blink 1.1s steps(2,end) infinite}
|
||
@keyframes blink{50%{opacity:.35;transform:scale(.97)}}
|
||
.led{display:inline-flex;gap:8px;padding:6px 12px;border-radius:8px;background:#0b0016;
|
||
border:2px solid #00e5ff;box-shadow:0 0 14px #00e5ff;font-family:ui-monospace,monospace;
|
||
font-weight:900;color:#c8ff3d;text-shadow:0 0 8px #c8ff3d;font-size:13px;letter-spacing:3px}
|
||
|
||
.panel{margin:16px 0;padding:16px;border-radius:18px;border:2px solid #ff2fb9;
|
||
background:linear-gradient(160deg,rgba(255,255,255,.10),rgba(255,47,185,.10) 45%,rgba(0,229,255,.10));
|
||
box-shadow:0 0 22px rgba(255,47,185,.55),inset 0 0 22px rgba(0,229,255,.22)}
|
||
.panel > h2{margin:0 0 12px;font-size:18px;color:#fff;text-shadow:0 0 10px #00e5ff}
|
||
.panel > h2 span{font-size:12px;color:#c8ff3d;margin-left:8px;font-weight:400}
|
||
.tiny{font-size:11px;color:#c8ff3d;line-height:1.7;margin-top:8px;display:block}
|
||
.hr{height:4px;margin:16px 0;border-radius:999px;
|
||
background:linear-gradient(90deg,#ff2fb9,#ffe94d,#00e5ff,#c8ff3d);
|
||
background-size:200% 100%;animation:flow 4s linear infinite}
|
||
|
||
/* ===== 表單 ===== */
|
||
.row{display:flex;gap:12px;flex-wrap:wrap}
|
||
.field{flex:1 1 150px;min-width:132px;display:flex;flex-direction:column;gap:6px}
|
||
.field label{font-size:12px;font-weight:900;color:#00e5ff;letter-spacing:.5px}
|
||
input,select{width:100%;padding:9px 11px;border-radius:10px;border:2px solid #a64bff;
|
||
background:rgba(10,0,30,.72);color:#fff;font-size:14px;font-family:inherit;outline:none}
|
||
input:focus,select:focus{border-color:#ffe94d;box-shadow:0 0 14px #ffe94d}
|
||
option{background:#1c0038}
|
||
.seg{display:flex;gap:8px}
|
||
.seg .chip{flex:1;text-align:center}
|
||
|
||
/* ===== 按鈕 / 卡片 ===== */
|
||
.chips{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
|
||
.chip{cursor:pointer;padding:7px 12px;border-radius:999px;border:2px solid #00e5ff;
|
||
background:rgba(0,229,255,.12);color:#fff;font-family:inherit;font-size:12px;font-weight:900}
|
||
.chip:hover{transform:translateY(-1px)}
|
||
.chip.on{background:linear-gradient(90deg,#00e5ff,#c8ff3d);color:#1a0030;border-color:#fff;
|
||
box-shadow:0 0 14px #c8ff3d}
|
||
.goals{display:flex;gap:10px;flex-wrap:wrap}
|
||
.goal{flex:1 1 170px;cursor:pointer;text-align:left;padding:12px;border-radius:14px;
|
||
border:2px solid #a64bff;background:rgba(10,0,30,.6);color:#fff;font-family:inherit;
|
||
font-size:15px;font-weight:900;transition:.15s}
|
||
.goal small{display:block;font-weight:400;font-size:11px;color:#ffd9f5;margin-top:4px}
|
||
.goal:hover{transform:translateY(-2px) rotate(-.6deg)}
|
||
.goal.on{border-color:#ffe94d;background:linear-gradient(160deg,#ff2fb9,#a64bff);
|
||
box-shadow:0 0 20px #ffe94d}
|
||
.acts{display:flex;gap:8px;flex-wrap:wrap}
|
||
.act{flex:1 1 170px;cursor:pointer;padding:10px;border-radius:12px;border:2px dashed #00e5ff;
|
||
background:rgba(0,229,255,.08);color:#fff;font-family:inherit;font-size:13px;text-align:left}
|
||
.act small{display:block;color:#ffd9f5;font-size:11px}
|
||
.act.on{border-style:solid;border-color:#ffe94d;background:linear-gradient(160deg,#00e5ff,#a64bff);
|
||
box-shadow:0 0 16px #ffe94d}
|
||
|
||
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(145px,1fr));gap:10px}
|
||
.card{padding:12px;border-radius:14px;border:2px dashed #c8ff3d;background:rgba(0,0,0,.3);text-align:center}
|
||
.card span{font-size:12px;color:#c8ff3d}
|
||
.card b{display:block;font-size:22px;color:#ffe94d;text-shadow:0 0 10px #ff2fb9;margin:4px 0 2px}
|
||
.card em{display:block;font-size:11px;color:#ffd9f5;font-style:normal;line-height:1.6}
|
||
.card.big b{font-size:30px;background:linear-gradient(90deg,#ffe94d,#00e5ff);
|
||
-webkit-background-clip:text;background-clip:text;color:transparent}
|
||
|
||
.warn{margin-top:10px;padding:10px 12px;border-radius:12px;font-size:13px;font-weight:700;
|
||
border:2px solid #ff2fb9;background:rgba(255,47,185,.16);color:#ffd9f5}
|
||
.warn b{color:#ffe94d}
|
||
.ok{margin-top:10px;padding:10px 12px;border-radius:12px;font-size:13px;font-weight:700;
|
||
border:2px solid #c8ff3d;background:rgba(200,255,61,.14);color:#eaffc4}
|
||
|
||
.bars{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px}
|
||
.barwrap{font-size:12px}
|
||
.barwrap .lb{display:flex;justify-content:space-between;gap:8px;margin-bottom:4px;color:#ffd9f5}
|
||
.bar{height:12px;border-radius:999px;border:1px solid rgba(255,255,255,.55);
|
||
background:rgba(0,0,0,.45);overflow:hidden}
|
||
.bar i{display:block;height:100%;background:linear-gradient(90deg,#ff2fb9,#ffe94d);transition:width .35s}
|
||
.bar i.good{background:linear-gradient(90deg,#c8ff3d,#00e5ff)}
|
||
|
||
.meal{margin:12px 0;padding:12px;border-radius:14px;border:2px solid #00e5ff;background:rgba(0,229,255,.07)}
|
||
.mealhead{display:flex;justify-content:space-between;align-items:baseline;gap:8px;
|
||
font-weight:900;color:#ffe94d;margin-bottom:8px;flex-wrap:wrap}
|
||
.mealhead small{color:#c8ff3d;font-weight:400}
|
||
.slot{margin:10px 0}
|
||
.slot > span{display:block;font-size:12px;font-weight:900;color:#00e5ff;margin-bottom:5px}
|
||
.opts{display:flex;gap:8px;overflow-x:auto;padding-bottom:4px}
|
||
.opt{flex:0 0 auto;cursor:pointer;text-align:left;padding:8px 10px;border-radius:12px;
|
||
border:2px solid #a64bff;background:rgba(10,0,30,.66);color:#fff;font-family:inherit;
|
||
font-size:12px;min-width:140px}
|
||
.opt b{display:block;font-size:13px;color:#fff;margin-bottom:2px}
|
||
.opt small{color:#ffd9f5;font-size:11px;line-height:1.5}
|
||
.opt.on{border-color:#ffe94d;background:linear-gradient(160deg,#a64bff,#ff2fb9);box-shadow:0 0 14px #ffe94d}
|
||
.opts::-webkit-scrollbar{height:6px}
|
||
.opts::-webkit-scrollbar-thumb{background:#a64bff;border-radius:99px}
|
||
|
||
.footer{margin-top:22px;text-align:center;font-size:12px;color:#ffd9f5;line-height:1.9}
|
||
.made{padding:10px 14px;border-radius:14px;border:2px solid #ffe94d;background:rgba(255,233,77,.10);
|
||
display:inline-block;box-shadow:0 0 14px rgba(255,233,77,.45)}
|
||
@media (max-width:560px){
|
||
.hero h1{font-size:22px}
|
||
.card b{font-size:19px}
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div id="root"></div>
|
||
<script type="text/babel">
|
||
const { useState, useMemo, useEffect } = React;
|
||
const KCAL_PER_KG = 7700;
|
||
|
||
const ACTIVITY = [
|
||
{ id:'a1', label:'几乎不动 / 久坐', desc:'每天 4000 步以下', f:1.2, icon:'🛋️' },
|
||
{ id:'a2', label:'轻度活动', desc:'4000 - 8000 步', f:1.375, icon:'🚶' },
|
||
{ id:'a3', label:'中度活动', desc:'8000 - 12000 步', f:1.55, icon:'🚴' },
|
||
{ id:'a4', label:'高度活动', desc:'12000 - 16000 步', f:1.65, icon:'🏃' },
|
||
{ id:'a5', label:'超高度活动', desc:'16000 步以上 / 体力劳动', f:1.8, icon:'🧗' }
|
||
];
|
||
|
||
/* 流星:top/left 起点,w 长度(px),dur 周期,delay 出场延迟,c 颜色 */
|
||
const METEORS = [
|
||
{ top:'3%', left:'80%', w:170, dur:'16s', delay:'0s', c:'#ffffff' },
|
||
{ top:'5%', left:'74%', w:120, dur:'16s', delay:'.5s', c:'#bdf3ff' },
|
||
{ top:'2%', left:'88%', w:200, dur:'16s', delay:'.95s', c:'#ffe94d' },
|
||
{ top:'18%', left:'58%', w:140, dur:'13s', delay:'6s', c:'#ff9de0' },
|
||
{ top:'22%', left:'50%', w:110, dur:'13s', delay:'6.6s', c:'#ffffff' },
|
||
{ top:'12%', left:'94%', w:160, dur:'19s', delay:'10s', c:'#00e5ff' },
|
||
{ top:'34%', left:'70%', w:130, dur:'21s', delay:'13s', c:'#c8ff3d' },
|
||
{ top:'40%', left:'46%', w:100, dur:'24s', delay:'17s', c:'#ffffff' },
|
||
{ top:'8%', left:'34%', w:150, dur:'26s', delay:'20s', c:'#ffe94d' },
|
||
{ top:'28%', left:'88%', w:180, dur:'17s', delay:'3s', c:'#a64bff' }
|
||
];
|
||
|
||
/* n 名称 / k 千卡 / p 蛋白 g / c 碳水 g / f 脂肪 g / b 膳食纤维 g
|
||
ca 钙 mg / fe 铁 mg / zn 锌 mg / va 维A µg / vc 维C mg / w 食物水分 ml */
|
||
const FOODS = {
|
||
oats40:{n:'燕麦 40g',k:150,p:5.2,c:26.4,f:3.2,b:4.2,ca:21,fe:1.6,zn:1.4,va:0,vc:0,w:4},
|
||
toastWhole1:{n:'全麦吐司 1 片',k:78,p:2.6,c:13.4,f:1.1,b:1.9,ca:15,fe:0.9,zn:0.3,va:0,vc:0,w:9},
|
||
toastWhole2:{n:'全麦吐司 2 片',k:156,p:5.2,c:26.8,f:2.2,b:3.8,ca:30,fe:1.8,zn:0.6,va:0,vc:0,w:18},
|
||
baozi:{n:'肉包 1 个 100g',k:230,p:7,c:42,f:4,b:1.6,ca:25,fe:1.2,zn:0.8,va:10,vc:0,w:45},
|
||
mantou:{n:'馒头 1.5 个',k:264,p:8.4,c:56,f:1.2,b:1.4,ca:23,fe:1.3,zn:0.9,va:0,vc:0,w:42},
|
||
riceWhite200:{n:'白米饭 200g',k:232,p:5.2,c:51.6,f:0.6,b:0.6,ca:20,fe:0.6,zn:0.9,va:0,vc:0,w:140},
|
||
riceWhite300:{n:'白米饭 300g 大碗',k:348,p:7.8,c:77.4,f:0.9,b:0.9,ca:30,fe:0.9,zn:1.4,va:0,vc:0,w:210},
|
||
brownRice150:{n:'糙米饭 150g',k:168,p:3.9,c:34.8,f:1.4,b:2.7,ca:15,fe:0.8,zn:1.1,va:0,vc:0,w:105},
|
||
quinoa100:{n:'藜麦饭 100g',k:120,p:4.4,c:21.3,f:1.9,b:2.8,ca:17,fe:1.5,zn:1.1,va:0,vc:0,w:70},
|
||
corn:{n:'玉米 1 根 200g',k:180,p:6,c:40,f:2.4,b:5.6,ca:4,fe:0.9,zn:1.1,va:18,vc:12,w:146},
|
||
sweetPotato:{n:'红薯 150g',k:129,p:2.4,c:30,f:0.2,b:4.5,ca:45,fe:0.9,zn:0.5,va:1060,vc:39,w:115},
|
||
soba80:{n:'荞麦面 80g 干',k:272,p:8.8,c:56,f:1.6,b:4.8,ca:24,fe:2.4,zn:1.6,va:0,vc:0,w:10},
|
||
pasta350:{n:'意面 350g 熟',k:490,p:17.5,c:98,f:3.5,b:6.3,ca:49,fe:3.2,zn:2.8,va:0,vc:0,w:245},
|
||
noodle250:{n:'面条 250g 熟',k:350,p:11,c:72,f:2,b:3,ca:25,fe:2,zn:1.5,va:0,vc:0,w:175},
|
||
chickenBreast:{n:'鸡胸肉 150g',k:248,p:46.5,c:0,f:5.4,b:0,ca:23,fe:1.5,zn:1.5,va:9,vc:0,w:98},
|
||
chickenThigh:{n:'鸡腿肉 120g',k:216,p:22,c:0,f:13.2,b:0,ca:12,fe:1.6,zn:1.8,va:18,vc:0,w:78},
|
||
fishFillet:{n:'龙利鱼 150g',k:124,p:26,c:0,f:1.5,b:0,ca:30,fe:0.6,zn:0.6,va:15,vc:0,w:115},
|
||
salmon:{n:'三文鱼 120g',k:250,p:24,c:0,f:16,b:0,ca:14,fe:0.5,zn:0.5,va:40,vc:0,w:76},
|
||
beefLean:{n:'瘦牛肉 200g',k:250,p:40,c:0,f:9,b:0,ca:18,fe:4.4,zn:8.2,va:0,vc:0,w:130},
|
||
tomatoBeef:{n:'番茄牛腩 300g',k:320,p:25,c:12,f:19,b:2.4,ca:38,fe:3.6,zn:6,va:90,vc:22,w:180},
|
||
tofu:{n:'北豆腐 150g',k:174,p:18,c:6,f:9.6,b:0.6,ca:207,fe:2.7,zn:1.3,va:0,vc:0,w:120},
|
||
shrimp150:{n:'虾仁 150g',k:150,p:31.5,c:1.5,f:1.5,b:0,ca:93,fe:1.4,zn:1.8,va:18,vc:0,w:115},
|
||
egg2:{n:'水煮蛋 2 个',k:144,p:12.6,c:1.4,f:9.9,b:0,ca:56,fe:1.8,zn:1.3,va:194,vc:0,w:74},
|
||
egg3fried:{n:'黄油煎蛋 3 个',k:295,p:19.5,c:2.1,f:22.5,b:0,ca:84,fe:2.7,zn:2,va:291,vc:0,w:111},
|
||
tomatoEgg:{n:'番茄炒蛋 2 蛋',k:190,p:11,c:8,f:12.6,b:1.6,ca:60,fe:1.8,zn:1.2,va:230,vc:22,w:145},
|
||
yogurtGreek:{n:'无糖希腊酸奶 150g',k:89,p:15,c:5.4,f:1.5,b:0,ca:150,fe:0.1,zn:0.8,va:2,vc:0,w:120},
|
||
yogurtWholeHoney:{n:'全脂酸奶 + 蜂蜜 200g',k:180,p:7,c:26,f:5.6,b:0,ca:240,fe:0.2,zn:1.4,va:28,vc:2,w:160},
|
||
milkSkim250:{n:'低脂牛奶 250ml',k:108,p:8.4,c:12.5,f:2.5,b:0,ca:300,fe:0.1,zn:1,va:60,vc:0,w:225},
|
||
milkWhole300:{n:'全脂牛奶 300ml',k:183,p:9.9,c:14.4,f:10.2,b:0,ca:339,fe:0.2,zn:1.2,va:114,vc:0,w:264},
|
||
soyMilk300:{n:'无糖豆浆 300ml',k:90,p:9,c:9,f:3,b:1.2,ca:36,fe:1.5,zn:0.9,va:0,vc:0,w:282},
|
||
peanutButter20:{n:'花生酱 20g',k:118,p:5,c:4,f:10,b:1.2,ca:9,fe:0.4,zn:0.6,va:0,vc:0,w:2},
|
||
nuts10:{n:'混合坚果 10g',k:60,p:1.7,c:2,f:5.3,b:0.8,ca:10,fe:0.5,zn:0.4,va:0,vc:0,w:1},
|
||
nuts30:{n:'混合坚果 30g',k:180,p:5,c:6,f:16,b:2.4,ca:30,fe:1.4,zn:1.2,va:0,vc:0,w:3},
|
||
cheese30:{n:'芝士片 30g',k:120,p:7,c:0.5,f:10,b:0,ca:220,fe:0.2,zn:1,va:170,vc:0,w:12},
|
||
avocado100:{n:'牛油果 100g',k:160,p:2,c:9,f:15,b:6.7,ca:12,fe:0.6,zn:0.6,va:7,vc:10,w:73},
|
||
broccoli:{n:'西兰花 200g',k:68,p:5.6,c:14,f:0.8,b:5.2,ca:94,fe:1.4,zn:0.8,va:62,vc:178,w:178},
|
||
spinach:{n:'菠菜 200g',k:46,p:5.6,c:7,f:0.8,b:4.4,ca:132,fe:5.4,zn:1.1,va:938,vc:64,w:182},
|
||
tomato:{n:'番茄 200g',k:36,p:1.8,c:7.8,f:0.4,b:2,ca:20,fe:0.5,zn:0.3,va:166,vc:28,w:188},
|
||
cucumber:{n:'凉拌黄瓜 200g',k:36,p:1.6,c:6,f:0.4,b:1,ca:32,fe:0.6,zn:0.4,va:30,vc:18,w:190},
|
||
stirVeg:{n:'橄榄油清炒时蔬 200g',k:120,p:3.2,c:9,f:8,b:3.4,ca:64,fe:1.4,zn:0.6,va:420,vc:48,w:180},
|
||
lettuce:{n:'蒜蓉生菜 200g',k:66,p:3,c:7,f:3,b:2.6,ca:72,fe:1.2,zn:0.5,va:300,vc:32,w:188},
|
||
soupSeaweed:{n:'紫菜蛋花汤 1 碗',k:95,p:7,c:3.5,f:6,b:0.6,ca:96,fe:1.2,zn:0.8,va:120,vc:1,w:230},
|
||
blueberry100:{n:'蓝莓 100g',k:57,p:0.7,c:14.5,f:0.3,b:2.4,ca:6,fe:0.3,zn:0.2,va:3,vc:10,w:84},
|
||
apple200:{n:'苹果 200g',k:104,p:0.5,c:27.4,f:0.3,b:4.8,ca:8,fe:0.2,zn:0.1,va:6,vc:9,w:172},
|
||
banana120:{n:'香蕉 1 根 120g',k:107,p:1.3,c:27,f:0.4,b:3.1,ca:7,fe:0.3,zn:0.2,va:4,vc:10,w:90},
|
||
orange200:{n:'橙子 200g',k:94,p:1.8,c:23.6,f:0.2,b:3.2,ca:80,fe:0.4,zn:0.2,va:22,vc:106,w:174},
|
||
proteinPowder:{n:'乳清蛋白粉 30g',k:113,p:24,c:2.4,f:1.2,b:0,ca:120,fe:0.3,zn:0.6,va:0,vc:0,w:3},
|
||
pbBananaToast:{n:'花生酱香蕉三明治',k:420,p:15,c:60,f:14,b:6.6,ca:55,fe:2.2,zn:1.8,va:10,vc:10,w:60},
|
||
milkOats300:{n:'燕麦 50g + 全脂奶 300ml',k:333,p:15.1,c:40.5,f:13.4,b:5.3,ca:360,fe:2.2,zn:2.6,va:114,vc:0,w:268}
|
||
};
|
||
|
||
const GOALS = {
|
||
cut:{
|
||
label:'减重', icon:'📉', en:'CUT', proteinPerKg:2.0, fatPct:0.25, fiber:30,
|
||
rates:[{v:0.25,t:'轻松 0.25 kg/周'},{v:0.5,t:'标准 0.5 kg/周'},{v:0.75,t:'激进 0.75 kg/周'}],
|
||
water:{female:2000,male:2200},
|
||
desc:'热量缺口 + 高蛋白 + 高纤维,主食偏慢碳水,少油少盐'
|
||
},
|
||
maintain:{
|
||
label:'维持', icon:'⚖️', en:'MAINTAIN', proteinPerKg:1.6, fatPct:0.28, fiber:25,
|
||
rates:[],
|
||
water:{female:1500,male:1700},
|
||
desc:'热量与 TDEE 持平,家常均衡饮食:一荤两素 + 主食 + 汤'
|
||
},
|
||
bulk:{
|
||
label:'增重', icon:'📈', en:'BULK', proteinPerKg:1.8, fatPct:0.28, fiber:30,
|
||
rates:[{v:0.2,t:'干净 0.2 kg/周'},{v:0.35,t:'标准 0.35 kg/周'},{v:0.5,t:'快速 0.5 kg/周'}],
|
||
water:{female:1700,male:1900},
|
||
desc:'热量盈余 + 足量碳水 + 高热量密度食物:全脂奶、坚果酱、红肉、意面'
|
||
}
|
||
};
|
||
|
||
const PLANS = {
|
||
cut:[
|
||
{name:'🌞 早餐', tip:'高蛋白开胃', slots:[
|
||
{label:'主食 · 慢碳水', options:['oats40','toastWhole1','sweetPotato']},
|
||
{label:'蛋白质', options:['egg2','yogurtGreek','milkSkim250']},
|
||
{label:'蔬果', options:['blueberry100','apple200','orange200']}
|
||
]},
|
||
{name:'🌈 午餐', tip:'饱腹感优先', slots:[
|
||
{label:'主食 · 慢碳水', options:['brownRice150','quinoa100','corn']},
|
||
{label:'优质蛋白 · 低脂', options:['chickenBreast','fishFillet','tofu']},
|
||
{label:'蔬菜', options:['broccoli','cucumber','stirVeg']}
|
||
]},
|
||
{name:'🌙 晚餐', tip:'清淡、好消化', slots:[
|
||
{label:'主食 · 慢碳水', options:['sweetPotato','soba80','corn']},
|
||
{label:'优质蛋白 · 低脂', options:['shrimp150','fishFillet','chickenBreast']},
|
||
{label:'蔬菜', options:['spinach','tomato','lettuce']}
|
||
]},
|
||
{name:'✨ 加餐', tip:'解馋不超标', slots:[
|
||
{label:'小食', options:['nuts10','yogurtGreek','proteinPowder']},
|
||
{label:'可选加料', options:['blueberry100','apple200','yogurtGreek']}
|
||
]}
|
||
],
|
||
maintain:[
|
||
{name:'🌞 早餐', tip:'家常早点', slots:[
|
||
{label:'主食', options:['toastWhole2','baozi','oats40']},
|
||
{label:'蛋白质', options:['egg2','milkSkim250','soyMilk300']},
|
||
{label:'蔬果', options:['apple200','orange200','blueberry100']}
|
||
]},
|
||
{name:'🌈 午餐', tip:'一荤两素 + 汤', slots:[
|
||
{label:'主食', options:['riceWhite200','mantou','brownRice150']},
|
||
{label:'荤菜', options:['tomatoEgg','chickenThigh','fishFillet']},
|
||
{label:'素菜', options:['stirVeg','lettuce','broccoli']},
|
||
{label:'汤', options:['soupSeaweed','tomato']}
|
||
]},
|
||
{name:'🌙 晚餐', tip:'同样均衡,少油少盐', slots:[
|
||
{label:'主食', options:['riceWhite200','noodle250','sweetPotato']},
|
||
{label:'荤菜', options:['salmon','chickenBreast','tofu']},
|
||
{label:'素菜', options:['lettuce','broccoli','spinach']}
|
||
]},
|
||
{name:'✨ 加餐', tip:'水果 / 奶制品 / 坚果', slots:[
|
||
{label:'小食', options:['yogurtWholeHoney','nuts30','apple200']},
|
||
{label:'可选加料', options:['blueberry100','soyMilk300','banana120']}
|
||
]}
|
||
],
|
||
bulk:[
|
||
{name:'🌞 早餐', tip:'热量密度拉满', slots:[
|
||
{label:'主食 · 碳水', options:['milkOats300','toastWhole2','oats40']},
|
||
{label:'蛋白质 · 全蛋 + 芝士', options:['egg3fried','cheese30','proteinPowder']},
|
||
{label:'蔬果', options:['banana120','blueberry100','orange200']},
|
||
{label:'加料 · 热量', options:['peanutButter20','nuts30','avocado100']}
|
||
]},
|
||
{name:'🌈 午餐', tip:'大碗主食 + 大块肉', slots:[
|
||
{label:'主食 · 大份', options:['riceWhite300','pasta350','mantou']},
|
||
{label:'蛋白质 · 红肉优先', options:['beefLean','tomatoBeef','chickenThigh']},
|
||
{label:'蔬菜', options:['stirVeg','broccoli','spinach']},
|
||
{label:'汤 / 额外热量', options:['soupSeaweed','avocado100','cheese30']}
|
||
]},
|
||
{name:'🌙 晚餐', tip:'训练后补碳水 + 蛋白', slots:[
|
||
{label:'主食 · 大份', options:['riceWhite300','noodle250','sweetPotato']},
|
||
{label:'蛋白质 · 足量', options:['salmon','beefLean','shrimp150']},
|
||
{label:'蔬菜', options:['broccoli','stirVeg','lettuce']},
|
||
{label:'加料 · 热量', options:['avocado100','nuts30','cheese30']}
|
||
]},
|
||
{name:'✨ 加餐(一天两次也不错)', tip:'睡前来一份也行', slots:[
|
||
{label:'高热量小食', options:['pbBananaToast','yogurtWholeHoney','milkWhole300']},
|
||
{label:'加料', options:['nuts30','cheese30','peanutButter20']}
|
||
]}
|
||
]
|
||
};
|
||
|
||
const fmt = (n) => (isFinite(n) ? Math.round(n).toLocaleString('zh-CN') : '—');
|
||
const r1 = (n) => (isFinite(n) ? Math.round(n * 10) / 10 : '—');
|
||
const bmiInfo = (bmi) => {
|
||
if (!bmi) return { t:'—', c:'#ffd9f5' };
|
||
if (bmi < 18.5) return { t:'偏瘦', c:'#00e5ff' };
|
||
if (bmi < 24) return { t:'健康', c:'#c8ff3d' };
|
||
if (bmi < 28) return { t:'超重', c:'#ffe94d' };
|
||
return { t:'肥胖', c:'#ff2fb9' };
|
||
};
|
||
|
||
function CalorieCalculator() {
|
||
const [sex, setSex] = useState('female');
|
||
const [age, setAge] = useState(28);
|
||
const [height, setHeight] = useState(165);
|
||
const [weight, setWeight] = useState(60);
|
||
const [actId, setActId] = useState('a2');
|
||
const [goal, setGoal] = useState('cut');
|
||
const [rate, setRate] = useState(0.5);
|
||
const [targetW, setTargetW] = useState(54);
|
||
const [picks, setPicks] = useState({});
|
||
|
||
const G = GOALS[goal];
|
||
|
||
const buildPicks = (g) => {
|
||
const p = {};
|
||
PLANS[g].forEach((meal, mi) => meal.slots.forEach((slot, si) => {
|
||
p[mi + '-' + si] = slot.options[0];
|
||
}));
|
||
return p;
|
||
};
|
||
const recoTarget = (g, w) => {
|
||
if (g === 'maintain') return Math.round(w * 2) / 2;
|
||
if (g === 'bulk') return Math.round(w * 1.05 * 2) / 2;
|
||
return Math.round(w * 0.9 * 2) / 2;
|
||
};
|
||
|
||
useEffect(() => {
|
||
setPicks(buildPicks(goal));
|
||
const rs = GOALS[goal].rates;
|
||
setRate(rs.length ? rs[1].v : 0);
|
||
setTargetW(recoTarget(goal, Number(weight) || 0));
|
||
}, [goal]);
|
||
|
||
const h = Number(height) || 0;
|
||
const w = Number(weight) || 0;
|
||
const a = Number(age) || 0;
|
||
const tw = Number(targetW) || 0;
|
||
|
||
const bmi = h > 0 ? w / ((h / 100) * (h / 100)) : 0;
|
||
const bmiTag = bmiInfo(bmi);
|
||
const fac = (ACTIVITY.find(x => x.id === actId) || ACTIVITY[1]).f;
|
||
const bmr = sex === 'female'
|
||
? 10 * w + 6.25 * h - 5 * a - 161
|
||
: 10 * w + 6.25 * h - 5 * a + 5;
|
||
const tdee = bmr * fac;
|
||
|
||
const deltaPerDay = goal === 'maintain' ? 0 : (rate * KCAL_PER_KG) / 7;
|
||
const rawTarget = goal === 'cut' ? tdee - deltaPerDay
|
||
: goal === 'bulk' ? tdee + deltaPerDay
|
||
: tdee;
|
||
const floor = sex === 'female' ? 1200 : 1500;
|
||
const floored = goal === 'cut' && rawTarget < floor;
|
||
const finalTarget = goal === 'cut' ? Math.max(rawTarget, floor) : rawTarget;
|
||
|
||
const kgDiff = Math.abs(tw - w);
|
||
const weeks = (goal === 'maintain' || !rate) ? 0 : kgDiff / rate;
|
||
const targetBmi = h > 0 ? tw / ((h / 100) * (h / 100)) : 0;
|
||
const targetBmiTag = bmiInfo(targetBmi);
|
||
|
||
const proteinT = w * G.proteinPerKg;
|
||
const fatT = (finalTarget * G.fatPct) / 9;
|
||
const carbT = Math.max(0, (finalTarget - proteinT * 4 - fatT * 9) / 4);
|
||
const macroKcal = proteinT * 4 + fatT * 9 + carbT * 4 || 1;
|
||
const pPct = (proteinT * 4 / macroKcal) * 100;
|
||
const fPct = (fatT * 9 / macroKcal) * 100;
|
||
const cPct = (carbT * 4 / macroKcal) * 100;
|
||
|
||
const warns = [];
|
||
if (goal === 'cut' && tw > 0 && tw >= w) {
|
||
warns.push('目标体重不小于当前体重:减重模式请把目标设得比现在低一些。');
|
||
}
|
||
if (goal === 'bulk' && tw > 0 && tw <= w) {
|
||
warns.push('目标体重不大于当前体重:增重模式请把目标设得比现在高一些。');
|
||
}
|
||
if (goal === 'cut' && rate > 0.5) {
|
||
warns.push('每周减重 0.75 kg 偏快(建议不超过 0.5 kg),容易掉肌肉,可考虑放慢节奏。');
|
||
}
|
||
if (goal === 'bulk' && rate > 0.5) {
|
||
warns.push('每周增重 0.5 kg 偏快,脂肪增长速度会明显上升。');
|
||
}
|
||
if (floored) {
|
||
warns.push('按目标体重算出的热量只有 ' + fmt(rawTarget) + ' 千卡,低于安全下限 ' +
|
||
fmt(floor) + ' 千卡。页面按 ' + fmt(floor) + ' 千卡显示,请不要长期低于下限。');
|
||
}
|
||
|
||
const totals = useMemo(() => {
|
||
const t = { k:0, p:0, c:0, f:0, b:0, ca:0, fe:0, zn:0, va:0, vc:0, w:0 };
|
||
PLANS[goal].forEach((meal, mi) => meal.slots.forEach((slot, si) => {
|
||
const fd = FOODS[picks[mi + '-' + si]];
|
||
if (fd) Object.keys(t).forEach(key => { t[key] += fd[key] || 0; });
|
||
}));
|
||
return t;
|
||
}, [goal, picks]);
|
||
|
||
const micro = [
|
||
{ key:'b', label:'膳食纤维', unit:'g', ref:G.fiber },
|
||
{ key:'ca', label:'钙', unit:'mg', ref:1000 },
|
||
{ key:'fe', label:'铁', unit:'mg', ref:sex === 'female' ? 20 : 12 },
|
||
{ key:'zn', label:'锌', unit:'mg', ref:sex === 'female' ? 7.5 : 12.5 },
|
||
{ key:'va', label:'维生素 A', unit:'µg', ref:sex === 'female' ? 700 : 900 },
|
||
{ key:'vc', label:'维生素 C', unit:'mg', ref:100 },
|
||
{ key:'w', label:'食物水分', unit:'ml', ref:G.water[sex] }
|
||
];
|
||
|
||
const kcalDiff = totals.k - finalTarget;
|
||
const choose = (mi, si, id) => setPicks(prev => Object.assign({}, prev, { [mi + '-' + si]: id }));
|
||
|
||
return (
|
||
<div className="wrap">
|
||
<div className="hero">
|
||
<h1>✧ 每日热量需求 · 膳食计算器 ✧</h1>
|
||
<div className="sub">BMI · BMR · TDEE · 减重 / 维持 / 增重 三套食谱 · 千禧闪亮版</div>
|
||
<div>
|
||
<span className="badge">★ NEW 三套独立食谱 ★</span>
|
||
<span className="badge">✨ 目标体重 & 节奏 ✨</span>
|
||
<span className="badge">◆ 七大营养素进度 ◆</span>
|
||
<span className="badge">☄ 流星雨特效 ☄</span>
|
||
</div>
|
||
<div style={{ marginTop: 12 }}>
|
||
<span className="led">0 0 0 8 8 6 6 2</span>
|
||
</div>
|
||
</div>
|
||
|
||
{/* 第一步 */}
|
||
<div className="panel">
|
||
<h2>第一步 · 基本信息<span>算 BMI 与基础代谢</span></h2>
|
||
<div className="row">
|
||
<div className="field">
|
||
<label>性别</label>
|
||
<div className="seg">
|
||
<button className={'chip' + (sex === 'female' ? ' on' : '')} onClick={() => setSex('female')}>👩 女生</button>
|
||
<button className={'chip' + (sex === 'male' ? ' on' : '')} onClick={() => setSex('male')}>👨 男生</button>
|
||
</div>
|
||
</div>
|
||
<div className="field">
|
||
<label>年龄(岁)</label>
|
||
<input type="number" value={age} min="10" max="99" onChange={e => setAge(e.target.value)} />
|
||
</div>
|
||
<div className="field">
|
||
<label>身高(cm)</label>
|
||
<input type="number" value={height} min="120" max="230" onChange={e => setHeight(e.target.value)} />
|
||
</div>
|
||
<div className="field">
|
||
<label>体重(kg)</label>
|
||
<input type="number" value={weight} step="0.5" min="30" max="250" onChange={e => setWeight(e.target.value)} />
|
||
</div>
|
||
</div>
|
||
|
||
<div className="hr"></div>
|
||
|
||
<div className="grid">
|
||
<div className="card big">
|
||
<span>你的 BMI</span>
|
||
<b>{bmi ? r1(bmi) : '—'}</b>
|
||
<em>分类:<b style={{ color: bmiTag.c }}>{bmiTag.t}</b>(偏瘦 <18.5 / 健康 <24 / 超重 <28 / 肥胖 ≥28)</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>理想体重区间</span>
|
||
<b style={{ fontSize: 17 }}>{h ? r1(18.5 * Math.pow(h / 100, 2)) + ' - ' + r1(23.9 * Math.pow(h / 100, 2)) + ' kg' : '—'}</b>
|
||
<em>按 BMI 18.5 - 23.9 估算</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>基础代谢 BMR</span>
|
||
<b>{fmt(bmr)}</b>
|
||
<em>Mifflin-St Jeor 公式,千卡/天</em>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
{/* 第二步 */}
|
||
<div className="panel">
|
||
<h2>第二步 · 活动量<span>按步数分档,得到 TDEE</span></h2>
|
||
<div className="acts">
|
||
{ACTIVITY.map(item => (
|
||
<button
|
||
key={item.id}
|
||
className={'act' + (actId === item.id ? ' on' : '')}
|
||
onClick={() => setActId(item.id)}
|
||
>
|
||
{item.icon} <b>{item.label}</b>
|
||
<small>{item.desc} · ×{item.f}</small>
|
||
</button>
|
||
))}
|
||
</div>
|
||
<div className="hr"></div>
|
||
<div className="grid">
|
||
<div className="card big">
|
||
<span>每日总消耗 TDEE</span>
|
||
<b>{fmt(tdee)}</b>
|
||
<em>BMR × 活动系数 {fac}</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>对应活动系数</span>
|
||
<b>× {fac}</b>
|
||
<em>{ACTIVITY.find(x => x.id === actId).desc}</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>基础代谢</span>
|
||
<b>{fmt(bmr)}</b>
|
||
<em>千卡/天</em>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
{/* 第三步 */}
|
||
<div className="panel">
|
||
<h2>第三步 · 目标模式<span>减重 / 维持 / 增重,一天要多少千卡</span></h2>
|
||
<div className="goals">
|
||
{Object.keys(GOALS).map(key => {
|
||
const g = GOALS[key];
|
||
return (
|
||
<button key={key} className={'goal' + (goal === key ? ' on' : '')} onClick={() => setGoal(key)}>
|
||
{g.icon} {g.label} <small>{g['en']} · {g.desc}</small>
|
||
</button>
|
||
);
|
||
})}
|
||
</div>
|
||
|
||
<div className="hr"></div>
|
||
|
||
<div className="row">
|
||
<div className="field">
|
||
<label>目标体重(kg)</label>
|
||
<input type="number" value={targetW} step="0.5" min="30" max="250"
|
||
onChange={e => setTargetW(e.target.value)} />
|
||
<div className="chips">
|
||
<button className="chip" onClick={() => setTargetW(recoTarget(goal, w))}>✦ 用推荐值</button>
|
||
</div>
|
||
</div>
|
||
<div className="field" style={{ flex: '1 1 260px' }}>
|
||
<label>{goal === 'maintain' ? '维持模式' : '节奏(体重变化速度)'}</label>
|
||
{goal === 'maintain' ? (
|
||
<div className="warn ok" style={{ marginTop: 0 }}>维持模式无需设定速度:每日热量 = TDEE</div>
|
||
) : (
|
||
<div className="chips">
|
||
{G.rates.map(item => (
|
||
<button key={item.v}
|
||
className={'chip' + (rate === item.v ? ' on' : '')}
|
||
onClick={() => setRate(item.v)}>
|
||
{item.t}
|
||
</button>
|
||
))}
|
||
</div>
|
||
)}
|
||
<span className="tiny">
|
||
参考换算:1 kg 体重 ≈ {fmt(KCAL_PER_KG)} 千卡;按目标速度换算出每天的热量缺口 / 盈余。
|
||
</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="hr"></div>
|
||
|
||
<div className="grid">
|
||
<div className="card big">
|
||
<span>每日热量目标</span>
|
||
<b>{fmt(finalTarget)}</b>
|
||
<em>
|
||
{goal === 'cut' && '每天缺口约 ' + fmt(deltaPerDay) + ' 千卡'}
|
||
{goal === 'bulk' && '每天盈余约 ' + fmt(deltaPerDay) + ' 千卡'}
|
||
{goal === 'maintain' && '与 TDEE 持平'}
|
||
</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>{goal === 'bulk' ? '还需增加' : goal === 'cut' ? '还需减掉' : '需要保持'}</span>
|
||
<b>{goal === 'maintain' ? '0 kg' : r1(kgDiff) + ' kg'}</b>
|
||
<em>{r1(w)} kg → {r1(tw)} kg</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>预计用时</span>
|
||
<b style={{ fontSize: 18 }}>
|
||
{goal === 'maintain' ? '长期' : weeks ? r1(weeks) + ' 周' : '—'}
|
||
</b>
|
||
<em>{goal === 'maintain' ? '保持现在的体重' : weeks ? '约 ' + r1(weeks / 4.345) + ' 个月' : '请设置目标体重与节奏'}</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>目标 BMI</span>
|
||
<b>{targetBmi ? r1(targetBmi) : '—'}</b>
|
||
<em>届时分类:<b style={{ color: targetBmiTag.c }}>{targetBmiTag.t}</b></em>
|
||
</div>
|
||
</div>
|
||
|
||
{warns.map((text, i) => <div className="warn" key={i}>⚠ {text}</div>)}
|
||
{warns.length === 0 && (
|
||
<div className="ok">✦ 目标设定合理:{G.label}模式下每天 {fmt(finalTarget)} 千卡,速度约 {goal === 'maintain' ? '保持' : rate + ' kg/周'}。</div>
|
||
)}
|
||
</div>
|
||
|
||
{/* 第四步 */}
|
||
<div className="panel">
|
||
<h2>第四步 · 今日 {G.label} 食谱<span>{G.icon} 每格选一个,右侧看合计</span></h2>
|
||
|
||
{PLANS[goal].map((meal, mi) => {
|
||
const mt = meal.slots.reduce((acc, slot, si) => {
|
||
const fd = FOODS[picks[mi + '-' + si]] || {};
|
||
acc.k += fd.k || 0; acc.p += fd.p || 0; acc.c += fd.c || 0; acc.f += fd.f || 0;
|
||
return acc;
|
||
}, { k:0, p:0, c:0, f:0 });
|
||
return (
|
||
<div className="meal" key={mi}>
|
||
<div className="mealhead">
|
||
<span>{meal.name} <small>· {meal.tip}</small></span>
|
||
<small>{fmt(mt.k)} 千卡 · 蛋白 {r1(mt.p)}g · 碳 {r1(mt.c)}g · 脂 {r1(mt.f)}g</small>
|
||
</div>
|
||
{meal.slots.map((slot, si) => (
|
||
<div className="slot" key={si}>
|
||
<span>{slot.label}</span>
|
||
<div className="opts">
|
||
{slot.options.map(id => {
|
||
const fd = FOODS[id];
|
||
const on = picks[mi + '-' + si] === id;
|
||
return (
|
||
<button key={id} className={'opt' + (on ? ' on' : '')} onClick={() => choose(mi, si, id)}>
|
||
<b>{fd.n}</b>
|
||
<small>{fmt(fd.k)} 千卡 · 蛋白 {r1(fd.p)}g · 碳水 {r1(fd.c)}g · 脂肪 {r1(fd.f)}g</small>
|
||
</button>
|
||
);
|
||
})}
|
||
</div>
|
||
</div>
|
||
))}
|
||
</div>
|
||
);
|
||
})}
|
||
|
||
<div className="chips" style={{ marginBottom: 14 }}>
|
||
<button className="chip" onClick={() => setPicks(buildPicks(goal))}>↺ 恢复推荐选择</button>
|
||
</div>
|
||
|
||
<div className="grid">
|
||
<div className="card big">
|
||
<span>全天合计</span>
|
||
<b>{fmt(totals.k)}</b>
|
||
<em>千卡</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>目标热量</span>
|
||
<b>{fmt(finalTarget)}</b>
|
||
<em>千卡</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>与目标差值</span>
|
||
<b style={{ color: Math.abs(kcalDiff) <= 50 ? '#c8ff3d' : '#ffe94d' }}>
|
||
{kcalDiff > 0 ? '+' : ''}{fmt(kcalDiff)}
|
||
</b>
|
||
<em>
|
||
{kcalDiff < -50 ? '比目标偏少,可多加一份主食或加餐'
|
||
: kcalDiff > 50 ? '比目标偏多,可去掉一份加料'
|
||
: '和目标几乎一致 ✦'}
|
||
</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>蛋白 / 碳水 / 脂肪</span>
|
||
<b style={{ fontSize: 17 }}>{fmt(totals.p)} / {fmt(totals.c)} / {fmt(totals.f)}</b>
|
||
<em>克(来自已选食物)</em>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
{/* 营养素 */}
|
||
<div className="panel">
|
||
<h2>营养素目标<span>{G.proteinPerKg} g 蛋白 / kg 体重 · 脂肪 {Math.round(G.fatPct * 100)}% 热量</span></h2>
|
||
<div className="grid">
|
||
<div className="card">
|
||
<span>蛋白质目标</span>
|
||
<b>{r1(proteinT)} g</b>
|
||
<em>{Math.round(pPct)}% 热量 · 每公斤体重 {G.proteinPerKg} g</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>脂肪目标</span>
|
||
<b>{r1(fatT)} g</b>
|
||
<em>{Math.round(fPct)}% 热量 · 优先不饱和脂肪</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>碳水目标</span>
|
||
<b>{r1(carbT)} g</b>
|
||
<em>{Math.round(cPct)}% 热量 · {goal === 'cut' ? '优先慢碳水' : goal === 'bulk' ? '训练前后多补' : '粗细搭配'}</em>
|
||
</div>
|
||
<div className="card">
|
||
<span>建议饮水</span>
|
||
<b>{fmt(G.water[sex])} ml</b>
|
||
<em>{sex === 'female' ? '女生' : '男生'} · {goal === 'cut' ? '减重期适当加量' : goal === 'bulk' ? '高蛋白记得多喝' : '日常补水'}</em>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="hr"></div>
|
||
|
||
<div className="bars">
|
||
{micro.map(m => {
|
||
const val = totals[m.key] || 0;
|
||
const pctRaw = m.ref ? (val / m.ref) * 100 : 0;
|
||
const good = pctRaw >= 80;
|
||
return (
|
||
<div className="barwrap" key={m.key}>
|
||
<div className="lb">
|
||
<span>{m.label}</span>
|
||
<span>{r1(val)} / {m.ref} {m.unit}({Math.round(pctRaw)}%)</span>
|
||
</div>
|
||
<div className="bar"><i className={good ? 'good' : ''} style={{ width: Math.min(100, pctRaw) + '%' }}></i></div>
|
||
</div>
|
||
);
|
||
})}
|
||
</div>
|
||
<span className="tiny">
|
||
✦ 达到参考值 80% 以上会变成绿色(参考值:钙 1000mg、铁 女 20 / 男 12mg、锌 女 7.5 / 男 12.5mg、
|
||
维A 女 700 / 男 900µg、维C 100mg)。食物水分不含饮料与白水,记得额外补水。
|
||
</span>
|
||
</div>
|
||
|
||
<div className="footer">
|
||
<div className="made">✈ 用 ♥ 制作 · 千禧闪亮版 ✈</div>
|
||
<div>本页为科普与估算工具,结果基于通用公式(Mifflin-St Jeor)与常见食物成分值,仅供参考。</div>
|
||
<div>不构成医疗或营养建议;孕产期、慢性疾病、进食障碍等情况请遵医嘱并咨询注册营养师。</div>
|
||
<div><span className="led">0 0 0 8 8 6 6 2</span></div>
|
||
</div>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
const mq = '✈⋯゙゚ 欢迎光临本站 ゚゙⋯✈ 减重 / 维持 / 增重 三套独立食谱 ✈ ☄ 今晚有流星雨 ☄ ✈ 记得多喝水 ✈ 不要熬夜噢 ✈ ';
|
||
|
||
ReactDOM.createRoot(document.getElementById('root')).render(
|
||
<>
|
||
<div className="marquee"><div className="marquee-track">{mq}{mq}</div></div>
|
||
<div className="stars"></div>
|
||
<div className="stars2"></div>
|
||
<div className="shower">
|
||
{METEORS.map((m, i) => (
|
||
<span
|
||
key={i}
|
||
className="meteor"
|
||
style={{
|
||
top: m.top,
|
||
left: m.left,
|
||
width: m.w + 'px',
|
||
animationDuration: m.dur,
|
||
animationDelay: m.delay,
|
||
'--glow': m.c,
|
||
background: 'linear-gradient(90deg,rgba(255,255,255,0) 0%,' + m.c + ' 100%)'
|
||
}}
|
||
></span>
|
||
))}
|
||
</div>
|
||
<span className="sparkle" style={{ top:'12%', left:'5%', animationDelay:'0s' }}>✧</span>
|
||
<span className="sparkle" style={{ top:'30%', left:'93%', animationDelay:'1.2s' }}>✦</span>
|
||
<span className="sparkle" style={{ top:'58%', left:'3%', animationDelay:'2.1s' }}>⋆</span>
|
||
<span className="sparkle" style={{ top:'80%', left:'88%', animationDelay:'0.6s' }}>✧</span>
|
||
<span className="sparkle" style={{ top:'44%', left:'50%', animationDelay:'1.8s' }}>✩</span>
|
||
<CalorieCalculator />
|
||
</>
|
||
);
|
||
</script>
|
||
</body>
|
||
</html>
|