From b3fdbc7cbfe408211877fec549913982120cafa7 Mon Sep 17 00:00:00 2001 From: "Wright (Hermes Agent)" Date: Mon, 24 Aug 2026 19:49:02 +0800 Subject: [PATCH] feat: upgrade AI prompt with professional FITT prescription, fix token truncation and configure auto deploy --- README.md | 39 ++ deploy.sh | 62 ++ index.html | 1804 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1905 insertions(+) create mode 100644 README.md create mode 100755 deploy.sh create mode 100644 index.html diff --git a/README.md b/README.md new file mode 100644 index 0000000..94e458f --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# 國小學生跳繩運動紀錄與 BMI 智能建議系統 (Rope Helper) + +專為台灣國小教師與體育教師量身打造的**純前端跳繩體能分析與 AI 運動處方建議系統**。結合**衛福部國健署兒童生長 BMI 對照常模**、**教育部體育署 SH150 普及化運動指引**與 **Google AI Studio (Gemini)** 免費模型。 + +--- + +## 🌟 核心特色 + +1. **純前端綠色架構**: + - 單一獨立網頁檔 `index.html`,無需安裝 Node.js、Python 或架設後端資料庫。 + - 所有學生資料均在老師本機瀏覽器內運算解析,確保學童個資安全。 +2. **彈性 Excel 匯入與範本下載**: + - 支援「學生基本資料」與「跳繩打卡紀錄」雙工作表整合活頁簿或分開上傳。 + - 內建標準 Excel 範本下載與智慧欄位名稱對應。 + - 預設提供「載入 3 個月示範資料(三年二班 25 位學童連續 90 天打卡數據)」,開箱即用。 +3. **衛福部兒童 BMI 常模智能判定**: + - 內建台灣 6~12 歲兒童生長標準,依性別與實足年齡精準判定「過輕、正常、過重、肥胖」。 +4. **Google AI Studio 免費 API 串接**: + - 老師可直接輸入自己的 Google AI Studio 免費 API Key(安全儲存於本機 localStorage)。 + - 支援 `gemini-2.5-flash`、`gemini-1.5-flash` 等模型。 + - 支援「一鍵全班批量生成(內建 15 RPM 速率防護間隔與即時進度條)」與「個別學生生成/重新生成/文字自訂微調」。 +5. **完整報表匯出與家長通知卡列印**: + - 支援匯出含原始紀錄、統計分析與 AI 建議之完整 Excel 報告。 + - 支援一鍵列印或轉存 PDF 專用之「學生跳繩運動成長卡(A4 親職回饋聯版型)」。 + +--- + +## 🚀 快速開始使用 + +1. **直接開啟**: + - 在電腦上直接雙擊打開 [index.html](file:///mnt/Project/Rope_hekper/index.html)(建議使用 Google Chrome、Edge 或 Safari 瀏覽器)。 +2. **體驗功能**: + - 點擊右上角「**載入示範班級資料**」即可立即查看班級數據儀表板與圖表。 +3. **設定 AI Studio API Key**: + - 點擊右上角「**設定 AI Studio Key**」。 + - 前往 [Google AI Studio](https://aistudio.google.com/app/apikey) 免費取得 API Key 貼上並儲存。 + - 點擊「**一鍵全班 AI 運動建議生成**」,系統將自動調用 Gemini 為每位學童產生量身打造的跳繩指引。 +4. **匯出與列印**: + - 點擊「**匯出分析 Excel**」或「**列印運動成長卡**」發放給家長。 diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..bdc3eca --- /dev/null +++ b/deploy.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# ============================================================================== +# Rope Helper 自動化部署腳本 (CI/CD Deploy Script) +# 目標:將本專案靜態檔案自動部署至本機 Docker (realm-view / Caddy) +# 服務網址:https://ridgerealm.com/rope_helper/ +# ============================================================================== + +set -e + +# 定義顏色 +GREEN='\033[0;32m' +SKY='\033[0;36m' +YELLOW='\033[1;33m' +RED='\033[0;31m' +NC='\033[0m' # No Color + +PROJECT_DIR="/mnt/Project/Rope_hekper" +TARGET_DIR="/mnt/focker/realm-view/public/rope_helper" +HEALTH_CHECK_URL="http://127.0.0.1:3333/rope_helper/" + +echo -e "${SKY}======================================================${NC}" +echo -e "${SKY}🚀 開始執行 Rope Helper CI/CD 自動化部署流程...${NC}" +echo -e "${SKY}======================================================${NC}" + +# 1. 檢查原始檔案 +if [ ! -f "$PROJECT_DIR/index.html" ]; then + echo -e "${RED}❌ 錯誤:找不到來源檔案 $PROJECT_DIR/index.html${NC}" + exit 1 +fi + +# 2. 確保目標目錄存在 +echo -e "${YELLOW}📁 [1/4] 檢查目標伺服器目錄...${NC}" +mkdir -p "$TARGET_DIR" + +# 3. 部署同步檔案 (使用 rsync 保持檔案屬性與安全同步) +echo -e "${YELLOW}📦 [2/4] 同步靜態網頁檔案至 Docker Web 目錄...${NC}" +rsync -av --delete \ + --exclude=".git" \ + --exclude=".github" \ + --exclude=".forgejo" \ + --exclude="deploy.sh" \ + --exclude="*.swp" \ + "$PROJECT_DIR/" "$TARGET_DIR/" + +# 4. 檔案權限設定 +echo -e "${YELLOW}🔒 [3/4] 校正檔案存取權限...${NC}" +chmod -R 755 "$TARGET_DIR" + +# 5. 健康檢查 (Health Check) +echo -e "${YELLOW}🩺 [4/4] 執行服務健康狀態檢查...${NC}" +HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$HEALTH_CHECK_URL" || echo "000") + +if [ "$HTTP_STATUS" -eq 200 ] || [ "$HTTP_STATUS" -eq 304 ]; then + echo -e "${GREEN}✅ 健康檢查通過 (HTTP $HTTP_STATUS)${NC}" +else + echo -e "${YELLOW}⚠️ 內部測試回應碼為 $HTTP_STATUS,但檔案已成功同步。${NC}" +fi + +echo -e "${GREEN}======================================================${NC}" +echo -e "${GREEN}🎉 部署完成!${NC}" +echo -e "${GREEN}🌐 網站正式網址:https://ridgerealm.com/rope_helper/${NC}" +echo -e "${GREEN}======================================================${NC}" diff --git a/index.html b/index.html new file mode 100644 index 0000000..04a6324 --- /dev/null +++ b/index.html @@ -0,0 +1,1804 @@ + + + + + + 國小學生跳繩運動紀錄與 BMI 智能建議系統 + + + + + + + + + + + + + + + +
+ + +
+ +
+ {{ getToastIcon(toast.type) }} +

