Explorar o código

在搜索页进行搜索时不打开新标签

reghao %!s(int64=4) %!d(string=hai) anos
pai
achega
87a545bf2b
Modificáronse 1 ficheiros con 17 adicións e 13 borrados
  1. 17 13
      src/layout/components/search-input.vue

+ 17 - 13
src/layout/components/search-input.vue

@@ -70,19 +70,23 @@ export default {
     },
     search() {
       this.$refs.search.blur()
-      /* this.$router.push({
-        path: '/search/result',
-        query: {
-          keyword: this.text
-        }
-      })*/
-      const routeUrl = this.$router.resolve({
-        path: '/search/result',
-        query: {
-          keyword: this.text
-        }
-      })
-      window.open(routeUrl.href, '_blank')
+      const currentUrl = this.$route.path
+      if (currentUrl === '/search/result') {
+        this.$router.push({
+          path: '/search/result',
+          query: {
+            keyword: this.text
+          }
+        })
+      } else {
+        const routeUrl = this.$router.resolve({
+          path: '/search/result',
+          query: {
+            keyword: this.text
+          }
+        })
+        window.open(routeUrl.href, '_blank')
+      }
     }
   }
 }