瀏覽代碼

修复首页搜索菜单外链无法点击跳转问题

RuoYi 5 年之前
父節點
當前提交
cc0cfdcf7e
共有 1 個文件被更改,包括 10 次插入2 次删除
  1. 10 2
      ruoyi-ui/src/components/HeaderSearch/index.vue

+ 10 - 2
ruoyi-ui/src/components/HeaderSearch/index.vue

@@ -70,7 +70,12 @@ export default {
70 70
       this.show = false
71 71
     },
72 72
     change(val) {
73
-      this.$router.push(val.path)
73
+      if(this.ishttp(val.path)) {
74
+        // http(s):// 路径新窗口打开
75
+        window.open(val.path, "_blank");
76
+      } else {
77
+        this.$router.push(val.path)
78
+      }
74 79
       this.search = ''
75 80
       this.options = []
76 81
       this.$nextTick(() => {
@@ -104,7 +109,7 @@ export default {
104 109
         if (router.hidden) { continue }
105 110
 
106 111
         const data = {
107
-          path: path.resolve(basePath, router.path),
112
+          path: !this.ishttp(router.path) ? path.resolve(basePath, router.path) : router.path,
108 113
           title: [...prefixTitle]
109 114
         }
110 115
 
@@ -134,6 +139,9 @@ export default {
134 139
       } else {
135 140
         this.options = []
136 141
       }
142
+    },
143
+    ishttp(url) {
144
+      return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1
137 145
     }
138 146
   }
139 147
 }