diff --git a/jyotish-app/api-bridge.js b/jyotish-app/api-bridge.js index 08af1bb2..d6073310 100644 --- a/jyotish-app/api-bridge.js +++ b/jyotish-app/api-bridge.js @@ -22,9 +22,19 @@ async function computeWithPython(birthData) { const data = await resp.json(); if (data.success) { console.log('[Compute] ✅ Python API v' + data.version); - // Python API返回 'birth',统一转为JS引擎的 'birth_info' 格式 - if (data.birth && !data.birth_info) { - data.birth_info = data.birth; + // Python API → JS引擎字段映射 + if (data.birth && !data.birth_info) data.birth_info = data.birth; + // ascendant.degree → ascendant.degree_in_sign + if (data.ascendant?.degree != null && data.ascendant.degree_in_sign == null) { + data.ascendant.degree_in_sign = data.ascendant.degree; + } + // planet degree → degree_in_sign + if (data.planets) { + for (const [k, v] of Object.entries(data.planets)) { + if (v?.degree != null && v.degree_in_sign == null) { + v.degree_in_sign = v.degree % 30; + } + } } return data; } diff --git a/jyotish-app/main.js b/jyotish-app/main.js index 03a4f645..ab83e8b4 100644 --- a/jyotish-app/main.js +++ b/jyotish-app/main.js @@ -272,7 +272,7 @@ function renderAll() { // Banner $('asc-sign').textContent = `${ascendant.sign} · ${signName(ascendant.sign)}`; - $('asc-degree').textContent = `${(ascendant.degree_in_sign != null ? ascendant.degree_in_sign : ascendant.degree).toFixed(2)}° | ${t('asc.lord')}: ${planetName(ascendant.lord)}`; + $('asc-degree').textContent = `${((ascendant.degree_in_sign ?? ascendant.degree) ?? 0).toFixed(2)}° | ${t('asc.lord')}: ${planetName(ascendant.lord)}`; if (moonP) $('asc-nakshatra').textContent = `${t('asc.nakshatra')}: ${moonP.nakshatra} Pada ${moonP.nakshatra_pada}`; $('asc-lord-badge').textContent = `${t('asc.lord')}: ${planetName(ascendant.lord)} (${ascendant.lord})`; diff --git a/jyotish-app/public/api-bridge.js b/jyotish-app/public/api-bridge.js index 08af1bb2..d6073310 100644 --- a/jyotish-app/public/api-bridge.js +++ b/jyotish-app/public/api-bridge.js @@ -22,9 +22,19 @@ async function computeWithPython(birthData) { const data = await resp.json(); if (data.success) { console.log('[Compute] ✅ Python API v' + data.version); - // Python API返回 'birth',统一转为JS引擎的 'birth_info' 格式 - if (data.birth && !data.birth_info) { - data.birth_info = data.birth; + // Python API → JS引擎字段映射 + if (data.birth && !data.birth_info) data.birth_info = data.birth; + // ascendant.degree → ascendant.degree_in_sign + if (data.ascendant?.degree != null && data.ascendant.degree_in_sign == null) { + data.ascendant.degree_in_sign = data.ascendant.degree; + } + // planet degree → degree_in_sign + if (data.planets) { + for (const [k, v] of Object.entries(data.planets)) { + if (v?.degree != null && v.degree_in_sign == null) { + v.degree_in_sign = v.degree % 30; + } + } } return data; }