"use client";
/**
* 策略说明卡片:一句话说明 + 计算公式 + 执行步骤 + 注意事项。
*
* 内容全部来自后端 describe_strategy(依 spec 真实推导);本组件只负责呈现,
* 并用 `RichText` 渲染后端使用的 **粗体** / `代码` 强调协议(否则星号会字面漏出)。
* 接口不可用时**如实显示「说明暂不可用」并给出原因**,不伪造文案(AGENT §24)。
*/
import { RichText } from "@/components/RichText";
import { Card, Pill } from "@/components/ui";
import type { StrategyDoc } from "@/lib/types";
export function StrategyDocBody({ doc }: { doc: StrategyDoc }) {
return (
💡
{doc.formula ? (
) : null}
{doc.steps?.length ? (
执行步骤
{doc.steps.map((s, i) => (
))}
) : null}
{doc.warnings?.length ? (
{doc.warnings.map((w, i) => (
注意
))}
) : null}
);
}
export function StrategyDocCard({
doc,
loading,
error,
title = "策略说明与计算公式",
compact = false,
}: {
doc: StrategyDoc | null;
loading: boolean;
error: string;
title?: string;
compact?: boolean;
}) {
return (
生成中
) : doc ? (
由后端依参数推导
) : null
}
>
{doc ? (
) : loading ? (
正在生成说明与公式…
) : (
说明暂不可用{error ? `:${error}` : "(后端 /api/strategies/describe 未就绪)"}。
策略仍可正常保存与运行;说明与公式由后端依 spec 推导,前端不自行拼造文案。
)}
{!compact && doc && (
因此不会出现「文档写一套、代码跑另一套」。
)}
);
}