dsh-metaphysics 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +8 -0
- package/client.js +729 -24
- package/engine/crosscheck.js +133 -0
- package/engine/followup.js +173 -0
- package/engine/geo.js +1 -1
- package/engine/index.js +48 -4
- package/engine/interpret.js +126 -10
- package/index.js +8 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -746,7 +746,7 @@ function resolveAddress(input) {
|
|
|
746
746
|
|
|
747
747
|
const DETAIL = /(区|县|镇|乡|村|小区|街道|路|号|巷|弄|组|队)/;
|
|
748
748
|
|
|
749
|
-
const USER_AGENT = 'dsh-metaphysics/0.
|
|
749
|
+
const USER_AGENT = 'dsh-metaphysics/0.16.0 (+https://github.com/xuanfu-web/dsh-metaphysics)';
|
|
750
750
|
|
|
751
751
|
async function onlineLookup(text, { timeoutMs = 2500 } = {}) {
|
|
752
752
|
if (typeof fetch !== 'function') return null;
|
|
@@ -5449,6 +5449,7 @@ function baziInterpret(r) {
|
|
|
5449
5449
|
const primary = pick(frame, 'primaryName', '未取定');
|
|
5450
5450
|
const gender = pick(r.input, 'gender', '');
|
|
5451
5451
|
const isMale = gender === 'male';
|
|
5452
|
+
const spouseKey = isMale ? '财' : '官杀';
|
|
5452
5453
|
|
|
5453
5454
|
const age = Number(pick(r.liunian?.[0], 'age', NaN));
|
|
5454
5455
|
const list = Array.isArray(r.dayun?.list) ? r.dayun.list : [];
|
|
@@ -5640,15 +5641,44 @@ function baziInterpret(r) {
|
|
|
5640
5641
|
key: 'geju', label: '格局依据',
|
|
5641
5642
|
text: (Array.isArray(frame.geju) ? frame.geju : []).map((g) => `${g.name}(${g.kind}):${g.evidence}`).join(';') || '未取到格局',
|
|
5642
5643
|
},
|
|
5644
|
+
{
|
|
5645
|
+
key: 'quant', label: '量化口径',
|
|
5646
|
+
text: `本报告的量化只到「档位」:事业看十神权重(${topName} ${top[0]?.[1] ?? '—'})、财富看财星权重(${groups['财'] ?? 0})、感情看配偶星权重(${spouseKey} ${groups[spouseKey] ?? 0});大运/流年用「大吉 / 吉 / 平 / 忌」四档。不换算金额、不给健康诊断——那需要地域、家庭、行业与体检数据,命盘本身推不出来。`,
|
|
5647
|
+
},
|
|
5643
5648
|
{
|
|
5644
5649
|
key: 'limits', label: '未纳入',
|
|
5645
5650
|
text: '本盘没有计算:流月与流日、神煞的加权轻重、地支藏干的动态引化(合冲后再论)。取用以扶抑为主、调候只做简化提示,各派取法不同;真太阳时未含历史时区与夏令时。把这些补上会改变"强弱"的边际判断,所以这里只给方向,不下断语。',
|
|
5646
5651
|
},
|
|
5647
5652
|
];
|
|
5648
5653
|
|
|
5654
|
+
const outline = [
|
|
5655
|
+
{ key: 'overall', label: '整体', text: `${level},喜${join(favor) || '—'}、忌${join(avoid) || '—'}` },
|
|
5656
|
+
{ key: 'career', label: '事业', text: `主格${primary},${topName}偏旺` },
|
|
5657
|
+
{ key: 'wealth', label: '财富', text: `财星权重 ${groups['财'] ?? 0}${favor.includes('金') ? ',喜金助财' : ''}` },
|
|
5658
|
+
{ key: 'love', label: '感情', text: `${spouseKey}星权重 ${groups[spouseKey] ?? 0},日支 ${pick(r.pillars?.day, 'branch', '—')}` },
|
|
5659
|
+
{ key: 'rhythm', label: '节奏', text: `当前${pick(cur, 'ganzhi', '—')}(${curTier}),${pick(ln, 'year', '')} ${pick(ln, 'ganzhi', '')}(${lnTier})` },
|
|
5660
|
+
];
|
|
5661
|
+
const tables = [
|
|
5662
|
+
{
|
|
5663
|
+
key: 'dayun', title: '大运表', columns: ['大运', '年龄', '十神', '档位', '理由'],
|
|
5664
|
+
rows: list.map((d) => [d.ganzhi, `${d.startAge}–${d.startAge + 9}`, d.stemTenGod || '', d.luck?.tier || '平', (d.luck?.reasons || []).join(',')]),
|
|
5665
|
+
},
|
|
5666
|
+
{
|
|
5667
|
+
key: 'liunian', title: '流年表(近十年)', columns: ['年份', '干支', '十神', '档位', '与原局'],
|
|
5668
|
+
rows: (r.liunian || []).slice(0, 10).map((l) => [String(l.year), l.ganzhi, l.stemTenGod || '', l.luck?.tier || '平', (l.relations || []).join('、')]),
|
|
5669
|
+
},
|
|
5670
|
+
];
|
|
5671
|
+
const triggerRows = (r.liunian || [])
|
|
5672
|
+
.filter((l) => Array.isArray(l.relations) && l.relations.length)
|
|
5673
|
+
.slice(0, 10)
|
|
5674
|
+
.map((l) => [String(l.year), l.relations.join('、'), `流年${l.ganzhi}与原局地支:${l.relations.join('、')}`]);
|
|
5675
|
+
if (triggerRows.length) {
|
|
5676
|
+
tables.push({ key: 'triggers', title: '触发事件表', columns: ['年份', '触发', '依据'], rows: triggerRows });
|
|
5677
|
+
}
|
|
5678
|
+
|
|
5649
5679
|
return {
|
|
5650
5680
|
lead: `下面按五个维度拆开说。所有内容来自你这张命盘的结构,讲的是倾向与建议,不是预言——方向供你参考,怎么走在你自己。`,
|
|
5651
|
-
dimensions, sections,
|
|
5681
|
+
dimensions, sections, outline, tables,
|
|
5652
5682
|
};
|
|
5653
5683
|
}
|
|
5654
5684
|
|
|
@@ -5836,6 +5866,10 @@ function ziweiInterpret(r) {
|
|
|
5836
5866
|
return `大限:${dx || '—'}。\n近五年流年:${yrs || '—'}。\n读法:大限定十年的主题,流年四化指出今年往哪边偏;两层方向相反时,以守住大限主题为主。`;
|
|
5837
5867
|
})(),
|
|
5838
5868
|
},
|
|
5869
|
+
{
|
|
5870
|
+
key: 'quant', label: '量化口径',
|
|
5871
|
+
text: '紫微这边只数「宫位里有什么」:大限看落宫与四化命中数、流年看命宫与四化星数;不把星曜折算成分数,也不预测金额与疾病诊断。四化命中数只是结构计数,不等于吉凶强度。',
|
|
5872
|
+
},
|
|
5839
5873
|
{
|
|
5840
5874
|
key: 'limits', label: '未纳入',
|
|
5841
5875
|
text: '本盘没有计算:飞星四化(宫干引发的连锁)、小限与大限的加权、流日流时的具体事项定位,以及双星组合的强弱细分。四化表取中州派常用口径,其他流派(如飞星派)结论会不同;这些不改变盘面事实,只影响轻重,所以只作方向参考。',
|
|
@@ -5871,9 +5905,54 @@ function ziweiInterpret(r) {
|
|
|
5871
5905
|
});
|
|
5872
5906
|
}
|
|
5873
5907
|
|
|
5908
|
+
const outline = [
|
|
5909
|
+
{ key: 'overall', label: '整体', text: `命宫${soulStar}${soulOwn ? '' : '(借对宫)'}${S.trait ? `,${S.trait}` : ''}` },
|
|
5910
|
+
{ key: 'career', label: '事业', text: `官禄${careerStar || '无正曜'}` },
|
|
5911
|
+
{ key: 'wealth', label: '财富', text: `财帛${wealthStar || '无正曜'}` },
|
|
5912
|
+
{ key: 'love', label: '感情', text: `夫妻${spouseStar || '无正曜'}` },
|
|
5913
|
+
{
|
|
5914
|
+
key: 'rhythm', label: '节奏',
|
|
5915
|
+
text: daxianPalace && daxianPalace.daxian
|
|
5916
|
+
? `当前大限${daxianPalace.palace}(${daxianPalace.daxian.start}–${daxianPalace.daxian.end}岁)${r.liunian?.[0]?.year ? `,${r.liunian[0].year} 流年` : ''}`
|
|
5917
|
+
: '当前大限未取到',
|
|
5918
|
+
},
|
|
5919
|
+
];
|
|
5920
|
+
const daxianSorted = (r.daxianList || []).slice().sort((a, b) => a.ages[0] - b.ages[0]);
|
|
5921
|
+
const tables = [
|
|
5922
|
+
{
|
|
5923
|
+
key: 'daxian', title: '大限表', columns: ['大限', '年龄', '会主星', '四化'],
|
|
5924
|
+
rows: daxianSorted.map((d) => [
|
|
5925
|
+
d.palace,
|
|
5926
|
+
`${d.ages[0]}–${d.ages[1]}`,
|
|
5927
|
+
(d.mainStars || []).join('、'),
|
|
5928
|
+
(d.mutagenHits || []).map((m) => `${m.star}${m.type}→${m.palace}`).join('、'),
|
|
5929
|
+
]),
|
|
5930
|
+
},
|
|
5931
|
+
{
|
|
5932
|
+
key: 'liunian', title: '流年表(近六年)', columns: ['年份', '干支', '年龄', '命宫', '四化'],
|
|
5933
|
+
rows: (r.liunian || []).slice(0, 6).map((l) => [
|
|
5934
|
+
String(l.year),
|
|
5935
|
+
l.ganzhi,
|
|
5936
|
+
String(l.age),
|
|
5937
|
+
l.lifePalace ? l.lifePalace.palace : '—',
|
|
5938
|
+
(l.mutagen || []).join('、'),
|
|
5939
|
+
]),
|
|
5940
|
+
},
|
|
5941
|
+
];
|
|
5942
|
+
const triggerRows = daxianSorted
|
|
5943
|
+
.flatMap((d) => (d.mutagenHits || []).map((m) => [
|
|
5944
|
+
`${d.palace}(${d.ages[0]}–${d.ages[1]}岁)`,
|
|
5945
|
+
`${m.star}化${m.type}→${m.palace}`,
|
|
5946
|
+
`大限${d.palace}引动`,
|
|
5947
|
+
]))
|
|
5948
|
+
.slice(0, 12);
|
|
5949
|
+
if (triggerRows.length) {
|
|
5950
|
+
tables.push({ key: 'triggers', title: '触发事件表(大限四化)', columns: ['大限', '触发', '依据'], rows: triggerRows });
|
|
5951
|
+
}
|
|
5952
|
+
|
|
5874
5953
|
return {
|
|
5875
5954
|
lead: `紫微斗数看的是你与环境的互动方式。下面按五个维度拆开,讲的是性格与处境的倾向,具体怎么选仍然在你。`,
|
|
5876
|
-
dimensions, sections,
|
|
5955
|
+
dimensions, sections, outline, tables,
|
|
5877
5956
|
};
|
|
5878
5957
|
}
|
|
5879
5958
|
|
|
@@ -6409,10 +6488,41 @@ function enrichPlain(result, r, ask) {
|
|
|
6409
6488
|
};
|
|
6410
6489
|
}
|
|
6411
6490
|
|
|
6491
|
+
const TECHNIQUE = {
|
|
6492
|
+
bazi: '八字(月令 · 十神 · 大运流年)',
|
|
6493
|
+
ziwei: '紫微(宫位 · 四化 · 大限流年)',
|
|
6494
|
+
liuyao: '六爻(卦宫 · 世应 · 动爻 · 日辰)',
|
|
6495
|
+
meihua: '梅花(体用 · 互卦 · 变卦)',
|
|
6496
|
+
daliuren: '六壬(月将加时 · 四课 · 三传)',
|
|
6497
|
+
qimen: '奇门(九宫 · 值符值使 · 用神)',
|
|
6498
|
+
tarot: '塔罗(牌阵 · 正逆位 · 元素)',
|
|
6499
|
+
hepan: '合盘(日主 · 夫妻宫 · 五行互补)',
|
|
6500
|
+
};
|
|
6501
|
+
|
|
6502
|
+
const confidenceOf = (dim) => {
|
|
6503
|
+
const n = Array.isArray(dim && dim.evidence) ? dim.evidence.length : 0;
|
|
6504
|
+
return n >= 3 ? '强' : n >= 2 ? '中' : '弱';
|
|
6505
|
+
};
|
|
6506
|
+
|
|
6507
|
+
const withReportMeta = (body, r, ask) => enrichPlain({
|
|
6508
|
+
...body,
|
|
6509
|
+
moduleType: MODULE_TYPE[r.system] || 'natal',
|
|
6510
|
+
system: r.system,
|
|
6511
|
+
systemLabel: SYSTEM_LABEL[r.system] || r.system,
|
|
6512
|
+
title: '解析与详解',
|
|
6513
|
+
dimensions: (body.dimensions || []).map((d) => ({ ...d, confidence: d.confidence || confidenceOf(d) })),
|
|
6514
|
+
sections: body.sections || [],
|
|
6515
|
+
outline: body.outline || [],
|
|
6516
|
+
tables: body.tables || [],
|
|
6517
|
+
technique: TECHNIQUE[r.system] || SYSTEM_LABEL[r.system] || r.system,
|
|
6518
|
+
disclaimer: body.disclaimer || DISCLAIMER,
|
|
6519
|
+
ask,
|
|
6520
|
+
}, r, ask);
|
|
6521
|
+
|
|
6412
6522
|
function interpret(r, opts) {
|
|
6413
6523
|
if (!isObj(r) || !r.system) return null;
|
|
6414
6524
|
const ask = askOf(opts);
|
|
6415
|
-
if (r.system === 'qimen') return
|
|
6525
|
+
if (r.system === 'qimen') return withReportMeta(interpretQimen(r, opts), r, ask);
|
|
6416
6526
|
const fn = BUILDERS[r.system];
|
|
6417
6527
|
if (!fn) return null;
|
|
6418
6528
|
let body;
|
|
@@ -6427,28 +6537,312 @@ function interpret(r, opts) {
|
|
|
6427
6537
|
lead: '这一盘的解析暂未生成,请稍后重试。',
|
|
6428
6538
|
dimensions: [],
|
|
6429
6539
|
sections: [],
|
|
6540
|
+
outline: [],
|
|
6541
|
+
tables: [],
|
|
6542
|
+
technique: TECHNIQUE[r.system] || '',
|
|
6430
6543
|
disclaimer: DISCLAIMER,
|
|
6431
6544
|
error: String(e && e.message),
|
|
6432
6545
|
ask,
|
|
6433
6546
|
};
|
|
6434
6547
|
}
|
|
6435
6548
|
const tuned = applyAsk(body.dimensions || [], ask, body.lead || '');
|
|
6436
|
-
return
|
|
6437
|
-
moduleType: MODULE_TYPE[r.system] || 'natal',
|
|
6438
|
-
system: r.system,
|
|
6439
|
-
systemLabel: SYSTEM_LABEL[r.system] || r.system,
|
|
6440
|
-
title: '解析与详解',
|
|
6549
|
+
return withReportMeta({
|
|
6441
6550
|
lead: tuned.lead,
|
|
6442
6551
|
dimensions: tuned.dims,
|
|
6443
6552
|
sections: body.sections || [],
|
|
6444
|
-
|
|
6445
|
-
|
|
6553
|
+
outline: body.outline || [],
|
|
6554
|
+
tables: body.tables || [],
|
|
6446
6555
|
}, r, ask);
|
|
6447
6556
|
}
|
|
6448
6557
|
|
|
6449
6558
|
return { DIMENSIONS, MODULE_TYPE, SYSTEM_LABEL, DIRECTIONS, DIRECTION_DEFAULT, dirOf, hexInfo, interpret };
|
|
6450
6559
|
})();
|
|
6451
6560
|
|
|
6561
|
+
__mods.followup = (function () {
|
|
6562
|
+
const { ZIWEI_STARS } = __mods['interpret-data'];
|
|
6563
|
+
|
|
6564
|
+
const TOPICS = [
|
|
6565
|
+
{ key: 'career', label: '事业', words: ['事业', '工作', '跳槽', '升职', '创业', '职业', '岗位', '离职', '加薪', '面试', 'offer'] },
|
|
6566
|
+
{ key: 'wealth', label: '财富', words: ['财', '钱', '收入', '投资', '买房', '存款', '亏', '赚', '分红'] },
|
|
6567
|
+
{ key: 'love', label: '感情', words: ['感情', '婚', '恋', '对象', '分手', '复合', '姻缘', '结婚', '桃花'] },
|
|
6568
|
+
{ key: 'health', label: '健康', words: ['健康', '病', '身体', '手术', '失眠', '体检', '医院'] },
|
|
6569
|
+
{ key: 'study', label: '学业', words: ['学业', '考试', '学习', '考研', '考公', '证书', '升学'] },
|
|
6570
|
+
{ key: 'travel', label: '出行', words: ['出行', '搬家', '旅行', '出国', '迁', '远行'] },
|
|
6571
|
+
];
|
|
6572
|
+
|
|
6573
|
+
const ZW_PALACE_BY_TOPIC = { career: '官禄', wealth: '财帛', love: '夫妻', health: '疾厄', study: '官禄', travel: '迁移', overall: '命宫' };
|
|
6574
|
+
|
|
6575
|
+
const parseYear = (q, r) => {
|
|
6576
|
+
const m = String(q).match(/(20\d{2})\s*年?/);
|
|
6577
|
+
if (m) return Number(m[1]);
|
|
6578
|
+
const base = Array.isArray(r.liunian) && r.liunian[0] ? Number(r.liunian[0].year) : null;
|
|
6579
|
+
if (!base) return null;
|
|
6580
|
+
if (/明年/.test(q)) return base + 1;
|
|
6581
|
+
if (/后年/.test(q)) return base + 2;
|
|
6582
|
+
if (/去年/.test(q)) return base - 1;
|
|
6583
|
+
if (/今年|本年/.test(q)) return base;
|
|
6584
|
+
return null;
|
|
6585
|
+
};
|
|
6586
|
+
|
|
6587
|
+
const topicOf = (q) => TOPICS.find((t) => t.words.some((w) => String(q).includes(w))) || null;
|
|
6588
|
+
|
|
6589
|
+
function baziAnswer(r, q) {
|
|
6590
|
+
const year = parseYear(q, r);
|
|
6591
|
+
const topic = topicOf(q);
|
|
6592
|
+
const liunian = Array.isArray(r.liunian) ? r.liunian : [];
|
|
6593
|
+
const dayun = Array.isArray(r.dayun?.list) ? r.dayun.list : [];
|
|
6594
|
+
const years = liunian.map((l) => l.year);
|
|
6595
|
+
if (year && !liunian.some((l) => Number(l.year) === year)) {
|
|
6596
|
+
return {
|
|
6597
|
+
ok: false, year, topic,
|
|
6598
|
+
answer: `这一盘已排的流年范围是 ${years[0]}–${years[years.length - 1]},没有 ${year} 年。可以把问题改到范围内,或用 asOf 指定你想看的年份重新排盘。`,
|
|
6599
|
+
evidence: [`已排流年:${years.join('、')}`], confidence: '弱',
|
|
6600
|
+
};
|
|
6601
|
+
}
|
|
6602
|
+
if (year) {
|
|
6603
|
+
const l = liunian.find((x) => Number(x.year) === year);
|
|
6604
|
+
const d = dayun.find((x) => Number(x.startAge) <= Number(l.age) && Number(l.age) <= Number(x.startAge) + 9) || null;
|
|
6605
|
+
const tier = l.luck?.tier || '平';
|
|
6606
|
+
const reasons = (l.luck?.reasons || []).slice(0, 3);
|
|
6607
|
+
const rel = (l.relations || []).join('、');
|
|
6608
|
+
const topicLine = topic ? topicSentence(r, topic.key) : '';
|
|
6609
|
+
return {
|
|
6610
|
+
ok: true, year, topic,
|
|
6611
|
+
answer: `${year} 年(${l.ganzhi})流年,十神为${l.stemTenGod || '—'},档位「${tier}」;所行大运 ${d ? `${d.ganzhi}(${d.luck?.tier || '平'})` : '未取到'}。` +
|
|
6612
|
+
`${reasons.length ? `理由:${reasons.join(',')}。` : ''}${rel ? `与该年地支相关的原局关系:${rel}。` : ''}${topicLine}`,
|
|
6613
|
+
evidence: [
|
|
6614
|
+
`流年 ${l.year} ${l.ganzhi}·${l.stemTenGod || ''}·${tier}`,
|
|
6615
|
+
d ? `大运 ${d.ganzhi}·${d.luck?.tier || '平'}` : '',
|
|
6616
|
+
rel ? `原局关系 ${rel}` : '',
|
|
6617
|
+
topic ? `问题方向:${topic.label}` : '',
|
|
6618
|
+
].filter(Boolean),
|
|
6619
|
+
confidence: d && reasons.length ? '强' : '中',
|
|
6620
|
+
};
|
|
6621
|
+
}
|
|
6622
|
+
if (topic) {
|
|
6623
|
+
const near = { wealth: 'overall', study: 'work', travel: 'overall' }[topic.key] || topic.key;
|
|
6624
|
+
const dim = (r.interpret?.dimensions || []).find((x) => x.key === topic.key || x.key === near);
|
|
6625
|
+
if (dim) {
|
|
6626
|
+
const groups = (r.frame && r.frame.godStats && r.frame.godStats.groups) || {};
|
|
6627
|
+
const quant = topic.key === 'wealth'
|
|
6628
|
+
? ` 财星权重 ${Number(groups['财'] || 0)}(只作结构参考,不含金额)。`
|
|
6629
|
+
: '';
|
|
6630
|
+
return {
|
|
6631
|
+
ok: true, year: null, topic,
|
|
6632
|
+
answer: `按${topic.label}这条线看:${dim.text}${quant}${dim.advice ? ` 建议:${dim.advice}` : ''}`,
|
|
6633
|
+
evidence: (dim.evidence || []).slice(0, 4), confidence: dim.confidence || '中',
|
|
6634
|
+
};
|
|
6635
|
+
}
|
|
6636
|
+
}
|
|
6637
|
+
return {
|
|
6638
|
+
ok: false, year: null, topic,
|
|
6639
|
+
answer: `这个问题里没有识别到具体的年份或方面。可以这样问:「2027 年事业怎么样」「财运如何」「感情在 2028 年」;已排流年是 ${years[0]}–${years[years.length - 1]}。`,
|
|
6640
|
+
evidence: [`可问年份:${years.join('、')}`], confidence: '弱',
|
|
6641
|
+
};
|
|
6642
|
+
}
|
|
6643
|
+
|
|
6644
|
+
function ziweiAnswer(r, q) {
|
|
6645
|
+
const year = parseYear(q, r);
|
|
6646
|
+
const topic = topicOf(q);
|
|
6647
|
+
const liunian = Array.isArray(r.liunian) ? r.liunian : [];
|
|
6648
|
+
if (year && !liunian.some((l) => Number(l.year) === year)) {
|
|
6649
|
+
return {
|
|
6650
|
+
ok: false, year, topic,
|
|
6651
|
+
answer: `这一盘的流年表覆盖 ${liunian[0]?.year}–${liunian[liunian.length - 1]?.year},没有 ${year} 年;可以换一个年份,或用 asOf 指定起点重新排盘。`,
|
|
6652
|
+
evidence: [`流年表:${liunian.map((l) => l.year).join('、')}`], confidence: '弱',
|
|
6653
|
+
};
|
|
6654
|
+
}
|
|
6655
|
+
if (year) {
|
|
6656
|
+
const l = liunian.find((x) => Number(x.year) === year);
|
|
6657
|
+
const dx = l.daxian || {};
|
|
6658
|
+
return {
|
|
6659
|
+
ok: true, year, topic,
|
|
6660
|
+
answer: `${year} 年(${l.ganzhi},${l.age} 岁)流年命宫落在「${l.lifePalace ? l.lifePalace.palace : '—'}」,四化为 ${(l.mutagen || []).join('、') || '不明显'};所行大限${dx.palace ? `在${dx.palace}(${dx.start}–${dx.end} 岁)` : '未取到'}。${topic ? `与「${topic.label}」对应的宫位信号见下条依据。` : ''}`,
|
|
6661
|
+
evidence: [
|
|
6662
|
+
`流年命宫 ${l.lifePalace ? l.lifePalace.palace : '—'}(${l.lifePalace ? l.lifePalace.branch : '—'})`,
|
|
6663
|
+
`四化 ${(l.mutagen || []).join('、') || '不明显'}`,
|
|
6664
|
+
dx.palace ? `大限 ${dx.palace}·${dx.start}–${dx.end}岁` : '',
|
|
6665
|
+
].filter(Boolean),
|
|
6666
|
+
confidence: (l.mutagen || []).length >= 3 ? '强' : '中',
|
|
6667
|
+
};
|
|
6668
|
+
}
|
|
6669
|
+
if (topic) {
|
|
6670
|
+
const name = ZW_PALACE_BY_TOPIC[topic.key] || '命宫';
|
|
6671
|
+
const p = (r.palaces || []).find((x) => x.palace === name);
|
|
6672
|
+
if (p) {
|
|
6673
|
+
const stars = (p.stars || []).filter((s) => s.type === '主星').map((s) => s.name);
|
|
6674
|
+
const trait = stars.map((s) => ZIWEI_STARS[s]?.trait).filter(Boolean).slice(0, 2).join(';');
|
|
6675
|
+
return {
|
|
6676
|
+
ok: true, year: null, topic,
|
|
6677
|
+
answer: `「${topic.label}」看${name}:主星${stars.length ? stars.join('、') : '无正曜(借对宫)'}${trait ? `——${trait}` : ''}。宫支${p.branch},${p.stems ? '' : ''}生年四化与煞星的影响需结合报告里的对应分节一起看。`,
|
|
6678
|
+
evidence: [`${name} ${p.branch}·${stars.join('、') || '无正曜'}`, ...(p.shensha || []).slice(0, 3)],
|
|
6679
|
+
confidence: stars.length ? '强' : '弱',
|
|
6680
|
+
};
|
|
6681
|
+
}
|
|
6682
|
+
}
|
|
6683
|
+
return {
|
|
6684
|
+
ok: false, year: null, topic,
|
|
6685
|
+
answer: '没有识别到具体年份或方面。可以问「2028 年事业」「感情怎么样」「财运在 2030 年」;也可以直接问某个宫位,如「夫妻宫」。',
|
|
6686
|
+
evidence: [], confidence: '弱',
|
|
6687
|
+
};
|
|
6688
|
+
}
|
|
6689
|
+
|
|
6690
|
+
function topicSentence(r, key) {
|
|
6691
|
+
const map = { career: '事业', wealth: '财富', love: '感情', health: '健康', study: '学业', travel: '出行' };
|
|
6692
|
+
return `这段时间可以重点对照报告里「${map[key] || '整体'}」一节看。`;
|
|
6693
|
+
}
|
|
6694
|
+
|
|
6695
|
+
function genericAnswer(r, q) {
|
|
6696
|
+
const topic = topicOf(q);
|
|
6697
|
+
const sections = Array.isArray(r.interpret?.sections) ? r.interpret.sections : [];
|
|
6698
|
+
const hit = topic
|
|
6699
|
+
? sections.find((s) => s.label.includes(topic.label) || s.text.includes(topic.label))
|
|
6700
|
+
: null;
|
|
6701
|
+
if (hit) {
|
|
6702
|
+
return { ok: true, year: null, topic, answer: hit.text, evidence: [`引用分节:${hit.label}`], confidence: '中' };
|
|
6703
|
+
}
|
|
6704
|
+
const first = sections[0];
|
|
6705
|
+
return {
|
|
6706
|
+
ok: false, year: null, topic,
|
|
6707
|
+
answer: first
|
|
6708
|
+
? `这一盘的追问需要落到具体方面(事业 / 财富 / 感情 / 健康 / 学业 / 出行)。先看「${first.label}」这一节,或把问题说得更具体一点。`
|
|
6709
|
+
: '这一盘暂时没有可追问的分节;先看完整解析,再问具体方面。',
|
|
6710
|
+
evidence: [], confidence: '弱',
|
|
6711
|
+
};
|
|
6712
|
+
}
|
|
6713
|
+
|
|
6714
|
+
function followup(r, question) {
|
|
6715
|
+
const q = String(question || '').trim();
|
|
6716
|
+
const result = r && r.system === 'bazi' ? baziAnswer(r, q)
|
|
6717
|
+
: r && r.system === 'ziwei' ? ziweiAnswer(r, q)
|
|
6718
|
+
: genericAnswer(r, q);
|
|
6719
|
+
return { question: q, ...result };
|
|
6720
|
+
}
|
|
6721
|
+
|
|
6722
|
+
return { followup };
|
|
6723
|
+
})();
|
|
6724
|
+
|
|
6725
|
+
__mods.crosscheck = (function () {
|
|
6726
|
+
const { ZIWEI_STARS } = __mods['interpret-data'];
|
|
6727
|
+
|
|
6728
|
+
const groupsOf = (bazi) => (bazi && bazi.frame && bazi.frame.godStats && bazi.frame.godStats.groups) || {};
|
|
6729
|
+
const topOf = (groups) => Object.entries(groups).sort((a, b) => Number(b[1]) - Number(a[1]))[0] || null;
|
|
6730
|
+
const zwPalace = (zw, name) => (zw.palaces || []).find((p) => p.palace === name) || null;
|
|
6731
|
+
const zwMain = (p) => (p && p.stars ? p.stars.filter((s) => s.type === '主星').map((s) => s.name) : []);
|
|
6732
|
+
const countSha = (p) => (p && p.stars ? p.stars.filter((s) => s.type === '煞星').length : 0);
|
|
6733
|
+
const tierOf = (bazi) => {
|
|
6734
|
+
const age = Number(bazi.liunian && bazi.liunian[0] ? bazi.liunian[0].age : NaN);
|
|
6735
|
+
const list = (bazi.dayun && bazi.dayun.list) || [];
|
|
6736
|
+
let cur = null;
|
|
6737
|
+
for (const d of list) if (Number.isFinite(age) && Number(d.startAge) <= age) cur = d;
|
|
6738
|
+
return cur ? (cur.luck && cur.luck.tier) || '平' : '—';
|
|
6739
|
+
};
|
|
6740
|
+
const daxianOf = (zw) => {
|
|
6741
|
+
const age = Number(zw.liunian && zw.liunian[0] ? zw.liunian[0].age : NaN);
|
|
6742
|
+
for (const p of zw.palaces || []) {
|
|
6743
|
+
const d = p.daxian || {};
|
|
6744
|
+
if (Number.isFinite(age) && Number(d.start) <= age && age <= Number(d.end)) return p;
|
|
6745
|
+
}
|
|
6746
|
+
return null;
|
|
6747
|
+
};
|
|
6748
|
+
|
|
6749
|
+
function crossCheck(bazi, zw) {
|
|
6750
|
+
const groups = groupsOf(bazi);
|
|
6751
|
+
const top = topOf(groups);
|
|
6752
|
+
const items = [];
|
|
6753
|
+
const push = (key, label, baziText, ziweiText, stance, note) => items.push({ key, label, bazi: baziText, ziwei: ziweiText, stance, note });
|
|
6754
|
+
|
|
6755
|
+
{
|
|
6756
|
+
const career = zwPalace(zw, '官禄');
|
|
6757
|
+
const main = zwMain(career);
|
|
6758
|
+
const baziStrong = Number(groups['官杀'] || 0) + Number(groups['食伤'] || 0) >= 2;
|
|
6759
|
+
const ziweiHas = main.length > 0;
|
|
6760
|
+
const stance = baziStrong && ziweiHas ? '同向' : !baziStrong && !ziweiHas ? '同向' : '有张力';
|
|
6761
|
+
push('career', '事业主线',
|
|
6762
|
+
`${top ? `十神以${top[0]}最重(${top[1]})` : '十神未取到'};官杀+食伤权重 ${(Number(groups['官杀'] || 0) + Number(groups['食伤'] || 0)).toFixed(1)}`,
|
|
6763
|
+
main.length ? `官禄宫主星 ${main.join('、')}${ZIWEI_STARS[main[0]] ? `(${ZIWEI_STARS[main[0]].work})` : ''}` : '官禄无正曜',
|
|
6764
|
+
stance,
|
|
6765
|
+
stance === '同向' ? '两边都指向(或都不强调)事业主线,方向可互参' : '一边强调事业主线、一边信号弱,建议以信号强的一边为主,另一边作补充');
|
|
6766
|
+
}
|
|
6767
|
+
|
|
6768
|
+
{
|
|
6769
|
+
const wealth = zwPalace(zw, '财帛');
|
|
6770
|
+
const main = zwMain(wealth);
|
|
6771
|
+
const sha = countSha(wealth);
|
|
6772
|
+
const w = Number(groups['财'] || 0);
|
|
6773
|
+
const baziStrong = w >= 2;
|
|
6774
|
+
const ziweiStrong = main.length > 0;
|
|
6775
|
+
const stance = baziStrong && ziweiStrong ? '同向' : !baziStrong && !ziweiStrong ? '同向' : '有张力';
|
|
6776
|
+
push('wealth', '财运结构',
|
|
6777
|
+
`财星权重 ${w}${baziStrong ? '(偏强)' : '(偏弱)'}`,
|
|
6778
|
+
`${main.length ? `财帛主星 ${main.join('、')}` : '财帛无正曜'}${sha ? `;煞星 ${sha} 颗` : ''}`,
|
|
6779
|
+
stance,
|
|
6780
|
+
'两套体系对「财」的定义不同:八字看十神财星,紫微看财帛宫,只作对照,不作数值合并');
|
|
6781
|
+
}
|
|
6782
|
+
|
|
6783
|
+
{
|
|
6784
|
+
const spouse = zwPalace(zw, '夫妻');
|
|
6785
|
+
const main = zwMain(spouse);
|
|
6786
|
+
const isMale = bazi.input && bazi.input.gender === 'male';
|
|
6787
|
+
const key = isMale ? '财' : '官杀';
|
|
6788
|
+
const v = Number(groups[key] || 0);
|
|
6789
|
+
const baziStrong = v >= 2;
|
|
6790
|
+
const ziweiStrong = main.length > 0;
|
|
6791
|
+
const stance = baziStrong && ziweiStrong ? '同向' : !baziStrong && !ziweiStrong ? '同向' : '有张力';
|
|
6792
|
+
push('love', '感情线索',
|
|
6793
|
+
`${isMale ? '妻' : '夫'}星(${key})权重 ${v}${baziStrong ? '(不弱)' : '(偏弱)'}`,
|
|
6794
|
+
main.length ? `夫妻宫主星 ${main.join('、')}${ZIWEI_STARS[main[0]] ? `(${ZIWEI_STARS[main[0]].love})` : ''}` : '夫妻宫无正曜',
|
|
6795
|
+
stance,
|
|
6796
|
+
stance === '同向' ? '两边对感情的强弱判断接近' : '一边说缘分不弱、一边主星信号弱,宜按「多主动创造场景」处理');
|
|
6797
|
+
}
|
|
6798
|
+
|
|
6799
|
+
{
|
|
6800
|
+
const wx = bazi.wuxing || {};
|
|
6801
|
+
const weakest = Object.entries(wx).sort((a, b) => Number(a[1]) - Number(b[1]))[0];
|
|
6802
|
+
const health = zwPalace(zw, '疾厄');
|
|
6803
|
+
const main = zwMain(health);
|
|
6804
|
+
const sha = countSha(health);
|
|
6805
|
+
push('health', '身体关注点',
|
|
6806
|
+
weakest ? `最弱五行 ${weakest[0]}(${weakest[1]})` : '五行未取到',
|
|
6807
|
+
`${main.length ? `疾厄主星 ${main.join('、')}` : '疾厄无正曜'}${sha ? `;煞星 ${sha} 颗` : ''}`,
|
|
6808
|
+
'互补',
|
|
6809
|
+
'两边指向的器官/系统不一定相同,合并起来看更稳;任何健康问题以体检与医生为准');
|
|
6810
|
+
}
|
|
6811
|
+
|
|
6812
|
+
{
|
|
6813
|
+
const t = tierOf(bazi);
|
|
6814
|
+
const d = daxianOf(zw);
|
|
6815
|
+
const sha = d ? countSha(d) : 0;
|
|
6816
|
+
const good = ['吉', '大吉'];
|
|
6817
|
+
const bad = ['忌', '大忌'];
|
|
6818
|
+
const baziGood = good.includes(t);
|
|
6819
|
+
const baziBad = bad.includes(t);
|
|
6820
|
+
const ziweiHeavy = sha >= 2;
|
|
6821
|
+
let stance = '有张力';
|
|
6822
|
+
let note = '一边顺、一边压,按「大方向跟顺的一边、具体动作避开压的年份」处理';
|
|
6823
|
+
if ((baziGood && !ziweiHeavy) || (baziBad && ziweiHeavy) || (!baziGood && !baziBad && !ziweiHeavy)) {
|
|
6824
|
+
stance = '同向';
|
|
6825
|
+
note = '两边对当前阶段的松紧判断接近';
|
|
6826
|
+
}
|
|
6827
|
+
push('rhythm', '当前节奏',
|
|
6828
|
+
`大运档位 ${t}`,
|
|
6829
|
+
`${d ? `大限在${d.palace}` : '大限未取到'}${sha ? `;煞星 ${sha} 颗` : ';无煞星'}`,
|
|
6830
|
+
stance, note);
|
|
6831
|
+
}
|
|
6832
|
+
|
|
6833
|
+
return { items };
|
|
6834
|
+
}
|
|
6835
|
+
|
|
6836
|
+
function crossText(cross) {
|
|
6837
|
+
if (!cross || !Array.isArray(cross.items)) return '';
|
|
6838
|
+
return cross.items
|
|
6839
|
+
.map((i) => `· ${i.label}:八字——${i.bazi};紫微——${i.ziwei};判断:${i.stance}(${i.note})`)
|
|
6840
|
+
.join('\n');
|
|
6841
|
+
}
|
|
6842
|
+
|
|
6843
|
+
return { crossCheck, crossText };
|
|
6844
|
+
})();
|
|
6845
|
+
|
|
6452
6846
|
__mods.index = (function () {
|
|
6453
6847
|
const { buildBazi } = __mods.bazi;
|
|
6454
6848
|
const { buildLiuyao, tossLines } = __mods.liuyao;
|
|
@@ -6463,6 +6857,8 @@ const { geocodeAddress, resolveAddress } = __mods.geo;
|
|
|
6463
6857
|
const { toJDN, ganzhiName, dayGanzhiIndex } = __mods.calendar;
|
|
6464
6858
|
const { randomOf, isSeed } = __mods.random;
|
|
6465
6859
|
const { interpret, DIRECTIONS, DIRECTION_DEFAULT } = __mods.interpret;
|
|
6860
|
+
const { followup } = __mods.followup;
|
|
6861
|
+
const { crossCheck, crossText } = __mods.crosscheck;
|
|
6466
6862
|
const { fail } = __mods.fail;
|
|
6467
6863
|
const { assertCivil } = __mods.validate;
|
|
6468
6864
|
|
|
@@ -6722,6 +7118,26 @@ function compute(args = {}) {
|
|
|
6722
7118
|
direction: typeof args.direction === 'string' ? args.direction : 'general',
|
|
6723
7119
|
});
|
|
6724
7120
|
}
|
|
7121
|
+
if (args.cross === true && (r.system === 'bazi' || r.system === 'ziwei')) {
|
|
7122
|
+
const cdt = parseDateTime(args.datetime);
|
|
7123
|
+
const common = {
|
|
7124
|
+
...cdt,
|
|
7125
|
+
gender: requireGender(args.gender),
|
|
7126
|
+
longitude: typeof args.longitude === 'number' ? args.longitude : undefined,
|
|
7127
|
+
address: typeof args.address === 'string' ? args.address : undefined,
|
|
7128
|
+
geo: args.geo && typeof args.geo === 'object' ? args.geo : undefined,
|
|
7129
|
+
trueSolar: args.trueSolar !== false,
|
|
7130
|
+
};
|
|
7131
|
+
const asOf = checkAsOf(args.asOf);
|
|
7132
|
+
const other = r.system === 'bazi'
|
|
7133
|
+
? buildZiwei({ ...common, leapAsNext: args.leapAsNext === true, asOf })
|
|
7134
|
+
: buildBazi({ ...common, lateZi: args.lateZi !== false, nowYear: asOf ? asOf.year : undefined });
|
|
7135
|
+
r.cross = crossCheck(r.system === 'bazi' ? r : other, r.system === 'ziwei' ? r : other);
|
|
7136
|
+
if (r.interpret) {
|
|
7137
|
+
r.interpret.sections.push({ key: 'crossSystem', label: '八字 × 紫微 交叉验证', text: crossText(r.cross) });
|
|
7138
|
+
}
|
|
7139
|
+
}
|
|
7140
|
+
if (typeof args.ask === 'string' && args.ask.trim()) r.followup = followup(r, args.ask);
|
|
6725
7141
|
return r;
|
|
6726
7142
|
}
|
|
6727
7143
|
|
|
@@ -6731,9 +7147,12 @@ function interpretText(i) {
|
|
|
6731
7147
|
if (i.answer) out.push(`▶ 先答所问:${i.answer}`);
|
|
6732
7148
|
if (i.plain) out.push(`▶ 说人话:${i.plain}`);
|
|
6733
7149
|
if (i.lead) out.push(i.lead);
|
|
7150
|
+
if (Array.isArray(i.outline) && i.outline.length) {
|
|
7151
|
+
out.push('一页读懂:' + i.outline.map((o) => `${o.label}·${o.text}`).join(' '));
|
|
7152
|
+
}
|
|
6734
7153
|
if (i.error) out.push(`⚠ 解析生成失败:${i.error}(上方盘面数据本身可用)`);
|
|
6735
7154
|
for (const d of i.dimensions || []) {
|
|
6736
|
-
const evidence = Array.isArray(d.evidence) && d.evidence.length ? `\n 依据:${d.evidence.join(';')}` : '';
|
|
7155
|
+
const evidence = Array.isArray(d.evidence) && d.evidence.length ? `\n 依据:${d.evidence.join(';')}${d.confidence ? ` 置信度:${d.confidence}` : ''}` : '';
|
|
6737
7156
|
const plain = d.plain ? `(${d.plain})` : '';
|
|
6738
7157
|
const know = (d.knowledge || [])
|
|
6739
7158
|
.map((k) => `\n 规则·${k.gist}〔${k.statusLabel}〕${k.detail} 出处:${k.source}${k.note ? ` 注:${k.note}` : ''}`)
|
|
@@ -6741,6 +7160,11 @@ function interpretText(i) {
|
|
|
6741
7160
|
out.push(`${d.label}:${plain}${d.text}${d.advice ? ` 建议:${d.advice}` : ''}${evidence}${know}`);
|
|
6742
7161
|
}
|
|
6743
7162
|
for (const s of i.sections || []) out.push(`${s.label}:${s.text}`);
|
|
7163
|
+
for (const t of i.tables || []) {
|
|
7164
|
+
if (!Array.isArray(t.rows) || !t.rows.length) continue;
|
|
7165
|
+
out.push(`【${t.title}】`);
|
|
7166
|
+
out.push([t.columns.join(' | '), ...t.rows.map((r) => r.join(' | '))].join('\n'));
|
|
7167
|
+
}
|
|
6744
7168
|
if (Array.isArray(i.followups) && i.followups.length) {
|
|
6745
7169
|
out.push('还可以这样追问:' + i.followups.map((q) => `「${q}」`).join(' '));
|
|
6746
7170
|
}
|
|
@@ -6918,12 +7342,20 @@ function computeRaw(args = {}) {
|
|
|
6918
7342
|
|
|
6919
7343
|
function renderText(result) {
|
|
6920
7344
|
const base = result.summary ?? JSON.stringify(result, null, 2);
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
7345
|
+
const parts = [base];
|
|
7346
|
+
if (result.interpret) {
|
|
7347
|
+
const extra = interpretText(result.interpret);
|
|
7348
|
+
if (extra) parts.push(extra);
|
|
7349
|
+
}
|
|
7350
|
+
if (result.cross) parts.push(`【八字 × 紫微 交叉验证】\n${crossText(result.cross)}`);
|
|
7351
|
+
if (result.followup) {
|
|
7352
|
+
const f = result.followup;
|
|
7353
|
+
parts.push(`【追问】${f.question}\n${f.answer}${f.evidence && f.evidence.length ? `\n 依据:${f.evidence.join(';')} 置信度:${f.confidence}` : ''}`);
|
|
7354
|
+
}
|
|
7355
|
+
return parts.filter(Boolean).join('\n\n');
|
|
6924
7356
|
}
|
|
6925
7357
|
|
|
6926
|
-
return { interpret, DIRECTIONS, DIRECTION_DEFAULT, BRIGHTNESS, flowOf, geocodeAddress, resolveAddress, buildBazi, buildLiuyao, tossLines, parseDateTime, compute, interpretText, renderText };
|
|
7358
|
+
return { interpret, DIRECTIONS, DIRECTION_DEFAULT, BRIGHTNESS, flowOf, geocodeAddress, resolveAddress, buildBazi, buildLiuyao, tossLines, followup, crossCheck, crossText, parseDateTime, compute, interpretText, renderText };
|
|
6927
7359
|
})();
|
|
6928
7360
|
|
|
6929
7361
|
const Engine = __mods.index;
|
|
@@ -7311,6 +7743,48 @@ return { interpret, DIRECTIONS, DIRECTION_DEFAULT, BRIGHTNESS, flowOf, geocodeAd
|
|
|
7311
7743
|
.mp-it-sec{margin-bottom:11px}
|
|
7312
7744
|
.mp-it-sh{font-size:13px;font-weight:700;color:var(--lu);letter-spacing:.06em;margin-bottom:4px}
|
|
7313
7745
|
.mp-it-stext{font-size:13px;line-height:1.9;color:var(--ink2);text-align:justify}
|
|
7746
|
+
.mp-outline{margin:12px 16px 0;border:1px solid var(--line);border-left:3px solid var(--lu);border-radius:8px;background:var(--card);padding:10px 12px}
|
|
7747
|
+
.mp-outline-h{font-size:12px;font-weight:700;letter-spacing:.12em;color:var(--lu);margin-bottom:6px;font-family:system-ui,sans-serif}
|
|
7748
|
+
.mp-outline-row{display:grid;grid-template-columns:56px minmax(0,1fr);gap:8px;padding:3px 0;font-size:13px;line-height:1.7;color:var(--ink2)}
|
|
7749
|
+
.mp-outline-row b{color:var(--label);font-weight:600;font-family:system-ui,sans-serif}
|
|
7750
|
+
.mp-toc{display:flex;flex-wrap:wrap;gap:6px 10px;margin:10px 16px 0;padding:8px 10px;border:1px dashed var(--line);border-radius:8px;font-size:12px;font-family:system-ui,sans-serif}
|
|
7751
|
+
.mp-toc a{color:var(--lu);text-decoration:none;border-bottom:1px dotted rgba(var(--lu-rgb),.5)}
|
|
7752
|
+
.mp-toc a:hover{color:var(--ink)}
|
|
7753
|
+
.mp-it-ev{margin-top:7px;border:1px solid var(--line);border-radius:6px;background:var(--band);font-size:12px;font-family:system-ui,sans-serif}
|
|
7754
|
+
.mp-it-ev>summary{cursor:pointer;padding:6px 9px;color:var(--muted);list-style:none}
|
|
7755
|
+
.mp-it-ev>summary::-webkit-details-marker{display:none}
|
|
7756
|
+
.mp-it-ev>summary::before{content:'▸ ';color:var(--label)}
|
|
7757
|
+
.mp-it-ev[open]>summary::before{content:'▾ '}
|
|
7758
|
+
.mp-it-ev-body{padding:2px 9px 8px;display:flex;flex-direction:column;gap:4px}
|
|
7759
|
+
.mp-it-ev-item{color:var(--ink2);line-height:1.7;padding-left:12px;position:relative}
|
|
7760
|
+
.mp-it-ev-item::before{content:'·';position:absolute;left:2px;color:var(--label)}
|
|
7761
|
+
.mp-it-ev-tech{margin-top:4px;color:var(--label);font-size:11px;letter-spacing:.06em}
|
|
7762
|
+
.mp-it-conf{font-size:11px;font-family:system-ui,sans-serif;border-radius:999px;padding:1px 8px;margin-left:6px;border:1px solid var(--line);color:var(--muted)}
|
|
7763
|
+
.mp-it-conf.c-强{color:var(--lu);border-color:rgba(var(--lu-rgb),.4)}
|
|
7764
|
+
.mp-it-conf.c-中{color:var(--label);border-color:var(--line)}
|
|
7765
|
+
.mp-it-conf.c-弱{color:var(--red);border-color:rgba(var(--red-rgb),.4)}
|
|
7766
|
+
.mp-tables{border-top:1px solid var(--line);padding:12px 16px 4px;background:var(--card)}
|
|
7767
|
+
.mp-table-wrap{margin-bottom:12px}
|
|
7768
|
+
.mp-table-h{font-size:12px;font-weight:700;letter-spacing:.1em;color:var(--lu);margin-bottom:5px;font-family:system-ui,sans-serif}
|
|
7769
|
+
.mp-table-scroll{overflow-x:auto;border:1px solid var(--line);border-radius:6px}
|
|
7770
|
+
.mp-table{width:100%;border-collapse:collapse;font-size:12px;line-height:1.6;color:var(--ink2);font-family:system-ui,sans-serif}
|
|
7771
|
+
.mp-table th,.mp-table td{padding:5px 9px;text-align:left;vertical-align:top;border-bottom:1px solid var(--line);white-space:nowrap}
|
|
7772
|
+
.mp-table th{background:var(--band);color:var(--label);font-weight:600;font-size:11px;letter-spacing:.06em}
|
|
7773
|
+
.mp-table tbody tr:last-child td{border-bottom:none}
|
|
7774
|
+
.mp-table tbody tr:nth-child(even) td{background:rgba(0,0,0,.02)}
|
|
7775
|
+
@media print{
|
|
7776
|
+
.mp-toc{display:none}
|
|
7777
|
+
.mp-it.folded .mp-it-wrap{display:block}
|
|
7778
|
+
.mp-table-scroll{overflow:visible}
|
|
7779
|
+
.mp-table th,.mp-table td{white-space:normal}
|
|
7780
|
+
.mp-table-wrap,.mp-it-sec,.mp-it-dim{break-inside:avoid}
|
|
7781
|
+
.mp-table-wrap{page-break-inside:avoid}
|
|
7782
|
+
}
|
|
7783
|
+
.mp-fu{margin:12px 16px;border:1px solid var(--line);border-left:3px solid var(--lu);border-radius:8px;background:var(--card);padding:10px 12px;font-size:13px;line-height:1.8;color:var(--ink2)}
|
|
7784
|
+
.mp-fu.miss{border-left-color:var(--red)}
|
|
7785
|
+
.mp-fu-h{font-size:12px;font-weight:700;letter-spacing:.08em;color:var(--lu);margin-bottom:4px;font-family:system-ui,sans-serif}
|
|
7786
|
+
.mp-fu.miss .mp-fu-h{color:var(--red)}
|
|
7787
|
+
.mp-fu-ev{margin-top:5px;font-size:12px;color:var(--muted);font-family:system-ui,sans-serif}
|
|
7314
7788
|
.mp-it-dis{padding:11px 16px;border-top:1px solid var(--line);background:var(--band);font-size:12px;line-height:1.75;color:var(--muted);font-family:system-ui,sans-serif}
|
|
7315
7789
|
|
|
7316
7790
|
@media (max-width:640px){
|
|
@@ -8161,15 +8635,30 @@ return { interpret, DIRECTIONS, DIRECTION_DEFAULT, BRIGHTNESS, flowOf, geocodeAd
|
|
|
8161
8635
|
if (!hasBody && !it.error && !it.answer) return '';
|
|
8162
8636
|
const folded = !!(opt && opt.folded);
|
|
8163
8637
|
const dims = (it.dimensions || []).map((d, i) => `<div class="mp-it-dim${d.focused ? ' focus' : ''}">
|
|
8164
|
-
<div class="mp-it-dh"><span class="mp-it-dno">${i + 1}</span><span class="mp-it-dlabel">${esc(d.label)}</span>${d.focused ? '<span class="mp-it-focus">最贴近你的问题</span>' : ''}</div>
|
|
8638
|
+
<div class="mp-it-dh"><span class="mp-it-dno">${i + 1}</span><span class="mp-it-dlabel">${esc(d.label)}</span>${d.focused ? '<span class="mp-it-focus">最贴近你的问题</span>' : ''}${d.confidence ? `<span class="mp-it-conf c-${esc(d.confidence)}">置信度 ${esc(d.confidence)}</span>` : ''}</div>
|
|
8165
8639
|
${d.plain ? `<div class="mp-it-dplain">${esc(d.plain)}</div>` : ''}
|
|
8166
8640
|
<div class="mp-it-dtext">${esc(d.text)}</div>
|
|
8167
|
-
${(d.evidence && d.evidence.length) ? `<div class="mp-it-
|
|
8641
|
+
${(d.evidence && d.evidence.length) ? `<details class="mp-it-ev"><summary>依据 · ${esc(d.evidence.length)} 条盘面事实</summary><div class="mp-it-ev-body">${d.evidence.map((x) => `<span class="mp-it-ev-item">${esc(x)}</span>`).join('')}<span class="mp-it-ev-tech">技法:${esc(it.technique || it.systemLabel || '')}</span></div></details>` : ''}
|
|
8168
8642
|
${(d.knowledge && d.knowledge.length) ? `<div class="mp-it-know">${d.knowledge.map((k) => `<div class="know-row"><span class="know-status ${k.status}">${esc(k.statusLabel)}</span><span class="know-body"><b>${esc(k.gist)}</b>${esc(k.detail)}${k.source ? `<i>出处:${esc(k.source)}</i>` : ''}${k.note ? `<em>注:${esc(k.note)}</em>` : ''}</span></div>`).join('')}</div>` : ''}
|
|
8169
8643
|
${d.advice ? `<div class="mp-it-adv"><b>建议</b>${esc(d.advice)}</div>` : ''}
|
|
8170
8644
|
</div>`).join('');
|
|
8645
|
+
const outline = (it.outline && it.outline.length)
|
|
8646
|
+
? `<div class="mp-outline"><div class="mp-outline-h">一页读懂</div>${it.outline.map((o) => `<div class="mp-outline-row"><b>${esc(o.label)}</b><span>${esc(o.text)}</span></div>`).join('')}</div>`
|
|
8647
|
+
: '';
|
|
8648
|
+
const toc = (it.sections && it.sections.length)
|
|
8649
|
+
? `<nav class="mp-toc" aria-label="报告目录">${it.sections.map((s) => `<a href="#mp-sec-${esc(s.key)}">${esc(s.label)}</a>`).join('')}</nav>`
|
|
8650
|
+
: '';
|
|
8651
|
+
const tables = (it.tables && it.tables.length)
|
|
8652
|
+
? `<div class="mp-tables">${it.tables.filter((t) => Array.isArray(t.rows) && t.rows.length).map((t) => `<div class="mp-table-wrap">
|
|
8653
|
+
<div class="mp-table-h">${esc(t.title)}</div>
|
|
8654
|
+
<div class="mp-table-scroll"><table class="mp-table">
|
|
8655
|
+
<thead><tr>${t.columns.map((c) => `<th>${esc(c)}</th>`).join('')}</tr></thead>
|
|
8656
|
+
<tbody>${t.rows.map((row) => `<tr>${row.map((c) => `<td>${esc(c)}</td>`).join('')}</tr>`).join('')}</tbody>
|
|
8657
|
+
</table></div>
|
|
8658
|
+
</div>`).join('')}</div>`
|
|
8659
|
+
: '';
|
|
8171
8660
|
const secs = (it.sections && it.sections.length)
|
|
8172
|
-
? `<div class="mp-it-secs">${it.sections.map((s) => `<div class="mp-it-sec">
|
|
8661
|
+
? `<div class="mp-it-secs">${it.sections.map((s) => `<div class="mp-it-sec" id="mp-sec-${esc(s.key)}">
|
|
8173
8662
|
<div class="mp-it-sh">${esc(s.label)}</div>
|
|
8174
8663
|
<div class="mp-it-stext">${esc(s.text)}</div>
|
|
8175
8664
|
</div>`).join('')}</div>`
|
|
@@ -8199,8 +8688,11 @@ return { interpret, DIRECTIONS, DIRECTION_DEFAULT, BRIGHTNESS, flowOf, geocodeAd
|
|
|
8199
8688
|
${plain}
|
|
8200
8689
|
${it.lead ? `<div class="mp-it-lead">${esc(it.lead)}</div>` : ''}
|
|
8201
8690
|
${it.error ? `<div class="mp-it-err"><b>⚠ 解析生成失败</b>${esc(it.error)}——上方盘面数据本身可用</div>` : ''}
|
|
8691
|
+
${outline}
|
|
8692
|
+
${toc}
|
|
8202
8693
|
<div class="mp-it-body">${dims}</div>
|
|
8203
8694
|
${secs}
|
|
8695
|
+
${tables}
|
|
8204
8696
|
${fu}
|
|
8205
8697
|
${gloss}
|
|
8206
8698
|
<div class="mp-it-dis">${esc(it.disclaimer)}</div>
|
|
@@ -8208,9 +8700,127 @@ return { interpret, DIRECTIONS, DIRECTION_DEFAULT, BRIGHTNESS, flowOf, geocodeAd
|
|
|
8208
8700
|
</div>`;
|
|
8209
8701
|
};
|
|
8210
8702
|
|
|
8703
|
+
pp.followupHTML = function (fx) {
|
|
8704
|
+
if (!fx) return '';
|
|
8705
|
+
const ev = (fx.evidence && fx.evidence.length)
|
|
8706
|
+
? `<div class="mp-fu-ev">依据:${fx.evidence.map((x) => esc(x)).join(';')} 置信度:${esc(fx.confidence || '弱')}</div>`
|
|
8707
|
+
: '';
|
|
8708
|
+
return `<div class="mp-fu${fx.ok ? '' : ' miss'}">
|
|
8709
|
+
<div class="mp-fu-h">追问 · ${esc(fx.question)}</div>
|
|
8710
|
+
<div class="mp-fu-a">${esc(fx.answer)}</div>
|
|
8711
|
+
${ev}
|
|
8712
|
+
</div>`;
|
|
8713
|
+
};
|
|
8714
|
+
|
|
8211
8715
|
pp.resultWithInterpret = function (html, it, opt) {
|
|
8212
8716
|
return (html || '') + pp.interpretHTML(it, opt);
|
|
8213
8717
|
};
|
|
8718
|
+
|
|
8719
|
+
pp.summaryCardPNG = function (r, it) {
|
|
8720
|
+
try {
|
|
8721
|
+
if (typeof document === 'undefined' || !document.createElement) return '';
|
|
8722
|
+
const outline = (it && it.outline) || [];
|
|
8723
|
+
const tables = ((it && it.tables) || []).filter((t) => Array.isArray(t.rows) && t.rows.length);
|
|
8724
|
+
const systemLabel = (it && it.systemLabel) || (r && r.system) || '命理报告';
|
|
8725
|
+
const W = 900;
|
|
8726
|
+
const PAD = 44;
|
|
8727
|
+
const line = 26;
|
|
8728
|
+
const font = (size, bold) => `${bold ? '600 ' : ''}${size}px "PingFang SC","Microsoft YaHei","Noto Sans CJK SC",sans-serif`;
|
|
8729
|
+
const canvas = document.createElement('canvas');
|
|
8730
|
+
const ctx = canvas.getContext ? canvas.getContext('2d') : null;
|
|
8731
|
+
if (!ctx) return '';
|
|
8732
|
+
const wrap = (text, maxWidth) => {
|
|
8733
|
+
const out = [];
|
|
8734
|
+
let cur = '';
|
|
8735
|
+
for (const ch of String(text)) {
|
|
8736
|
+
const test = cur + ch;
|
|
8737
|
+
if (ctx.measureText(test).width > maxWidth && cur) { out.push(cur); cur = ch; } else cur = test;
|
|
8738
|
+
}
|
|
8739
|
+
if (cur) out.push(cur);
|
|
8740
|
+
return out.length ? out : [''];
|
|
8741
|
+
};
|
|
8742
|
+
ctx.font = font(15);
|
|
8743
|
+
let bodyH = 0;
|
|
8744
|
+
const outlineBlocks = outline.map((o) => {
|
|
8745
|
+
const lines = wrap(o.text, W - PAD * 2 - 70);
|
|
8746
|
+
bodyH += Math.min(lines.length, 2) * line + 10;
|
|
8747
|
+
return { o, lines: lines.slice(0, 2) };
|
|
8748
|
+
});
|
|
8749
|
+
const table = tables[0] || null;
|
|
8750
|
+
const tableRows = table ? table.rows.slice(0, 6) : [];
|
|
8751
|
+
const tableH = table ? 54 + tableRows.length * 34 : 0;
|
|
8752
|
+
const H = 150 + bodyH + (outlineBlocks.length ? 34 : 0) + tableH + 120;
|
|
8753
|
+
|
|
8754
|
+
canvas.width = W;
|
|
8755
|
+
canvas.height = H;
|
|
8756
|
+
ctx.fillStyle = 'rgb(255,255,255)';
|
|
8757
|
+
ctx.fillRect(0, 0, W, H);
|
|
8758
|
+
ctx.fillStyle = 'rgb(31,111,63)';
|
|
8759
|
+
ctx.fillRect(0, 0, W, 8);
|
|
8760
|
+
|
|
8761
|
+
let y = 52;
|
|
8762
|
+
ctx.fillStyle = 'rgb(27,27,27)';
|
|
8763
|
+
ctx.font = font(28, true);
|
|
8764
|
+
ctx.fillText(`${systemLabel} · 摘要`, PAD, y);
|
|
8765
|
+
y += 30;
|
|
8766
|
+
ctx.fillStyle = 'rgb(111,106,96)';
|
|
8767
|
+
ctx.font = font(14);
|
|
8768
|
+
const meta = [r && r.input && r.input.datetime ? `出生/起局:${r.input.datetime}` : '', '本地计算 · 可复现'].filter(Boolean).join(' ');
|
|
8769
|
+
ctx.fillText(meta, PAD, y);
|
|
8770
|
+
y += 34;
|
|
8771
|
+
|
|
8772
|
+
if (outlineBlocks.length) {
|
|
8773
|
+
ctx.fillStyle = 'rgb(31,111,63)';
|
|
8774
|
+
ctx.font = font(16, true);
|
|
8775
|
+
ctx.fillText('一页读懂', PAD, y);
|
|
8776
|
+
y += 26;
|
|
8777
|
+
for (const { o, lines } of outlineBlocks) {
|
|
8778
|
+
ctx.fillStyle = 'rgb(138,131,120)';
|
|
8779
|
+
ctx.font = font(14, true);
|
|
8780
|
+
ctx.fillText(o.label, PAD, y);
|
|
8781
|
+
ctx.fillStyle = 'rgb(63,58,51)';
|
|
8782
|
+
ctx.font = font(15);
|
|
8783
|
+
lines.forEach((text, i) => ctx.fillText(text, PAD + 70, y + i * line));
|
|
8784
|
+
y += lines.length * line + 10;
|
|
8785
|
+
}
|
|
8786
|
+
y += 8;
|
|
8787
|
+
}
|
|
8788
|
+
|
|
8789
|
+
if (table) {
|
|
8790
|
+
ctx.fillStyle = 'rgb(31,111,63)';
|
|
8791
|
+
ctx.font = font(16, true);
|
|
8792
|
+
ctx.fillText(table.title, PAD, y);
|
|
8793
|
+
y += 24;
|
|
8794
|
+
ctx.fillStyle = 'rgb(138,131,120)';
|
|
8795
|
+
ctx.font = font(13);
|
|
8796
|
+
ctx.fillText(table.columns.join(' · '), PAD, y);
|
|
8797
|
+
y += 8;
|
|
8798
|
+
ctx.strokeStyle = 'rgb(229,225,216)';
|
|
8799
|
+
ctx.beginPath(); ctx.moveTo(PAD, y); ctx.lineTo(W - PAD, y); ctx.stroke();
|
|
8800
|
+
y += 22;
|
|
8801
|
+
ctx.fillStyle = 'rgb(63,58,51)';
|
|
8802
|
+
ctx.font = font(14);
|
|
8803
|
+
for (const row of tableRows) {
|
|
8804
|
+
const text = row.filter(Boolean).join(' · ');
|
|
8805
|
+
const clipped = wrap(text, W - PAD * 2)[0];
|
|
8806
|
+
ctx.fillText(clipped, PAD, y);
|
|
8807
|
+
y += 34;
|
|
8808
|
+
}
|
|
8809
|
+
}
|
|
8810
|
+
|
|
8811
|
+
y = H - 62;
|
|
8812
|
+
ctx.strokeStyle = 'rgb(229,225,216)';
|
|
8813
|
+
ctx.beginPath(); ctx.moveTo(PAD, y - 18); ctx.lineTo(W - PAD, y - 18); ctx.stroke();
|
|
8814
|
+
ctx.fillStyle = 'rgb(138,131,120)';
|
|
8815
|
+
ctx.font = font(12);
|
|
8816
|
+
ctx.fillText('内容用于传统文化学习与自我探索,不构成医疗、投资、法律或人事决策依据。', PAD, y + 6);
|
|
8817
|
+
ctx.fillText('dsh-metaphysics · 本机计算,未上传任何数据', PAD, y + 26);
|
|
8818
|
+
|
|
8819
|
+
return canvas.toDataURL ? canvas.toDataURL('image/png') : '';
|
|
8820
|
+
} catch (e) {
|
|
8821
|
+
return '';
|
|
8822
|
+
}
|
|
8823
|
+
};
|
|
8214
8824
|
})();
|
|
8215
8825
|
|
|
8216
8826
|
const HIST_KEY = 'dsh-metaphysics/history-v1';
|
|
@@ -8295,6 +8905,11 @@ const CSS = `
|
|
|
8295
8905
|
.mp-empty b{display:block;font-size:15px;color:var(--dsw-alias-label-primary);margin-bottom:6px;font-weight:600}
|
|
8296
8906
|
.mp-note{margin-top:12px;padding:9px 14px;border-radius:10px;font-size:12px;background:color-mix(in srgb,var(--dsw-alias-state-warning-primary) 14%,transparent);color:var(--dsw-alias-state-warning-primary)}
|
|
8297
8907
|
.mp-bar{display:flex;gap:8px;align-items:center;margin-top:14px}
|
|
8908
|
+
.mp-askbox{display:flex;gap:8px;align-items:center;margin-top:12px}
|
|
8909
|
+
.mp-askbox .mp-input{flex:1;min-width:0}
|
|
8910
|
+
.mp-fx{margin-top:10px}
|
|
8911
|
+
.mp-checks{flex-direction:row;align-items:center;gap:7px;font-size:12.5px}
|
|
8912
|
+
.mp-checks input{width:15px;height:15px;accent-color:var(--dsw-alias-brand-primary)}
|
|
8298
8913
|
.mp-auto{margin:-8px 0 14px;padding-left:2px;font-size:12.5px;line-height:1.7;color:var(--dsw-alias-label-secondary)}
|
|
8299
8914
|
.mp-cast{margin:0 0 14px;padding-left:2px;font-size:12.5px;line-height:1.7;color:var(--dsw-alias-label-secondary)}
|
|
8300
8915
|
.mp-cast b{color:var(--dsw-alias-label-primary);font-weight:600}
|
|
@@ -8380,6 +8995,9 @@ function App() {
|
|
|
8380
8995
|
const [hpChart, setHpChart] = useState('bazi');
|
|
8381
8996
|
const [qimenRule, setQimenRule] = useState('chaibu');
|
|
8382
8997
|
const [trueSolar, setTrueSolar] = useState(true);
|
|
8998
|
+
const [crossOn, setCrossOn] = useState(false);
|
|
8999
|
+
const [askText, setAskText] = useState('');
|
|
9000
|
+
const [fx, setFx] = useState(null);
|
|
8383
9001
|
const [onlineGeo, setOnlineGeo] = useState(false);
|
|
8384
9002
|
const [lines, setLines] = useState('');
|
|
8385
9003
|
const [result, setResult] = useState(null);
|
|
@@ -8405,19 +9023,21 @@ function App() {
|
|
|
8405
9023
|
const usesTimeInput = !(tab === 'meihua' && mhMode === 'number');
|
|
8406
9024
|
const showDT = tab !== 'tarot' && usesTimeInput;
|
|
8407
9025
|
|
|
8408
|
-
const run = async (kind, override, modeOverride) => {
|
|
9026
|
+
const run = async (kind, override, modeOverride, over) => {
|
|
8409
9027
|
const k = kind || tab;
|
|
8410
9028
|
const mh = modeOverride || mhMode;
|
|
8411
9029
|
const dt = override ? override : { date, time };
|
|
9030
|
+
const genderV = over && over.gender ? over.gender : gender;
|
|
9031
|
+
const addressV = over && typeof over.address === 'string' ? over.address : address;
|
|
8412
9032
|
try {
|
|
8413
9033
|
const datetime = `${dt.date}T${dt.time}`;
|
|
8414
9034
|
const args = { system: k };
|
|
8415
9035
|
if (k !== 'tarot') args.datetime = datetime;
|
|
8416
9036
|
if (k === 'bazi' || k === 'ziwei' || k === 'hepan') {
|
|
8417
|
-
args.gender =
|
|
9037
|
+
args.gender = genderV;
|
|
8418
9038
|
args.trueSolar = trueSolar;
|
|
8419
|
-
if (
|
|
8420
|
-
args.address =
|
|
9039
|
+
if (addressV.trim()) {
|
|
9040
|
+
args.address = addressV.trim();
|
|
8421
9041
|
try {
|
|
8422
9042
|
const g = await Engine.geocodeAddress(args.address, { online: onlineGeo });
|
|
8423
9043
|
if (g && typeof g.lon === 'number') { args.longitude = g.lon; args.geo = g; }
|
|
@@ -8425,6 +9045,7 @@ function App() {
|
|
|
8425
9045
|
console.error('[metaphysics] 地址解析失败,退回内置表', e);
|
|
8426
9046
|
}
|
|
8427
9047
|
}
|
|
9048
|
+
if (k !== 'hepan') args.cross = crossOn;
|
|
8428
9049
|
}
|
|
8429
9050
|
if (k === 'liuyao') {
|
|
8430
9051
|
const parsed = Core.parseLines(lines);
|
|
@@ -8475,8 +9096,12 @@ function App() {
|
|
|
8475
9096
|
? { question: needAsk(k) ? question.trim() : '', direction }
|
|
8476
9097
|
: undefined;
|
|
8477
9098
|
const it = Engine.interpret ? Engine.interpret(r, ask) : null;
|
|
9099
|
+
if (it && r.cross && Engine.crossText) {
|
|
9100
|
+
it.sections = [...(it.sections || []), { key: 'crossSystem', label: '八字 × 紫微 交叉验证', text: Engine.crossText(r.cross) }];
|
|
9101
|
+
}
|
|
8478
9102
|
const timed = kindOf(k) === 'cast' && (k !== 'meihua' || mh === 'time');
|
|
8479
9103
|
setResult({ kind: k, r, it, at: dt, timed });
|
|
9104
|
+
setFx(null);
|
|
8480
9105
|
setError(''); setCopied('');
|
|
8481
9106
|
if (k !== 'tarot') {
|
|
8482
9107
|
const entry = {
|
|
@@ -8539,6 +9164,17 @@ function App() {
|
|
|
8539
9164
|
run(tab);
|
|
8540
9165
|
};
|
|
8541
9166
|
|
|
9167
|
+
const openSample = () => {
|
|
9168
|
+
const sample = { date: '1990-05-12', time: '14:30' };
|
|
9169
|
+
setTab('bazi');
|
|
9170
|
+
setGender('male');
|
|
9171
|
+
setAddress('河北石家庄');
|
|
9172
|
+
setManual((m) => Object.assign({}, m, { birth: sample }));
|
|
9173
|
+
setDate(sample.date);
|
|
9174
|
+
setTime(sample.time);
|
|
9175
|
+
run('bazi', sample, null, { gender: 'male', address: '河北石家庄' });
|
|
9176
|
+
};
|
|
9177
|
+
|
|
8542
9178
|
const switchMode = (m) => {
|
|
8543
9179
|
setMhMode(m);
|
|
8544
9180
|
run(tab, { date, time }, m);
|
|
@@ -8583,6 +9219,46 @@ function App() {
|
|
|
8583
9219
|
} catch (e) { setCopied('复制失败'); }
|
|
8584
9220
|
};
|
|
8585
9221
|
|
|
9222
|
+
const doAsk = () => {
|
|
9223
|
+
if (!result || !result.r || !askText.trim()) return;
|
|
9224
|
+
try {
|
|
9225
|
+
setFx(Engine.followup ? Engine.followup(result.r, askText.trim()) : null);
|
|
9226
|
+
} catch (e) { setFx({ question: askText.trim(), ok: false, answer: '追问失败:' + (e && e.message ? e.message : e), evidence: [], confidence: '弱' }); }
|
|
9227
|
+
};
|
|
9228
|
+
|
|
9229
|
+
const downloadReport = () => {
|
|
9230
|
+
if (!result || !result.r) return;
|
|
9231
|
+
try {
|
|
9232
|
+
const text = Engine.renderText ? Engine.renderText(result.r) : (result.r.summary || '');
|
|
9233
|
+
const blob = new Blob([text], { type: 'text/markdown;charset=utf-8' });
|
|
9234
|
+
const a = document.createElement('a');
|
|
9235
|
+
a.href = URL.createObjectURL(blob);
|
|
9236
|
+
a.download = `命理报告-${result.r.system}.md`;
|
|
9237
|
+
document.body.appendChild(a);
|
|
9238
|
+
a.click();
|
|
9239
|
+
a.remove();
|
|
9240
|
+
setTimeout(() => URL.revokeObjectURL(a.href), 2000);
|
|
9241
|
+
} catch (e) {
|
|
9242
|
+
console.error('[metaphysics] 导出失败', e);
|
|
9243
|
+
}
|
|
9244
|
+
};
|
|
9245
|
+
|
|
9246
|
+
const downloadCard = () => {
|
|
9247
|
+
if (!result || !result.r) return;
|
|
9248
|
+
try {
|
|
9249
|
+
const url = PP.summaryCardPNG ? PP.summaryCardPNG(result.r, result.it) : '';
|
|
9250
|
+
if (!url) { setCopied('当前环境不支持 Canvas 导出'); return; }
|
|
9251
|
+
const a = document.createElement('a');
|
|
9252
|
+
a.href = url;
|
|
9253
|
+
a.download = `命理摘要-${result.r.system}.png`;
|
|
9254
|
+
document.body.appendChild(a);
|
|
9255
|
+
a.click();
|
|
9256
|
+
a.remove();
|
|
9257
|
+
} catch (e) {
|
|
9258
|
+
console.error('[metaphysics] 长图导出失败', e);
|
|
9259
|
+
}
|
|
9260
|
+
};
|
|
9261
|
+
|
|
8586
9262
|
const field = (label, node) => h('label', { className: 'mp-field' }, h('span', { className: 'mp-lbl' }, label), node);
|
|
8587
9263
|
|
|
8588
9264
|
const replay = (x) => {
|
|
@@ -8636,6 +9312,12 @@ function App() {
|
|
|
8636
9312
|
className: 'mp-input', placeholder: '如 河北石家庄 / 成都', value: address,
|
|
8637
9313
|
onChange: (e) => setAddress(e.target.value),
|
|
8638
9314
|
})) : null,
|
|
9315
|
+
(tab === 'bazi' || tab === 'ziwei') ? h('label', { className: 'mp-field mp-checks' },
|
|
9316
|
+
h('input', {
|
|
9317
|
+
type: 'checkbox', checked: crossOn,
|
|
9318
|
+
onChange: (e) => setCrossOn(e.target.checked),
|
|
9319
|
+
}),
|
|
9320
|
+
h('span', { className: 'mp-lbl' }, '八字 × 紫微 交叉验证')) : null,
|
|
8639
9321
|
tab === 'hepan' ? field('对方出生日期', h('input', {
|
|
8640
9322
|
className: 'mp-input', type: 'date', value: pDate, onChange: (e) => setPDate(e.target.value),
|
|
8641
9323
|
})) : null,
|
|
@@ -8708,6 +9390,10 @@ function App() {
|
|
|
8708
9390
|
onBlur: (e) => refreshInterpret(undefined, e.target.value),
|
|
8709
9391
|
})) : null,
|
|
8710
9392
|
h('div', { key: 'actions', className: 'mp-actions' },
|
|
9393
|
+
h('button', {
|
|
9394
|
+
className: 'mp-btn ghost', style: { fontSize: 12, padding: '5px 12px', marginRight: 8 },
|
|
9395
|
+
onClick: openSample, title: '用固定示例盘看完整报告(不改动你已填的数据)',
|
|
9396
|
+
}, '看示例'),
|
|
8711
9397
|
h('button', { className: 'mp-btn', onClick: go, title: '时间仍为自动时,点它会取当下再起卦' },
|
|
8712
9398
|
tab === 'tarot' ? '抽牌' : tab === 'bazi' || tab === 'ziwei' ? '排盘' : tab === 'hepan' ? '合盘' : '起卦'))),
|
|
8713
9399
|
|
|
@@ -8764,7 +9450,26 @@ function App() {
|
|
|
8764
9450
|
|
|
8765
9451
|
result ? h('div', { key: 'bar', className: 'mp-bar' },
|
|
8766
9452
|
h('button', { className: 'mp-btn ghost', style: { fontSize: 12, padding: '5px 12px' }, onClick: copyResult },
|
|
8767
|
-
copied || '复制文字结果')
|
|
9453
|
+
copied || '复制文字结果'),
|
|
9454
|
+
h('button', {
|
|
9455
|
+
className: 'mp-btn ghost', style: { fontSize: 12, padding: '5px 12px', marginLeft: 8 },
|
|
9456
|
+
onClick: downloadReport, title: '导出盘面 + 解析(含一页读懂、三张表)为 Markdown',
|
|
9457
|
+
}, '导出 .md'),
|
|
9458
|
+
h('button', {
|
|
9459
|
+
className: 'mp-btn ghost', style: { fontSize: 12, padding: '5px 12px', marginLeft: 8 },
|
|
9460
|
+
onClick: downloadCard, title: '生成 PNG 摘要卡(一页读懂 + 首张表),适合直接分享',
|
|
9461
|
+
}, '存为摘要长图')) : null,
|
|
9462
|
+
|
|
9463
|
+
result ? h('div', { key: 'ask', className: 'mp-askbox' },
|
|
9464
|
+
h('input', {
|
|
9465
|
+
className: 'mp-input', value: askText, maxLength: 120,
|
|
9466
|
+
placeholder: '追问:如 2027 年事业怎么样(回车提交)',
|
|
9467
|
+
onChange: (e) => setAskText(e.target.value),
|
|
9468
|
+
onKeyDown: (e) => { if (e.key === 'Enter') doAsk(); },
|
|
9469
|
+
}),
|
|
9470
|
+
h('button', { className: 'mp-btn ghost', style: { fontSize: 12, padding: '5px 12px' }, onClick: doAsk }, '追问')) : null,
|
|
9471
|
+
|
|
9472
|
+
fx ? h('div', { key: 'fx', className: 'mp-fx', dangerouslySetInnerHTML: { __html: PP.followupHTML(fx) } }) : null,
|
|
8768
9473
|
|
|
8769
9474
|
(!result && !error) ? h('div', { key: 'ph', className: 'mp-dim', style: { marginTop: 24, fontSize: 12 } },
|
|
8770
9475
|
'选择体系后点「排盘」。所有计算在本机完成,不上传任何数据。') : null,
|