From f9a6a467a60a4f28b0ba34a778c687b605d3b8eb Mon Sep 17 00:00:00 2001
From: 梁灏 <admin@aresn.com>
Date: Sun, 1 Jul 2018 11:33:33 +0800
Subject: [PATCH] update Button

---
 src/components/button/button.vue |  9 ++++++---
 src/mixins/link.js               | 18 +++++++++++-------
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/components/button/button.vue b/src/components/button/button.vue
index 76e0fce..d2c7be0 100644
--- a/src/components/button/button.vue
+++ b/src/components/button/button.vue
@@ -5,7 +5,9 @@
         :disabled="disabled"
         :href="linkUrl"
         :target="target"
-        @click="handleClickLink">
+        @click.exact="handleClickLink($event, false)"
+        @click.ctrl="handleClickLink($event, true)"
+        @click.meta="handleClickLink($event, true)">
         <Icon class="ivu-load-loop" type="ios-loading" v-if="loading"></Icon>
         <Icon :type="icon" :custom="customIcon" v-if="(icon || customIcon) && !loading"></Icon>
         <span v-if="showSlot" ref="slot"><slot></slot></span>
@@ -99,10 +101,11 @@
             }
         },
         methods: {
-            handleClickLink (event) {
+            // Ctrl or CMD and click, open in new window when use `to`
+            handleClickLink (event, new_window) {
                 this.$emit('click', event);
 
-                this.handleCheckClick(event);
+                this.handleCheckClick(event, new_window);
             }
         },
         mounted () {
diff --git a/src/mixins/link.js b/src/mixins/link.js
index c1ca187..e2ff4d8 100644
--- a/src/mixins/link.js
+++ b/src/mixins/link.js
@@ -24,21 +24,25 @@ export default {
         }
     },
     methods: {
-        handleClick () {
-            const isRoute = this.$router;
-            if (isRoute) {
-                this.replace ? this.$router.replace(this.to) : this.$router.push(this.to);
+        handleClick (new_window = false) {
+            if (new_window){
+                window.open(this.to);
             } else {
-                window.location.href = this.to;
+                const isRoute = this.$router;
+                if (isRoute) {
+                    this.replace ? this.$router.replace(this.to) : this.$router.push(this.to);
+                } else {
+                    window.location.href = this.to;
+                }
             }
         },
-        handleCheckClick (event) {
+        handleCheckClick (event, new_window = false) {
             if (this.to) {
                 if (this.target === '_blank') {
                     return false;
                 } else {
                     event.preventDefault();
-                    this.handleClick();
+                    this.handleClick(new_window);
                 }
             }
         }
--
libgit2 0.21.4