Skip to content

DiffCodeBlock 代码对比 ​

面向 AI 代码助手的变更审查组件,自动计算行级增删差异并支持应用/忽略回调。

基础用法 ​

greet.ts+1-1
11 function greet(name: string) {
2- return 'Hello ' + name
2+ return `Hello, ${name}!`
33 }
<script setup>
import DiffCodeBlock from '@/vue/components/DiffCodeBlock.vue'

const oldCode = `function greet(name: string) {
  return 'Hello ' + name
}`

const newCode = `function greet(name: string) {
  return \`Hello, \${name}!\`
}`
</script>

<template>
  <DiffCodeBlock
    title="greet.ts"
    :old-code="oldCode"
    :new-code="newCode"
    actionable
  />
</template>

API ​

属性名说明类型默认值
oldCode修改前代码string''
newCode修改后代码string''
title标题 / 文件名string''
theme主题'dark' | 'light''dark'
actionable是否显示应用/忽略按钮booleanfalse

基于 MIT 许可发布