计划

一个可折叠的计划组件,用于显示 AI 生成的执行计划,支持流式传输和闪烁动画。

Plan 组件提供了一个灵活的系统来显示 AI 生成的执行计划,具有可折叠的内容。非常适合显示多步骤工作流、任务分解和实施策略,支持流式传输内容和加载状态。

使用 CLI 安装

AI Elements Vue
shadcn-vue CLI
npx ai-elements-vue@latest add plan

手动安装

将以下代码复制并粘贴到同一文件夹中。

Plan.vue
PlanHeader.vue
PlanTitle.vue
PlanDescription.vue
PlanAction.vue
PlanContent.vue
PlanFooter.vue
PlanTrigger.vue
context.ts
index.ts
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { Card } from '@repo/shadcn-vue/components/ui/card'
import { Collapsible } from '@repo/shadcn-vue/components/ui/collapsible'
import { cn } from '@repo/shadcn-vue/lib/utils'
import { computed } from 'vue'
import { providePlan } from './context'

interface PlanProps {
  isStreaming?: boolean
  class?: HTMLAttributes['class']
}

const props = withDefaults(
  defineProps<PlanProps>(),
  {
    isStreaming: false,
  },
)

providePlan({
  isStreaming: computed(() => props.isStreaming),
})
</script>

<template>
  <Collapsible as-child data-slot="plan" v-bind="props">
    <Card :class="cn('shadow-none', props.class)">
      <slot />
    </Card>
  </Collapsible>
</template>

特性

  • 具有平滑动画的可折叠内容
  • 流式传输支持,带有闪烁加载状态
  • 基于 shadcn-vue Card 和 Collapsible 组件构建
  • 具有全面类型定义的 TypeScript 支持
  • 使用 Tailwind CSS 可自定义样式
  • 响应式设计,具有移动友好的交互
  • 键盘导航和可访问性支持
  • 主题感知,具有自动深色模式支持
  • 基于上下文的状态管理,用于流式传输

Props

<Plan />

isStreamingboolean
false
内容是否正在流式传输。在标题和描述上启用闪烁动画。默认为 false。
defaultOpenboolean
false
计划是否默认展开。
classstring
应用于组件的额外类。

<PlanHeader />

classstring
应用于组件的额外类。

<PlanDescription />

classstring
应用于组件的额外类。

<PlanTrigger />

classstring
应用于组件的额外类。

:::