{{ toast.message }}

+ +
+
+
+ +
+ +
+
+
+
+ + + +
+
+

+ 國小跳繩健康管理與 AI 運動建議系統 + 體育署 SH150 • 國教署指引 +

+ +
+
+ + +
+ + + +
+
+
+ + +
+ + +
+
+ + + +
+ + +
+ + +
+
+ + +
+ +
+
+ 班級學生總數 +
+ {{ students.length }} + 位學童 +
+ 男 {{ boyCount }} 人 / 女 {{ girlCount }} 人 +
+ +
+ 累積總跳繩次數 +
+ {{ totalClassJumps.toLocaleString() }} + +
+ 人均 {{ students.length ? Math.round(totalClassJumps / students.length).toLocaleString() : 0 }} 次 +
+ +
+ 累積運動總時間 +
+ {{ (totalClassMinutes / 60).toFixed(1) }} + 小時 ({{ totalClassMinutes.toLocaleString() }} 分) +
+ 人均 {{ students.length ? Math.round(totalClassMinutes / students.length) : 0 }} 分鐘 +
+ +
+ AI 建議生成進度 +
+ {{ aiGeneratedCount }} + / {{ students.length }} 人 +
+
+
+
+
+
+ + +
+ +
+
+
+

+ 衛福部兒童 BMI 常模分布 +

+

依性別年齡標準界定體位常態

+
+ 國教署標準 +
+
+ +
+
+
+
{{ bmiSummary.underweight }}
+
過輕
+
+
+
{{ bmiSummary.normal }}
+
正常
+
+
+
{{ bmiSummary.overweight }}
+
過重
+
+
+
{{ bmiSummary.obese }}
+
肥胖
+
+
+
+ + +
+
+
+

全班跳繩運動週趨勢 (近12週)

+

分析全班每週累計次數與運動時間變化

+
+
+ 跳繩總次數 + 運動分鐘數 +
+
+
+ +
+
+
+ + +
+
+
+ +
+
+

教育部體育署 SH150 與跳繩體適能方案指引

+

+ 國教署推動國小學童在校與課後每週運動 150 分鐘。跳繩是鍛鍊心肺耐力、骨骼密度與身體協調的最佳全身性運動。 + 本系統已依據學童 BMI 與年級生理發展,為您配置最適切的 AI 運動評估模型。 +

+
+
+ +
+
+ + +
+ +
+ +
+
+ + +
+ + + + +
+ + +
+ + +
+
+ + +
+
+ 正在為【{{ batchProgress.currentStudentName }}】生成國教署跳繩處方建議... (速率防護間隔中) + {{ Math.round((batchProgress.current / batchProgress.total) * 100) }}% +
+
+
+
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
座號姓名 / 性別年級 / 年齡身高 / 體重BMI 與體位判定累計跳繩次數累計時間 (分)打卡天數AI 運動處方建議操作
+ {{ student.seatNo || '-' }} + +
+ {{ student.name }} + + {{ student.gender }} + +
+
+ {{ student.grade }}年級 ({{ student.age }}歲) + + {{ student.height }} cm / {{ student.weight }} kg + +
+ {{ student.bmi.toFixed(1) }} + + {{ student.bmiStatus }} + +
+
+ {{ (student.totalJumps || 0).toLocaleString() }} 次 + + {{ student.totalMinutes || 0 }} 分 + + {{ student.logDays || 0 }} 天 + +
+ {{ student.aiAdvice }} +
+ 尚未生成建議 +
+
+ + + +
+
+ 無符合條件之學生資料,請嘗試清除搜尋條件或匯入 Excel 檔案。 +
+
+
+
+ + +
+
+ +
+
+
+
+ +
+
+

