From e8fe5f14553e4e95050dc1e929f6fb545ed80148 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 28 Sep 2023 22:12:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DHeaderSearch=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=B7=B3=E8=BD=ACquery=E5=8F=82=E6=95=B0=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/HeaderSearch/index.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/HeaderSearch/index.vue b/src/components/HeaderSearch/index.vue index 7451037..4aadce6 100644 --- a/src/components/HeaderSearch/index.vue +++ b/src/components/HeaderSearch/index.vue @@ -45,12 +45,17 @@ function close() { } function change(val) { const path = val.path; + const query = val.query; if (isHttp(path)) { // http(s):// 路径新窗口打开 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 = '' @@ -77,7 +82,7 @@ function initFuse(list) { } // 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) { @@ -98,10 +103,13 @@ function generateRoutes(routes, basePath = '', prefixTitle = []) { 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] }