From 6c20faffd517e139a85478cb2a94950f1f7bb770 Mon Sep 17 00:00:00 2001 From: 732642856 <732642856@qq.com> Date: Mon, 4 May 2026 23:01:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=89=8D=E7=AB=AF=20JS=20computeDasha?= =?UTF-8?q?=20=E5=90=8C=E6=AD=A5=20balance/full=5Fyears/is=5Fbalance=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 与后端 Python cmd_dasha 保持一致: - 第一个 MD 的 years 字段显示 balance 值 - 新增 full_years / is_balance / balance_years / elapsed_at_birth 字段 - 日期计算保持使用完整年数(数学等价性不变) --- jyotish-app/jyotish-engine.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/jyotish-app/jyotish-engine.js b/jyotish-app/jyotish-engine.js index c115762e..c34be483 100644 --- a/jyotish-app/jyotish-engine.js +++ b/jyotish-app/jyotish-engine.js @@ -468,6 +468,8 @@ export function computeDasha(moonLon, birthDate, referenceDate) { const startDt = new Date(birthDt.getTime() - elapsed * 365.25 * 24 * 3600000); const startIdx = DASHA_ORDER.indexOf(nak.lord); + const remaining = nak.years - elapsed; + const timeline = []; let dt = new Date(startDt.getTime()); @@ -475,7 +477,17 @@ export function computeDasha(moonLon, birthDate, referenceDate) { const lord = DASHA_ORDER[(startIdx + i) % 9]; const years = DASHA_YEARS[lord]; const endDt = new Date(dt.getTime() + years * 365.25 * 24 * 3600000); - timeline.push({ lord, lord_cn: PLANET_CN[lord], start: fmtDate(dt), end: fmtDate(endDt), years, antardasha: null }); + const isBalance = i === 0; + timeline.push({ + lord, lord_cn: PLANET_CN[lord], + start: fmtDate(dt), end: fmtDate(endDt), + years: isBalance ? Math.round(remaining * 100) / 100 : years, + full_years: years, + is_balance: isBalance, + balance_years: isBalance ? Math.round(remaining * 100) / 100 : null, + elapsed_at_birth: isBalance ? Math.round(elapsed * 100) / 100 : null, + antardasha: null + }); dt = endDt; }