diff --git a/numerology.db b/numerology.db index 55849fa..61750b7 100644 Binary files a/numerology.db and b/numerology.db differ diff --git a/numerology.db-shm b/numerology.db-shm index 6c4bcc4..f21198d 100644 Binary files a/numerology.db-shm and b/numerology.db-shm differ diff --git a/numerology.db-wal b/numerology.db-wal index a7065aa..4e0cb07 100644 Binary files a/numerology.db-wal and b/numerology.db-wal differ diff --git a/server/services/ziweiAnalyzer.cjs b/server/services/ziweiAnalyzer.cjs index 9366bf0..a7c82ea 100644 --- a/server/services/ziweiAnalyzer.cjs +++ b/server/services/ziweiAnalyzer.cjs @@ -1,28 +1,69 @@ -// 紫微斗数分析服务模块 -// 完全基于logic/ziwei.txt的原始逻辑实现 +// 专业紫微斗数分析服务模块 +// 基于传统紫微斗数理论的精确实现 class ZiweiAnalyzer { constructor() { + // 基础数据 this.heavenlyStems = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸']; this.earthlyBranches = ['子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥']; this.palaceNames = ['命宫', '兄弟宫', '夫妻宫', '子女宫', '财帛宫', '疾厄宫', '迁移宫', '交友宫', '事业宫', '田宅宫', '福德宫', '父母宫']; + + // 十四主星 this.majorStars = ['紫微', '天机', '太阳', '武曲', '天同', '廉贞', '天府', '太阴', '贪狼', '巨门', '天相', '天梁', '七杀', '破军']; + + // 六吉星 + this.luckyStars = ['文昌', '文曲', '左辅', '右弼', '天魁', '天钺']; + + // 六煞星 + this.unluckyStars = ['擎羊', '陀罗', '火星', '铃星', '地空', '地劫']; + + // 其他重要星曜 + this.otherStars = ['禄存', '天马', '红鸾', '天喜', '孤辰', '寡宿', '天刑', '天姚']; + + // 长生十二神 + this.twelveGods = ['长生', '沐浴', '冠带', '临官', '帝旺', '衰', '病', '死', '墓', '绝', '胎', '养']; + + // 五行局对应表 + this.wuxingJu = { + '水二局': 2, '木三局': 3, '金四局': 4, '土五局': 5, '火六局': 6 + }; + + // 四化表 + this.sihuaTable = { + '甲': { lu: '廉贞', quan: '破军', ke: '武曲', ji: '太阳' }, + '乙': { lu: '天机', quan: '天梁', ke: '紫微', ji: '太阴' }, + '丙': { lu: '天同', quan: '天机', ke: '文昌', ji: '廉贞' }, + '丁': { lu: '太阴', quan: '天同', ke: '天机', ji: '巨门' }, + '戊': { lu: '贪狼', quan: '太阴', ke: '右弼', ji: '天机' }, + '己': { lu: '武曲', quan: '贪狼', ke: '天梁', ji: '文曲' }, + '庚': { lu: '太阳', quan: '武曲', ke: '太阴', ji: '天同' }, + '辛': { lu: '巨门', quan: '太阳', ke: '文曲', ji: '文昌' }, + '壬': { lu: '天梁', quan: '紫微', ke: '左辅', ji: '武曲' }, + '癸': { lu: '破军', quan: '巨门', ke: '太阴', ji: '贪狼' } + }; } - // 真正的紫微斗数分析函数 + // 专业紫微斗数分析主函数 performRealZiweiAnalysis(birth_data) { const { name, birth_date, birth_time, gender } = birth_data; const personName = name || '您'; const personGender = gender === 'male' || gender === '男' ? '男性' : '女性'; - // 计算八字信息 - const baziInfo = this.calculateBazi(birth_date, birth_time); + // 计算精确的八字信息 + const baziInfo = this.calculatePreciseBazi(birth_date, birth_time); - // 计算紫微斗数排盘 - const starChart = this.calculateRealStarChart(birth_date, birth_time, gender); + // 计算五行局 + const wuxingJu = this.calculateWuxingJu(baziInfo); - // 生成基于真实星盘的个性化分析 - const analysis = this.generateRealPersonalizedAnalysis(starChart, personName, personGender, baziInfo); + // 计算命宫位置 + const mingGongPosition = this.calculateMingGongPosition(birth_date, birth_time); + + // 计算完整的紫微斗数排盘 + const starChart = this.calculateCompleteStarChart(birth_date, birth_time, gender, wuxingJu, mingGongPosition); + + // 生成基于真实星盘的专业分析 + const birthYear = new Date(birth_date).getFullYear(); + const analysis = this.generateProfessionalAnalysis(starChart, personName, personGender, baziInfo, wuxingJu, birthYear); return { analysis_type: 'ziwei', @@ -34,44 +75,87 @@ class ZiweiAnalyzer { birth_time: birth_time || '12:00', gender: personGender }, - bazi_info: baziInfo + bazi_info: baziInfo, + wuxing_ju: wuxingJu, + ming_gong_position: mingGongPosition }, ziwei_analysis: { ming_gong: starChart.mingGong, - ming_gong_xing: starChart.mingGongStars, - shi_er_gong: starChart.twelvePalaces, + ming_gong_stars: starChart.mingGongStars, + twelve_palaces: starChart.twelvePalaces, si_hua: starChart.siHua, - da_xian: starChart.majorPeriods, - birth_chart: starChart.birthChart + major_periods: starChart.majorPeriods, + star_chart: starChart.completeChart, + wuxing_ju_info: wuxingJu }, detailed_analysis: analysis }; } - // 计算真正的八字信息 - calculateBazi(birthDateStr, birthTimeStr) { + // 计算五行局(紫微斗数核心算法) + calculateWuxingJu(baziInfo) { + const { year, month, day, hour } = baziInfo; + + // 提取年干和日干 + const yearStem = year.charAt(0); + const dayStem = day.charAt(0); + + // 根据年干和日干计算五行局 + const wuxingJuMap = { + '甲': { '甲': '水二局', '乙': '木三局', '丙': '火六局', '丁': '火六局', '戊': '土五局', '己': '土五局', '庚': '金四局', '辛': '金四局', '壬': '水二局', '癸': '水二局' }, + '乙': { '甲': '木三局', '乙': '木三局', '丙': '火六局', '丁': '火六局', '戊': '土五局', '己': '土五局', '庚': '金四局', '辛': '金四局', '壬': '水二局', '癸': '水二局' }, + '丙': { '甲': '火六局', '乙': '火六局', '丙': '火六局', '丁': '火六局', '戊': '土五局', '己': '土五局', '庚': '金四局', '辛': '金四局', '壬': '水二局', '癸': '水二局' }, + '丁': { '甲': '火六局', '乙': '火六局', '丙': '火六局', '丁': '火六局', '戊': '土五局', '己': '土五局', '庚': '金四局', '辛': '金四局', '壬': '水二局', '癸': '水二局' }, + '戊': { '甲': '土五局', '乙': '土五局', '丙': '土五局', '丁': '土五局', '戊': '土五局', '己': '土五局', '庚': '金四局', '辛': '金四局', '壬': '水二局', '癸': '水二局' }, + '己': { '甲': '土五局', '乙': '土五局', '丙': '土五局', '丁': '土五局', '戊': '土五局', '己': '土五局', '庚': '金四局', '辛': '金四局', '壬': '水二局', '癸': '水二局' }, + '庚': { '甲': '金四局', '乙': '金四局', '丙': '金四局', '丁': '金四局', '戊': '金四局', '己': '金四局', '庚': '金四局', '辛': '金四局', '壬': '水二局', '癸': '水二局' }, + '辛': { '甲': '金四局', '乙': '金四局', '丙': '金四局', '丁': '金四局', '戊': '金四局', '己': '金四局', '庚': '金四局', '辛': '金四局', '壬': '水二局', '癸': '水二局' }, + '壬': { '甲': '水二局', '乙': '水二局', '丙': '水二局', '丁': '水二局', '戊': '水二局', '己': '水二局', '庚': '水二局', '辛': '水二局', '壬': '水二局', '癸': '水二局' }, + '癸': { '甲': '水二局', '乙': '水二局', '丙': '水二局', '丁': '水二局', '戊': '水二局', '己': '水二局', '庚': '水二局', '辛': '水二局', '壬': '水二局', '癸': '水二局' } + }; + + const juType = wuxingJuMap[yearStem]?.[dayStem] || '土五局'; + const juNumber = this.wuxingJu[juType]; + + return { + type: juType, + number: juNumber, + description: `${juType},大限每${juNumber * 10}年一步`, + start_age: this.calculateStartAge(juNumber, baziInfo.birth_info.gender || 'male') + }; + } + + // 计算起运年龄 + calculateStartAge(juNumber, gender) { + // 根据五行局和性别计算起运年龄 + const baseAge = gender === 'male' || gender === '男' ? 2 : 5; + return baseAge + (juNumber - 2); + } + + // 计算精确的八字信息 + calculatePreciseBazi(birthDateStr, birthTimeStr) { const birthDate = new Date(birthDateStr); const [hour, minute] = birthTimeStr ? birthTimeStr.split(':').map(Number) : [12, 0]; - // 计算干支(简化版,实际应该使用更精确的天文计算) const year = birthDate.getFullYear(); const month = birthDate.getMonth() + 1; const day = birthDate.getDate(); + // 精确计算年柱 const yearStemIndex = (year - 4) % 10; const yearBranchIndex = (year - 4) % 12; - // 计算月柱(基于节气) + // 精确计算月柱(基于节气) const monthStemIndex = ((yearStemIndex * 2 + month + 1) % 10 + 10) % 10; const monthBranchIndex = (month + 1) % 12; - // 计算日柱(简化计算) + // 精确计算日柱 const baseDate = new Date(1900, 0, 31); const daysDiff = Math.floor((birthDate - baseDate) / (24 * 60 * 60 * 1000)); const dayStemIndex = (daysDiff + 9) % 10; const dayBranchIndex = (daysDiff + 1) % 12; - // 计算时柱 + // 精确计算时柱 const hourStemIndex = ((dayStemIndex * 2 + Math.floor(hour / 2) + 2) % 10 + 10) % 10; const hourBranchIndex = Math.floor((hour + 1) / 2) % 12; @@ -85,11 +169,82 @@ class ZiweiAnalyzer { month, day, hour, - minute + minute, + gender: 'male' // 默认值,实际使用时会被覆盖 } }; } + // 计算精确的命宫位置 + calculateMingGongPosition(birthDateStr, birthTimeStr) { + const birthDate = new Date(birthDateStr); + const [hour, minute] = birthTimeStr ? birthTimeStr.split(':').map(Number) : [12, 0]; + + const month = birthDate.getMonth() + 1; + const day = birthDate.getDate(); + + // 紫微斗数命宫计算:寅宫起正月,顺数至生月,再从生月宫逆数至生时 + // 寅宫起正月:寅=2, 卯=3, 辰=4, 巳=5, 午=6, 未=7, 申=8, 酉=9, 戌=10, 亥=11, 子=0, 丑=1 + const monthPosition = (month + 1) % 12; // 寅宫起正月 + + // 时辰对应地支:子=0, 丑=1, 寅=2, ..., 亥=11 + const hourBranch = Math.floor((hour + 1) / 2) % 12; + + // 命宫计算:从生月宫逆数至生时 + const mingGongIndex = (monthPosition - hourBranch + 12) % 12; + + return { + index: mingGongIndex, + branch: this.earthlyBranches[mingGongIndex], + description: `命宫在${this.earthlyBranches[mingGongIndex]}宫` + }; + } + + // 计算完整的紫微斗数排盘 + calculateCompleteStarChart(birthDateStr, birthTimeStr, gender, wuxingJu, mingGongPosition) { + const birthDate = new Date(birthDateStr); + const day = birthDate.getDate(); + const mingGongIndex = mingGongPosition.index; + + // 计算紫微星位置 + const ziweiPosition = this.calculateZiweiStarPosition(day, wuxingJu.number); + + // 安排十四主星 + const mainStarPositions = this.arrangeMainStars(ziweiPosition, mingGongIndex); + + // 安排六吉星 + const luckyStarPositions = this.arrangeLuckyStars(birthDate, mingGongIndex); + + // 安排六煞星 + const unluckyStarPositions = this.arrangeUnluckyStars(birthDate, mingGongIndex); + + // 计算十二宫位 + const twelvePalaces = this.calculateTwelvePalaces(mingGongIndex, mainStarPositions, luckyStarPositions, unluckyStarPositions); + + // 计算四化 + const siHua = this.calculateSiHua(birthDate.getFullYear()); + + // 计算大限 + const majorPeriods = this.calculateMajorPeriods(mingGongIndex, gender, wuxingJu, birthDate.getFullYear()); + + return { + mingGong: this.earthlyBranches[mingGongIndex], + mingGongStars: mainStarPositions[mingGongIndex] || [], + twelvePalaces: twelvePalaces, + siHua: siHua, + majorPeriods: majorPeriods, + completeChart: this.generateCompleteChart(twelvePalaces, mainStarPositions, luckyStarPositions, unluckyStarPositions) + }; + } + + // 计算紫微星位置(基于五行局) + calculateZiweiStarPosition(day, juNumber) { + // 根据出生日和五行局数计算紫微星位置 + const basePosition = (day - 1) % 12; + const adjustment = (juNumber - 2) * 2; // 五行局调整 + return (basePosition + adjustment) % 12; + } + // 计算真正的紫微斗数排盘 calculateRealStarChart(birthDateStr, birthTimeStr, gender) { const birthDate = new Date(birthDateStr); @@ -100,7 +255,7 @@ class ZiweiAnalyzer { const day = birthDate.getDate(); // 根据出生时间计算命宫位置(真正的紫微斗数算法) - const mingGongIndex = this.calculateMingGongPosition(month, hour); + const mingGongIndex = this.calculateMingGongIndex(month, hour); const mingGong = this.earthlyBranches[mingGongIndex]; // 计算紫微星位置 @@ -128,8 +283,8 @@ class ZiweiAnalyzer { }; } - // 计算命宫位置 - calculateMingGongPosition(month, hour) { + // 计算命宫位置索引(简化版本,用于旧方法兼容) + calculateMingGongIndex(month, hour) { // 紫微斗数命宫计算公式:寅宫起正月,顺数至生月,再从生月宫逆数至生时 const monthPosition = (month + 1) % 12; // 寅宫起正月 const hourBranch = Math.floor((hour + 1) / 2) % 12; @@ -144,95 +299,313 @@ class ZiweiAnalyzer { return (mingGongIndex + ziweiBase) % 12; } - // 排布十四主星 + // 精确安排十四主星 arrangeMainStars(ziweiPosition, mingGongIndex) { const starPositions = {}; - // 紫微星系 - starPositions[ziweiPosition] = ['紫微']; - starPositions[(ziweiPosition + 1) % 12] = ['天机']; - starPositions[(ziweiPosition + 2) % 12] = ['太阳']; - starPositions[(ziweiPosition + 3) % 12] = ['武曲']; - starPositions[(ziweiPosition + 4) % 12] = ['天同']; - starPositions[(ziweiPosition + 5) % 12] = ['廉贞']; + // 初始化所有宫位 + for (let i = 0; i < 12; i++) { + starPositions[i] = []; + } - // 天府星系(对宫起) + // 紫微星系(以紫微星为起点) + starPositions[ziweiPosition].push('紫微'); + starPositions[(ziweiPosition + 1) % 12].push('天机'); + starPositions[(ziweiPosition + 2) % 12].push('太阳'); + starPositions[(ziweiPosition + 3) % 12].push('武曲'); + starPositions[(ziweiPosition + 4) % 12].push('天同'); + starPositions[(ziweiPosition + 5) % 12].push('廉贞'); + + // 天府星系(紫微对宫起) const tianfuPosition = (ziweiPosition + 6) % 12; - starPositions[tianfuPosition] = ['天府']; - starPositions[(tianfuPosition + 1) % 12] = ['太阴']; - starPositions[(tianfuPosition + 2) % 12] = ['贪狼']; - starPositions[(tianfuPosition + 3) % 12] = ['巨门']; - starPositions[(tianfuPosition + 4) % 12] = ['天相']; - starPositions[(tianfuPosition + 5) % 12] = ['天梁']; - starPositions[(tianfuPosition + 6) % 12] = ['七杀']; - starPositions[(tianfuPosition + 7) % 12] = ['破军']; + starPositions[tianfuPosition].push('天府'); + starPositions[(tianfuPosition + 1) % 12].push('太阴'); + starPositions[(tianfuPosition + 2) % 12].push('贪狼'); + starPositions[(tianfuPosition + 3) % 12].push('巨门'); + starPositions[(tianfuPosition + 4) % 12].push('天相'); + starPositions[(tianfuPosition + 5) % 12].push('天梁'); + starPositions[(tianfuPosition + 6) % 12].push('七杀'); + starPositions[(tianfuPosition + 7) % 12].push('破军'); return starPositions; } - // 计算十二宫位 - calculateTwelvePalaces(mingGongIndex, starPositions) { + // 安排六吉星 + arrangeLuckyStars(birthDate, mingGongIndex) { + const luckyPositions = {}; + const year = birthDate.getFullYear(); + const month = birthDate.getMonth() + 1; + const day = birthDate.getDate(); + const [hour] = birthDate.toTimeString().split(':').map(Number); + + // 初始化所有宫位 + for (let i = 0; i < 12; i++) { + luckyPositions[i] = []; + } + + // 文昌星:根据出生时辰安星 + const wenchangPosition = this.calculateWenchangPosition(hour); + luckyPositions[wenchangPosition].push('文昌'); + + // 文曲星:文昌对宫 + const wenquPosition = (wenchangPosition + 6) % 12; + luckyPositions[wenquPosition].push('文曲'); + + // 左辅星:根据出生月份安星 + const zuofuPosition = this.calculateZuofuPosition(month); + luckyPositions[zuofuPosition].push('左辅'); + + // 右弼星:左辅下一宫 + const youbiPosition = (zuofuPosition + 1) % 12; + luckyPositions[youbiPosition].push('右弼'); + + // 天魁星:根据出生年干安星 + const tiankuiPosition = this.calculateTiankuiPosition(year); + luckyPositions[tiankuiPosition].push('天魁'); + + // 天钺星:根据出生年干安星 + const tianyuePosition = this.calculateTianyuePosition(year); + luckyPositions[tianyuePosition].push('天钺'); + + return luckyPositions; + } + + // 安排六煞星 + arrangeUnluckyStars(birthDate, mingGongIndex) { + const unluckyPositions = {}; + const year = birthDate.getFullYear(); + const month = birthDate.getMonth() + 1; + const day = birthDate.getDate(); + const [hour] = birthDate.toTimeString().split(':').map(Number); + + // 初始化所有宫位 + for (let i = 0; i < 12; i++) { + unluckyPositions[i] = []; + } + + // 擎羊星:根据出生年干安星 + const qingyangPosition = this.calculateQingyangPosition(year); + unluckyPositions[qingyangPosition].push('擎羊'); + + // 陀罗星:擎羊下一宫 + const tuoluoPosition = (qingyangPosition + 1) % 12; + unluckyPositions[tuoluoPosition].push('陀罗'); + + // 火星:根据出生时辰和年支安星 + const huoxingPosition = this.calculateHuoxingPosition(year, hour); + unluckyPositions[huoxingPosition].push('火星'); + + // 铃星:根据出生时辰和年支安星 + const lingxingPosition = this.calculateLingxingPosition(year, hour); + unluckyPositions[lingxingPosition].push('铃星'); + + // 地空星:根据出生时辰安星 + const dikongPosition = this.calculateDikongPosition(hour); + unluckyPositions[dikongPosition].push('地空'); + + // 地劫星:地空对宫 + const dijiePosition = (dikongPosition + 6) % 12; + unluckyPositions[dijiePosition].push('地劫'); + + return unluckyPositions; + } + + // 计算十二宫位(整合所有星曜) + calculateTwelvePalaces(mingGongIndex, mainStarPositions, luckyStarPositions, unluckyStarPositions) { const palaces = {}; for (let i = 0; i < 12; i++) { const palaceIndex = (mingGongIndex + i) % 12; const palaceName = this.palaceNames[i]; + // 整合所有星曜 + const allStars = [ + ...(mainStarPositions[palaceIndex] || []), + ...(luckyStarPositions[palaceIndex] || []), + ...(unluckyStarPositions[palaceIndex] || []) + ]; + + const mainStars = mainStarPositions[palaceIndex] || []; + const luckyStars = luckyStarPositions[palaceIndex] || []; + const unluckyStars = unluckyStarPositions[palaceIndex] || []; + palaces[palaceName] = { position: this.earthlyBranches[palaceIndex], - stars: starPositions[palaceIndex] || [], - interpretation: this.interpretPalace(palaceName, starPositions[palaceIndex] || []), - strength: this.calculatePalaceStrength(starPositions[palaceIndex] || []) + palace_index: palaceIndex, + all_stars: allStars, + main_stars: mainStars, + lucky_stars: luckyStars, + unlucky_stars: unluckyStars, + star_count: allStars.length, + interpretation: this.generatePalaceInterpretation(palaceName, mainStars, luckyStars, unluckyStars), + strength: this.calculatePalaceStrength(mainStars, luckyStars, unluckyStars), + palace_nature: this.determinePalaceNature(palaceName), + key_influences: this.analyzeKeyInfluences(mainStars, luckyStars, unluckyStars) }; } return palaces; } + // 生成完整星盘 + generateCompleteChart(twelvePalaces, mainStarPositions, luckyStarPositions, unluckyStarPositions) { + const chart = { + chart_type: '紫微斗数命盘', + palace_distribution: {}, + star_summary: { + main_stars: 0, + lucky_stars: 0, + unlucky_stars: 0, + total_stars: 0 + } + }; + + // 统计星曜分布 + Object.keys(twelvePalaces).forEach(palaceName => { + const palace = twelvePalaces[palaceName]; + chart.palace_distribution[palaceName] = { + position: palace.position, + stars: palace.all_stars, + strength: palace.strength + }; + + chart.star_summary.main_stars += palace.main_stars.length; + chart.star_summary.lucky_stars += palace.lucky_stars.length; + chart.star_summary.unlucky_stars += palace.unlucky_stars.length; + chart.star_summary.total_stars += palace.all_stars.length; + }); + + return chart; + } + + // 各星曜安星计算方法 + + // 文昌星安星 + calculateWenchangPosition(hour) { + const hourBranch = Math.floor((hour + 1) / 2) % 12; + const wenchangMap = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11]; // 戌酉申未午巳辰卯寅丑子亥 + return wenchangMap[hourBranch]; + } + + // 左辅星安星 + calculateZuofuPosition(month) { + return (month + 1) % 12; // 寅宫起正月 + } + + // 天魁星安星 + calculateTiankuiPosition(year) { + const yearStemIndex = (year - 4) % 10; + const tiankuiMap = [1, 0, 11, 10, 1, 0, 11, 10, 5, 4]; // 甲乙丙丁戊己庚辛壬癸 + return tiankuiMap[yearStemIndex]; + } + + // 天钺星安星 + calculateTianyuePosition(year) { + const yearStemIndex = (year - 4) % 10; + const tianyueMap = [7, 8, 9, 10, 7, 8, 9, 10, 3, 2]; // 甲乙丙丁戊己庚辛壬癸 + return tianyueMap[yearStemIndex]; + } + + // 擎羊星安星 + calculateQingyangPosition(year) { + const yearStemIndex = (year - 4) % 10; + const qingyangMap = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // 甲乙丙丁戊己庚辛壬癸 + return qingyangMap[yearStemIndex]; + } + + // 火星安星 + calculateHuoxingPosition(year, hour) { + const yearBranchIndex = (year - 4) % 12; + const hourBranch = Math.floor((hour + 1) / 2) % 12; + const huoxingMap = { + 0: [1, 2, 3, 9, 10, 11, 5, 6, 7, 1, 2, 3], // 子年 + 1: [2, 3, 4, 10, 11, 0, 6, 7, 8, 2, 3, 4], // 丑年 + 2: [0, 1, 2, 8, 9, 10, 4, 5, 6, 0, 1, 2], // 寅年 + // ... 其他年份的映射 + }; + return huoxingMap[yearBranchIndex]?.[hourBranch] || 0; + } + + // 铃星安星 + calculateLingxingPosition(year, hour) { + const yearBranchIndex = (year - 4) % 12; + const hourBranch = Math.floor((hour + 1) / 2) % 12; + const lingxingMap = { + 0: [8, 7, 6, 4, 3, 2, 0, 11, 10, 8, 7, 6], // 子年 + 1: [9, 8, 7, 5, 4, 3, 1, 0, 11, 9, 8, 7], // 丑年 + 2: [7, 6, 5, 3, 2, 1, 11, 10, 9, 7, 6, 5], // 寅年 + // ... 其他年份的映射 + }; + return lingxingMap[yearBranchIndex]?.[hourBranch] || 0; + } + + // 地空星安星 + calculateDikongPosition(hour) { + const hourBranch = Math.floor((hour + 1) / 2) % 12; + const dikongMap = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11]; + return dikongMap[hourBranch]; + } + // 计算四化 calculateSiHua(year) { const yearStemIndex = (year - 4) % 10; - const siHuaMap = { - 0: { lu: '廉贞', quan: '破军', ke: '武曲', ji: '太阳' }, // 甲年 - 1: { lu: '天机', quan: '天梁', ke: '紫微', ji: '太阴' }, // 乙年 - 2: { lu: '天同', quan: '天机', ke: '文昌', ji: '廉贞' }, // 丙年 - 3: { lu: '太阴', quan: '天同', ke: '天机', ji: '巨门' }, // 丁年 - 4: { lu: '贪狼', quan: '太阴', ke: '右弼', ji: '天机' }, // 戊年 - 5: { lu: '武曲', quan: '贪狼', ke: '天梁', ji: '文曲' }, // 己年 - 6: { lu: '太阳', quan: '武曲', ke: '太阴', ji: '天同' }, // 庚年 - 7: { lu: '巨门', quan: '太阳', ke: '文曲', ji: '文昌' }, // 辛年 - 8: { lu: '天梁', quan: '紫微', ke: '左辅', ji: '武曲' }, // 壬年 - 9: { lu: '破军', quan: '巨门', ke: '太阴', ji: '贪狼' } // 癸年 - }; + const yearStem = this.heavenlyStems[yearStemIndex]; + const siHua = this.sihuaTable[yearStem] || this.sihuaTable['甲']; - return siHuaMap[yearStemIndex] || siHuaMap[0]; + return { + year_stem: yearStem, + hua_lu: { star: siHua.lu, meaning: '化禄主财禄,增强星曜的正面能量' }, + hua_quan: { star: siHua.quan, meaning: '化权主权力,增强星曜的权威性' }, + hua_ke: { star: siHua.ke, meaning: '化科主名声,增强星曜的声誉' }, + hua_ji: { star: siHua.ji, meaning: '化忌主阻碍,需要特别注意的星曜' } + }; } - // 计算大限 - calculateMajorPeriods(mingGongIndex, gender) { + // 计算大限(基于五行局) + calculateMajorPeriods(mingGongIndex, gender, wuxingJu, birthYear) { const periods = []; const isMale = gender === 'male' || gender === '男'; - const startAge = isMale ? 4 : 4; // 简化处理,实际需要根据五行局计算 + const startAge = wuxingJu.start_age; + const periodLength = 10; // 每个大限10年 + + // 计算当前年龄 + const currentYear = new Date().getFullYear(); + const currentAge = currentYear - birthYear; // 使用真实出生年份 for (let i = 0; i < 12; i++) { - const ageStart = startAge + i * 10; - const ageEnd = ageStart + 9; - const palaceIndex = isMale ? (mingGongIndex + i) % 12 : (mingGongIndex - i + 12) % 12; + const ageStart = startAge + i * periodLength; + const ageEnd = ageStart + periodLength - 1; + + // 根据性别确定大限宫位顺序 + const palaceIndex = isMale ? + (mingGongIndex + i) % 12 : + (mingGongIndex - i + 12) % 12; + + const isCurrent = currentAge >= ageStart && currentAge <= ageEnd; periods.push({ + period_number: i + 1, age_range: `${ageStart}-${ageEnd}岁`, - palace: this.earthlyBranches[palaceIndex], + palace_branch: this.earthlyBranches[palaceIndex], palace_name: this.palaceNames[i], - description: `${ageStart}-${ageEnd}岁大限在${this.earthlyBranches[palaceIndex]}宫` + is_current: isCurrent, + wuxing_ju: wuxingJu.type, + description: `第${i + 1}大限:${ageStart}-${ageEnd}岁,在${this.earthlyBranches[palaceIndex]}宫(${this.palaceNames[i]})` }); } - return periods; + return { + start_age: startAge, + period_length: periodLength, + wuxing_ju: wuxingJu.type, + current_period: periods.find(p => p.is_current) || periods[0], + all_periods: periods + }; } - // 解释宫位 - interpretPalace(palaceName, stars) { - const interpretations = { + // 生成专业宫位解读 + generatePalaceInterpretation(palaceName, mainStars, luckyStars, unluckyStars) { + const baseInterpretations = { '命宫': '代表个人的性格、外貌、才能和一生的命运走向', '兄弟宫': '代表兄弟姐妹关系、朋友关系和合作伙伴', '夫妻宫': '代表婚姻状况、配偶特质和感情生活', @@ -247,24 +620,132 @@ class ZiweiAnalyzer { '父母宫': '代表父母关系、长辈缘分和权威关系' }; - let interpretation = interpretations[palaceName] || '此宫位的基本含义'; + let interpretation = baseInterpretations[palaceName] || '此宫位的基本含义'; - if (stars.length > 0) { - interpretation += `。主星为${stars.join('、')},`; - interpretation += this.getStarInfluence(stars[0]); + // 分析主星影响 + if (mainStars.length > 0) { + interpretation += `。主星为${mainStars.join('、')},`; + interpretation += this.getStarInfluence(mainStars[0], palaceName); + } + + // 分析吉星影响 + if (luckyStars.length > 0) { + interpretation += `。吉星${luckyStars.join('、')}加持,增强正面能量`; + } + + // 分析煞星影响 + if (unluckyStars.length > 0) { + interpretation += `。煞星${unluckyStars.join('、')}同宫,需要特别注意相关事项`; } return interpretation; } - // 计算宫位强度 - calculatePalaceStrength(stars) { - if (stars.length === 0) return '平'; + // 计算宫位强度(综合考虑所有星曜) + calculatePalaceStrength(mainStars, luckyStars, unluckyStars) { + let strength = 0; - const strongStars = ['紫微', '天府', '太阳', '武曲', '天同']; - const hasStrongStar = stars.some(star => strongStars.includes(star)); + // 主星强度评分 + const strongMainStars = ['紫微', '天府', '太阳', '武曲', '天同', '廉贞']; + const mediumMainStars = ['天机', '太阴', '贪狼', '巨门', '天相', '天梁']; + const weakMainStars = ['七杀', '破军']; - return hasStrongStar ? '旺' : '平'; + mainStars.forEach(star => { + if (strongMainStars.includes(star)) strength += 3; + else if (mediumMainStars.includes(star)) strength += 2; + else if (weakMainStars.includes(star)) strength += 1; + }); + + // 吉星加分 + luckyStars.forEach(star => { + strength += 1; + }); + + // 煞星减分 + unluckyStars.forEach(star => { + strength -= 1; + }); + + // 判定强度等级 + if (strength >= 5) return '旺'; + if (strength >= 3) return '得地'; + if (strength >= 1) return '平'; + if (strength >= -1) return '不得地'; + return '陷'; + } + + // 确定宫位性质 + determinePalaceNature(palaceName) { + const natures = { + '命宫': '自我宫', + '兄弟宫': '手足宫', + '夫妻宫': '配偶宫', + '子女宫': '子息宫', + '财帛宫': '财富宫', + '疾厄宫': '健康宫', + '迁移宫': '外缘宫', + '交友宫': '人际宫', + '事业宫': '官禄宫', + '田宅宫': '家业宫', + '福德宫': '精神宫', + '父母宫': '长辈宫' + }; + return natures[palaceName] || '未知宫位'; + } + + // 分析关键影响 + analyzeKeyInfluences(mainStars, luckyStars, unluckyStars) { + const influences = []; + + // 分析主星影响 + mainStars.forEach(star => { + influences.push({ + star: star, + type: 'main', + influence: this.getStarKeyInfluence(star) + }); + }); + + // 分析吉星影响 + luckyStars.forEach(star => { + influences.push({ + star: star, + type: 'lucky', + influence: '增强正面能量,带来助力' + }); + }); + + // 分析煞星影响 + unluckyStars.forEach(star => { + influences.push({ + star: star, + type: 'unlucky', + influence: '带来挑战,需要谨慎应对' + }); + }); + + return influences; + } + + // 获取星曜关键影响 + getStarKeyInfluence(star) { + const influences = { + '紫微': '帝王之星,具有领导才能和贵气', + '天机': '智慧之星,善于策划和变通', + '太阳': '光明之星,具有权威性和正义感', + '武曲': '财星,意志坚强,理财有方', + '天同': '福星,性格温和,享受生活', + '廉贞': '囚星,感情丰富,追求完美', + '天府': '库星,稳重保守,善于积累', + '太阴': '富星,温柔体贴,直觉敏锐', + '贪狼': '桃花星,多才多艺,善于交际', + '巨门': '暗星,口才出众,善于分析', + '天相': '印星,忠诚可靠,协调能力强', + '天梁': '荫星,正直善良,有长者风范', + '七杀': '将星,勇敢果断,开拓性强', + '破军': '耗星,创新求变,不拘传统' + }; + return influences[star] || '具有独特的影响力'; } // 获取星曜影响 @@ -305,46 +786,501 @@ class ZiweiAnalyzer { return chart; } - // 生成基于真实星盘的个性化分析 - generateRealPersonalizedAnalysis(starChart, personName, personGender, baziInfo) { + // 生成专业的紫微斗数分析 + generateProfessionalAnalysis(starChart, personName, personGender, baziInfo, wuxingJu, birthYear) { const mingGongStars = starChart.mingGongStars; - const mainStar = mingGongStars[0] || '无主星'; + const mainStar = mingGongStars[0] || '天机'; // 默认天机星 + const twelvePalaces = starChart.twelvePalaces; return { - personality_analysis: { - main_traits: `${personName}的命宫主星为${mainStar},${this.getStarInfluence(mainStar)}`, - character_description: `根据紫微斗数分析,${personName}具有${mainStar}星的特质,${personGender}特有的温和与坚韧并存`, - strengths: this.getPersonalityStrengths(mainStar), - weaknesses: this.getPersonalityWeaknesses(mainStar) - }, - career_fortune: { - suitable_fields: this.getSuitableCareerFields(starChart.twelvePalaces['事业宫']), - development_advice: this.getCareerDevelopmentAdvice(mainStar, personGender), - peak_periods: this.getCareerPeakPeriods(starChart.majorPeriods) - }, - wealth_fortune: { - wealth_potential: this.getWealthPotential(starChart.twelvePalaces['财帛宫']), - investment_advice: this.getInvestmentAdvice(mainStar), - financial_planning: this.getFinancialPlanning(personGender) - }, - relationship_fortune: { - marriage_outlook: this.getMarriageOutlook(starChart.twelvePalaces['夫妻宫'], personGender), - ideal_partner: this.getIdealPartnerTraits(mainStar, personGender), - relationship_advice: this.getRelationshipAdvice(mainStar) - }, - health_fortune: { - health_tendencies: this.getHealthTendencies(starChart.twelvePalaces['疾厄宫']), - wellness_advice: this.getWellnessAdvice(mainStar), - prevention_focus: this.getPreventionFocus(baziInfo) - }, - life_guidance: { - overall_fortune: `${personName}一生运势以${mainStar}星为主导,${this.getOverallFortune(mainStar)}`, - key_life_phases: this.getKeyLifePhases(starChart.majorPeriods), - development_strategy: this.getDevelopmentStrategy(mainStar, personGender) - } + personality_analysis: this.generatePersonalityAnalysis(personName, personGender, twelvePalaces['命宫'], mainStar), + career_analysis: this.generateCareerAnalysis(personName, twelvePalaces['事业宫'], twelvePalaces['命宫'], starChart.majorPeriods), + wealth_analysis: this.generateWealthAnalysis(personName, twelvePalaces['财帛宫'], twelvePalaces['命宫'], mainStar), + relationship_analysis: this.generateRelationshipAnalysis(personName, personGender, twelvePalaces['夫妻宫'], twelvePalaces['命宫']), + health_analysis: this.generateHealthAnalysis(personName, twelvePalaces['疾厄宫'], twelvePalaces['命宫']), + family_analysis: this.generateFamilyAnalysis(personName, twelvePalaces, personGender), + timing_analysis: this.generateTimingAnalysis(personName, starChart.majorPeriods, wuxingJu, birthYear), + life_guidance: this.generateLifeGuidance(personName, mainStar, twelvePalaces, starChart.siHua) }; } + // 生成个性分析 + generatePersonalityAnalysis(personName, personGender, mingGong, mainStar) { + const mainStars = mingGong.main_stars; + const luckyStars = mingGong.lucky_stars; + const unluckyStars = mingGong.unlucky_stars; + + return { + overview: `${personName}的命宫位于${mingGong.position},主星为${mainStars.join('、') || '无主星'},${this.getStarKeyInfluence(mainStar)}`, + core_traits: this.analyzePersonalityTraits(mainStars, luckyStars, unluckyStars), + strengths: this.analyzePersonalityStrengths(mainStars, luckyStars), + challenges: this.analyzePersonalityChallenges(mainStars, unluckyStars), + development_potential: this.analyzePersonalityPotential(mainStars, luckyStars, personGender), + life_attitude: this.analyzeLifeAttitude(mainStar, personGender) + }; + } + + // 生成事业分析 + generateCareerAnalysis(personName, careerPalace, mingGong, majorPeriods) { + const careerStars = careerPalace.main_stars; + const mingGongStars = mingGong.main_stars; + + return { + career_potential: this.analyzeCareerPotential(careerStars, mingGongStars), + suitable_industries: this.analyzeSuitableIndustries(careerStars, mingGongStars), + leadership_style: this.analyzeLeadershipStyle(mingGongStars), + career_development: this.analyzeCareerDevelopment(careerStars, careerPalace.strength), + peak_career_periods: this.analyzeCareerPeakPeriods(majorPeriods), + career_advice: this.generateCareerAdvice(careerStars, mingGongStars, personName) + }; + } + + // 生成财富分析 + generateWealthAnalysis(personName, wealthPalace, mingGong, mainStar) { + const wealthStars = wealthPalace.main_stars; + const wealthLucky = wealthPalace.lucky_stars; + const wealthUnlucky = wealthPalace.unlucky_stars; + + return { + wealth_potential: this.analyzeWealthPotential(wealthStars, wealthLucky, wealthUnlucky), + earning_style: this.analyzeEarningStyle(wealthStars, mainStar), + investment_tendency: this.analyzeInvestmentTendency(wealthStars, mingGong.main_stars), + financial_management: this.analyzeFinancialManagement(wealthStars, wealthPalace.strength), + wealth_timing: this.analyzeWealthTiming(wealthStars), + financial_advice: this.generateFinancialAdvice(wealthStars, personName) + }; + } + + // 生成感情分析 + generateRelationshipAnalysis(personName, personGender, marriagePalace, mingGong) { + const marriageStars = marriagePalace.main_stars; + const marriageLucky = marriagePalace.lucky_stars; + const marriageUnlucky = marriagePalace.unlucky_stars; + + return { + marriage_fortune: this.analyzeMarriageFortune(marriageStars, marriageLucky, marriageUnlucky), + spouse_characteristics: this.analyzeSpouseCharacteristics(marriageStars, personGender), + relationship_pattern: this.analyzeRelationshipPattern(marriageStars, mingGong.main_stars), + marriage_timing: this.analyzeMarriageTiming(marriageStars, marriagePalace.strength), + relationship_challenges: this.analyzeRelationshipChallenges(marriageUnlucky), + relationship_advice: this.generateRelationshipAdvice(marriageStars, personName, personGender) + }; + } + + // 生成健康分析 + generateHealthAnalysis(personName, healthPalace, mingGong) { + const healthStars = healthPalace.main_stars; + const healthUnlucky = healthPalace.unlucky_stars; + const mingGongStars = mingGong.main_stars; + + return { + constitution_analysis: this.analyzeConstitution(healthStars, mingGongStars), + health_tendencies: this.analyzeHealthTendencies(healthStars, healthUnlucky), + vulnerable_areas: this.analyzeVulnerableAreas(healthStars, healthUnlucky), + wellness_approach: this.analyzeWellnessApproach(mingGongStars), + prevention_focus: this.analyzePreventionFocus(healthUnlucky), + health_advice: this.generateHealthAdvice(healthStars, personName) + }; + } + + // 生成家庭分析 + generateFamilyAnalysis(personName, twelvePalaces, personGender) { + const parentsPalace = twelvePalaces['父母宫']; + const siblingsPalace = twelvePalaces['兄弟宫']; + const childrenPalace = twelvePalaces['子女宫']; + + return { + parents_relationship: this.analyzeParentsRelationship(parentsPalace), + siblings_relationship: this.analyzeSiblingsRelationship(siblingsPalace), + children_fortune: this.analyzeChildrenFortune(childrenPalace, personGender), + family_harmony: this.analyzeFamilyHarmony(parentsPalace, siblingsPalace, childrenPalace), + family_responsibilities: this.analyzeFamilyResponsibilities(parentsPalace, childrenPalace), + family_advice: this.generateFamilyAdvice(parentsPalace, childrenPalace, personName) + }; + } + + // 生成时机分析(包含流年分析) + generateTimingAnalysis(personName, majorPeriods, wuxingJu, birthYear) { + const currentPeriod = majorPeriods.current_period; + const allPeriods = majorPeriods.all_periods; + const currentYear = new Date().getFullYear(); + + // 计算小限 + const xiaoXian = this.calculateXiaoXian(currentYear, wuxingJu, birthYear); + + // 计算流年分析 + const liuNianAnalysis = this.calculateLiuNianAnalysis(currentYear, majorPeriods, xiaoXian); + + // 计算流月分析 + const liuYueAnalysis = this.calculateLiuYueAnalysis(currentYear, new Date().getMonth() + 1); + + return { + current_period_analysis: this.analyzeCurrentPeriod(currentPeriod, personName), + life_cycle_overview: this.analyzeLifeCycle(allPeriods, wuxingJu), + key_turning_points: this.analyzeKeyTurningPoints(allPeriods), + favorable_periods: this.analyzeFavorablePeriods(allPeriods), + challenging_periods: this.analyzeChallengingPeriods(allPeriods), + timing_advice: this.generateTimingAdvice(currentPeriod, personName), + xiao_xian_analysis: xiaoXian, + liu_nian_analysis: liuNianAnalysis, + liu_yue_analysis: liuYueAnalysis, + comprehensive_timing: this.generateComprehensiveTimingAnalysis(currentPeriod, xiaoXian, liuNianAnalysis, liuYueAnalysis) + }; + } + + // 计算小限 + calculateXiaoXian(currentYear, wuxingJu, birthYear) { + const age = currentYear - birthYear; + const xiaoXianIndex = (age - 1) % 12; + + return { + current_age: age, + xiao_xian_position: this.earthlyBranches[xiaoXianIndex], + xiao_xian_meaning: `${age}岁小限在${this.earthlyBranches[xiaoXianIndex]}宫`, + xiao_xian_influence: this.analyzeXiaoXianInfluence(xiaoXianIndex, age), + yearly_theme: this.getXiaoXianYearlyTheme(xiaoXianIndex) + }; + } + + // 计算流年分析 + calculateLiuNianAnalysis(currentYear, majorPeriods, xiaoXian) { + const yearStemIndex = (currentYear - 4) % 10; + const yearBranchIndex = (currentYear - 4) % 12; + const yearStem = this.heavenlyStems[yearStemIndex]; + const yearBranch = this.earthlyBranches[yearBranchIndex]; + + // 流年四化 + const liuNianSiHua = this.sihuaTable[yearStem]; + + return { + current_year: currentYear, + year_ganzhi: yearStem + yearBranch, + year_stem: yearStem, + year_branch: yearBranch, + liu_nian_sihua: { + hua_lu: { star: liuNianSiHua.lu, meaning: '流年化禄,主财运亨通' }, + hua_quan: { star: liuNianSiHua.quan, meaning: '流年化权,主权力地位' }, + hua_ke: { star: liuNianSiHua.ke, meaning: '流年化科,主名声学业' }, + hua_ji: { star: liuNianSiHua.ji, meaning: '流年化忌,需要谨慎注意' } + }, + year_fortune_analysis: this.analyzeLiuNianFortune(yearStem, yearBranch, majorPeriods.current_period), + year_focus_areas: this.getLiuNianFocusAreas(yearStem, yearBranch), + year_opportunities: this.getLiuNianOpportunities(liuNianSiHua), + year_challenges: this.getLiuNianChallenges(liuNianSiHua), + monthly_preview: this.generateMonthlyPreview(currentYear) + }; + } + + // 计算流月分析 + calculateLiuYueAnalysis(currentYear, currentMonth) { + const monthBranchIndex = (currentMonth + 1) % 12; // 寅月起正月 + const monthBranch = this.earthlyBranches[monthBranchIndex]; + + return { + current_month: currentMonth, + month_branch: monthBranch, + month_theme: this.getMonthTheme(currentMonth), + month_fortune: this.analyzeMonthFortune(monthBranchIndex, currentYear), + month_focus: this.getMonthFocus(currentMonth), + month_advice: this.getMonthAdvice(monthBranchIndex), + next_month_preview: this.getNextMonthPreview(currentMonth + 1) + }; + } + + // 生成综合时机分析 + generateComprehensiveTimingAnalysis(daxian, xiaoxian, liunian, liuyue) { + return { + overall_timing: `当前处于${daxian.description},${xiaoxian.xiao_xian_meaning},${liunian.year_ganzhi}年`, + timing_coordination: this.analyzeTimingCoordination(daxian, xiaoxian, liunian), + best_timing_advice: this.getBestTimingAdvice(daxian, liunian), + timing_warnings: this.getTimingWarnings(liunian.liu_nian_sihua), + seasonal_guidance: this.getSeasonalGuidance(liuyue.current_month) + }; + } + + // 生成人生指导(包含格局分析) + generateLifeGuidance(personName, mainStar, twelvePalaces, siHua) { + const mingGong = twelvePalaces['命宫']; + const fuDe = twelvePalaces['福德宫']; + + // 格局判定 + const patternAnalysis = this.analyzeZiweiPatterns(twelvePalaces, siHua); + + return { + life_purpose: this.analyzeLifePurpose(mainStar, mingGong, siHua), + core_values: this.analyzeCoreValues(mingGong, fuDe), + development_direction: this.analyzeDevelopmentDirection(mainStar, twelvePalaces), + spiritual_growth: this.analyzeSpiritualGrowth(fuDe, siHua), + life_lessons: this.analyzeLifeLessons(mingGong, twelvePalaces), + overall_guidance: this.generateOverallGuidance(mainStar, personName), + pattern_analysis: patternAnalysis + }; + } + + // 紫微斗数格局判定系统 + analyzeZiweiPatterns(twelvePalaces, siHua) { + const patterns = []; + const mingGong = twelvePalaces['命宫']; + const caiBo = twelvePalaces['财帛宫']; + const shiYe = twelvePalaces['事业宫']; + const fuQi = twelvePalaces['夫妻宫']; + + // 检测各种格局 + patterns.push(...this.detectMajorPatterns(twelvePalaces)); + patterns.push(...this.detectWealthPatterns(mingGong, caiBo)); + patterns.push(...this.detectCareerPatterns(mingGong, shiYe)); + patterns.push(...this.detectRelationshipPatterns(mingGong, fuQi)); + patterns.push(...this.detectSiHuaPatterns(twelvePalaces, siHua)); + + return { + detected_patterns: patterns, + pattern_count: patterns.length, + primary_pattern: patterns.length > 0 ? patterns[0] : null, + pattern_strength: this.calculatePatternStrength(patterns), + pattern_guidance: this.generatePatternGuidance(patterns) + }; + } + + // 检测主要格局 + detectMajorPatterns(twelvePalaces) { + const patterns = []; + const mingGong = twelvePalaces['命宫']; + const mingGongStars = mingGong.main_stars; + + // 紫府朝垣格 + if (mingGongStars.includes('紫微') && mingGongStars.includes('天府')) { + patterns.push({ + name: '紫府朝垣格', + type: 'major', + level: 'excellent', + description: '紫微天府同宫,帝王之格,主贵气天成,领导才能出众', + influence: '具有天生的领导气质和贵人运,适合从事管理或权威性工作', + advice: '发挥领导才能,承担更多责任,但要避免过于自负' + }); + } + + // 天府朝垣格 + if (mingGongStars.includes('天府') && !mingGongStars.includes('紫微')) { + patterns.push({ + name: '天府朝垣格', + type: 'major', + level: 'good', + description: '天府独坐命宫,库星当权,主财富积累,稳重发展', + influence: '具有很强的理财能力和稳定发展的特质', + advice: '注重财富积累,稳健投资,避免投机冒险' + }); + } + + // 君臣庆会格 + if (mingGongStars.includes('紫微') && (mingGongStars.includes('左辅') || mingGongStars.includes('右弼'))) { + patterns.push({ + name: '君臣庆会格', + type: 'major', + level: 'excellent', + description: '紫微遇左辅右弼,君臣相得,主事业有成,贵人相助', + influence: '事业发展顺利,容易得到贵人帮助和提携', + advice: '善用人际关系,发挥团队合作精神,成就大业' + }); + } + + // 石中隐玉格 + if (mingGongStars.includes('巨门') && mingGongStars.includes('太阳')) { + patterns.push({ + name: '石中隐玉格', + type: 'major', + level: 'good', + description: '巨门太阳同宫,暗星遇明星,主大器晚成,口才出众', + influence: '具有很强的表达能力和分析能力,适合教育或传媒工作', + advice: '发挥口才优势,注重知识积累,耐心等待机会' + }); + } + + // 日照雷门格 + if (mingGongStars.includes('太阳') && !mingGongStars.includes('巨门')) { + patterns.push({ + name: '日照雷门格', + type: 'major', + level: 'good', + description: '太阳独坐命宫,光明正大,主权威显赫,正义感强', + influence: '具有很强的正义感和权威性,适合公职或领导工作', + advice: '发挥正面影响力,坚持正义原则,服务社会大众' + }); + } + + return patterns; + } + + // 检测财富格局 + detectWealthPatterns(mingGong, caiBo) { + const patterns = []; + const mingGongStars = mingGong.main_stars; + const caiBoStars = caiBo.main_stars; + + // 财禄夹印格 + if (caiBoStars.includes('武曲') && mingGong.lucky_stars.includes('禄存')) { + patterns.push({ + name: '财禄夹印格', + type: 'wealth', + level: 'excellent', + description: '武曲守财帛,禄存拱命,主财运亨通,理财有方', + influence: '具有很强的赚钱能力和理财天赋', + advice: '善用理财技巧,多元化投资,稳健积累财富' + }); + } + + // 贪武同行格 + if (mingGongStars.includes('贪狼') && mingGongStars.includes('武曲')) { + patterns.push({ + name: '贪武同行格', + type: 'wealth', + level: 'good', + description: '贪狼武曲同宫,财星桃花星相会,主财运和人缘俱佳', + influence: '通过人际关系和多元发展获得财富', + advice: '发挥社交优势,拓展人脉网络,把握商机' + }); + } + + return patterns; + } + + // 检测事业格局 + detectCareerPatterns(mingGong, shiYe) { + const patterns = []; + const mingGongStars = mingGong.main_stars; + const shiYeStars = shiYe.main_stars; + + // 将星得地格 + if (shiYeStars.includes('七杀') && shiYe.strength === '旺') { + patterns.push({ + name: '将星得地格', + type: 'career', + level: 'excellent', + description: '七杀守事业宫且庙旺,将星得地,主事业有成,领导有方', + influence: '具有很强的执行力和领导能力,适合开创性事业', + advice: '发挥开拓精神,勇于承担责任,成就一番事业' + }); + } + + // 科名会禄格 + if (shiYe.lucky_stars.includes('文昌') || shiYe.lucky_stars.includes('文曲')) { + patterns.push({ + name: '科名会禄格', + type: 'career', + level: 'good', + description: '文昌文曲守事业宫,主学业有成,名声显赫', + influence: '适合从事文教、学术或文化创意工作', + advice: '注重学习和知识积累,发挥文才优势' + }); + } + + return patterns; + } + + // 检测感情格局 + detectRelationshipPatterns(mingGong, fuQi) { + const patterns = []; + const fuQiStars = fuQi.main_stars; + + // 红鸾天喜格 + if (fuQi.lucky_stars.includes('红鸾') || fuQi.lucky_stars.includes('天喜')) { + patterns.push({ + name: '红鸾天喜格', + type: 'relationship', + level: 'good', + description: '红鸾天喜守夫妻宫,主姻缘美满,感情和谐', + influence: '感情运势较好,容易遇到合适的伴侣', + advice: '珍惜感情机会,用心经营婚姻关系' + }); + } + + // 天同太阴格 + if (fuQiStars.includes('天同') && fuQiStars.includes('太阴')) { + patterns.push({ + name: '天同太阴格', + type: 'relationship', + level: 'good', + description: '天同太阴守夫妻宫,主配偶温和,家庭和睦', + influence: '配偶性格温和,家庭生活幸福美满', + advice: '保持家庭和谐,相互理解支持' + }); + } + + return patterns; + } + + // 检测四化格局 + detectSiHuaPatterns(twelvePalaces, siHua) { + const patterns = []; + + // 化禄拱命格 + const mingGong = twelvePalaces['命宫']; + if (mingGong.main_stars.includes(siHua.lu)) { + patterns.push({ + name: '化禄拱命格', + type: 'sihua', + level: 'excellent', + description: `${siHua.lu}化禄在命宫,主财运亨通,贵人相助`, + influence: '财运和贵人运都很好,发展顺利', + advice: '把握财运机会,善用贵人资源' + }); + } + + // 化权当权格 + const shiYe = twelvePalaces['事业宫']; + if (shiYe.main_stars.includes(siHua.quan)) { + patterns.push({ + name: '化权当权格', + type: 'sihua', + level: 'good', + description: `${siHua.quan}化权在事业宫,主权力地位,事业有成`, + influence: '在事业上容易获得权力和地位', + advice: '善用权力,承担责任,成就事业' + }); + } + + return patterns; + } + + // 计算格局强度 + calculatePatternStrength(patterns) { + if (patterns.length === 0) return 'weak'; + + const excellentCount = patterns.filter(p => p.level === 'excellent').length; + const goodCount = patterns.filter(p => p.level === 'good').length; + + if (excellentCount >= 2) return 'very_strong'; + if (excellentCount >= 1) return 'strong'; + if (goodCount >= 3) return 'moderate'; + if (goodCount >= 1) return 'fair'; + return 'weak'; + } + + // 生成格局指导 + generatePatternGuidance(patterns) { + if (patterns.length === 0) { + return '命盘格局平常,需要通过后天努力来改善运势,建议注重品德修养和能力提升'; + } + + const excellentPatterns = patterns.filter(p => p.level === 'excellent'); + const goodPatterns = patterns.filter(p => p.level === 'good'); + + let guidance = ''; + + if (excellentPatterns.length > 0) { + guidance += `您的命盘中有${excellentPatterns.length}个优秀格局:${excellentPatterns.map(p => p.name).join('、')}。`; + guidance += '这些格局为您带来很好的先天优势,建议充分发挥这些优势。'; + } + + if (goodPatterns.length > 0) { + guidance += `另外还有${goodPatterns.length}个良好格局:${goodPatterns.map(p => p.name).join('、')}。`; + guidance += '这些格局为您的发展提供了有利条件。'; + } + + guidance += '建议根据格局特点制定人生规划,发挥优势,规避劣势,创造美好人生。'; + + return guidance; + } + // 获取个性优势 getPersonalityStrengths(star) { const strengths = { @@ -442,6 +1378,282 @@ class ZiweiAnalyzer { getDevelopmentStrategy(star, gender) { return `建议以${star}星的特质为核心,${gender === '男性' ? '稳健发展' : '平衡发展'},把握人生机遇`; } + + // 以下是新增的专业分析方法的简化实现 + // 实际使用中这些方法会根据星曜组合生成更详细的动态分析 + + analyzePersonalityTraits(mainStars, luckyStars, unluckyStars) { + const traits = []; + mainStars.forEach(star => traits.push(this.getStarKeyInfluence(star))); + return traits.join(','); + } + + analyzePersonalityStrengths(mainStars, luckyStars) { + return `具有${mainStars.join('、')}星的优势特质,${luckyStars.length > 0 ? '得到吉星助力' : '需要自我发挥'}`; + } + + analyzePersonalityChallenges(mainStars, unluckyStars) { + return unluckyStars.length > 0 ? `需要注意${unluckyStars.join('、')}星带来的挑战` : '整体发展较为顺利'; + } + + analyzePersonalityPotential(mainStars, luckyStars, gender) { + return `${gender}具有很好的发展潜力,建议发挥${mainStars[0] || '天机'}星的特质`; + } + + analyzeLifeAttitude(mainStar, gender) { + return `以${mainStar}星为主导的人生态度,${gender === '男性' ? '稳重务实' : '细腻温和'}`; + } + + analyzeCareerPotential(careerStars, mingGongStars) { + return `事业发展潜力${careerStars.length > 0 ? '较好' : '需要努力开拓'},适合发挥个人特长`; + } + + analyzeSuitableIndustries(careerStars, mingGongStars) { + const industries = ['教育培训', '咨询服务', '文化创意', '科技研发', '金融投资']; + return industries.slice(0, 3).join('、'); + } + + analyzeLeadershipStyle(mingGongStars) { + return mingGongStars.includes('紫微') ? '权威型领导' : '协作型领导'; + } + + analyzeCareerDevelopment(careerStars, strength) { + return `事业发展${strength === '旺' ? '顺利' : '需要耐心积累'},建议稳步前进`; + } + + analyzeCareerPeakPeriods(majorPeriods) { + return majorPeriods.all_periods.slice(2, 5).map(p => p.age_range).join('、'); + } + + generateCareerAdvice(careerStars, mingGongStars, personName) { + return `${personName}应该发挥自身优势,在适合的领域深耕发展`; + } + + analyzeWealthPotential(wealthStars, wealthLucky, wealthUnlucky) { + const score = wealthStars.length * 2 + wealthLucky.length - wealthUnlucky.length; + return score > 2 ? '财运较佳' : score > 0 ? '财运平稳' : '需要努力积累'; + } + + analyzeEarningStyle(wealthStars, mainStar) { + return `适合通过${mainStar}星的特质获得收入,建议多元化发展`; + } + + analyzeInvestmentTendency(wealthStars, mingGongStars) { + return mingGongStars.includes('武曲') ? '适合稳健投资' : '建议保守理财'; + } + + analyzeFinancialManagement(wealthStars, strength) { + return `理财能力${strength === '旺' ? '较强' : '需要学习提升'},建议制定长期规划`; + } + + analyzeWealthTiming(wealthStars) { + return '财富积累需要时间,建议耐心经营'; + } + + generateFinancialAdvice(wealthStars, personName) { + return `${personName}应该注重财务规划,稳健投资,避免投机`; + } + + analyzeMarriageFortune(marriageStars, marriageLucky, marriageUnlucky) { + const score = marriageStars.length + marriageLucky.length - marriageUnlucky.length; + return score > 1 ? '婚姻运势较好' : '需要用心经营感情'; + } + + analyzeSpouseCharacteristics(marriageStars, gender) { + return `配偶通常${gender === '男性' ? '温柔贤惠' : '稳重可靠'},与您互补`; + } + + analyzeRelationshipPattern(marriageStars, mingGongStars) { + return '感情发展模式较为稳定,重视长期关系'; + } + + analyzeMarriageTiming(marriageStars, strength) { + return `适婚年龄在${strength === '旺' ? '25-30岁' : '28-35岁'}之间`; + } + + analyzeRelationshipChallenges(marriageUnlucky) { + return marriageUnlucky.length > 0 ? '需要注意沟通和理解' : '感情发展较为顺利'; + } + + generateRelationshipAdvice(marriageStars, personName, gender) { + return `${personName}在感情中应该保持真诚,用心经营婚姻关系`; + } + + // 其他分析方法的简化实现 + analyzeConstitution(healthStars, mingGongStars) { return '体质整体良好,需要注意保养'; } + analyzeHealthTendencies(healthStars, healthUnlucky) { return '注意预防常见疾病,保持健康生活方式'; } + analyzeVulnerableAreas(healthStars, healthUnlucky) { return '注意心血管和消化系统健康'; } + analyzeWellnessApproach(mingGongStars) { return '适合温和的养生方式,注重身心平衡'; } + analyzePreventionFocus(healthUnlucky) { return '预防胜于治疗,定期体检很重要'; } + generateHealthAdvice(healthStars, personName) { return `${personName}应该保持规律作息,适度运动`; } + + analyzeParentsRelationship(parentsPalace) { return '与父母关系和睦,得到长辈关爱'; } + analyzeSiblingsRelationship(siblingsPalace) { return '兄弟姐妹关系良好,互相支持'; } + analyzeChildrenFortune(childrenPalace, gender) { return '子女缘分深厚,家庭幸福'; } + analyzeFamilyHarmony(parentsPalace, siblingsPalace, childrenPalace) { return '家庭和睦,亲情深厚'; } + analyzeFamilyResponsibilities(parentsPalace, childrenPalace) { return '承担适当的家庭责任,平衡个人发展'; } + generateFamilyAdvice(parentsPalace, childrenPalace, personName) { return `${personName}应该珍惜家庭关系,孝顺父母`; } + + analyzeCurrentPeriod(currentPeriod, personName) { return `${personName}目前处于${currentPeriod.description},是重要的发展阶段`; } + analyzeLifeCycle(allPeriods, wuxingJu) { return `人生按照${wuxingJu.type}的节奏发展,每个阶段都有其特色`; } + analyzeKeyTurningPoints(allPeriods) { return '人生的关键转折点通常在大限交替时期'; } + analyzeFavorablePeriods(allPeriods) { return allPeriods.slice(2, 6).map(p => p.age_range).join('、'); } + analyzeChallengingPeriods(allPeriods) { return '需要特别注意的时期要谨慎应对'; } + generateTimingAdvice(currentPeriod, personName) { return `${personName}应该把握当前时机,积极发展`; } + + analyzeLifePurpose(mainStar, mingGong, siHua) { return `人生目标是发挥${mainStar}星的特质,实现自我价值`; } + analyzeCoreValues(mingGong, fuDe) { return '核心价值观注重诚信、善良和智慧'; } + analyzeDevelopmentDirection(mainStar, twelvePalaces) { return `发展方向应该结合${mainStar}星的特质,全面发展`; } + analyzeSpiritualGrowth(fuDe, siHua) { return '精神成长需要不断学习和修养'; } + analyzeLifeLessons(mingGong, twelvePalaces) { return '人生课题是学会平衡各方面的发展'; } + generateOverallGuidance(mainStar, personName) { return `${personName}应该发挥${mainStar}星的优势,创造美好人生`; } + + // 流年分析辅助方法 + analyzeXiaoXianInfluence(xiaoXianIndex, age) { + const influences = { + 0: '子宫小限,主智慧学习,适合思考规划', + 1: '丑宫小限,主稳定积累,宜踏实工作', + 2: '寅宫小限,主生机勃勃,适合开创新局', + 3: '卯宫小限,主温和发展,宜人际交往', + 4: '辰宫小限,主变化转机,注意把握时机', + 5: '巳宫小限,主智慧显现,适合学习进修', + 6: '午宫小限,主光明发展,事业运势较好', + 7: '未宫小限,主收获成果,宜总结经验', + 8: '申宫小限,主行动力强,适合积极进取', + 9: '酉宫小限,主收敛整理,宜内省修养', + 10: '戌宫小限,主稳定发展,注重基础建设', + 11: '亥宫小限,主休养生息,适合蓄势待发' + }; + return influences[xiaoXianIndex] || '运势平稳,宜顺势而为'; + } + + getXiaoXianYearlyTheme(xiaoXianIndex) { + const themes = ['学习年', '积累年', '开创年', '发展年', '变化年', '进修年', '成就年', '收获年', '进取年', '修养年', '建设年', '蓄势年']; + return themes[xiaoXianIndex] || '发展年'; + } + + analyzeLiuNianFortune(yearStem, yearBranch, currentPeriod) { + return `${yearStem}${yearBranch}年与${currentPeriod.palace_name}大限相配,整体运势${Math.random() > 0.5 ? '向好' : '平稳'},需要把握机会`; + } + + getLiuNianFocusAreas(yearStem, yearBranch) { + const focusAreas = { + '甲': ['事业发展', '学习进修', '人际关系'], + '乙': ['财务管理', '健康养生', '家庭和谐'], + '丙': ['创新创业', '表达沟通', '社交拓展'], + '丁': ['感情婚姻', '艺术创作', '精神修养'], + '戊': ['稳定发展', '投资理财', '基础建设'], + '己': ['内在成长', '技能提升', '人脉积累'], + '庚': ['决断执行', '目标达成', '领导管理'], + '辛': ['细节完善', '品质提升', '专业精进'], + '壬': ['流动变化', '适应调整', '机会把握'], + '癸': ['内省思考', '智慧积累', '潜力开发'] + }; + return focusAreas[yearStem] || ['全面发展', '平衡协调', '稳步前进']; + } + + getLiuNianOpportunities(sihua) { + return [ + `${sihua.lu}化禄带来的财运机会`, + `${sihua.quan}化权带来的权力机会`, + `${sihua.ke}化科带来的名声机会` + ]; + } + + getLiuNianChallenges(sihua) { + return [ + `需要特别注意${sihua.ji}化忌带来的挑战`, + '避免冲动决策,保持理性思考', + '注意人际关系的维护和协调' + ]; + } + + generateMonthlyPreview(currentYear) { + const months = ['正月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']; + return months.map((month, index) => ({ + month: month, + theme: `${month}主题:${['新开始', '积累期', '发展期', '调整期', '成长期', '收获期', '反思期', '准备期', '行动期', '完善期', '总结期', '规划期'][index]}`, + focus: ['学习', '工作', '感情', '健康', '财运', '人际', '事业', '家庭', '投资', '创新', '休息', '计划'][index] + })); + } + + getMonthTheme(month) { + const themes = { + 1: '新春开局,万象更新', 2: '春回大地,生机勃勃', 3: '春暖花开,适合发展', + 4: '春夏之交,变化调整', 5: '初夏时节,积极进取', 6: '仲夏时光,收获成果', + 7: '盛夏季节,注意平衡', 8: '夏秋之际,稳定发展', 9: '金秋时节,收获满满', + 10: '深秋季节,内省修养', 11: '初冬时节,蓄势待发', 12: '年终岁末,总结规划' + }; + return themes[month] || '平稳发展,顺势而为'; + } + + analyzeMonthFortune(monthBranchIndex, currentYear) { + const fortunes = ['运势上升', '平稳发展', '需要谨慎', '机会较多', '挑战与机遇并存']; + return fortunes[monthBranchIndex % 5]; + } + + getMonthFocus(month) { + const focuses = { + 1: '制定年度计划,开启新征程', 2: '人际关系建设,拓展社交圈', 3: '学习进修提升,增强实力', + 4: '事业发展规划,把握机遇', 5: '财务管理优化,理性投资', 6: '健康养生调理,平衡身心', + 7: '感情关系维护,增进理解', 8: '技能专业提升,精益求精', 9: '收获成果总结,经验积累', + 10: '内在修养提升,智慧增长', 11: '年终总结反思,查漏补缺', 12: '来年规划准备,蓄势待发' + }; + return focuses[month] || '全面发展,平衡协调'; + } + + getMonthAdvice(monthBranchIndex) { + const advices = [ + '保持积极心态,勇于尝试新事物', + '稳扎稳打,注重基础建设', + '把握机会,积极主动出击', + '温和处事,重视人际和谐', + '适应变化,灵活调整策略', + '深入学习,提升专业能力', + '发挥优势,展现个人魅力', + '收获成果,总结经验教训', + '行动果断,追求卓越品质', + '内省修养,提升精神境界', + '稳定发展,夯实基础根基', + '休养生息,为未来做准备' + ]; + return advices[monthBranchIndex] || '顺势而为,保持平常心'; + } + + getNextMonthPreview(nextMonth) { + if (nextMonth > 12) nextMonth = 1; + return { + month: nextMonth, + preview: `下月${nextMonth}月预览:${this.getMonthTheme(nextMonth)}`, + preparation: '建议提前做好相应准备,把握时机' + }; + } + + analyzeTimingCoordination(daxian, xiaoxian, liunian) { + return `大限、小限、流年三者协调${Math.random() > 0.5 ? '较好' : '需要注意平衡'},建议统筹规划`; + } + + getBestTimingAdvice(daxian, liunian) { + return `结合${daxian.palace_name}大限和${liunian.year_ganzhi}年的特点,建议在适当时机积极行动`; + } + + getTimingWarnings(sihua) { + return [ + `特别注意${sihua.ji}化忌的影响`, + '避免在不利时机做重大决策', + '保持谨慎乐观的态度' + ]; + } + + getSeasonalGuidance(currentMonth) { + const seasons = { + 1: '冬春之际,宜规划布局', 2: '春季开始,宜积极行动', 3: '春季发展,宜把握机会', + 4: '春夏之交,宜调整策略', 5: '初夏时节,宜稳步推进', 6: '仲夏时光,宜收获成果', + 7: '盛夏季节,宜保持平衡', 8: '夏秋之际,宜稳定发展', 9: '金秋时节,宜总结收获', + 10: '深秋季节,宜内省修养', 11: '初冬时节,宜蓄势待发', 12: '年终岁末,宜规划未来' + }; + return seasons[currentMonth] || '顺应自然,把握节奏'; + } } module.exports = ZiweiAnalyzer; \ No newline at end of file diff --git a/src/components/AnalysisResultDisplay.tsx b/src/components/AnalysisResultDisplay.tsx index d8805dd..814342b 100644 --- a/src/components/AnalysisResultDisplay.tsx +++ b/src/components/AnalysisResultDisplay.tsx @@ -1,5 +1,6 @@ import React from 'react'; import CompleteBaziAnalysis from './CompleteBaziAnalysis'; +import CompleteZiweiAnalysis from './CompleteZiweiAnalysis'; import BaziAnalysisDisplay from './BaziAnalysisDisplay'; interface AnalysisResultDisplayProps { @@ -70,13 +71,29 @@ const AnalysisResultDisplay: React.FC = ({ analysisR // 渲染紫微斗数分析 const renderZiweiAnalysis = () => { - // 处理新的数据结构: { type: 'ziwei', data: analysisResult } + // 如果有 birthDate,使用新的 CompleteZiweiAnalysis 组件 + if (birthDate) { + return ; + } + // 如果有分析结果但没有 birthDate,尝试从结果中提取出生信息 + if (analysisResult && analysisResult.data) { + const basicInfo = analysisResult.data.basic_info; + if (basicInfo && basicInfo.personal_data) { + const extractedBirthDate = { + date: basicInfo.personal_data.birth_date || '', + time: basicInfo.personal_data.birth_time || '12:00', + name: basicInfo.personal_data.name || '', + gender: basicInfo.personal_data.gender === '男性' ? 'male' : 'female' + }; + return ; + } + } + + // 回退到旧的渲染方式(向后兼容) const data = analysisResult?.data || analysisResult; const ziweiData = data?.ziwei_analysis || data?.ziwei || data; const analysisData = data?.detailed_analysis || data?.analysis || data; - - return (
{/* 命宫信息 */} diff --git a/src/components/CompleteZiweiAnalysis.tsx b/src/components/CompleteZiweiAnalysis.tsx new file mode 100644 index 0000000..5034bd8 --- /dev/null +++ b/src/components/CompleteZiweiAnalysis.tsx @@ -0,0 +1,1134 @@ +import React, { useState, useEffect } from 'react'; +import { Radar, RadarChart, PolarGrid, PolarAngleAxis, PolarRadiusAxis, ResponsiveContainer } from 'recharts'; +import { Calendar, Star, BookOpen, Sparkles, User, BarChart3, Zap, TrendingUp, Loader2, Clock, Target, Heart, DollarSign, Activity, Crown, Compass, Moon, Sun } from 'lucide-react'; +import { Card, CardContent, CardHeader, CardTitle } from './ui/Card'; +import { localApi } from '../lib/localApi'; + +interface CompleteZiweiAnalysisProps { + birthDate: { + date: string; + time: string; + name?: string; + gender?: string; + }; +} + +const CompleteZiweiAnalysis: React.FC = ({ birthDate }) => { + const [isLoading, setIsLoading] = useState(true); + const [error, setError] = useState(null); + const [analysisData, setAnalysisData] = useState(null); + + // 四化飞星详细解释 + const sihuaExplanations = { + '化禄': { + concept: '化禄是四化之首,主财禄、享受、缘分', + influence: '增强星曜的正面能量,带来财运、人缘和享受,代表得到、收获和满足', + application: '化禄星所在宫位通常是您的幸运领域,容易获得成功和满足感', + timing: '大限或流年遇化禄,主该时期财运亨通,事业顺利,人际关系和谐' + }, + '化权': { + concept: '化权主权力、地位、能力的发挥', + influence: '增强星曜的权威性和主导力,带来领导机会、权力地位和成就感', + application: '化权星所在宫位是您容易掌控和发挥影响力的领域', + timing: '大限或流年遇化权,主该时期权力增长,地位提升,能力得到认可' + }, + '化科': { + concept: '化科主名声、学业、贵人和文书', + influence: '增强星曜的声誉和学习能力,带来名声、考试运和贵人相助', + application: '化科星所在宫位是您容易获得名声和学习成就的领域', + timing: '大限或流年遇化科,主该时期名声远播,学业有成,贵人运旺' + }, + '化忌': { + concept: '化忌主阻碍、困扰、执着和变化', + influence: '增强星曜的负面特质,带来阻碍、烦恼,但也促使变化和成长', + application: '化忌星所在宫位需要特别注意,容易遇到挫折,但也是成长的机会', + timing: '大限或流年遇化忌,主该时期需谨慎行事,可能有变动,但危机中有转机' + } + }; + + // 大限宫位解释 + const majorPeriodPalaceExplanations: { [key: string]: { focus: string; opportunities: string; challenges: string; advice: string } } = { + '命宫': { + focus: '个人发展、性格展现、人生方向', + opportunities: '自我提升、个人魅力增强、人生新方向的确立', + challenges: '可能面临身份转换、性格调整的压力', + advice: '专注于自我完善,建立正确的人生观和价值观' + }, + '兄弟宫': { + focus: '人际关系、合作伙伴、朋友圈子', + opportunities: '结交新朋友、建立合作关系、团队协作成功', + challenges: '可能与朋友产生分歧、合作关系不稳定', + advice: '重视友情,学会与人合作,建立良好的人际网络' + }, + '夫妻宫': { + focus: '婚姻感情、配偶关系、合作伙伴', + opportunities: '感情生活美满、婚姻幸福、合作成功', + challenges: '可能面临感情波折、婚姻考验', + advice: '用心经营感情,学会包容和理解,重视沟通' + }, + '子女宫': { + focus: '子女教育、创造力、部属关系', + opportunities: '子女有成就、创意发挥、领导能力提升', + challenges: '子女教育问题、创意受阻、管理困难', + advice: '关注子女成长,发挥创造潜能,培养领导才能' + }, + '财帛宫': { + focus: '财运发展、理财能力、物质享受', + opportunities: '财运亨通、投资获利、物质生活改善', + challenges: '可能面临财务压力、投资风险', + advice: '谨慎理财,稳健投资,避免过度消费' + }, + '疾厄宫': { + focus: '健康状况、意外灾厄、身体调养', + opportunities: '身体健康改善、疾病康复、养生有成', + challenges: '可能面临健康问题、意外事故', + advice: '注重健康养生,定期体检,避免过度劳累' + }, + '迁移宫': { + focus: '外出发展、环境变化、人际拓展', + opportunities: '外出发展顺利、环境改善、人脉扩展', + challenges: '可能面临环境适应问题、外出不利', + advice: '积极适应环境变化,把握外出发展机会' + }, + '交友宫': { + focus: '朋友关系、社交活动、人脉建立', + opportunities: '朋友相助、社交成功、人脉广阔', + challenges: '可能遇到损友、社交困扰', + advice: '慎选朋友,积极参与社交活动,建立良好人脉' + }, + '事业宫': { + focus: '事业发展、工作状况、社会地位', + opportunities: '事业成功、升职加薪、地位提升', + challenges: '可能面临工作压力、事业瓶颈', + advice: '专注事业发展,提升专业能力,把握机遇' + }, + '田宅宫': { + focus: '不动产、居住环境、家庭财产', + opportunities: '置业成功、居住环境改善、家产增加', + challenges: '可能面临房产问题、居住不稳', + advice: '谨慎投资房产,改善居住环境,重视家庭和谐' + }, + '福德宫': { + focus: '精神享受、兴趣爱好、内心满足', + opportunities: '精神富足、兴趣发展、内心平静', + challenges: '可能面临精神压力、兴趣受阻', + advice: '培养健康兴趣,追求精神满足,保持心理平衡' + }, + '父母宫': { + focus: '父母关系、长辈缘分、权威关系', + opportunities: '父母健康、长辈相助、权威认可', + challenges: '可能面临长辈健康问题、权威冲突', + advice: '孝顺父母,尊重长辈,处理好权威关系' + } + }; + + // 主星详细解释 + const starExplanations: { [key: string]: { nature: string; personality: string; career: string; fortune: string } } = { + '紫微': { + nature: '帝王星,紫微斗数中的主星之首', + personality: '具有领导才能,天生贵气,自尊心强,喜欢受人尊敬,有组织管理能力', + career: '适合担任领导职务,在政府机关、大企业或自主创业方面有优势', + fortune: '一生多贵人相助,财运稳定,晚年富贵' + }, + '天机': { + nature: '智慧星,主聪明机智', + personality: '思维敏捷,善于策划,喜欢思考,具有很强的分析能力和应变能力', + career: '适合从事需要智慧的工作,如咨询、策划、教育、科研等', + fortune: '财运起伏较大,需要通过智慧理财,中年后财运渐佳' + }, + '太阳': { + nature: '光明星,主权威和名声', + personality: '性格开朗,光明磊落,具有正义感,喜欢帮助他人,有很强的表现欲', + career: '适合公职、教育、传媒等需要权威性和影响力的工作', + fortune: '财运与名声相关,通过正当途径获得财富,中年发达' + }, + '武曲': { + nature: '财星,主财富和意志力', + personality: '意志坚强,执行力强,重视物质,有很强的赚钱能力和理财观念', + career: '适合金融、投资、工程、技术等需要专业技能的工作', + fortune: '天生财运佳,善于理财投资,一生不缺钱财' + }, + '天同': { + nature: '福星,主享受和人缘', + personality: '性格温和,人缘好,喜欢享受生活,有很强的亲和力和包容心', + career: '适合服务业、娱乐业、餐饮业等需要人际交往的工作', + fortune: '财运平稳,多通过人脉关系获得财富,晚年享福' + }, + '廉贞': { + nature: '囚星,主感情和艺术', + personality: '感情丰富,有艺术天分,追求完美,但情绪波动较大,容易钻牛角尖', + career: '适合艺术、设计、娱乐、美容等创意性工作', + fortune: '财运与感情和创意相关,需要发挥艺术才能获得财富' + }, + '天府': { + nature: '库星,主稳重和积累', + personality: '稳重可靠,有很强的组织能力,善于积累,注重安全感', + career: '适合管理、行政、金融、房地产等稳定性工作', + fortune: '财运稳定,善于积累财富,一生衣食无忧' + }, + '太阴': { + nature: '母星,主细腻和直觉', + personality: '细腻敏感,直觉力强,善于照顾他人,但有时过于敏感和多疑', + career: '适合教育、医疗、服务、文艺等需要细心和耐心的工作', + fortune: '财运与女性或家庭相关,通过细心经营获得财富' + }, + '贪狼': { + nature: '欲望星,主多才多艺', + personality: '多才多艺,善于交际,欲望强烈,喜欢新鲜事物,但容易三心二意', + career: '适合销售、娱乐、旅游、外贸等需要交际能力的工作', + fortune: '财运多变,机会很多,但需要专注才能获得稳定财富' + }, + '巨门': { + nature: '暗星,主口才和分析', + personality: '口才好,分析力强,善于发现问题,但有时过于挑剔和多疑', + career: '适合律师、记者、教师、研究等需要口才和分析能力的工作', + fortune: '财运需要通过专业技能获得,中年后财运较佳' + }, + '天相': { + nature: '印星,主忠诚和协调', + personality: '忠诚可靠,协调能力强,善于辅助他人,但有时缺乏主见', + career: '适合秘书、助理、公务员、顾问等辅助性工作', + fortune: '财运稳定,多通过辅助他人获得财富,一生平稳' + }, + '天梁': { + nature: '寿星,主正直和长者风范', + personality: '正直善良,有长者风范,喜欢帮助他人,具有很强的责任感', + career: '适合教育、公益、医疗、宗教等需要奉献精神的工作', + fortune: '财运与德行相关,通过正当途径获得财富,晚年富足' + }, + '七杀': { + nature: '将星,主冲劲和开拓', + personality: '冲劲十足,勇于开拓,不怕困难,但有时过于冲动和急躁', + career: '适合军警、体育、创业、销售等需要冲劲的工作', + fortune: '财运起伏较大,需要通过努力奋斗获得财富' + }, + '破军': { + nature: '耗星,主变化和创新', + personality: '喜欢变化,勇于创新,不满足现状,但有时过于冲动和破坏性', + career: '适合创新、改革、艺术、科技等需要突破的工作', + fortune: '财运变化很大,需要通过创新获得财富,晚年较佳' + } + }; + + // 星曜颜色配置 + const starColors: { [key: string]: string } = { + '紫微': 'bg-purple-100 text-purple-800 border-purple-300', + '天机': 'bg-blue-100 text-blue-800 border-blue-300', + '太阳': 'bg-orange-100 text-orange-800 border-orange-300', + '武曲': 'bg-gray-100 text-gray-800 border-gray-300', + '天同': 'bg-green-100 text-green-800 border-green-300', + '廉贞': 'bg-red-100 text-red-800 border-red-300', + '天府': 'bg-yellow-100 text-yellow-800 border-yellow-300', + '太阴': 'bg-indigo-100 text-indigo-800 border-indigo-300', + '贪狼': 'bg-pink-100 text-pink-800 border-pink-300', + '巨门': 'bg-slate-100 text-slate-800 border-slate-300', + '天相': 'bg-cyan-100 text-cyan-800 border-cyan-300', + '天梁': 'bg-emerald-100 text-emerald-800 border-emerald-300', + '七杀': 'bg-rose-100 text-rose-800 border-rose-300', + '破军': 'bg-amber-100 text-amber-800 border-amber-300' + }; + + // 吉星煞星颜色配置 + const luckyStarColors = 'bg-green-50 text-green-700 border-green-200'; + const unluckyStarColors = 'bg-red-50 text-red-700 border-red-200'; + + // 宫位强度颜色 + const strengthColors: { [key: string]: string } = { + '旺': 'text-green-600 bg-green-50', + '得地': 'text-blue-600 bg-blue-50', + '平': 'text-yellow-600 bg-yellow-50', + '不得地': 'text-orange-600 bg-orange-50', + '陷': 'text-red-600 bg-red-50' + }; + + // 五行局颜色 + const wuxingJuColors: { [key: string]: string } = { + '水二局': 'text-blue-700 bg-blue-100', + '木三局': 'text-green-700 bg-green-100', + '金四局': 'text-gray-700 bg-gray-100', + '土五局': 'text-yellow-700 bg-yellow-100', + '火六局': 'text-red-700 bg-red-100' + }; + + useEffect(() => { + const fetchAnalysisData = async () => { + try { + setIsLoading(true); + setError(null); + + const birthData = { + name: birthDate.name || '用户', + birth_date: birthDate.date, + birth_time: birthDate.time, + gender: birthDate.gender || 'male' + }; + + const ziweiResponse = await localApi.analysis.ziwei(birthData); + + if (ziweiResponse.error) { + throw new Error(ziweiResponse.error.message || '紫微斗数分析失败'); + } + + const analysisResult = ziweiResponse.data?.analysis; + if (!analysisResult) { + throw new Error('分析结果为空'); + } + + setAnalysisData(analysisResult); + } catch (err) { + console.error('获取分析数据出错:', err); + setError(err instanceof Error ? err.message : '分析数据获取失败,请稍后重试'); + } finally { + setIsLoading(false); + } + }; + + if (birthDate?.date) { + fetchAnalysisData(); + } + }, [birthDate]); + + // 渲染加载状态 + if (isLoading) { + return ( +
+ + + +

正在进行专业紫微斗数分析

+

请稍候,正在排盘并生成您的详细命理报告...

+
+
+
+ ); + } + + // 渲染错误状态 + if (error) { + return ( +
+ + +
+

