@@ -20,6 +20,14 @@ interface Props {
2020 filename? : string
2121}
2222
23+ interface DiffResult {
24+ stat: {
25+ isChanged: boolean
26+ addNum: number
27+ delNum: number
28+ }
29+ }
30+
2331const props = withDefaults (defineProps <Props >(), {
2432 language: ' plaintext' ,
2533 context: 10 ,
@@ -31,6 +39,10 @@ const props = withDefaults(defineProps<Props>(), {
3139 filename: undefined ,
3240})
3341
42+ const emits = defineEmits <{
43+ (e : ' diff' , diffResult : DiffResult ): void
44+ }>()
45+
3446const isUnifiedViewer = computed (() => props .outputFormat === ' line-by-line' )
3547
3648const oldString = computed (() => {
@@ -52,9 +64,18 @@ const raw = computed(() =>
5264 : createSplitDiff (oldString .value , newString .value , props .language , props .diffStyle , props .context ),
5365)
5466const diffChange = ref (raw .value )
67+ const isNotChanged = computed (() => diffChange .value .stat .additionsNum === 0 && diffChange .value .stat .deletionsNum === 0 )
68+
5569watch (() => props , () => {
5670 diffChange .value = raw .value
57- }, { deep: true })
71+ emits (' diff' , {
72+ stat: {
73+ isChanged: ! isNotChanged .value ,
74+ addNum: diffChange .value .stat .additionsNum ,
75+ delNum: diffChange .value .stat .deletionsNum ,
76+ },
77+ })
78+ }, { deep: true , immediate: true })
5879 </script >
5980
6081<template >
@@ -73,4 +94,5 @@ watch(() => props, () => {
7394 </div >
7495</template >
7596
76- <style lang="scss"></style >
97+ <style lang="scss">
98+ </style >
0 commit comments