v6.9.6: 字段映射完整修复 — degree→degree_in_sign + toFixed空值保护

This commit is contained in:
732642856
2026-06-12 15:31:49 +08:00
parent 8e036106b8
commit b563e0cd47
3 changed files with 27 additions and 7 deletions
+13 -3
View File
@@ -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;
}
+1 -1
View File
@@ -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})`;
+13 -3
View File
@@ -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;
}