Skip to content

Commit

Permalink
add icons page
Browse files Browse the repository at this point in the history
  • Loading branch information
PanJiaChen committed Aug 29, 2017
1 parent 97570fa commit 90fd432
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/icons/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import Vue from 'vue'
import IconSvg from '@/components/Icon-svg'// svg组件

import generateIconsView from '@/views/svg-icons/generateIconsView.js'// just for views/icons , you can delete it
// register globally
Vue.component('icon-svg', IconSvg)
const requireAll = requireContext => requireContext.keys().map(requireContext)
const req = require.context('./svg', false, /\.svg$/)

requireAll(req)
const iconMap = requireAll(req)

console.log(generateIconsView)
generateIconsView.generate(iconMap) // just for views/icons , you can delete it
1 change: 1 addition & 0 deletions src/icons/svg/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ export const asyncRouterMap = [
noDropdown: true,
children: [{ path: 'index', component: _import('permission/index'), name: '权限测试页', meta: { role: ['admin'] }}]
},
{
path: '/icon',
component: Layout,
icon: 'icons',
noDropdown: true,
children: [{ path: 'index', component: _import('svg-icons/index'), name: 'icons' }]
},
{
path: '/components',
component: Layout,
Expand Down
10 changes: 10 additions & 0 deletions src/views/svg-icons/generateIconsView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const data = {
state: {
iconsMap: []
},
generate(iconsMap) {
this.state.iconsMap = iconsMap
}
}

export default data
52 changes: 52 additions & 0 deletions src/views/svg-icons/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<template>
<div class="icons-container">
<div class="icons-wrapper">
<div v-for='item of iconsMap' :key='item' class='icon-item'>
<icon-svg :icon-class="item" />
<span>{{item}}</span>
</div>
</div>
</div>
</template>

<script>
import icons from './generateIconsView'
export default {
data() {
return {
iconsMap: []
}
},
mounted() {
const iconsMap = icons.state.iconsMap.map((i) => {
return i.default.id.split('-')[1]
})
this.iconsMap = iconsMap
}
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.icons-container {
margin: 40px 20px 0;
overflow: hidden;
.icons-wrapper {
margin: 0 auto;
}
.icon-item {
margin: 20px;
height: 137px;
text-align: center;
width: 120px;
float: left;
font-size: 40px;
color: #666;
}
span {
display: block;
font-size: 24px;
margin-top: 10px;
}
}
</style>

0 comments on commit 90fd432

Please sign in to comment.