2019-12-25 19:04:17 +08:00
|
|
|
<template>
|
2020-03-16 15:50:43 +08:00
|
|
|
<div v-if="mode==='debug'">
|
2019-12-25 19:04:17 +08:00
|
|
|
<n-input
|
|
|
|
v-model="pattern"
|
2020-03-16 15:50:43 +08:00
|
|
|
:style="{
|
|
|
|
marginBottom: '24px',
|
|
|
|
marginTop: '18px'
|
|
|
|
}"
|
2020-03-17 16:48:36 +08:00
|
|
|
placeholder="查询图标"
|
2019-12-25 19:04:17 +08:00
|
|
|
/>
|
|
|
|
<div class="icons">
|
|
|
|
<icon-wrapper
|
2020-03-20 11:18:41 +08:00
|
|
|
v-for="name in filteredNames"
|
2019-12-25 19:04:17 +08:00
|
|
|
:key="name"
|
|
|
|
:name="name"
|
|
|
|
>
|
2020-03-20 19:17:26 +08:00
|
|
|
<n-icon depth="tertiary">
|
2019-12-25 19:04:17 +08:00
|
|
|
<component :is="name" />
|
|
|
|
</n-icon>
|
|
|
|
</icon-wrapper>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-03-16 15:50:43 +08:00
|
|
|
import icons from '../../../../../src/_icons/index'
|
2019-12-25 19:04:17 +08:00
|
|
|
import iconWrapper from './iconWrapper'
|
2020-09-03 17:02:31 +08:00
|
|
|
import { modeRef } from '../../../../use-dev-mode'
|
2019-12-25 19:04:17 +08:00
|
|
|
|
2020-03-20 19:17:26 +08:00
|
|
|
const prefixedIcons = Object.entries(icons).reduce((prevValue, [key, value]) => {
|
|
|
|
prevValue['icon-' + key] = value
|
|
|
|
return prevValue
|
|
|
|
}, {})
|
|
|
|
|
2019-12-25 19:04:17 +08:00
|
|
|
export default {
|
|
|
|
components: {
|
2020-03-16 15:50:43 +08:00
|
|
|
iconWrapper,
|
2020-03-20 19:17:26 +08:00
|
|
|
...prefixedIcons
|
2019-12-25 19:04:17 +08:00
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
pattern: '',
|
2020-09-03 17:02:31 +08:00
|
|
|
modeRef
|
2019-12-25 19:04:17 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2020-03-16 15:50:43 +08:00
|
|
|
mode () {
|
2020-09-03 17:02:31 +08:00
|
|
|
return this.modeRef.value
|
2020-03-16 15:50:43 +08:00
|
|
|
},
|
|
|
|
names () {
|
2020-03-20 19:17:26 +08:00
|
|
|
return Object.keys(prefixedIcons)
|
2020-03-16 15:50:43 +08:00
|
|
|
},
|
2019-12-25 19:04:17 +08:00
|
|
|
filteredNames () {
|
|
|
|
if (this.pattern.trim()) {
|
|
|
|
const pattern = this.pattern.trim()
|
|
|
|
return this.names.filter(name => ~(name.search(pattern)))
|
|
|
|
} else {
|
2020-03-17 16:48:36 +08:00
|
|
|
return this.names
|
2020-03-16 15:50:43 +08:00
|
|
|
}
|
2019-12-25 19:04:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.icons {
|
|
|
|
width: 100%;
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(5, 20%);
|
|
|
|
}
|
|
|
|
</style>
|