|
|
@@ -1,21 +1,24 @@
|
|
|
import { createRouter, createWebHistory } from "vue-router";
|
|
|
-import PortalPage from "@/views/PortalPage/PortalPage";
|
|
|
+import AuthPage from "@/views/AuthPage/AuthPage";
|
|
|
+import store from "@/store";
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
+
|
|
|
|
|
|
const routes = [
|
|
|
{
|
|
|
path: "/",
|
|
|
- redirect: "/portal",
|
|
|
+ redirect: "/auth",
|
|
|
},
|
|
|
{
|
|
|
path: "/portal",
|
|
|
name: "Portal",
|
|
|
- // 落地页同步加载
|
|
|
- component: PortalPage,
|
|
|
+ component: () => import("../views/PortalPage/PortalPage.vue"),
|
|
|
},
|
|
|
{
|
|
|
path: "/auth",
|
|
|
name: "Auth",
|
|
|
- component: () => import("../views/AuthPage/AuthPage.vue"),
|
|
|
+ // 落地页同步加载
|
|
|
+ component: AuthPage,
|
|
|
},
|
|
|
{
|
|
|
path: "/task",
|
|
|
@@ -60,4 +63,18 @@ const router = createRouter({
|
|
|
routes,
|
|
|
});
|
|
|
|
|
|
+router.beforeEach((to, from, next) => {
|
|
|
+ if (to.name !== "Auth" && !store.state.user.token) {
|
|
|
+ ElMessage({
|
|
|
+ showClose: true,
|
|
|
+ message: "请先登录",
|
|
|
+ type: "warning",
|
|
|
+ duration: 1000,
|
|
|
+ });
|
|
|
+ next({ name: "Auth" });
|
|
|
+ } else {
|
|
|
+ next();
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
export default router;
|