|
@@ -1,12 +1,34 @@
|
|
|
import Vue from "vue";
|
|
|
-import VueRouter, { Route, RouteConfig } from "vue-router";
|
|
|
-import layout from "../views/layout/index.vue";
|
|
|
-import { getTitle } from "@/utils";
|
|
|
+import VueRouter, { RouteConfig } from "vue-router";
|
|
|
+import layout from "@/layout/index.vue";
|
|
|
import user from "@/store/modules/user";
|
|
|
import { Loading } from "element-ui";
|
|
|
import { Message } from "@/utils/message";
|
|
|
import { login } from "@/utils/cookies";
|
|
|
+import { setPageTitle } from "@/utils";
|
|
|
Vue.use(VueRouter);
|
|
|
+export const nav: RouteConfig[] = [
|
|
|
+ {
|
|
|
+ path: "/home",
|
|
|
+ component: () => import("../views/home/index.vue"),
|
|
|
+ meta: { title: "home" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "/mall",
|
|
|
+ component: () => import("../views/mall/index.vue"),
|
|
|
+ meta: { title: "mall" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "/shops",
|
|
|
+ component: () => import("../views/shops/index.vue"),
|
|
|
+ meta: { title: "shops" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "/info",
|
|
|
+ component: () => import("../views/info/index.vue"),
|
|
|
+ meta: { title: "info" }
|
|
|
+ }
|
|
|
+];
|
|
|
const router = new VueRouter({
|
|
|
mode: "history",
|
|
|
base: process.env.BASE_URL,
|
|
@@ -23,16 +45,104 @@ const router = new VueRouter({
|
|
|
component: layout,
|
|
|
redirect: "/home",
|
|
|
children: [
|
|
|
+ ...nav,
|
|
|
+ {
|
|
|
+ path: "/login",
|
|
|
+ component: () => import("../views/account/login.vue"),
|
|
|
+ meta: { title: "login" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "/register",
|
|
|
+ component: () => import("../views/account/register.vue"),
|
|
|
+ meta: { title: "register" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "/findPassword",
|
|
|
+ component: () => import("../views/account/findPassword.vue"),
|
|
|
+ meta: { title: "findPassword" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "/user",
|
|
|
+ component: () => import("../views/account/user/index.vue"),
|
|
|
+ // meta: { title: "user" },
|
|
|
+ redirect: "/user/collect",
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ path: "collect",
|
|
|
+ component: () => import("../views/account/user/collect.vue"),
|
|
|
+ meta: { title: "collect" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "issue",
|
|
|
+ component: () => import("../views/account/user/issue.vue"),
|
|
|
+ meta: { title: "issue" }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "/shop/:sid",
|
|
|
+ component: () => import("../views/shops/details/index.vue"),
|
|
|
+ redirect: "/shop/:sid/products",
|
|
|
+ props: true,
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ path: "products",
|
|
|
+ component: () => import("../views/shops/details/products.vue"),
|
|
|
+ meta: { title: "shopDetails" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "honor",
|
|
|
+ component: () => import("../views/shops/details/honor.vue"),
|
|
|
+ meta: { title: "shopHonor" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "profile",
|
|
|
+ component: () => import("../views/shops/details/profile.vue"),
|
|
|
+ meta: { title: "shopProfile" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: ":pid",
|
|
|
+ props: true,
|
|
|
+ component: () => import("../views/shops/details/product.vue"),
|
|
|
+ meta: { title: "productDetails" }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "/shopEnter",
|
|
|
+ component: () => import("../views/shops/enter/index.vue"),
|
|
|
+ meta: { title: "shopEnter" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "/shopEnter/add",
|
|
|
+ component: () => import("../views/shops/enter/add.vue"),
|
|
|
+ meta: { title: "shopEnterAdd" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "/info/buy",
|
|
|
+ component: () => import("../views/info/details/buy.vue"),
|
|
|
+ meta: { title: "infoBuy" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "/info/sell",
|
|
|
+ component: () => import("../views/info/details/sell.vue"),
|
|
|
+ meta: { title: "infoSell" }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: "/info/add",
|
|
|
+ component: () => import("../views/info/add.vue"),
|
|
|
+ meta: { title: "infoAdd" }
|
|
|
+ },
|
|
|
{
|
|
|
- path: "/home",
|
|
|
- component: () => import("../views/home/index.vue"),
|
|
|
- meta: { title: "首页", nav: true }
|
|
|
+ path: "/news",
|
|
|
+ component: () => import("../views/news/index.vue"),
|
|
|
+ meta: { title: "news" }
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
path: "/error/:code",
|
|
|
- component: () => import("../views/error.vue")
|
|
|
+ component: () => import("../views/errorPage/index.vue")
|
|
|
}
|
|
|
]
|
|
|
});
|
|
@@ -58,13 +168,12 @@ router.beforeEach(async (to, from, next) => {
|
|
|
fullscreen: true,
|
|
|
text: "跳转中..."
|
|
|
});
|
|
|
- if (errCode)
|
|
|
- return next({
|
|
|
- path: `/error/${errCode}`,
|
|
|
- replace: true
|
|
|
- });
|
|
|
- const title = getTitle(to);
|
|
|
- if (title) document.title = `${title} - ${process.env.VUE_APP_publicName}`;
|
|
|
+ // if (errCode)
|
|
|
+ // return next({
|
|
|
+ // path: `/error/${errCode}`,
|
|
|
+ // replace: true
|
|
|
+ // });
|
|
|
+ setPageTitle(to.meta.title);
|
|
|
next();
|
|
|
});
|
|
|
router.afterEach((to, from) =>
|