分析失败

+

{error}

+ +
+
+
+ ); + } + + if (!analysisData) { + return ( +
+ + +
⚠️
+

数据获取异常

+

未能获取到完整的分析数据,请重新提交分析

+
+
+
+ ); + } + + // 渲染宫位卡片 + const renderPalaceCard = (palaceName: string, palace: any) => { + if (!palace) return null; + + return ( + + + + {palaceName} + +
+ {palace.position} + + {palace.strength} + +
+
+ + {/* 主星 */} + {palace.main_stars && palace.main_stars.length > 0 && ( +
+
主星
+
+ {palace.main_stars.map((star: string, index: number) => ( + + {star} + + ))} +
+
+ )} + + {/* 吉星 */} + {palace.lucky_stars && palace.lucky_stars.length > 0 && ( +
+
吉星
+
+ {palace.lucky_stars.map((star: string, index: number) => ( + + {star} + + ))} +
+
+ )} + + {/* 煞星 */} + {palace.unlucky_stars && palace.unlucky_stars.length > 0 && ( +
+
煞星
+
+ {palace.unlucky_stars.map((star: string, index: number) => ( + + {star} + + ))} +
+
+ )} + + {/* 宫位解读 */} + {palace.interpretation && ( +
+

{palace.interpretation}

+
+ )} +
+
+ ); + }; + + // 渲染格局卡片 + const renderPatternCard = (pattern: any) => { + const levelColors = { + 'excellent': 'bg-green-100 text-green-800 border-green-300', + 'good': 'bg-blue-100 text-blue-800 border-blue-300', + 'fair': 'bg-yellow-100 text-yellow-800 border-yellow-300', + 'weak': 'bg-gray-100 text-gray-800 border-gray-300' + }; + + return ( + + +
+ {pattern.name} + + {pattern.level === 'excellent' ? '优秀' : pattern.level === 'good' ? '良好' : pattern.level === 'fair' ? '一般' : '较弱'} + +
+

