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 | 是否显示应用/忽略按钮 | boolean | false |
