IDE 类型定义

IDE 类型定义

概述

types.ts 定义了 IDE 组件使用的 TypeScript 类型。

文件路径

src/components/ide/types.ts

类型定义

OutputFormat

输出格式类型,支持三种格式:

export type OutputFormat = "json" | "yaml" | "markdown";
说明
jsonJSON 格式输出
yamlYAML 格式输出
markdownMarkdown 格式输出

使用示例

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 转换函数
← 返回目录