@@ -3,7 +3,7 @@ import { useClipboard } from '@vueuse/core'
33import { ElMessage } from 'element-plus'
44import { t } from '../lang'
55import SM from '../message'
6- import { formatStyle , type FormatStyleValue } from '../utils'
6+ import { compareStyles , formatStyle , type FormatStyleValue , getVisibleCssDiffs } from '../utils'
77
88export function useDevToolsPanel ( ) {
99const inputValue = ref ( '' )
@@ -83,40 +83,17 @@ export function useDevToolsPanel() {
8383function compareSelectedEl ( ) {
8484const [ { style : styles1 = { } } , { style : styles2 = { } } ] = selectedEl
8585
86- const diffs : Array < CssDiffsType > = [ ]
87-
88- const allProperties = new Set ( [
89- ...Object . keys ( styles1 ) ,
90- ...Object . keys ( styles2 ) ,
91- ] )
92-
93- allProperties . forEach ( ( property ) => {
94- const left = styles1 [ property ] || '未定义'
95- const right = styles2 [ property ] || '未定义'
96-
97- diffs . push ( {
98- property,
99- left,
100- right,
101- isDiff : left !== right ,
102- } )
103- } )
104-
105- cssDiffs . push ( ...diffs )
86+ cssDiffs . length = 0
87+ cssDiffs . push ( ...compareStyles ( styles1 , styles2 ) )
10688}
10789
10890const renderCssDiffs = computed ( ( ) => {
109- return inputValueFilter ( isAllProperty . value
110- ? cssDiffs
111- : cssDiffs . filter ( css => css . isDiff ) , inputValue . value )
91+ return getVisibleCssDiffs ( cssDiffs , {
92+ isAllProperty : isAllProperty . value ,
93+ inputValue : inputValue . value ,
94+ } )
11295} )
11396
114- function inputValueFilter ( cssDiffs : Array < CssDiffsType > , inputValue : string ) {
115- return ! inputValue
116- ? cssDiffs
117- : cssDiffs . filter ( c => c . property . includes ( inputValue ) )
118- }
119-
12097function onTableCellClassName ( { columnIndex } : { columnIndex : number } ) {
12198return ! columnIndex ? 'text-[var(--el-table-text-color)] cursor-auto' : ''
12299}
0 commit comments