'use client'; /** * 案例 · 《增删卜易》卦例 * ====================== * 一例一个大框,框内照书的次序读: * 例N 古筮知识:… * 酉月辛亥日,占谒贵求财,得「兑之解」 * 干支:酉月 辛亥日 (旬空:寅卯) * 兑宫:兑为泽(六冲)    震宫:雷水解 * 六神 【本  卦】     【变  卦】 * 螣蛇 ▅▅ ▅▅ 父母未土 世   ▅▅ ▅▅ 父母戌土 * … * 原注:… / 1、选取用神:… / 2、吉凶判断:… / 3、应期细节:… * * 卦盘是本页的视觉中心,但不再拆成小卡片:只用一层浅底把六行托住。 * 数据:public/data/zengshan-cases.json;卦盘由同一引擎按「投掷值 + 同月建同日辰」重排。 */ import React, { useEffect, useMemo, useState } from 'react'; import SiteHeader from '@/components/site/SiteHeader'; import { encodeCastState } from '@/lib/liuyao/cast-url'; import type { CoinResult } from '@/components/liuyao/types'; import { buildLiuyaoInput, castTimeInfo, parseTimeInput } from '@/lib/liuyao/ganzhi'; import { castLiuyao, type LiuyaoChart, type LiuyaoLine } from '@/lib/liuyao/najia'; interface ExampleCase { id: number; topic: string; question: string; ganzhi: string; void: string; guaPair: string; ben: string; benPalace: string; benTag: string; zhi: string; zhiPalace: string; zhiTag: string; note: string; yong: string; luck: string; timing: string; coins: number[]; solar: string | null; } interface Payload { source: string; count: number; cases: ExampleCase[]; } const INK = '#242422'; const BODY = '#33322E'; const MUTED = '#6F6A60'; const HAIR = '#E1D8C8'; const CARD = '#FCFAF5'; const SOFT = '#F4EFE5'; const ACCENT = '#C23A2B'; const PER_PAGE = 6; const FILTERS = ['全部', '六冲', '六合', '游魂', '归魂'] as const; type Filter = (typeof FILTERS)[number]; function chartHref(c: ExampleCase): string | null { if (!c.solar || c.coins.length !== 6) return null; const qs = encodeCastState({ coins: c.coins as CoinResult[], timeInput: c.solar, gender: '男', marital: 'unmarried', question: c.question, }); return `/liuyao?${qs}`; } function buildChart(c: ExampleCase): LiuyaoChart | null { if (!c.solar || c.coins.length !== 6) return null; try { return castLiuyao(buildLiuyaoInput(castTimeInfo(parseTimeInput(c.solar)), c.coins)); } catch { return null; } } /** 爻画:实心块,跨字体对齐 */ function YaoBar({ yang, tone }: { yang: boolean; tone: string }) { if (yang) return ; return ( ); } /** 卦盘:照书的列次排(六神 / 伏神 / 本卦 / 世应 / 动 / 变卦 / 世应) * 用 CSS grid 统一列宽,表头的「本卦 / 变卦」正好压在自己那两列(爻画 + 纳甲)之上。 */ function CaseChart({ chart }: { chart: LiuyaoChart }) { const lines = useMemo(() => [...chart.lines].sort((a, b) => b.position - a.position), [chart.lines]); const changed = chart.changedLines; const changedWorld = chart.changed?.generation ?? null; const changedResponse = changedWorld ? ((changedWorld + 2) % 6) + 1 : null; const hiddenList = lines .filter((l) => l.hiddenSpirit) .map((l) => ({ position: l.position, text: `${l.hiddenSpirit?.relation}${l.hiddenSpirit?.stemBranch}` })); const hasHidden = hiddenList.length > 0; const gridClass = 'ex-grid'; const hiddenAttr = hasHidden ? '1' : '0'; const row = (l: LiuyaoLine) => { const ch = changed?.[l.position - 1]; const h = l.hiddenSpirit; return (
{l.sixGod} {hasHidden && ( {h ? `${h.relation}${h.stemBranch}` : ''} )} {`${l.relation}${l.stem}${l.branch}${l.element}`} {l.isWorld ? '世' : l.isResponse ? '应' : ''} {l.isMoving ? (l.isYang ? '○→' : '×→') : ''} {ch ? : null} {ch ? `${ch.relation}${ch.stem}${ch.branch}${ch.element}` : ''} {ch ? (l.position === changedWorld ? '世' : l.position === changedResponse ? '应' : '') : ''}
); }; return (
{/* 宫位与卦名 */}
{chart.base.palace}宫:{chart.base.name} {chart.base.tags.length ? `(${chart.base.tags.join('、')})` : ''} {chart.changed && ( {chart.changed.palace}宫:{chart.changed.name} {chart.changed.tags.length ? `(${chart.changed.tags.join('、')})` : ''} )}
{/* 列名:本卦 / 变卦 各压在「爻画 + 纳甲」两列之上 */}
六神 {hasHidden && 伏神} 【本  卦】 【变  卦】
{lines.map(row)}
{/* 窄屏收起伏神列,改在表下注一行 */} {hasHidden && (

伏神:{hiddenList.map((x) => `${x.text}(${x.position}爻)`).join(' ')}

)}
); } function CaseCard({ c }: { c: ExampleCase }) { const chart = useMemo(() => buildChart(c), [c]); const href = chartHref(c); return (
{/* 例N + 古筮知识 */}

例{c.id} 古筮知识: {c.topic}

{/* 占问与干支 */}

{c.ganzhi && `${c.ganzhi.replace(/\s+/g, '')},`} {c.question} {c.guaPair && `,得「${c.guaPair}」`}

干支:{c.ganzhi || '原文未记'} {c.void && ` (旬空:${c.void})`}

{/* 卦盘:一层浅底托住六行 */} {chart ? (
) : (

原例未记月建或干支,无法还原卦盘。

)} {/* 原注与三段评述:照书的顺序,不拆卡 */}
{c.note && (

原注: {c.note}

)} {c.yong && (

1、选取用神: {c.yong}

)} {c.luck && (

2、吉凶判断: {c.luck}

)} {c.timing && (

3、应期细节: {c.timing}

)}
{/* 操作 */}
{href ? ( 排出此卦 · 看完整盘面 ) : null} {c.solar && ( 对应公历 {c.solar.replace('T', ' ')}(同月建、同日辰) )}
); } export default function ExamplesView() { const [data, setData] = useState(null); const [error, setError] = useState(''); const [query, setQuery] = useState(''); const [filter, setFilter] = useState('全部'); const [page, setPage] = useState(1); useEffect(() => { let alive = true; void fetch('/data/zengshan-cases.json') .then((r) => (r.ok ? (r.json() as Promise) : Promise.reject(new Error(`读取失败(${r.status})`)))) .then((json) => { if (alive) setData(json); }) .catch((e) => { if (alive) setError((e as Error).message); }); return () => { alive = false; }; }, []); const filtered = useMemo(() => { const list = data?.cases ?? []; const q = query.trim(); return list.filter((c) => { if (filter !== '全部' && !`${c.benTag}${c.zhiTag}`.includes(filter)) return false; if (!q) return true; return [c.question, c.ben, c.zhi, c.benTag, c.topic, c.note, c.yong, c.luck, c.timing, String(c.id)].some((v) => (v ?? '').includes(q), ); }); }, [data, query, filter]); const totalPages = Math.max(1, Math.ceil(filtered.length / PER_PAGE)); const current = Math.min(page, totalPages); const visible = filtered.slice((current - 1) * PER_PAGE, current * PER_PAGE); return (
❖

案例

来源:《增删卜易》卦例 · 朱辰彬《增删卜易卦例初探》

{/* 侧栏:桌面固定在右,移动端在列表上方 */} {/* 主内容 */}
{error && (

{error}

)} {!data && !error && (

读取中…

)}
{visible.map((c) => ( ))}
{data && filtered.length === 0 && (

没有匹配的卦例。

)} {data && filtered.length > 0 && ( )}

古法口径不等于现代结论;案例仅作研读参照。

); }