diff --git a/src/stores/permisstion.js b/src/stores/permisstion.js index 5733e3d..ddf9255 100644 --- a/src/stores/permisstion.js +++ b/src/stores/permisstion.js @@ -43,14 +43,6 @@ export const usePermisstionStroe = defineStore('permisstion', () => { route.component = loadView(route.component) } } - if (route.pathParams != null) { - let pathParams = route.pathParams - route.pathParams = JSON.parse(route.pathParams) - route.query = {} - for (const key in route.pathParams) { - route.query = {[key]: route.pathParams[key]} - } - } if (route.children !== null && route.children && route.children.length !== 0) { route.children = formatAsyncRouters(route.children) } @@ -69,12 +61,32 @@ export const usePermisstionStroe = defineStore('permisstion', () => { if (item.children && item.children.length !== 0) { generateMenu(item.children) } + if (item.pathParams != null) { + item.path = formatPath(item.path, JSON.parse(item.pathParams)) + } item.title = item.meta.title item.icon = item.meta.icon return true }) } + // 拼接地址 + const formatPath = (path, query) => { + const queryArr = [] + let newPath = path + for (const key in query) { + queryArr.push({label: key, value: query[key]}) + } + queryArr.forEach((item, index)=>{ + if(!index) { + newPath += `?${item.label}=${item.value}` + } else { + newPath += `&${item.label}=${item.value}` + } + }) + return newPath + } + const loadView = (view) => { if (import.meta.env.MODE === 'development') {