PageSourceSearch

https://fitdietaihkapp.manus.space/assets/BodyMeasurements-CFf1cnEY.js

js fitdietaihkapp.manus.space collected 2026-10-03 05:02:14 UTC 17,304 bytes, 1 lines download raw bytes

1import{r as n,t as o,b as r,j as e,A as ee,C as u,e as g,B as N,i as se,c as U,d as L,k as te}from"./index-bM8UT4Os.js";import{I as p}from"./input-BwpLlRYf.js";import{L as y}from"./label-2Seh_wFH.js";import{S as T}from"./scale-C2__GAhb.js";import{P as O}from"./plus-DSaqw8wa.js";import{F as G,C as ae}from"./file-up-B_NGjEWN.js";import{T as re}from"./trash-2-4iirX7DH.js";import"./dialog-CxcTDVnZ.js";import"./useComposition-DO5dIJEj.js";function pe(){const[W,b]=n.useState(""),[i,v]=n.useState(""),[m,w]=n.useState(""),[x,F]=n.useState(""),[C,E]=n.useState(""),[h,S]=n.useState("manual"),[Q,M]=n.useState(!1),[a,k]=n.useState(null),[H,z]=n.useState(""),K=n.useRef(null),d=o.useUtils(),{data:D,isLoading:J}=o.bodyMeasurements.getHistory.useQuery({limit:30}),{data:c}=o.bodyMeasurements.getTrend.useQuery({days:90}),P=o.bodyMeasurements.add.useMutation({onSuccess:()=>{r.success("上磅記錄已儲存 ⚖️"),$(),d.bodyMeasurements.getHistory.invalidate(),d.bodyMeasurements.getTrend.invalidate(),d.bodyMeasurements.getLatest.invalidate()},onError:s=>r.error("儲存唔到: "+s.message)}),q=o.healthReport.analyze.useMutation({onSuccess:s=>{if(M(!1),!s||!s.extractedData){r.error("AI 回覆格式錯誤");return}k(s.extractedData),z(s.reportUrl||""),s.extractedData.weight&&b(String(s.extractedData.weight)),s.extractedData.bodyFatPercentage&&v(String(s.extractedData.bodyFatPercentage)),s.extractedData.muscleMass&&w(String(s.extractedData.muscleMass)),s.extractedData.waistCircumference&&F(String(s.extractedData.waistCircumference)),r.success("AI 已辨識報告數據!OK 就儲存 ✅")},onError:s=>{M(!1),r.error("辨識唔到: "+s.message)}}),R=o.healthReport.confirmAndSave.useMutation({onSuccess:()=>{r.success("健康報告數據已儲存 📋"),$(),d.bodyMeasurements.getHistory.invalidate(),d.bodyMeasurements.getTrend.invalidate(),d.bodyMeasurements.getLatest.invalidate()},onError:s=>r.error("儲存唔到: "+s.message)}),V=o.bodyMeasurements.delete.useMutation({onSuccess:()=>{r.success("已剷咗"),d.bodyMeasurements.getHistory.invalidate(),d.bodyMeasurements.getTrend.invalidate()}}),$=()=>{b(""),v(""),w(""),F(""),E(""),k(null),z(""),S("manual")},X=s=>{s.preventDefault();const t=parseFloat(W);if(!t||t<20||t>300){r.error("入返有效體重 (20-300 kg)");return}a&&H?R.mutate({weight:t,bodyFatPercentage:i?parseFloat(i):void 0,muscleMass:m?parseFloat(m):void 0,waistCircumference:x?parseFloat(x):void 0,visceralFat:a.visceralFat||void 0,bmi:a.bmi||void 0,basalMetabolicRate:a.basalMetabolicRate||void 0,bodyWater:a.bodyWater||void 0,boneMass:a.boneMass||void 0,reportUrl:H,notes:C||void 0}):P.mutate({weight:t,bodyFatPercentage:i?parseFloat(i):void 0,muscleMass:m?parseFloat(m):void 0,waistCircumference:x?parseFloat(x):void 0,notes:C||void 0})},Y=s=>{const t=s.target.files?.[0];if(!t)return;if(t.size>20*1024*1024){r.error("檔案太大,最大 20MB");return}M(!0);const A=new FileReader;A.onload=I=>{const l=I.target?.result,f=l.split(","),j=f.length>1?f[1]:l;if(!j){r.error("檔案讀取失敗"),M(!1);return}q.mutate({fileBase64:j,mimeType:t.type,fileName:t.name})},A.readAsDataURL(t)},B=(()=>{if(!c||!Array.isArray(c)||c.length<2)return null;const s=c[c.length-1]?.weight,t=c[0]?.weight;return s===void 0||t===void 0?null:{change:s-t,latest:s,first:t}})(),Z=s=>s?s.split(/[||]/).map(t=>t.trim()).filter(Boolean).filter(t=>!/^(內臟脂肪|BMI|BMR|體水分|骨質量|報告)\s*[::]/i.test(t)).filter(t=>!t.includes("manus-storage")).join(" · "):"",_=()=>{if(!c||!Array.isArray(c)||c.length<2)return null;const s=c.map(l=>l?.weight).filter(l=>l!==void 0),t=Math.min(...s),I=Math.max(...s)-t||1;return e.jsx("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:184",className:"flex items-end gap-[2px] h-16 mt-2",children:s.map((l,f)=>{const j=(l-t)/I*100;return e.jsx("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:188",className:"flex-1 bg-gradient-to-t from-blue-500 to-cyan-400 rounded-t-sm min-w-[3px] transition-all",style:{height:`${Math.max(10,j)}%`},title:`${l} kg`},f)})})};return e.jsx(ee,{"data-loc":"client/src/pages/BodyMeasurements.tsx:201",title:"上磅記錄",showBack:!0,children:e.jsx("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:202",className:"py-6 px-4",children:e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:203",className:"max-w-2xl mx-auto 
1space-y-5",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:205",className:"mb-2",children:[e.jsxs("h1",{"data-loc":"client/src/pages/BodyMeasurements.tsx:206",className:"text-2xl md:text-3xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(T,{"data-loc":"client/src/pages/BodyMeasurements.tsx:207",className:"w-6 h-6 text-primary"}),"上磅記錄"]}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:210",className:"text-sm text-muted-foreground mt-1",children:"自己入或 Upload InBody / 電子磅報告 📊"})]}),B&&e.jsx(u,{"data-loc":"client/src/pages/BodyMeasurements.tsx:217",className:"card-premium",children:e.jsxs(g,{"data-loc":"client/src/pages/BodyMeasurements.tsx:218",className:"pt-5",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:219",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:220",children:[e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:221",className:"text-xs text-muted-foreground",children:"90 日體重變化"}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:222",className:"flex items-center gap-2 mt-1",children:[e.jsx(T,{"data-loc":"client/src/pages/BodyMeasurements.tsx:223",className:"w-5 h-5 text-primary"}),e.jsxs("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:224",className:"text-xl font-bold text-primary",children:[B.change>0?"+":"",B.change.toFixed(1)," kg"]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:229",className:"text-right",children:[e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:230",className:"text-xs text-muted-foreground",children:"最新體重"}),e.jsxs("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:231",className:"text-2xl font-bold text-foreground",children:[B.latest.toFixed(1),e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:231",className:"text-sm text-muted-foreground ml-1",children:"kg"})]})]})]}),_()]})}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:240",className:"flex gap-2",children:[e.jsxs(N,{"data-loc":"client/src/pages/BodyMeasurements.tsx:241",variant:h==="manual"?"default":"outline",className:"flex-1",onClick:()=>{S("manual"),k(null)},children:[e.jsx(O,{"data-loc":"client/src/pages/BodyMeasurements.tsx:246",className:"w-4 h-4 mr-1"})," 自己入"]}),e.jsxs(N,{"data-loc":"client/src/pages/BodyMeasurements.tsx:248",variant:h==="upload"?"default":"outline",className:"flex-1",onClick:()=>S("upload"),children:[e.jsx(G,{"data-loc":"client/src/pages/BodyMeasurements.tsx:253",className:"w-4 h-4 mr-1"})," Upload 報告"]})]}),h==="upload"&&!a&&e.jsx(u,{"data-loc":"client/src/pages/BodyMeasurements.tsx:259",className:"card-premium border-dashed border-2",children:e.jsxs(g,{"data-loc":"client/src/pages/BodyMeasurements.tsx:260",className:"pt-6 pb-6",children:[e.jsx("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:261",onClick:()=>K.current?.click(),className:"text-center cursor-pointer py-6",children:Q?e.jsxs(e.Fragment,{children:[e.jsx(se,{"data-loc":"client/src/pages/BodyMeasurements.tsx:267",className:"w-10 h-10 text-blue-400 mx-auto mb-3 animate-spin"}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:268",className:"text-sm text-foreground/80",children:"AI 辨識中..."}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:269",className:"text-xs text-muted-foreground mt-1",children:"正在分析你嘅健康報告"})]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-loc":"client/src/pages/BodyMeasurements.tsx:273",className:"w-10 h-10 text-blue-400 mx-auto mb-3"}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:274",className:"text-sm text-foreground/80",children:"撳呢度 Upload 健康報告"}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:275",className:"text-xs text-muted-foreground mt-1",children:"支援 InBody 報告、電子磅截圖、體檢 PDF 等任何格式"}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:278",className:"text-xs text-foreground
1/70 mt-2",children:"PDF / JPG / PNG / HEIC(最大 20MB)"})]})}),e.jsx("input",{"data-loc":"client/src/pages/BodyMeasurements.tsx:284",ref:K,type:"file",accept:"image/*,.pdf,.heic",onChange:Y,className:"hidden"})]})}),a&&e.jsxs(u,{"data-loc":"client/src/pages/BodyMeasurements.tsx:297",className:"card-premium",children:[e.jsx(U,{"data-loc":"client/src/pages/BodyMeasurements.tsx:298",className:"pb-2",children:e.jsxs(L,{"data-loc":"client/src/pages/BodyMeasurements.tsx:299",className:"text-sm flex items-center gap-2 text-foreground",children:[e.jsx(ae,{"data-loc":"client/src/pages/BodyMeasurements.tsx:300",className:"w-4 h-4"}),"AI 辨識結果 — Check 下數據"]})}),e.jsxs(g,{"data-loc":"client/src/pages/BodyMeasurements.tsx:304",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:305",className:"grid grid-cols-2 gap-2 text-xs mb-3",children:[a.visceralFat&&e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:307",className:"bg-secondary/60 p-2 rounded",children:[e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:308",className:"text-muted-foreground",children:"內臟脂肪:"})," ",e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:309",className:"text-foreground font-medium",children:a.visceralFat})]}),a.bmi&&e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:313",className:"bg-secondary/60 p-2 rounded",children:[e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:314",className:"text-muted-foreground",children:"BMI:"})," ",e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:315",className:"text-foreground font-medium",children:a.bmi})]}),a.basalMetabolicRate&&e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:319",className:"bg-secondary/60 p-2 rounded",children:[e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:320",className:"text-muted-foreground",children:"BMR:"})," ",e.jsxs("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:321",className:"text-foreground font-medium",children:[a.basalMetabolicRate," kcal"]})]}),a.bodyWater&&e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:325",className:"bg-secondary/60 p-2 rounded",children:[e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:326",className:"text-muted-foreground",children:"體水分:"})," ",e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:327",className:"text-foreground font-medium",children:a.bodyWater})]}),a.boneMass&&e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:331",className:"bg-secondary/60 p-2 rounded",children:[e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:332",className:"text-muted-foreground",children:"骨質量:"})," ",e.jsxs("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:333",className:"text-foreground font-medium",children:[a.boneMass," kg"]})]})]}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:337",className:"text-xs text-muted-foreground",children:"以下欄位已自動填入,你可以改完再儲存"})]})]}),(h==="manual"||a)&&e.jsxs(u,{"data-loc":"client/src/pages/BodyMeasurements.tsx:346",className:"card-premium",children:[e.jsx(U,{"data-loc":"client/src/pages/BodyMeasurements.tsx:347",className:"pb-3",children:e.jsxs(L,{"data-loc":"client/src/pages/BodyMeasurements.tsx:348",className:"text-lg flex items-center gap-2",children:[e.jsx(O,{"data-loc":"client/src/pages/BodyMeasurements.tsx:349",className:"w-4 h-4"}),a?"OK 儲存":"記錄今日數據"]})}),e.jsx(g,{"data-loc":"client/src/pages/BodyMeasurements.tsx:353",children:e.jsxs("form",{"data-loc":"client/src/pages/BodyMeasurements.tsx:354",onSubmit:X,className:"space-y-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:355",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:356",children:[e.jsx(y,{"data-loc":"client/src/pages/BodyMeasurements.tsx:357",className:"text-sm",children:"體重 (kg) *"}),e.jsx(p,{"data-loc":"client/src/pages/BodyMeasurements.tsx:358",type:"number",step:"0.1",placeholder:"ä¾
1‹å¦‚ 65.5",value:W,onChange:s=>b(s.target.value),className:"mt-1"})]}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:367",children:[e.jsx(y,{"data-loc":"client/src/pages/BodyMeasurements.tsx:368",className:"text-sm",children:"體脂率 (%)"}),e.jsx(p,{"data-loc":"client/src/pages/BodyMeasurements.tsx:369",type:"number",step:"0.1",placeholder:"例如 20.5",value:i,onChange:s=>v(s.target.value),className:"mt-1"})]}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:378",children:[e.jsx(y,{"data-loc":"client/src/pages/BodyMeasurements.tsx:379",className:"text-sm",children:"肌肉量 (kg)"}),e.jsx(p,{"data-loc":"client/src/pages/BodyMeasurements.tsx:380",type:"number",step:"0.1",placeholder:"例如 28.0",value:m,onChange:s=>w(s.target.value),className:"mt-1"})]}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:389",children:[e.jsx(y,{"data-loc":"client/src/pages/BodyMeasurements.tsx:390",className:"text-sm",children:"腰圍 (cm)"}),e.jsx(p,{"data-loc":"client/src/pages/BodyMeasurements.tsx:391",type:"number",step:"0.1",placeholder:"例如 75.0",value:x,onChange:s=>F(s.target.value),className:"mt-1"})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:401",children:[e.jsx(y,{"data-loc":"client/src/pages/BodyMeasurements.tsx:402",className:"text-sm",children:"備註"}),e.jsx(p,{"data-loc":"client/src/pages/BodyMeasurements.tsx:403",placeholder:"例如:早上空腹量度",value:C,onChange:s=>E(s.target.value),className:"mt-1"})]}),e.jsx(N,{"data-loc":"client/src/pages/BodyMeasurements.tsx:410",type:"submit",className:"w-full",disabled:P.isPending||R.isPending,children:P.isPending||R.isPending?"儲存緊...":a?"OK 儲存報告數據 ✅":"記錄上磅 ⚖️"})]})})]}),e.jsxs(u,{"data-loc":"client/src/pages/BodyMeasurements.tsx:428",className:"card-premium",children:[e.jsx(U,{"data-loc":"client/src/pages/BodyMeasurements.tsx:429",className:"pb-3",children:e.jsxs(L,{"data-loc":"client/src/pages/BodyMeasurements.tsx:430",className:"text-lg flex items-center gap-2",children:[e.jsx(te,{"data-loc":"client/src/pages/BodyMeasurements.tsx:431",className:"w-4 h-4"}),"歷史記錄"]})}),e.jsx(g,{"data-loc":"client/src/pages/BodyMeasurements.tsx:435",children:J?e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:437",className:"text-center text-muted-foreground py-4",children:"載入中..."}):!D||D.length===0?e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:439",className:"text-center py-8",children:[e.jsx(T,{"data-loc":"client/src/pages/BodyMeasurements.tsx:440",className:"w-12 h-12 text-foreground/70 mx-auto mb-3"}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:441",className:"text-muted-foreground",children:"仲未有記錄"}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:442",className:"text-xs text-muted-foreground mt-1",children:"上面入返你嘅體重開始追蹤"})]}):e.jsx("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:445",className:"space-y-2",children:D.map(s=>{const t=Z(s.notes);return e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:450",className:"flex items-center justify-between gap-3 p-3 rounded-lg bg-secondary/60 border border-border",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:451",className:"flex-1 min-w-0",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:452",className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:453",className:"text-lg font-bold text-foreground",children:[s.weight.toFixed(1)," kg"]}),s.bodyFatPercentage&&e.jsxs("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:455",className:"text-xs px-2 py-0.5 rounded-full bg-orange-500/20 text-orange-300",children:[s.bodyFatPercentage.toFixed(1),"% 體脂"]}),s.muscleMass&&e.jsxs("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:460",className:"text-xs px-2 py-0.5 rounded-full bg-green-500/20 text-green-300",children:[s.muscleMass.toFixed(1)," kg 肌肉"]})]}),e.jsxs("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:465",className:"text-xs text-muted-foreground mt-1",children:[new Date(s.measuredAt).toLocaleDateString("zh-HK",{year:"numeric",month:"short",day:"numeric",weekday:"short"}),t&&` · ${t}`]})]}),e.jsx(N,{"data-loc":"client/src/pages/BodyMeasurements.tsx:470",variant:"ghost",size:"sm",onClick:()=>V.mutate({id:s.id}),className:"text-muted-foreground hover:text-red-400","aria-label":`刪除 ${s.weight.toFixed(1)} 公斤的體成分記錄`,children:e.jsx(re,{"data-loc":"client/src/pages/BodyMeasurements.tsx:477",className:"w-4 h-4"})})]},s.id)})})})]})]})})})}export{pe as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.