Commit 2a7765f93d23cab86afdb80e89bf656fe5207dac
1 parent
f9a6a467
update Menu
Showing
2 changed files
with
23 additions
and
10 deletions
Show diff stats
src/components/button/button.vue
@@ -102,7 +102,7 @@ | @@ -102,7 +102,7 @@ | ||
102 | }, | 102 | }, |
103 | methods: { | 103 | methods: { |
104 | // Ctrl or CMD and click, open in new window when use `to` | 104 | // Ctrl or CMD and click, open in new window when use `to` |
105 | - handleClickLink (event, new_window) { | 105 | + handleClickLink (event, new_window = false) { |
106 | this.$emit('click', event); | 106 | this.$emit('click', event); |
107 | 107 | ||
108 | this.handleCheckClick(event, new_window); | 108 | this.handleCheckClick(event, new_window); |
src/components/menu/menu-item.vue
1 | <template> | 1 | <template> |
2 | - <a v-if="to" :href="linkUrl" :target="target" :class="classes" @click="handleClickItem" :style="itemStyle"><slot></slot></a> | 2 | + <a |
3 | + v-if="to" | ||
4 | + :href="linkUrl" | ||
5 | + :target="target" | ||
6 | + :class="classes" | ||
7 | + @click.exact="handleClickItem($event, false)" | ||
8 | + @click.ctrl="handleClickItem($event, true)" | ||
9 | + @click.meta="handleClickItem($event, true)" | ||
10 | + :style="itemStyle"><slot></slot></a> | ||
3 | <li v-else :class="classes" @click.stop="handleClickItem" :style="itemStyle"><slot></slot></li> | 11 | <li v-else :class="classes" @click.stop="handleClickItem" :style="itemStyle"><slot></slot></li> |
4 | </template> | 12 | </template> |
5 | <script> | 13 | <script> |
@@ -46,18 +54,23 @@ | @@ -46,18 +54,23 @@ | ||
46 | } | 54 | } |
47 | }, | 55 | }, |
48 | methods: { | 56 | methods: { |
49 | - handleClickItem (event) { | 57 | + handleClickItem (event, new_window = false) { |
50 | if (this.disabled) return; | 58 | if (this.disabled) return; |
51 | 59 | ||
52 | - let parent = findComponentUpward(this, 'Submenu'); | ||
53 | - | ||
54 | - if (parent) { | ||
55 | - this.dispatch('Submenu', 'on-menu-item-select', this.name); | 60 | + if (new_window) { |
61 | + // 如果是 new_window,直接新开窗口就行,无需发送状态 | ||
62 | + this.handleCheckClick(event, new_window); | ||
56 | } else { | 63 | } else { |
57 | - this.dispatch('Menu', 'on-menu-item-select', this.name); | ||
58 | - } | 64 | + let parent = findComponentUpward(this, 'Submenu'); |
59 | 65 | ||
60 | - this.handleCheckClick(event); | 66 | + if (parent) { |
67 | + this.dispatch('Submenu', 'on-menu-item-select', this.name); | ||
68 | + } else { | ||
69 | + this.dispatch('Menu', 'on-menu-item-select', this.name); | ||
70 | + } | ||
71 | + | ||
72 | + this.handleCheckClick(event, new_window); | ||
73 | + } | ||
61 | } | 74 | } |
62 | }, | 75 | }, |
63 | mounted () { | 76 | mounted () { |