Commit d082f8ccc91825fb5c9943da5e7d31d9cb478641

Authored by 梁灏
1 parent 3679837b

menu add global setting #5592

src/components/menu/submenu.vue
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <li :class="classes" @mouseenter="handleMouseenter" @mouseleave="handleMouseleave"> 2 <li :class="classes" @mouseenter="handleMouseenter" @mouseleave="handleMouseleave">
3 <div :class="[prefixCls + '-submenu-title']" ref="reference" @click.stop="handleClick" :style="titleStyle"> 3 <div :class="[prefixCls + '-submenu-title']" ref="reference" @click.stop="handleClick" :style="titleStyle">
4 <slot name="title"></slot> 4 <slot name="title"></slot>
5 - <Icon type="ios-arrow-down" :class="[prefixCls + '-submenu-title-icon']"></Icon> 5 + <Icon :type="arrowType" :custom="customArrowType" :size="arrowSize" :class="[prefixCls + '-submenu-title-icon']" />
6 </div> 6 </div>
7 <collapse-transition v-if="mode === 'vertical'"> 7 <collapse-transition v-if="mode === 'vertical'">
8 <ul :class="[prefixCls]" v-show="opened"><slot></slot></ul> 8 <ul :class="[prefixCls]" v-show="opened"><slot></slot></ul>
@@ -75,6 +75,41 @@ @@ -75,6 +75,41 @@
75 return this.hasParentSubmenu && this.mode !== 'horizontal' ? { 75 return this.hasParentSubmenu && this.mode !== 'horizontal' ? {
76 paddingLeft: 43 + (this.parentSubmenuNum - 1) * 24 + 'px' 76 paddingLeft: 43 + (this.parentSubmenuNum - 1) * 24 + 'px'
77 } : {}; 77 } : {};
  78 + },
  79 + // 3.4.0, global setting customArrow 有值时,arrow 赋值空
  80 + arrowType () {
  81 + let type = 'ios-arrow-down';
  82 +
  83 + if (this.$IVIEW) {
  84 + if (this.$IVIEW.menu.customArrow) {
  85 + type = '';
  86 + } else if (this.$IVIEW.menu.arrow) {
  87 + type = this.$IVIEW.menu.arrow;
  88 + }
  89 + }
  90 + return type;
  91 + },
  92 + // 3.4.0, global setting
  93 + customArrowType () {
  94 + let type = '';
  95 +
  96 + if (this.$IVIEW) {
  97 + if (this.$IVIEW.menu.customArrow) {
  98 + type = this.$IVIEW.menu.customArrow;
  99 + }
  100 + }
  101 + return type;
  102 + },
  103 + // 3.4.0, global setting
  104 + arrowSize () {
  105 + let size = '';
  106 +
  107 + if (this.$IVIEW) {
  108 + if (this.$IVIEW.menu.arrowSize) {
  109 + size = this.$IVIEW.menu.arrowSize;
  110 + }
  111 + }
  112 + return size;
78 } 113 }
79 }, 114 },
80 methods: { 115 methods: {
@@ -178,6 +178,11 @@ const install = function(Vue, opts = {}) { @@ -178,6 +178,11 @@ const install = function(Vue, opts = {}) {
178 arrow: opts.cell ? opts.cell.arrow ? opts.cell.arrow : '' : '', 178 arrow: opts.cell ? opts.cell.arrow ? opts.cell.arrow : '' : '',
179 customArrow: opts.cell ? opts.cell.customArrow ? opts.cell.customArrow : '' : '', 179 customArrow: opts.cell ? opts.cell.customArrow ? opts.cell.customArrow : '' : '',
180 arrowSize: opts.cell ? opts.cell.arrowSize ? opts.cell.arrowSize : '' : '' 180 arrowSize: opts.cell ? opts.cell.arrowSize ? opts.cell.arrowSize : '' : ''
  181 + },
  182 + menu: {
  183 + arrow: opts.menu ? opts.menu.arrow ? opts.menu.arrow : '' : '',
  184 + customArrow: opts.menu ? opts.menu.customArrow ? opts.menu.customArrow : '' : '',
  185 + arrowSize: opts.menu ? opts.menu.arrowSize ? opts.menu.arrowSize : '' : ''
181 } 186 }
182 }; 187 };
183 188
src/styles/components/menu.less
@@ -160,16 +160,24 @@ @@ -160,16 +160,24 @@
160 } 160 }
161 161
162 &-vertical &-submenu-title-icon{ 162 &-vertical &-submenu-title-icon{
163 - float: right;  
164 - position: relative;  
165 - top: 4px; 163 + // #5592 支持自定义图标 size 后,换一种位置
  164 + //float: right;
  165 + //position: relative;
  166 + //top: 4px;
  167 + position: absolute;
  168 + top: 50%;
  169 + right: 24px;
  170 + transform: translateY(-50%);
166 } 171 }
167 &-submenu-title-icon { 172 &-submenu-title-icon {
168 transition: transform @transition-time @ease-in-out; 173 transition: transform @transition-time @ease-in-out;
169 } 174 }
170 - &-opened > * > &-submenu-title-icon{ 175 + &-horizontal &-opened > * > &-submenu-title-icon{
171 transform: rotate(180deg); 176 transform: rotate(180deg);
172 } 177 }
  178 + &-vertical &-opened > * > &-submenu-title-icon{
  179 + transform: translateY(-50%) rotate(180deg);
  180 + }
173 181
174 &-vertical &-submenu{ 182 &-vertical &-submenu{
175 &-nested{ 183 &-nested{