| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- const n = `<template>
- <s-modal
- v-model:value="show"
- keyboard
- :title="$l('图标选择')"
- :width="width"
- :tabs="tabs"
- @tabsChange="handTabChange"
- @handCancel="cancelHandel"
- >
- <div class="icon-body">
- <a-input-search
- v-model:value="keyword"
- class="icon-search"
- :placeholder="$l('搜索图标')"
- allow-clear
- />
- <div class="icon-list">
- <div
- v-for="icon in icons"
- :key="icon"
- class="item-icon"
- v-clipboard="\`<\${icon}/>\`"
- @click="handToast(icon)"
- >
- <component :is="icon" :class="icon" />
- <div class="name">{{ icon }}</div>
- </div>
- <div v-if="!icons.length" class="icon-empty">{{ $l('暂无数据') }}</div>
- </div>
- </div>
- </s-modal>
- </template>
- <script setup>
- import { computed, ref, watch } from 'vue'
- import { filterIcons, getIconTabs } from './icon-groups'
- const props = defineProps({
- // 显隐(v-model:value)
- value: {
- type: Boolean,
- default: false
- },
- // 弹窗宽度
- width: {
- type: Number,
- default: 1028
- }
- })
- const emit = defineEmits(['update:value'])
- const show = ref(false)
- // 顶部页签:全部 / 线框 / 实底 / 双色,按图标风格后缀分类
- const tabs = computed(() => getIconTabs().slice(1))
- const activeGroup = ref('outlined')
- const keyword = ref('')
- const icons = computed(() => filterIcons(activeGroup.value, keyword.value))
- watch(
- () => props.value,
- (val) => {
- show.value = val
- }
- )
- const cancelHandel = () => {
- show.value = false
- emit('update:value', false)
- }
- const handTabChange = (key) => {
- activeGroup.value = key
- }
- // 弹窗关闭就清空关键字,下次打开回到完整列表
- watch(show, (val) => {
- if (!val) keyword.value = ''
- })
- const handToast = (icon) => {
- window.$message.success(\`<\${icon}/>\`)
- }
- <\/script>
- <style lang="less" scoped>
- .icon-body {
- height: 60vh;
- display: flex;
- flex-direction: column;
- }
- .icon-search {
- flex: 0 0 auto;
- margin-bottom: 12px;
- }
- .icon-list {
- flex: 1 1 auto;
- min-height: 0;
- overflow: hidden auto;
- width: 100%;
- display: flex;
- justify-content: flex-start;
- align-items: flex-start;
- align-content: flex-start;
- flex-wrap: wrap;
- .item-icon {
- width: 130px;
- margin: 16px;
- cursor: pointer;
- font-size: 28px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- .name {
- font-size: 11px;
- margin-top: 10px;
- }
- }
- }
- .icon-empty {
- width: 100%;
- padding: 60px 0;
- text-align: center;
- color: var(--s-text-color-secondary);
- }
- </style>
- `;
- export {
- n as default
- };
|