101 lines
4.0 KiB
TypeScript
101 lines
4.0 KiB
TypeScript
import { RootNodeDict } from "@/types";
|
|
import { cloneDeep } from "lodash";
|
|
const beforeCount = 7;
|
|
const ROUTE_MAP: any = {
|
|
0: {
|
|
superAdmin: [{ page: "/", name: "学习中心管理", icon: "home", modId: 1001 }],
|
|
school: [{ page: "/", name: "学习中心管理", icon: "home", modId: 1001 }],
|
|
teacher: [{ page: "/", name: "学习中心管理", icon: "home", modId: 1001 }],
|
|
},
|
|
1: {
|
|
superAdmin: [{ page: "/subject", name: "学段学科设置", icon: "home", modId: 1002 }],
|
|
school: [{ page: "/subject", name: "学段学科设置", icon: "home", modId: 1002 }],
|
|
teacher: [],
|
|
},
|
|
2: {
|
|
superAdmin: [
|
|
{ page: "/textbook/list", name: "基础教材设置", icon: "home", modId: 2001 },
|
|
{ page: "/textbook/school", name: "学校教材设置", icon: "home", modId: 2002 },
|
|
{ page: "/textbook/manage", name: "教材管理", icon: "home", modId: 2004 },
|
|
],
|
|
school: [
|
|
{ page: "/textbook", name: "教材设置", icon: "home", modId: 2003 },
|
|
{ page: "/textbook/manage", name: "教材管理", icon: "home", modId: 2004 },
|
|
],
|
|
teacher: [],
|
|
},
|
|
3: {
|
|
superAdmin: [
|
|
{ page: "/tutorboox/list", name: "基础教辅设置", icon: "home", modId: 3001 },
|
|
{ page: "/tutorboox/school", name: "学校教辅设置", icon: "home", modId: 3002 },
|
|
{ page: "/tutorboox/manage", name: "教辅管理", icon: "home", modId: 3004 },
|
|
],
|
|
school: [
|
|
{ page: "/tutorboox", name: "教辅设置", icon: "home", modId: 3003 },
|
|
{ page: "/tutorboox/manage", name: "教辅管理", icon: "home", modId: 3004 },
|
|
],
|
|
teacher: [],
|
|
},
|
|
4: {
|
|
superAdmin: [
|
|
{ page: "/knowbook/list", name: "基础知识点设置", icon: "home", modId: 4001 },
|
|
{ page: "/knowbook/school", name: "学校知识点设置", icon: "home", modId: 4002 },
|
|
{ page: "/knowbook/manage", name: "知识点管理", icon: "home", modId: 4004 },
|
|
],
|
|
school: [
|
|
{ page: "/knowbook", name: "知识点设置", icon: "home", modId: 4003 },
|
|
{ page: "/knowbook/manage", name: "知识点管理", icon: "home", modId: 4004 },
|
|
],
|
|
teacher: [],
|
|
},
|
|
5: {
|
|
superAdmin: [{ page: "/nodeauthorize", name: "开通设置", icon: "home", modId: 5001 }],
|
|
school: [{ page: "/nodeauthorize", name: "开通设置", icon: "home", modId: 5001 }],
|
|
teacher: [],
|
|
},
|
|
6: {
|
|
superAdmin: [{ page: "/interacttask", name: "交互设置", icon: "home", modId: 6001 }],
|
|
school: [{ page: "/interacttask", name: "交互设置", icon: "home", modId: 6001 }],
|
|
teacher: [],
|
|
},
|
|
};
|
|
|
|
export function getLeftMenuRoutes(entranceId: number, identity: number) {
|
|
const tempMap: any = cloneDeep(ROUTE_MAP);
|
|
|
|
RootNodeDict.forEach((element, index) => {
|
|
const idx = beforeCount + 1 + index;
|
|
const item = {
|
|
superAdmin: [
|
|
{
|
|
page: `/${element.path}/tree`,
|
|
name: element.v + "目录树",
|
|
icon: "home",
|
|
modId: idx * 1000 + 1,
|
|
},
|
|
{ page: "/enable/" + (index + 1), name: element.v + "目录开通", modId: idx * 1000 + 2 },
|
|
],
|
|
school: [{ page: `/${element.path}/tree`, name: "目录树列表", icon: "home", modId: idx * 1000 + 1 }],
|
|
teacher: [],
|
|
};
|
|
tempMap[idx] = item;
|
|
});
|
|
|
|
const entrance = tempMap[entranceId];
|
|
if (!entrance) return [];
|
|
let key: any = {
|
|
1: "superAdmin",
|
|
2: "school",
|
|
3: "teacher",
|
|
};
|
|
const list = entrance[key[identity]];
|
|
return list || [];
|
|
}
|
|
|
|
export function getRoutes(entranceId: number, identity: number, modId: number) {
|
|
const list = getLeftMenuRoutes(entranceId, identity);
|
|
return list.find((item: any) => item.modId === modId);
|
|
}
|
|
|
|
export { beforeCount };
|