refacor: change
This commit is contained in:
		@@ -1,39 +0,0 @@
 | 
				
			|||||||
<template>
 | 
					 | 
				
			||||||
  <i :class="iconName" :style="appendStyle" />
 | 
					 | 
				
			||||||
</template>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
<script>
 | 
					 | 
				
			||||||
export default {
 | 
					 | 
				
			||||||
  name: 'ElIcon',
 | 
					 | 
				
			||||||
  props: {
 | 
					 | 
				
			||||||
    iconClass: {
 | 
					 | 
				
			||||||
      type: String,
 | 
					 | 
				
			||||||
      required: true
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    iconColor: {
 | 
					 | 
				
			||||||
      type: String,
 | 
					 | 
				
			||||||
      required: false,
 | 
					 | 
				
			||||||
      default: ''
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  },
 | 
					 | 
				
			||||||
  computed: {
 | 
					 | 
				
			||||||
    iconName() {
 | 
					 | 
				
			||||||
      return `sub-el-icon el-icon-${this.iconClass}`
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    appendStyle() {
 | 
					 | 
				
			||||||
      if (this.iconColor) {
 | 
					 | 
				
			||||||
        return 'color: ' + this.iconColor + ';'
 | 
					 | 
				
			||||||
      } else {
 | 
					 | 
				
			||||||
        return ''
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
</script>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
<style scoped>
 | 
					 | 
				
			||||||
.sub-el-icon {
 | 
					 | 
				
			||||||
  width: 1em;
 | 
					 | 
				
			||||||
  height: 1em;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
</style>
 | 
					 | 
				
			||||||
@@ -1,10 +1,8 @@
 | 
				
			|||||||
import Vue from 'vue'
 | 
					import Vue from 'vue'
 | 
				
			||||||
import SvgIcon from '@/components/SvgIcon'// svg component
 | 
					import SvgIcon from '@/components/SvgIcon'// svg component
 | 
				
			||||||
import ElIcon from '@/components/ElIcon'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// register globally
 | 
					// register globally
 | 
				
			||||||
Vue.component('svg-icon', SvgIcon)
 | 
					Vue.component('svg-icon', SvgIcon)
 | 
				
			||||||
Vue.component('el-icon', ElIcon)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const req = require.context('./svg', false, /\.svg$/)
 | 
					const req = require.context('./svg', false, /\.svg$/)
 | 
				
			||||||
const requireAll = requireContext => requireContext.keys().map(requireContext)
 | 
					const requireAll = requireContext => requireContext.keys().map(requireContext)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,4 @@
 | 
				
			|||||||
<script>
 | 
					<script>
 | 
				
			||||||
import variables from '@/styles/variables.scss'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  name: 'MenuItem',
 | 
					  name: 'MenuItem',
 | 
				
			||||||
  functional: true,
 | 
					  functional: true,
 | 
				
			||||||
@@ -9,25 +7,21 @@ export default {
 | 
				
			|||||||
      type: String,
 | 
					      type: String,
 | 
				
			||||||
      default: ''
 | 
					      default: ''
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    elicon: {
 | 
					 | 
				
			||||||
      type: String,
 | 
					 | 
				
			||||||
      default: ''
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    title: {
 | 
					    title: {
 | 
				
			||||||
      type: String,
 | 
					      type: String,
 | 
				
			||||||
      default: ''
 | 
					      default: ''
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  render(h, context) {
 | 
					  render(h, context) {
 | 
				
			||||||
    const { icon, elicon, title } = context.props
 | 
					    const { icon, title } = context.props
 | 
				
			||||||
    const vnodes = []
 | 
					    const vnodes = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (icon) {
 | 
					    if (icon) {
 | 
				
			||||||
 | 
					      if (icon.includes('el-icon')) {
 | 
				
			||||||
 | 
					        vnodes.push(<i class={[icon, 'sub-el-icon']} />)
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
        vnodes.push(<svg-icon icon-class={icon}/>)
 | 
					        vnodes.push(<svg-icon icon-class={icon}/>)
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (elicon) {
 | 
					 | 
				
			||||||
      vnodes.push(<el-icon icon-class={elicon} icon-color={variables.menuText}/>)
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (title) {
 | 
					    if (title) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,14 +3,14 @@
 | 
				
			|||||||
    <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
 | 
					    <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
 | 
				
			||||||
      <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
 | 
					      <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
 | 
				
			||||||
        <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
 | 
					        <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
 | 
				
			||||||
          <item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :elicon="onlyOneChild.meta.elicon||item.meta && item.meta.elicon" :title="onlyOneChild.meta.title" />
 | 
					          <item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="onlyOneChild.meta.title" />
 | 
				
			||||||
        </el-menu-item>
 | 
					        </el-menu-item>
 | 
				
			||||||
      </app-link>
 | 
					      </app-link>
 | 
				
			||||||
    </template>
 | 
					    </template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body>
 | 
					    <el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body>
 | 
				
			||||||
      <template slot="title">
 | 
					      <template slot="title">
 | 
				
			||||||
        <item v-if="item.meta" :icon="item.meta && item.meta.icon" :elicon="item.meta && item.meta.elicon" :title="item.meta.title" />
 | 
					        <item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" />
 | 
				
			||||||
      </template>
 | 
					      </template>
 | 
				
			||||||
      <sidebar-item
 | 
					      <sidebar-item
 | 
				
			||||||
        v-for="child in item.children"
 | 
					        v-for="child in item.children"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,7 +25,7 @@ import nestedRouter from './modules/nested'
 | 
				
			|||||||
 * meta : {
 | 
					 * meta : {
 | 
				
			||||||
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
 | 
					    roles: ['admin','editor']    control the page roles (you can set multiple roles)
 | 
				
			||||||
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
 | 
					    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
 | 
				
			||||||
    icon: 'svg-name'             the icon show in the sidebar
 | 
					    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
 | 
				
			||||||
    noCache: true                if set true, the page will no be cached(default is false)
 | 
					    noCache: true                if set true, the page will no be cached(default is false)
 | 
				
			||||||
    affix: true                  if set true, the tag will affix in the tags-view
 | 
					    affix: true                  if set true, the tag will affix in the tags-view
 | 
				
			||||||
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
 | 
					    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
 | 
				
			||||||
@@ -197,7 +197,7 @@ export const asyncRoutes = [
 | 
				
			|||||||
    name: 'Example',
 | 
					    name: 'Example',
 | 
				
			||||||
    meta: {
 | 
					    meta: {
 | 
				
			||||||
      title: 'Example',
 | 
					      title: 'Example',
 | 
				
			||||||
      icon: 'example'
 | 
					      icon: 'el-icon-s-help'
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    children: [
 | 
					    children: [
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,6 +60,9 @@
 | 
				
			|||||||
    .sub-el-icon {
 | 
					    .sub-el-icon {
 | 
				
			||||||
      margin-right: 13px;
 | 
					      margin-right: 13px;
 | 
				
			||||||
      margin-left: -1px;
 | 
					      margin-left: -1px;
 | 
				
			||||||
 | 
					      color: currentColor;
 | 
				
			||||||
 | 
					      width: 1em;
 | 
				
			||||||
 | 
					      height: 1em;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    .el-menu {
 | 
					    .el-menu {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user