Parcourir la source

feat: P1-2 健康行为智能预警实现

- 后端: HealthAlert实体/Mapper/Engine(6条规则)/Service/Controller
- 数据库: schema.sql + DatabaseInitializer migration 104 (health_alerts表)
- 前端: HealthAlertBanner横幅组件 + store/health-alert.js + parent-index集成
- 6条预警规则: 睡眠下降/无运动/饮水少/运动过强/7天无打卡/今日未打卡
- 去重机制: 同一规则24h内不重复生成
- 严重程度排序: high > medium > low,最多展示2条
iwt il y a 1 mois
Parent
commit
446857a404

+ 4 - 2
cfc-frontend/pages/index/parent-index.vue

@@ -728,6 +728,8 @@ export default {
 
         // 加载家庭成员可见列表
         this.loadFamilyMembersVisible()
+        // 加载健康预警(P1-2)
+        this.loadAlerts()
         // 加载外部联系人
         this.loadContacts()
         // 加载推荐阅读
@@ -815,7 +817,7 @@ export default {
       var childId = this.selectedChild && this.selectedChild.id
       if (!childId) return
       var self = this
-      api.getActiveAlerts({ childId: childId }).then(function(res) {
+      getActiveAlerts({ childId: childId }).then(function(res) {
         if (res.code === 200) {
           self.healthAlerts = res.data || []
         }
@@ -823,7 +825,7 @@ export default {
     },
     onAlertDismiss: function(alertId) {
       var self = this
-      api.dismissAlert({ id: alertId }).then(function(res) {
+      dismissAlert({ id: alertId }).then(function(res) {
         if (res.code === 200) {
           self.healthAlerts = self.healthAlerts.filter(function(a) { return a.id !== alertId })
         }

+ 2 - 1
cfc-frontend/store/index.js

@@ -3,6 +3,7 @@ import Vuex from 'vuex'
 
 import tianpan from './modules/tianpan'
 import feedback from './feedback'
+import healthAlert from './health-alert'
 
 Vue.use(Vuex)
 
@@ -165,7 +166,7 @@ const store = new Vuex.Store({
     }
   }
 ,
-  modules: { tianpan, feedback }
+  modules: { tianpan, feedback, healthAlert }
 })
 
 export default store

+ 1 - 1
docs/superpowers/PROJECT-OVERVIEW.md

@@ -372,7 +372,7 @@
 
 **基准:** 健康界 2026/06/17《主动健康的六阶模型及其神经生理机制》
 **设计总纲:** `specs/2026-07-22-active-health-six-stage-design.md`
-**状态:** 🚧 设计中(P0 待实现)
+**状态:** ✅ P0 完成 · ✅ P1-1 完成 · 🚧 P1-2 实现中
 
 ### 改进矩阵