<template>
|
<div class="icon-body">
|
<el-input v-model="iconName" style="position: relative" clearable placeholder="请输入图标名称" @clear="filterIcons" @input="filterIcons">
|
<template #suffix><i class="el-icon-search el-input__icon" /></template>
|
</el-input>
|
<el-scrollbar height="200px">
|
<div class="icon-list">
|
<div class="icon-item hovers" :style="{ '--color': thcolor }" v-for="(item, index) in iconList" :key="index" @click="selectedIcon(item)">
|
<svg-icon :icon-class="item" style="height: 30px; width: 16px" />
|
<span class="txt">{{ item }}</span>
|
</div>
|
</div>
|
</el-scrollbar>
|
</div>
|
</template>
|
|
<script setup>
|
import icons from "./requireIcons";
|
import useSettingsStore from "@/store/modules/settings";
|
const thcolor = computed(() => useSettingsStore().theme);
|
const iconName = ref("");
|
const iconList = ref(icons);
|
const emit = defineEmits(["selected"]);
|
|
function filterIcons() {
|
iconList.value = icons;
|
if (iconName.value) {
|
iconList.value = icons.filter((item) => item.indexOf(iconName.value) !== -1);
|
}
|
}
|
|
function selectedIcon(name) {
|
emit("selected", name);
|
document.body.click();
|
}
|
|
function reset() {
|
iconName.value = "";
|
iconList.value = icons;
|
}
|
|
defineExpose({
|
reset,
|
});
|
</script>
|
|
<style lang="scss" scoped>
|
.hovers {
|
cursor: pointer;
|
transition: transform 0.5s;
|
}
|
|
.hovers:hover {
|
color: var(--color);
|
transform: scale(1.3);
|
}
|
.icon-body {
|
width: 100%;
|
padding: 10px;
|
.icon-list {
|
height: 200px;
|
display: flex;
|
flex-wrap: wrap;
|
align-content: flex-start;
|
|
.icon-item {
|
// height: 30px;
|
// line-height: 30px;
|
// margin-bottom: -5px;
|
// cursor: pointer;
|
// width: 33%;
|
// float: left;
|
width: 65px;
|
// height: 60px;
|
text-align: center;
|
// line-height: 50px;
|
margin-left: 5px;
|
display: flex;
|
flex-direction: column;
|
justify-content: center;
|
align-items: center;
|
// overflow-x: hidden;
|
.txt {
|
width: 100%;
|
font-size: 14px;
|
overflow: hidden;
|
white-space: nowrap;
|
text-overflow: ellipsis;
|
}
|
}
|
span {
|
display: inline-block;
|
vertical-align: -0.15em;
|
fill: currentColor;
|
overflow: hidden;
|
}
|
}
|
}
|
</style>
|