feat: 图标选择器

This commit is contained in:
WANGFAN\wangf 2024-10-27 14:59:43 +08:00
parent 9798965f6a
commit 9d29270cc5
5 changed files with 17 additions and 16 deletions

View File

@ -57,7 +57,7 @@ const onIcon = (iconName: string) => {
emit("select", iconName); emit("select", iconName);
}; };
const visible = ref(false); const visible = ref<boolean>(false);
const open = () => { const open = () => {
searchName.value = ""; searchName.value = "";
visible.value = true; visible.value = true;

View File

@ -28,7 +28,7 @@ export default {
["draggable"]: "draggable", ["draggable"]: "draggable",
["editor"]: "editor", ["editor"]: "editor",
["newbie"]: "newbie", ["newbie"]: "newbie",
["icon-component"]: "icon component", ["icon-selector"]: "icon selector",
["user-center"]: "user center", ["user-center"]: "user center",
["markdown"]: "Markdown", ["markdown"]: "Markdown",
["custom-instruction"]: "custom instruction", ["custom-instruction"]: "custom instruction",

View File

@ -28,7 +28,7 @@ export default {
["draggable"]: "拖拽", ["draggable"]: "拖拽",
["editor"]: "富文本", ["editor"]: "富文本",
["newbie"]: "新手指引", ["newbie"]: "新手指引",
["icon-component"]: "icon组件", ["icon-selector"]: "图标选择器",
["user-center"]: "用户中心", ["user-center"]: "用户中心",
["markdown"]: "Markdown", ["markdown"]: "Markdown",
["custom-instruction"]: "自定义指令", ["custom-instruction"]: "自定义指令",

View File

@ -389,11 +389,11 @@ export const dynamicRoutes: RouteRecordRaw[] = [
} }
}, },
{ {
path: "/common-component/icon-component", path: "/common-component/icon-selector",
name: "icon-component", name: "icon-selector",
component: () => import("@/views/common-component/icon-component/icon-component.vue"), component: () => import("@/views/common-component/icon-selector/icon-selector.vue"),
meta: { meta: {
title: "icon-component", title: "icon-selector",
hide: false, hide: false,
disable: false, disable: false,
keepAlive: true, keepAlive: true,

View File

@ -2,17 +2,13 @@
<div class="snow-page"> <div class="snow-page">
<div class="snow-inner-page"> <div class="snow-inner-page">
<div class="title">图标选择器</div> <div class="title">图标选择器</div>
<a-input <a-input ref="inputRef" :style="{ width: '400px' }" placeholder="请选择图标" v-model="iconName" @focus="onFocus">
:style="{ width: '400px' }"
placeholder="请选择图标"
allow-clear
v-model="iconName"
@focus="onFocus"
@clear="onClear"
>
<template #suffix v-if="iconName"> <template #suffix v-if="iconName">
<component :is="iconName"></component> <component :is="iconName"></component>
</template> </template>
<template #append>
<span class="icon-reset" @click="reset">重置</span>
</template>
</a-input> </a-input>
<a-divider /> <a-divider />
<div class="target-title">当前选择的图标</div> <div class="target-title">当前选择的图标</div>
@ -26,10 +22,12 @@
<script setup lang="ts"> <script setup lang="ts">
const iconName = ref<string>(""); const iconName = ref<string>("");
const SelectIconRef = ref(); const SelectIconRef = ref();
const onFocus = () => { const onFocus = () => {
SelectIconRef.value.open(); SelectIconRef.value.open();
}; };
const onClear = () => {
const reset = () => {
iconName.value = ""; iconName.value = "";
}; };
@ -47,4 +45,7 @@ const select = (icon: string) => {
.target-title { .target-title {
margin-bottom: $margin; margin-bottom: $margin;
} }
.icon-reset {
cursor: pointer;
}
</style> </style>