Skip to content

Commit

Permalink
perf: 图标选择器逻辑优化
Browse files Browse the repository at this point in the history
  • Loading branch information
kailong321200875 committed Jan 6, 2024
1 parent a926c56 commit c2dde25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/components/IconPicker/src/IconPicker.vue
Expand Up @@ -90,6 +90,11 @@ const popoverShow = () => {
}
const iconSelect = (icon: string) => {
// 如果是同一个icon则不做处理,则相当于点击了清空按钮
if (icon === unref(modelValue)) {
modelValue.value = ''
return
}
modelValue.value = icon
}
Expand All @@ -106,7 +111,7 @@ const inputClear = () => {

<template>
<div :class="prefixCls" class="flex justify-center items-center box">
<ElInput disabled v-model="modelValue" />
<ElInput disabled v-model="modelValue" clearable />
<ElPopover
placement="bottom"
trigger="click"
Expand Down Expand Up @@ -144,8 +149,10 @@ const inputClear = () => {
icon === modelValue ? 'var(--el-color-primary)' : 'var(--el-border-color)'
}`,
boxSizing: 'border-box',
margin: '2px'
margin: '2px',
transition: 'all 0.3s'
}"
class="hover:border-color-[var(--el-color-primary)]!"
@click="iconSelect(icon)"
>
<Icon
Expand Down
2 changes: 1 addition & 1 deletion src/views/Components/IconPicker.vue
Expand Up @@ -6,7 +6,7 @@ import { useI18n } from '@/hooks/web/useI18n'
const { t } = useI18n()
const currentIcon = ref('tdesign:book-open')
const currentIcon = ref('')
</script>

<template>
Expand Down

0 comments on commit c2dde25

Please sign in to comment.