把 XH巡课 的当前可运行版本放进仓库,方便后续继续改并同步。
This commit is contained in:
commit
6e5107f1b6
134 files changed
+11284
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import { useAuthStore } from "../stores/auth";
|
||||
|
||||
export const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
{ path: "/login", component: () => import("../views/Login.vue") },
|
||||
{ path: "/register", component: () => import("../views/Register.vue") },
|
||||
{ path: "/", component: () => import("../views/Home.vue") },
|
||||
{ path: "/studio", component: () => import("../views/Studio.vue"), meta: { auth: true } },
|
||||
{ path: "/watch/:id", component: () => import("../views/Watch.vue"), meta: { auth: true } },
|
||||
{ path: "/inspect", component: () => import("../views/Inspect.vue"), meta: { auth: true } },
|
||||
{ path: "/admin", component: () => import("../views/Admin.vue"), meta: { auth: true } },
|
||||
{ path: "/replays", component: () => import("../views/Replays.vue"), meta: { auth: true } }
|
||||
]
|
||||
});
|
||||
|
||||
router.beforeEach(async (to) => {
|
||||
if (!to.meta.auth) return true;
|
||||
const auth = useAuthStore();
|
||||
if (auth.user) return true;
|
||||
try {
|
||||
await auth.refresh();
|
||||
return true;
|
||||
} catch {
|
||||
return "/login";
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user