提交源文件

This commit is contained in:
gyq
2024-02-19 09:39:40 +08:00
commit 6bb26dd514
23 changed files with 850 additions and 0 deletions

40
src/router/index.js Normal file
View File

@@ -0,0 +1,40 @@
import { createRouter, createWebHashHistory } from "vue-router";
import home from "@/views/home.vue";
const routes = [
{
path: "/",
name: "home",
component: home,
},
{
path: "/login",
name: "login",
meta: {
index: 0,
},
component: () => import("@/views/login.vue"),
},
{
path: "/register",
name: "register",
meta: {
index: 1,
},
component: () => import("@/views/register.vue"),
},
];
const router = createRouter({
history: createWebHashHistory(),
routes,
});
router.beforeEach(async (to, from) => {
const token = localStorage.getItem("token");
if (!token && to.name !== "login" && to.name !== "register") {
return { name: "login" };
}
});
export default router;