Add login gate, calculation history, and AI markdown download.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-13 09:39:38 +08:00
parent abf78cbbb5
commit 462bec2739
23 changed files with 878 additions and 74 deletions
+25 -1
View File
@@ -17,6 +17,7 @@ import RegionSelect, {
useRegionLocation,
} from "@/components/shared/region-select";
import { streamAiCompletion } from "@/lib/ai/client-stream";
import { saveHistoryEntry } from "@/lib/history/storage";
import type { GuaResult } from "@/lib/calc/hexagram";
import todayJson from "@/lib/data/today.json";
@@ -68,7 +69,7 @@ export default function LiuyaoForm() {
setIsLoading(true);
try {
await streamAiCompletion(
const text = await streamAiCompletion(
{
mode: "liuyao",
payload: {
@@ -85,6 +86,18 @@ export default function LiuyaoForm() {
},
setCompletion,
);
saveHistoryEntry({
mode: "liuyao",
title: guaData!.result.guaTitle,
question,
summary: guaData!.result.guaResult,
completion: text,
meta: {
地域: location!.name,
: `${calcDate} ${calcTime}`,
卦象: guaData!.result.guaTitle,
},
});
} catch (e) {
setError(e instanceof Error ? e.message : String(e));
} finally {
@@ -112,6 +125,11 @@ export default function LiuyaoForm() {
setError("");
}
const downloadPreamble =
guaData && location
? `# 六爻算卦 AI 解读\n\n- 问事:${question}\n- 地域:${location.name}\n- 时间:${calcDate} ${calcTime}\n- 卦象:${guaData.result.guaTitle}\n`
: undefined;
return (
<ModeWorkspace
aiPanel={
@@ -122,6 +140,12 @@ export default function LiuyaoForm() {
onCompletion={handleAnalyze}
error={error}
emptyHint="完成起卦后,点击「AI 解读」"
downloadFilename={
completion && guaData
? `六爻-${guaData.result.guaTitle.replace(/[/\\?%*:|"<>]/g, "-")}.md`
: undefined
}
downloadPreamble={downloadPreamble}
/>
}
>