IDE 类型定义
概述
types.ts 定义了 IDE 组件使用的 TypeScript 类型。
文件路径
src/components/ide/types.ts
类型定义
OutputFormat
输出格式类型,支持三种格式:
export type OutputFormat = "json" | "yaml" | "markdown";
| 值 | 说明 |
|---|---|
json | JSON 格式输出 |
yaml | YAML 格式输出 |
markdown | Markdown 格式输出 |
使用示例
import { type OutputFormat } from "./types";
// 状态管理
const [outputFormat, setOutputFormat] = useState<OutputFormat>("markdown");
// 格式切换
const handleFormatChange = (format: OutputFormat) => {
setOutputFormat(format);
};
// 条件渲染
switch (outputFormat) {
case "json":
return JSON.stringify(data, null, 2);
case "yaml":
return toYaml(data);
case "markdown":
return formatAsMarkdown(data);
}
相关文件
prompt-ide.tsx- 主 IDE 组件utils.ts- 包含toYaml转换函数