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

This commit is contained in:
疯狂的狮子Li
2023-10-09 11:29:20 +08:00
parent c1520bb423
commit 78d22032d1
2 changed files with 25 additions and 7 deletions

View File

@@ -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) {
@@ -99,9 +104,13 @@ function generateRoutes(routes, basePath = '', prefixTitle = []) {
}
}
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]
}
@@ -176,4 +185,4 @@ watch(searchPool, (list) => {
}
}
}
</style>
</style>