修复HeaderSearch组件跳转query参数丢失问题

master
RuoYi 1 year ago
parent 8e7754c5d7
commit e8fe5f1455
  1. 12
      src/components/HeaderSearch/index.vue

@ -45,13 +45,18 @@ 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 {
if (query) {
router.push({ path: path, query: JSON.parse(query) });
} else {
router.push(path)
}
}
search.value = ''
options.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]
}

Loading…
Cancel
Save