路由权限重构
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -171,7 +171,7 @@ const tabChange = (k: string) => {
|
||||
|
||||
// 高风险场景查看变更
|
||||
const openSceneChange = (record: any) => {
|
||||
routerPushByKey('home_highriskdetail', { query: { params: JSON.stringify(record) } })
|
||||
routerPushByKey('details_index', { query: { params: JSON.stringify(record) } })
|
||||
};
|
||||
// 查看分析记录
|
||||
const viewAnalysis = (record: any) => {
|
||||
|
||||
@@ -91,7 +91,7 @@ const opts = computed<Opt[]>(() => {
|
||||
// 打开详情、修改重报
|
||||
const openDetail = (c: any,type:string = '') => {
|
||||
if(type==='detail'){
|
||||
routerPushByKey("my_highriskdetail",{ query: { id: c.change_id.toString() } });
|
||||
routerPushByKey("details_index",{ query: { id: c.change_id.toString() } });
|
||||
}
|
||||
if(type==='edit'){
|
||||
routerPushByKey("my_initiatechange",{ query: { id: c.change_id.toString() } });
|
||||
|
||||
@@ -61,7 +61,7 @@ const downloadFile = (record: any) => {
|
||||
};
|
||||
// 打开变更单
|
||||
const openChange = (record: any) => {
|
||||
routerPushByKey('home_highriskdetail', { query: { params: JSON.stringify(record) } })
|
||||
routerPushByKey('details_index', { query: { params: JSON.stringify(record) } })
|
||||
};
|
||||
// 填写投用日期
|
||||
const fillUseTime = (record: any) => {
|
||||
|
||||
@@ -136,7 +136,7 @@ const downloadTemplate = (record: any) => {
|
||||
};
|
||||
// 打开变更单
|
||||
const openChange = (record: any) => {
|
||||
routerPushByKey('home_highriskdetail', { query: { params: JSON.stringify(record) } })
|
||||
routerPushByKey('details_index', { query: { params: JSON.stringify(record) } })
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
@@ -169,22 +169,32 @@ const getAllPaths = (tree:any) => {
|
||||
})
|
||||
return paths
|
||||
}
|
||||
|
||||
// 过滤路由
|
||||
const filterRoutes = (routes:any) => {
|
||||
return routes
|
||||
.filter((route:any) => route.name != null && route.meta?.constant !== true)
|
||||
.map((route:any) => ({
|
||||
...route,
|
||||
children: Array.isArray(route.children)
|
||||
? filterRoutes(route.children)
|
||||
: route.children
|
||||
}));
|
||||
}
|
||||
// 获取所有路由
|
||||
const getAllRoutes = () => {
|
||||
console.log(router.getRoutes())
|
||||
const filtered = router.getRoutes().filter((item:any) => {
|
||||
// 条件1:有name且非常量
|
||||
if (item.name === undefined || item.meta?.constant === true) return false;
|
||||
// 条件2:path中斜杠数量 < 2(即只有一级)
|
||||
const path = item.path || '';
|
||||
const slashCount = (path.match(/\//g) || []).length;
|
||||
if (slashCount >= 2) return false;
|
||||
return true;
|
||||
})
|
||||
// 过滤路由
|
||||
const result = filterRoutes(router.getRoutes());
|
||||
console.log(router.getRoutes());
|
||||
// 过滤一级路由
|
||||
const filtered = result.filter((route:any) => {
|
||||
// 计算 path 中 '/' 的个数
|
||||
const slashCount = (route.path.match(/\//g) || []).length;
|
||||
return slashCount <= 1;
|
||||
});
|
||||
// 复制title到顶层
|
||||
const tree = filtered.map((item:any) => copyTitleToTop(item));
|
||||
routeTree.value = tree;
|
||||
|
||||
console.log(tree)
|
||||
allPaths.value = getAllPaths(tree);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user