Commit 7b487076fdcff5be8b8297a9aa53f7e7e1283389
1 parent
d6fc746e
fix
Showing
7 changed files
with
50 additions
and
37 deletions
Show diff stats
src/components/mew-menu/index.js
| 1 | -import Menu from './menu.vue'; | ||
| 2 | -import MenuGroup from './menu-group.vue'; | ||
| 3 | -import MenuItem from './menu-item.vue'; | ||
| 4 | -import Submenu from './submenu.vue'; | 1 | +import MewMenu from './menu.vue'; |
| 2 | +import MewMenuGroup from './menu-group.vue'; | ||
| 3 | +import MewMenuItem from './menu-item.vue'; | ||
| 4 | +import MewSubmenu from './submenu.vue'; | ||
| 5 | 5 | ||
| 6 | -Menu.Group = MenuGroup; | ||
| 7 | -Menu.Item = MenuItem; | ||
| 8 | -Menu.Sub = Submenu; | 6 | +MewMenu.Group = MewMenuGroup; |
| 7 | +MewMenu.Item = MewMenuItem; | ||
| 8 | +MewMenu.Sub = MewSubmenu; | ||
| 9 | 9 | ||
| 10 | -export default Menu; | ||
| 11 | \ No newline at end of file | 10 | \ No newline at end of file |
| 11 | +export default MewMenu; | ||
| 12 | \ No newline at end of file | 12 | \ No newline at end of file |
src/components/mew-menu/menu-item.vue
| @@ -12,14 +12,14 @@ | @@ -12,14 +12,14 @@ | ||
| 12 | </template> | 12 | </template> |
| 13 | <script> | 13 | <script> |
| 14 | import Emitter from '../../mixins/emitter'; | 14 | import Emitter from '../../mixins/emitter'; |
| 15 | - import { findComponentUpward } from '../../utils/assist'; | 15 | + import { findComponentUpward, findBrothersComponents, findComponentsDownward } from '../../utils/assist'; |
| 16 | import mixin from './mixin'; | 16 | import mixin from './mixin'; |
| 17 | import mixinsLink from '../../mixins/link'; | 17 | import mixinsLink from '../../mixins/link'; |
| 18 | 18 | ||
| 19 | const prefixCls = 'ivu-menu'; | 19 | const prefixCls = 'ivu-menu'; |
| 20 | 20 | ||
| 21 | export default { | 21 | export default { |
| 22 | - name: 'MenuItem', | 22 | + name: 'MewMenuItem', |
| 23 | mixins: [ Emitter, mixin, mixinsLink ], | 23 | mixins: [ Emitter, mixin, mixinsLink ], |
| 24 | props: { | 24 | props: { |
| 25 | name: { | 25 | name: { |
| @@ -60,16 +60,22 @@ | @@ -60,16 +60,22 @@ | ||
| 60 | if (new_window || this.target === '_blank') { | 60 | if (new_window || this.target === '_blank') { |
| 61 | // 如果是 new_window,直接新开窗口就行,无需发送状态 | 61 | // 如果是 new_window,直接新开窗口就行,无需发送状态 |
| 62 | this.handleCheckClick(event, new_window); | 62 | this.handleCheckClick(event, new_window); |
| 63 | - let parentMenu = findComponentUpward(this, 'Menu'); | 63 | + let parentMenu = findComponentUpward(this, 'MewMenu'); |
| 64 | if (parentMenu) parentMenu.handleEmitSelectEvent(this.name); | 64 | if (parentMenu) parentMenu.handleEmitSelectEvent(this.name); |
| 65 | } else { | 65 | } else { |
| 66 | - let parent = findComponentUpward(this, 'Submenu'); | 66 | + let parent = findComponentUpward(this, 'MewSubmenu'); |
| 67 | 67 | ||
| 68 | if (parent) { | 68 | if (parent) { |
| 69 | - this.dispatch('Submenu', 'on-menu-item-select', this.name); | 69 | + this.dispatch('MewSubmenu', 'on-menu-item-select', this.name); |
| 70 | } else { | 70 | } else { |
| 71 | - this.dispatch('Menu', 'on-menu-item-select', this.name); | 71 | + this.dispatch('MewMenu', 'on-menu-item-select', this.name); |
| 72 | } | 72 | } |
| 73 | + findBrothersComponents(this, 'SideMenuItem',false).forEach(item => { | ||
| 74 | + findComponentsDownward(item, 'MewSubmenu').forEach(item => { | ||
| 75 | + item.active = false; | ||
| 76 | + item.opened = false | ||
| 77 | + }); | ||
| 78 | + }); | ||
| 73 | 79 | ||
| 74 | this.handleCheckClick(event, new_window); | 80 | this.handleCheckClick(event, new_window); |
| 75 | } | 81 | } |
| @@ -79,7 +85,7 @@ | @@ -79,7 +85,7 @@ | ||
| 79 | this.$on('on-update-active-name', (name) => { | 85 | this.$on('on-update-active-name', (name) => { |
| 80 | if (this.name === name) { | 86 | if (this.name === name) { |
| 81 | this.active = true; | 87 | this.active = true; |
| 82 | - this.dispatch('Submenu', 'on-update-active-name', name); | 88 | + this.dispatch('MewSubmenu', 'on-update-active-name', name); |
| 83 | } else { | 89 | } else { |
| 84 | this.active = false; | 90 | this.active = false; |
| 85 | } | 91 | } |
src/components/mew-menu/menu.vue
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | const prefixCls = 'ivu-menu'; | 8 | const prefixCls = 'ivu-menu'; |
| 9 | 9 | ||
| 10 | export default { | 10 | export default { |
| 11 | - name: 'Menu', | 11 | + name: 'MewMenu', |
| 12 | mixins: [ Emitter ], | 12 | mixins: [ Emitter ], |
| 13 | props: { | 13 | props: { |
| 14 | mode: { | 14 | mode: { |
| @@ -73,53 +73,53 @@ | @@ -73,53 +73,53 @@ | ||
| 73 | if (this.currentActiveName === undefined) { | 73 | if (this.currentActiveName === undefined) { |
| 74 | this.currentActiveName = -1; | 74 | this.currentActiveName = -1; |
| 75 | } | 75 | } |
| 76 | - this.broadcast('Submenu', 'on-update-active-name', false); | ||
| 77 | - this.broadcast('MenuItem', 'on-update-active-name', this.currentActiveName); | 76 | + this.broadcast('MewSubmenu', 'on-update-active-name', false); |
| 77 | + this.broadcast('MewMenuItem', 'on-update-active-name', this.currentActiveName); | ||
| 78 | }, | 78 | }, |
| 79 | updateOpenKeys (name) { | 79 | updateOpenKeys (name) { |
| 80 | let names = [...this.openedNames]; | 80 | let names = [...this.openedNames]; |
| 81 | const index = names.indexOf(name); | 81 | const index = names.indexOf(name); |
| 82 | - if (this.accordion) findComponentsDownward(this, 'Submenu').forEach(item => { | 82 | + if (this.accordion) findComponentsDownward(this, 'MewSubmenu').forEach(item => { |
| 83 | item.opened = false; | 83 | item.opened = false; |
| 84 | }); | 84 | }); |
| 85 | if (index >= 0) { | 85 | if (index >= 0) { |
| 86 | let currentSubmenu = null; | 86 | let currentSubmenu = null; |
| 87 | - findComponentsDownward(this, 'Submenu').forEach(item => { | 87 | + findComponentsDownward(this, 'MewSubmenu').forEach(item => { |
| 88 | if (item.name === name) { | 88 | if (item.name === name) { |
| 89 | currentSubmenu = item; | 89 | currentSubmenu = item; |
| 90 | item.opened = false; | 90 | item.opened = false; |
| 91 | } | 91 | } |
| 92 | }); | 92 | }); |
| 93 | - findComponentsUpward(currentSubmenu, 'Submenu').forEach(item => { | 93 | + findComponentsUpward(currentSubmenu, 'MewSubmenu').forEach(item => { |
| 94 | item.opened = true; | 94 | item.opened = true; |
| 95 | }); | 95 | }); |
| 96 | - findComponentsDownward(currentSubmenu, 'Submenu').forEach(item => { | 96 | + findComponentsDownward(currentSubmenu, 'MewSubmenu').forEach(item => { |
| 97 | item.opened = false; | 97 | item.opened = false; |
| 98 | }); | 98 | }); |
| 99 | } else { | 99 | } else { |
| 100 | if (this.accordion) { | 100 | if (this.accordion) { |
| 101 | let currentSubmenu = null; | 101 | let currentSubmenu = null; |
| 102 | - findComponentsDownward(this, 'Submenu').forEach(item => { | 102 | + findComponentsDownward(this, 'MewSubmenu').forEach(item => { |
| 103 | if (item.name === name) { | 103 | if (item.name === name) { |
| 104 | currentSubmenu = item; | 104 | currentSubmenu = item; |
| 105 | item.opened = true; | 105 | item.opened = true; |
| 106 | } | 106 | } |
| 107 | }); | 107 | }); |
| 108 | - findComponentsUpward(currentSubmenu, 'Submenu').forEach(item => { | 108 | + findComponentsUpward(currentSubmenu, 'MewSubmenu').forEach(item => { |
| 109 | item.opened = true; | 109 | item.opened = true; |
| 110 | }); | 110 | }); |
| 111 | } else { | 111 | } else { |
| 112 | - findComponentsDownward(this, 'Submenu').forEach(item => { | 112 | + findComponentsDownward(this, 'MewSubmenu').forEach(item => { |
| 113 | if (item.name === name) item.opened = true; | 113 | if (item.name === name) item.opened = true; |
| 114 | }); | 114 | }); |
| 115 | } | 115 | } |
| 116 | } | 116 | } |
| 117 | - let openedNames = findComponentsDownward(this, 'Submenu').filter(item => item.opened).map(item => item.name); | 117 | + let openedNames = findComponentsDownward(this, 'MewSubmenu').filter(item => item.opened).map(item => item.name); |
| 118 | this.openedNames = [...openedNames]; | 118 | this.openedNames = [...openedNames]; |
| 119 | this.$emit('on-open-change', openedNames); | 119 | this.$emit('on-open-change', openedNames); |
| 120 | }, | 120 | }, |
| 121 | updateOpened () { | 121 | updateOpened () { |
| 122 | - const items = findComponentsDownward(this, 'Submenu'); | 122 | + const items = findComponentsDownward(this, 'MewSubmenu'); |
| 123 | 123 | ||
| 124 | if (items.length) { | 124 | if (items.length) { |
| 125 | items.forEach(item => { | 125 | items.forEach(item => { |
src/components/mew-menu/mixin.js
| @@ -2,15 +2,15 @@ import { findComponentUpward, findComponentsUpward } from '../../utils/assist'; | @@ -2,15 +2,15 @@ import { findComponentUpward, findComponentsUpward } from '../../utils/assist'; | ||
| 2 | export default { | 2 | export default { |
| 3 | data () { | 3 | data () { |
| 4 | return { | 4 | return { |
| 5 | - menu: findComponentUpward(this, 'Menu') | 5 | + menu: findComponentUpward(this, 'MewMenu') |
| 6 | }; | 6 | }; |
| 7 | }, | 7 | }, |
| 8 | computed: { | 8 | computed: { |
| 9 | hasParentSubmenu () { | 9 | hasParentSubmenu () { |
| 10 | - return !!findComponentUpward(this, 'Submenu'); | 10 | + return !!findComponentUpward(this, 'MewSubmenu'); |
| 11 | }, | 11 | }, |
| 12 | parentSubmenuNum () { | 12 | parentSubmenuNum () { |
| 13 | - return findComponentsUpward(this, 'Submenu').length; | 13 | + return findComponentsUpward(this, 'MewSubmenu').length; |
| 14 | }, | 14 | }, |
| 15 | mode () { | 15 | mode () { |
| 16 | return this.menu.mode; | 16 | return this.menu.mode; |
src/components/mew-menu/submenu.vue
| @@ -28,7 +28,7 @@ | @@ -28,7 +28,7 @@ | ||
| 28 | const prefixCls = 'ivu-menu'; | 28 | const prefixCls = 'ivu-menu'; |
| 29 | 29 | ||
| 30 | export default { | 30 | export default { |
| 31 | - name: 'Submenu', | 31 | + name: 'MewSubmenu', |
| 32 | mixins: [ Emitter, mixin ], | 32 | mixins: [ Emitter, mixin ], |
| 33 | components: { Icon, Drop, CollapseTransition }, | 33 | components: { Icon, Drop, CollapseTransition }, |
| 34 | props: { | 34 | props: { |
| @@ -78,7 +78,7 @@ | @@ -78,7 +78,7 @@ | ||
| 78 | }, | 78 | }, |
| 79 | // 3.4.0, global setting customArrow 有值时,arrow 赋值空 | 79 | // 3.4.0, global setting customArrow 有值时,arrow 赋值空 |
| 80 | arrowType () { | 80 | arrowType () { |
| 81 | - let type = 'ios-arrow-down'; | 81 | + let type = 'ios-arrow-forward'; |
| 82 | 82 | ||
| 83 | if (this.$IVIEW) { | 83 | if (this.$IVIEW) { |
| 84 | if (this.$IVIEW.menu.customArrow) { | 84 | if (this.$IVIEW.menu.customArrow) { |
| @@ -166,12 +166,12 @@ | @@ -166,12 +166,12 @@ | ||
| 166 | mounted () { | 166 | mounted () { |
| 167 | this.$on('on-menu-item-select', (name) => { | 167 | this.$on('on-menu-item-select', (name) => { |
| 168 | if (this.mode === 'horizontal') this.opened = false; | 168 | if (this.mode === 'horizontal') this.opened = false; |
| 169 | - this.dispatch('Menu', 'on-menu-item-select', name); | 169 | + this.dispatch('MewMenu', 'on-menu-item-select', name); |
| 170 | return true; | 170 | return true; |
| 171 | }); | 171 | }); |
| 172 | this.$on('on-update-active-name', (status) => { | 172 | this.$on('on-update-active-name', (status) => { |
| 173 | - if (findComponentUpward(this, 'Submenu')) this.dispatch('Submenu', 'on-update-active-name', status); | ||
| 174 | - if (findComponentsDownward(this, 'Submenu')) findComponentsDownward(this, 'Submenu').forEach(item => { | 173 | + if (findComponentUpward(this, 'MewSubmenu')) this.dispatch('MewSubmenu', 'on-update-active-name', status); |
| 174 | + if (findComponentsDownward(this, 'MewSubmenu')) findComponentsDownward(this, 'MewSubmenu').forEach(item => { | ||
| 175 | item.active = false; | 175 | item.active = false; |
| 176 | }); | 176 | }); |
| 177 | this.active = status; | 177 | this.active = status; |
src/styles/components/menu.less
| @@ -178,7 +178,6 @@ | @@ -178,7 +178,6 @@ | ||
| 178 | transform: rotate(180deg); | 178 | transform: rotate(180deg); |
| 179 | } | 179 | } |
| 180 | &-vertical &-opened > * > &-submenu-title-icon{ | 180 | &-vertical &-opened > * > &-submenu-title-icon{ |
| 181 | - transform: translateY(-50%) rotate(180deg); | ||
| 182 | } | 181 | } |
| 183 | 182 | ||
| 184 | &-vertical &-submenu{ | 183 | &-vertical &-submenu{ |
| @@ -240,6 +239,7 @@ | @@ -240,6 +239,7 @@ | ||
| 240 | &-active:not(.@{menu-prefix-cls}-submenu){ | 239 | &-active:not(.@{menu-prefix-cls}-submenu){ |
| 241 | /*wynn*/ | 240 | /*wynn*/ |
| 242 | color: @mew-common-color; | 241 | color: @mew-common-color; |
| 242 | + background: #f6f6f6; | ||
| 243 | //border-right: 2px solid @primary-color; | 243 | //border-right: 2px solid @primary-color; |
| 244 | } | 244 | } |
| 245 | } | 245 | } |
| @@ -266,7 +266,7 @@ | @@ -266,7 +266,7 @@ | ||
| 266 | &-dark&-vertical &-opened{ | 266 | &-dark&-vertical &-opened{ |
| 267 | background: @menu-dark-active-bg; | 267 | background: @menu-dark-active-bg; |
| 268 | .@{menu-prefix-cls}-submenu-title{ | 268 | .@{menu-prefix-cls}-submenu-title{ |
| 269 | - background: @menu-dark-title; | 269 | + background: #f6f6f6; |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | .@{menu-prefix-cls}-submenu-has-parent-submenu{ | 272 | .@{menu-prefix-cls}-submenu-has-parent-submenu{ |
src/utils/assist.js
| @@ -235,8 +235,15 @@ export function findComponentsUpward (context, componentName) { | @@ -235,8 +235,15 @@ export function findComponentsUpward (context, componentName) { | ||
| 235 | // Find brothers components | 235 | // Find brothers components |
| 236 | export function findBrothersComponents (context, componentName, exceptMe = true) { | 236 | export function findBrothersComponents (context, componentName, exceptMe = true) { |
| 237 | let res = context.$parent.$children.filter(item => { | 237 | let res = context.$parent.$children.filter(item => { |
| 238 | + if(componentName === "SideMenuItem"){ | ||
| 239 | + console.log(item) | ||
| 240 | + console.log(item.$options.name) | ||
| 241 | + } | ||
| 238 | return item.$options.name === componentName; | 242 | return item.$options.name === componentName; |
| 239 | }); | 243 | }); |
| 244 | + if(componentName === "SideMenuItem"){ | ||
| 245 | + console.log(res) | ||
| 246 | + } | ||
| 240 | let index = res.findIndex(item => item._uid === context._uid); | 247 | let index = res.findIndex(item => item._uid === context._uid); |
| 241 | if (exceptMe) res.splice(index, 1); | 248 | if (exceptMe) res.splice(index, 1); |
| 242 | return res; | 249 | return res; |