Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 12 additions & 22 deletions entrypoints/devtools-panel/hooks/useDevToolsPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { formatStyle, type FormatStyleValue } from '../utils'
export function useDevToolsPanel() {
const { t } = useI18n()
const inputValue = ref('')
const { copy } = useClipboard({
read: true,
legacy: true,
})

const selectedEl: Array<SelectedElType> = reactive([])
const cssDiffs: Array<CssDiffsType> = reactive([])
Expand Down Expand Up @@ -85,6 +89,7 @@ export function useDevToolsPanel() {
const [{ style: styles1 = {} }, { style: styles2 = {} }] = selectedEl

const diffs: Array<CssDiffsType> = []
cssDiffs.length = 0

const allProperties = new Set([
...Object.keys(styles1),
Expand Down Expand Up @@ -134,29 +139,14 @@ export function useDevToolsPanel() {
function handleCopyStyle(row: CssDiffsType, column: any) {
if (column.property !== 'property') {
const source = `${row.property}: ${row[column.property as 'left' | 'right']};`

const { text, copied, copy } = useClipboard({
read: true,
source,
legacy: true,
})

copy(source)

watch(
() => copied.value,
(copied) => {
if (copied) {
ElMessage({
message: `${t('copyInfo')} > ${text.value}`,
type: 'success',
})
}
},
{
immediate: true,
},
)
.then(() => {
ElMessage({
message: `${t('copyInfo')} > ${source}`,
type: 'success',
})
})
.catch(() => null)
}
}

Expand Down