Skip to content

Commit 90fd432

Browse files
committed
add icons page
1 parent 97570fa commit 90fd432

File tree

5 files changed

+74
-2
lines changed

5 files changed

+74
-2
lines changed

src/icons/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import Vue from 'vue'
22
import IconSvg from '@/components/Icon-svg'// svg组件
3-
3+
import generateIconsView from '@/views/svg-icons/generateIconsView.js'// just for views/icons , you can delete it
44
// register globally
55
Vue.component('icon-svg', IconSvg)
66
const requireAll = requireContext => requireContext.keys().map(requireContext)
77
const req = require.context('./svg', false, /\.svg$/)
88

9-
requireAll(req)
9+
const iconMap = requireAll(req)
1010

11+
console.log(generateIconsView)
12+
generateIconsView.generate(iconMap) // just for views/icons , you can delete it

src/icons/svg/icons.svg

Lines changed: 1 addition & 0 deletions
Loading

src/router/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ export const asyncRouterMap = [
5555
noDropdown: true,
5656
children: [{ path: 'index', component: _import('permission/index'), name: '权限测试页', meta: { role: ['admin'] }}]
5757
},
58+
{
59+
path: '/icon',
60+
component: Layout,
61+
icon: 'icons',
62+
noDropdown: true,
63+
children: [{ path: 'index', component: _import('svg-icons/index'), name: 'icons' }]
64+
},
5865
{
5966
path: '/components',
6067
component: Layout,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const data = {
2+
state: {
3+
iconsMap: []
4+
},
5+
generate(iconsMap) {
6+
this.state.iconsMap = iconsMap
7+
}
8+
}
9+
10+
export default data

src/views/svg-icons/index.vue

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<template>
2+
<div class="icons-container">
3+
<div class="icons-wrapper">
4+
<div v-for='item of iconsMap' :key='item' class='icon-item'>
5+
<icon-svg :icon-class="item" />
6+
<span>{{item}}</span>
7+
</div>
8+
</div>
9+
</div>
10+
</template>
11+
12+
<script>
13+
import icons from './generateIconsView'
14+
15+
export default {
16+
data() {
17+
return {
18+
iconsMap: []
19+
}
20+
},
21+
mounted() {
22+
const iconsMap = icons.state.iconsMap.map((i) => {
23+
return i.default.id.split('-')[1]
24+
})
25+
this.iconsMap = iconsMap
26+
}
27+
}
28+
</script>
29+
30+
<style rel="stylesheet/scss" lang="scss" scoped>
31+
.icons-container {
32+
margin: 40px 20px 0;
33+
overflow: hidden;
34+
.icons-wrapper {
35+
margin: 0 auto;
36+
}
37+
.icon-item {
38+
margin: 20px;
39+
height: 137px;
40+
text-align: center;
41+
width: 120px;
42+
float: left;
43+
font-size: 40px;
44+
color: #666;
45+
}
46+
span {
47+
display: block;
48+
font-size: 24px;
49+
margin-top: 10px;
50+
}
51+
}
52+
</style>

0 commit comments

Comments
 (0)