This commit is contained in:
xiaozhiyong
2023-02-14 13:35:22 +08:00
parent 3796514d32
commit 308362a143
11 changed files with 679 additions and 120 deletions

View File

@@ -12,66 +12,10 @@ NProgress.configure({ showSpinner: false }); // NProgress Configuration
const whiteList = ["/login"]; // no redirect whitelist
const asyncRoutes = [
{
component: "Layout",
hidden: false,
menuType: "C",
meta: { title: "", icon: "" },
path: "/",
children: [
{
component: "refineryInfo/index",
hidden: false,
menuType: "C",
meta: { title: "炼厂信息", icon: "iconfenpei3" },
name: "refineryInfo",
path: "refineryInfo",
},
],
},
{
component: "Layout",
hidden: false,
menuType: "C",
meta: { title: "", icon: "" },
path: "/",
children: [
{
component: "product/index",
hidden: false,
menuType: "C",
meta: { title: "产品列表", icon: "iconfenpei3" },
name: "Product",
path: "product",
},
],
},
{
component: "Layout",
hidden: false,
menuType: "C",
meta: { title: "", icon: "" },
path: "/",
children: [
{
component: "order/index",
hidden: false,
menuType: "C",
meta: { title: "订单管理", icon: "iconfenpei3" },
name: "Order",
path: "order",
},
],
},
];
router.beforeEach(async (to, from, next) => {
NProgress.start();
document.title = getPageTitle(to.meta.title);
const hasToken = localStorage.getItem("token");
// const hasToken = 1;
if (hasToken) {
if (to.path === "/login") {
next({ path: "/" });
@@ -91,8 +35,7 @@ router.beforeEach(async (to, from, next) => {
};
store.dispatch("user/info", infoRes.data);
// let routerRes = await serve.getRouter();
let routerRes = { data: asyncRoutes };
let routerRes = await serve.getCustomerRouters();
let realRouter = filterAsyncRouter(routerRes.data);
store.dispatch("permission/generateRoutes", realRouter);
router.addRoutes(realRouter);