From e8fe5f14553e4e95050dc1e929f6fb545ed80148 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期四, 28 九月 2023 22:12:58 +0800
Subject: [PATCH] 修复HeaderSearch组件跳转query参数丢失问题

---
 src/components/HeaderSearch/index.vue |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/components/HeaderSearch/index.vue b/src/components/HeaderSearch/index.vue
index 89acd33..4aadce6 100644
--- a/src/components/HeaderSearch/index.vue
+++ b/src/components/HeaderSearch/index.vue
@@ -45,12 +45,17 @@
 }
 function change(val) {
   const path = val.path;
+  const query = val.query;
   if (isHttp(path)) {
     // http(s):// 璺緞鏂扮獥鍙f墦寮�
     const pindex = path.indexOf("http");
     window.open(path.substr(pindex, path.length), "_blank");
   } else {
-    router.push(path)
+    if (query) {
+      router.push({ path: path, query: JSON.parse(query) });
+    } else {
+      router.push(path)
+    }
   }
 
   search.value = ''
@@ -65,7 +70,6 @@
     threshold: 0.4,
     location: 0,
     distance: 100,
-    maxPatternLength: 32,
     minMatchCharLength: 1,
     keys: [{
       name: 'title',
@@ -78,7 +82,7 @@
 }
 // Filter out the routes that can be displayed in the sidebar
 // And generate the internationalized title
-function generateRoutes(routes, basePath = '', prefixTitle = []) {
+function generateRoutes(routes, basePath = '', prefixTitle = [], query = {}) {
   let res = []
 
   for (const r of routes) {
@@ -99,10 +103,13 @@
         res.push(data)
       }
     }
+    if (r.query) {
+      data.query = r.query
+    }
 
     // recursive child routes
     if (r.children) {
-      const tempRoutes = generateRoutes(r.children, data.path, data.title)
+      const tempRoutes = generateRoutes(r.children, data.path, data.title, data.query)
       if (tempRoutes.length >= 1) {
         res = [...res, ...tempRoutes]
       }

--
Gitblit v1.9.3