匯入班級 Excel 活頁簿 / CSV

+

支援單一活頁簿雙工作表,或分別上傳兩個檔案

+
+
+ + +
+ + +

點擊選擇檔案 或 拖曳 Excel 檔案至此

+

支援 .xlsx, .xls, .csv 格式 (多檔自動合併辨識)

+ +
+
+ + +
+
+ + 強大且彈性的智慧欄位對應支援: +
+

基本資料表:自動對應「座號/學號/編號」、「姓名/學生姓名」、「性別 (男/女/1/2)」、「年級」、「身高(cm)」、「體重(kg)」等。

+

跳繩紀錄表:自動對應「座號/姓名」、「日期 (支援西元/民國年/Excel數值日期)」、「跳繩次數/次數/下數」、「運動時間/時間(分鐘)」等。

+
+
+ + +
+
+
+
+ +
+
+

標準 Excel 範本下載

+

已預先規劃好工作表結構與格式,填入即可匯入

+
+
+ +
+
+
+
📄 標準班級跳繩整合活頁簿 (.xlsx)
+
含「學生基本資料」與「跳繩打卡紀錄」雙工作表與範例資料
+
+ +
+ +
+
+
🌟 載入 3 個月示範資料 (25 位學生)
+
模擬三年二班 25 位學童連續 90 天各類體能跳繩數據
+
+ +
+
+
+ +
+ 支援雙檔案同時上傳 + +
+
+
+
+ +
+
+ + +
+
+ +
+
+
+ {{ selectedStudent.seatNo }} +
+
+

+ {{ selectedStudent.name }} + {{ selectedStudent.grade }}年級 / {{ selectedStudent.gender }} ({{ selectedStudent.age }}歲) +

+

身高 {{ selectedStudent.height }} cm / 體重 {{ selectedStudent.weight }} kg (BMI: {{ selectedStudent.bmi.toFixed(1) }})

+
+
+ +
+ + +
+ +
+
+
BMI 體位判定
+
{{ selectedStudent.bmiStatus }}
+
標準常模對照
+
+
+
累積跳繩次數
+
{{ (selectedStudent.totalJumps || 0).toLocaleString() }} 次
+
日均 {{ selectedStudent.logDays ? Math.round(selectedStudent.totalJumps / selectedStudent.logDays) : 0 }} 次
+
+
+
累積運動時長
+
{{ selectedStudent.totalMinutes || 0 }} 分鐘
+
共打卡 {{ selectedStudent.logDays || 0 }} 天
+
+
+
平均跳繩速率
+
+ {{ selectedStudent.totalMinutes ? Math.round(selectedStudent.totalJumps / selectedStudent.totalMinutes) : 0 }} 下/分 +
+
體適能強度指標
+
+
+ + +
+

+ 📈 個人跳繩歷程趨勢圖 + 近幾週運動紀錄 +

+
+ +
+
+ + +
+
+
+ 🤖 +
+

Google Gemini AI 國小跳繩運動處方建議

+

依據國教署跳繩教學綱要、{{ selectedStudent.grade }}年級發展重點及【{{ selectedStudent.bmiStatus }}】量身規劃

+
+
+
+ + +
+
+ + +
+ +
老師可在此直接編輯文字微調內容
+
+
+ 尚無運動建議。請確保已設定 Google AI Studio API Key,並點擊右上角「產生 AI 建議」按鈕。 +
+
+ + +
+

📅 跳繩詳細打卡紀錄 ({{ selectedStudent.logs ? selectedStudent.logs.length : 0 }} 筆)

+
+ + + + + + + + + + + + + + + + + + + + +
日期跳繩次數運動時間 (分)速率 (下/分)
{{ log.date }}{{ log.count }} 次{{ log.minutes }} 分{{ log.minutes ? Math.round(log.count / log.minutes) : '-' }}
尚無打卡紀錄
+
+
+
+ + +
+ + +
+
+
+ + +
+
+
+
+ +

Google AI Studio API 設定

+
+ +
+ +
+
+
+ + +
+
+ +
+

+ 🔑 金鑰將安全保存在您本機瀏覽器 localStorage 中,絕不上傳第三方伺服器。 +

+
+ +
+ + +
+ +
+ + +
+ + +
+ 連線狀態測試: + +
+ + +
+
+ 💡 如何免費取得 Google API Key? +
+

1. 前往 Google AI Studio 登入 Google 帳號。

+

2. 點擊「Create API key」建立專屬金鑰後複製貼上至上方。

+

3. 免費方案即享每分鐘 15 次請求額度,足供班級使用!

+
+
+ +
+ + +
+
+
+ + + + + +
+
+ © 2026 國小跳繩健康管理系統 • 體育署 SH150 體適能指引 • 衛福部國健署兒童 BMI 常模 + 純前端離線安全架構 • 本地運算保護學童隱私 +
+
+
+ + + + +