{pattern.type === 'major' ? '主要格局' : pattern.type === 'wealth' ? '财富格局' : pattern.type === 'career' ? '事业格局' : pattern.type === 'relationship' ? '感情格局' : '四化格局'}

+
+ +

{pattern.description}

+
+
影响
+

{pattern.influence}

+
+
+
建议
+

{pattern.advice}

+
+
+
+ ); + }; + + return ( +
+
+ + {/* 标题和基本信息 */} + + + + + {analysisData.basic_info?.personal_data?.name || '用户'}的专业紫微斗数命理分析报告 + + +
+
+ + {analysisData.basic_info?.personal_data?.birth_date} +
+
+ + {analysisData.basic_info?.personal_data?.birth_time} +
+
+ + {analysisData.basic_info?.personal_data?.gender} +
+
+
+ +
+ {/* 八字信息 */} +
+

八字信息

+
+
+

年柱:{analysisData.basic_info?.bazi_info?.year}

+

月柱:{analysisData.basic_info?.bazi_info?.month}

+
+
+

日柱:{analysisData.basic_info?.bazi_info?.day}

+

时柱:{analysisData.basic_info?.bazi_info?.hour}

+
+
+
+ + {/* 五行局和命宫 */} +
+
+

五行局

+
+ {analysisData.basic_info?.wuxing_ju?.type} +
+

{analysisData.basic_info?.wuxing_ju?.description}

+
+
+

命宫位置

+
+ {analysisData.basic_info?.ming_gong_position?.branch} +
+

{analysisData.basic_info?.ming_gong_position?.description}

+
+
+
+
+
+ + {/* 命宫主星信息 */} + {analysisData.ziwei_analysis?.ming_gong_stars && analysisData.ziwei_analysis.ming_gong_stars.length > 0 && ( + + + + + 命宫主星详解 + +

命宫在{analysisData.ziwei_analysis?.ming_gong},主星决定了您的基本性格和人生走向

+
+ +
+ {analysisData.ziwei_analysis.ming_gong_stars.map((star: string, index: number) => { + const explanation = starExplanations[star]; + return ( +
+
+
+ {star} +
+ {explanation && ( + {explanation.nature} + )} +
+ + {explanation && ( +
+
+
+ + 性格特质 +
+

{explanation.personality}

+
+ +
+
+ + 事业方向 +
+

{explanation.career}

+
+ +
+
+ + 财运特点 +
+

{explanation.fortune}

+
+
+ )} + + {!explanation && ( +
+

此星曜的详细解释正在完善中...

+
+ )} +
+ ); + })} + + {/* 主星组合解读 */} + {analysisData.ziwei_analysis.ming_gong_stars.length > 1 && ( +
+

+ + 主星组合特色 +

+

+ 您的命宫有{analysisData.ziwei_analysis.ming_gong_stars.join('、')}同宫,这种组合使您兼具了多种星曜的特质。 + {analysisData.ziwei_analysis.ming_gong_stars.length === 2 ? + '双星同宫往往能够互补优势,但也需要平衡不同星曜的能量。' : + '多星同宫的格局较为复杂,需要综合各星曜的特质来理解您的性格。' + } +

+
+ )} +
+
+
+ )} + + {/* 十二宫位详解 */} + + + + + 十二宫位详解 + +

紫微斗数将人生分为十二个宫位,每个宫位代表不同的人生领域

+
+ +
+ {analysisData.ziwei_analysis?.twelve_palaces && Object.entries(analysisData.ziwei_analysis.twelve_palaces).map(([palaceName, palace]) => + renderPalaceCard(palaceName, palace) + )} +
+
+
+ + {/* 四化飞星 */} + {analysisData.ziwei_analysis?.si_hua && ( + + + + + 四化飞星 + +

根据{analysisData.ziwei_analysis.si_hua.year_stem}年干的四化飞星分析

+
+ +
+ {/* 四化概述 */} +
+

四化飞星概述

+

+ 四化飞星是紫微斗数的核心理论,由{analysisData.ziwei_analysis.si_hua.year_stem}年干所化出。 + 四化分别是化禄(财禄)、化权(权力)、化科(名声)、化忌(阻碍), + 它们会影响相应星曜的能量表现,是判断吉凶和时机的重要依据。 +

+
+ + {/* 四化详解 */} +
+ {/* 化禄 */} +
+
+ 💰 +
+

化禄 - {analysisData.ziwei_analysis.si_hua.hua_lu.star}

+

{sihuaExplanations['化禄'].concept}

+
+
+
+
+ 影响: + {sihuaExplanations['化禄'].influence} +
+
+ 应用: + {sihuaExplanations['化禄'].application} +
+
+ 时机: + {sihuaExplanations['化禄'].timing} +
+
+
+ + {/* 化权 */} +
+
+ 👑 +
+

化权 - {analysisData.ziwei_analysis.si_hua.hua_quan.star}

+

{sihuaExplanations['化权'].concept}

+
+
+
+
+ 影响: + {sihuaExplanations['化权'].influence} +
+
+ 应用: + {sihuaExplanations['化权'].application} +
+
+ 时机: + {sihuaExplanations['化权'].timing} +
+
+
+ + {/* 化科 */} +
+
+ 🎓 +
+

化科 - {analysisData.ziwei_analysis.si_hua.hua_ke.star}

+

{sihuaExplanations['化科'].concept}

+
+
+
+
+ 影响: + {sihuaExplanations['化科'].influence} +
+
+ 应用: + {sihuaExplanations['化科'].application} +
+
+ 时机: + {sihuaExplanations['化科'].timing} +
+
+
+ + {/* 化忌 */} +
+
+ ⚠️ +
+

化忌 - {analysisData.ziwei_analysis.si_hua.hua_ji.star}

+

{sihuaExplanations['化忌'].concept}

+
+
+
+
+ 影响: + {sihuaExplanations['化忌'].influence} +
+
+ 应用: + {sihuaExplanations['化忌'].application} +
+
+ 时机: + {sihuaExplanations['化忌'].timing} +
+
+
+
+
+
+
+ )} + + {/* 大限分析 */} + {analysisData.ziwei_analysis?.major_periods && ( + + + + + 大限分析 + +

{analysisData.ziwei_analysis.major_periods.wuxing_ju},起运年龄{analysisData.ziwei_analysis.major_periods.start_age}岁

+
+ + {/* 当前大限 */} + {analysisData.ziwei_analysis.major_periods.current_period && ( +
+

当前大限

+

{analysisData.ziwei_analysis.major_periods.current_period.description}

+
+ )} + + {/* 所有大限 */} +
+

十二大限详解

+
+ {analysisData.ziwei_analysis.major_periods.all_periods?.map((period: any, index: number) => { + const explanation = majorPeriodPalaceExplanations[period.palace_name] || { + focus: '该宫位的重点领域', + opportunities: '潜在的发展机会', + challenges: '可能面临的挑战', + advice: '建议关注的方向' + }; + + return ( +
+
+ 第{period.period_number}大限 + {period.age_range} +
+ +
+
+ {period.palace_branch}宫 + ({period.palace_name}) +
+ {period.is_current && ( +
+ 当前大限 + 正在经历 +
+ )} + {!period.is_current && ( + p.is_current) + ? 'bg-gray-100 text-gray-600' + : 'bg-blue-100 text-blue-600' + }`}> + {index < analysisData.ziwei_analysis.major_periods.all_periods?.findIndex((p: any) => p.is_current) ? '已过' : '未来'} + + )} +
+ +
+
+ 重点领域: +

{explanation.focus}

+
+ +
+ 发展机会: +

{explanation.opportunities}

+
+ +
+ 注意事项: +

{explanation.challenges}

+
+ +
+ 建议方向: +

{explanation.advice}

+
+
+
+ ); + })} +
+
+
+
+ )} + + {/* 格局判定 */} + {analysisData.detailed_analysis?.life_guidance?.pattern_analysis && ( + + + + + 格局判定 + +
+ 检测到{analysisData.detailed_analysis.life_guidance.pattern_analysis.pattern_count}个格局 + + {analysisData.detailed_analysis.life_guidance.pattern_analysis.pattern_strength === 'very_strong' ? '极强' : + analysisData.detailed_analysis.life_guidance.pattern_analysis.pattern_strength === 'strong' ? '强' : + analysisData.detailed_analysis.life_guidance.pattern_analysis.pattern_strength === 'moderate' ? '中等' : + analysisData.detailed_analysis.life_guidance.pattern_analysis.pattern_strength === 'fair' ? '一般' : '较弱'} + +
+
+ + {/* 格局指导 */} +
+

格局总评

+

{analysisData.detailed_analysis.life_guidance.pattern_analysis.pattern_guidance}

+
+ + {/* 具体格局 */} + {analysisData.detailed_analysis.life_guidance.pattern_analysis.detected_patterns && ( +
+ {analysisData.detailed_analysis.life_guidance.pattern_analysis.detected_patterns.map((pattern: any) => + renderPatternCard(pattern) + )} +
+ )} +
+
+ )} + + {/* 流年分析 */} + {analysisData.detailed_analysis?.timing_analysis?.liu_nian_analysis && ( + + + + + 流年分析 + +

{analysisData.detailed_analysis.timing_analysis.liu_nian_analysis.year_ganzhi}年运势分析

+
+ +
+ {/* 流年四化 */} +
+

流年四化

+
+
+
{analysisData.detailed_analysis.timing_analysis.liu_nian_analysis.liu_nian_sihua.hua_lu.star}
+
化禄
+
+
+
{analysisData.detailed_analysis.timing_analysis.liu_nian_analysis.liu_nian_sihua.hua_quan.star}
+
化权
+
+
+
{analysisData.detailed_analysis.timing_analysis.liu_nian_analysis.liu_nian_sihua.hua_ke.star}
+
化科
+
+
+
{analysisData.detailed_analysis.timing_analysis.liu_nian_analysis.liu_nian_sihua.hua_ji.star}
+
化忌
+
+
+
+ + {/* 年度重点 */} +
+
+

年度机会

+
    + {analysisData.detailed_analysis.timing_analysis.liu_nian_analysis.year_opportunities?.map((opportunity: string, index: number) => ( +
  • • {opportunity}
  • + ))} +
+
+
+

注意事项

+
    + {analysisData.detailed_analysis.timing_analysis.liu_nian_analysis.year_challenges?.map((challenge: string, index: number) => ( +
  • • {challenge}
  • + ))} +
+
+
+ + {/* 重点领域 */} +
+

年度重点领域

+
+ {analysisData.detailed_analysis.timing_analysis.liu_nian_analysis.year_focus_areas?.map((area: string, index: number) => ( + + {area} + + ))} +
+
+
+
+
+ )} + + {/* 专业分析模块 */} +
+ {/* 个性分析 */} + {analysisData.detailed_analysis?.personality_analysis && ( + + + + + 个性分析 + + + +
+

性格概述

+

{analysisData.detailed_analysis.personality_analysis.overview}

+
+
+

核心特质

+

{analysisData.detailed_analysis.personality_analysis.core_traits}

+
+
+

优势特长

+

{analysisData.detailed_analysis.personality_analysis.strengths}

+
+
+

需要注意

+

{analysisData.detailed_analysis.personality_analysis.challenges}

+
+
+
+ )} + + {/* 事业分析 */} + {analysisData.detailed_analysis?.career_analysis && ( + + + + + 事业分析 + + + +
+

事业潜力

+

{analysisData.detailed_analysis.career_analysis.career_potential}

+
+
+

适合行业

+

{analysisData.detailed_analysis.career_analysis.suitable_industries}

+
+
+

领导风格

+

{analysisData.detailed_analysis.career_analysis.leadership_style}

+
+
+

发展建议

+

{analysisData.detailed_analysis.career_analysis.career_advice}

+
+
+
+ )} + + {/* 财富分析 */} + {analysisData.detailed_analysis?.wealth_analysis && ( + + + + + 财富分析 + + + +
+

财运潜力

+

{analysisData.detailed_analysis.wealth_analysis.wealth_potential}

+
+
+

赚钱方式

+

{analysisData.detailed_analysis.wealth_analysis.earning_style}

+
+
+

投资倾向

+

{analysisData.detailed_analysis.wealth_analysis.investment_tendency}

+
+
+

理财建议

+

{analysisData.detailed_analysis.wealth_analysis.financial_advice}

+
+
+
+ )} + + {/* 感情分析 */} + {analysisData.detailed_analysis?.relationship_analysis && ( + + + + + 感情分析 + + + +
+

婚姻运势

+

{analysisData.detailed_analysis.relationship_analysis.marriage_fortune}

+
+
+

配偶特质

+

{analysisData.detailed_analysis.relationship_analysis.spouse_characteristics}

+
+
+

感情模式

+

{analysisData.detailed_analysis.relationship_analysis.relationship_pattern}

+
+
+

感情建议

+

{analysisData.detailed_analysis.relationship_analysis.relationship_advice}

+
+
+
+ )} +
+ + {/* 人生指导 */} + {analysisData.detailed_analysis?.life_guidance && ( + + + + + 人生指导 + + + +
+
+
+

人生目标

+

{analysisData.detailed_analysis.life_guidance.life_purpose}

+
+
+

核心价值观

+

{analysisData.detailed_analysis.life_guidance.core_values}

+
+
+

发展方向

+

{analysisData.detailed_analysis.life_guidance.development_direction}

+
+
+
+
+

精神成长

+

{analysisData.detailed_analysis.life_guidance.spiritual_growth}

+
+
+

人生课题

+

{analysisData.detailed_analysis.life_guidance.life_lessons}

+
+
+

总体指导

+

{analysisData.detailed_analysis.life_guidance.overall_guidance}

+
+
+
+
+
+ )} + + {/* 分析说明 */} + + +

+ 本分析报告基于传统紫微斗数理论,结合现代分析方法生成。 + 紫微斗数是中华传统命理学的重要组成部分,仅供参考,不可过分依赖。 + 人生的幸福需要通过自己的努力和智慧来创造。 +

+
+ 分析时间:{new Date().toLocaleString('zh-CN')} +
+
+
+
+
+ ); +}; + +export default CompleteZiweiAnalysis; \ No newline at end of file diff --git a/test-ziwei.js b/test-ziwei.js new file mode 100644 index 0000000..e69de29