| | |
| | | class="header-search-select" |
| | | @change="change" |
| | | > |
| | | <el-option v-for="option in options" :key="option.item.path" :value="option.item" :label="option.item.title.join(' > ')" /> |
| | | <el-option v-for="option in options" :key="option.item.path" :value="option.item" |
| | | :label="option.item.title.join(' > ')"/> |
| | | </el-select> |
| | | </div> |
| | | </template> |
| | |
| | | } |
| | | const change = (val: any) => { |
| | | 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 = [] |
| | |
| | | } |
| | | // Filter out the routes that can be displayed in the sidebar |
| | | // And generate the internationalized title |
| | | const generateRoutes = (routes: RouteOption[], basePath = '', prefixTitle: string[] = []) => { |
| | | const generateRoutes = (routes: RouteOption[], basePath = '', prefixTitle: string[] = [], query: any = {}) => { |
| | | let res: Router = [] |
| | | routes.forEach(r => { |
| | | // skip hidden router |
| | |
| | | const p = r.path.length > 0 && r.path[0] === '/' ? r.path : '/' + r.path; |
| | | const data = { |
| | | path: !isHttp(r.path) ? getNormalPath(basePath + p) : r.path, |
| | | title: [...prefixTitle] |
| | | title: [...prefixTitle], |
| | | query: '' |
| | | } |
| | | if (r.meta && r.meta.title) { |
| | | data.title = [...data.title, r.meta.title]; |
| | |
| | | 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]; |
| | | } |