diff --git a/app/templates/goals.html b/app/templates/goals.html index 4edc79f..9713a31 100644 --- a/app/templates/goals.html +++ b/app/templates/goals.html @@ -102,22 +102,27 @@ async function loadGoals() { const goals = await res.json(); const grid = document.getElementById('goals-grid'); - // 获取每个目标的子目标数量 + // 获取每个目标的子目标信息 const goalsWithChildren = await Promise.all(goals.map(async g => { const childrenRes = await fetch(`${API_BASE}/${g.id}/children`); const children = await childrenRes.json(); - return {...g, childCount: children.length}; + return {...g, children: children}; })); - grid.innerHTML = goalsWithChildren.map(g => ` + grid.innerHTML = goalsWithChildren.map(g => { + const level = g.level || '入门'; + const childNames = g.children && g.children.length > 0 + ? g.children.map(c => escapeHtml(c.name)).join(', ') + : ''; + return `
${escapeHtml(g.content || '').substring(0, 80)}${g.content && g.content.length > 80 ? '...' : ''}