This commit is contained in:
oneao committed 2025-06-10 21:27:20 +08:00
commit c570ec514c
550 files changed
+152597

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
import { useUserStore } from "@/store/modules/user";
import { Message } from "@arco-design/web-vue";
import type { App } from "vue";
import { createRouter, createWebHashHistory } from "vue-router";
import routes from "./routes";
const router = createRouter({
history: createWebHashHistory(),
strict: true,
routes: routes,
scrollBehavior: () => ({ left: 0, top: 0 })
});
const whiteList = ["/login"];
router.beforeEach((to, from, next) => {
window.NProgress?.start?.();
const userStore = useUserStore();
const isLogin = userStore.isLogined;
const isWhiteListed = whiteList.includes(to.path);
if (!isLogin && !isWhiteListed) {
Message.warning("尚未登录,请先登录!");
setTimeout(() => {
next("/login");
}, 500);
} else {
next();
}
});
router.afterEach(() => {
window.NProgress?.done?.();
});
export function setupRouter(app: App) {
app.use(router);
}
+47
View File
@@ -0,0 +1,47 @@
import { RouteRecordRaw } from "vue-router";
import BaseLayout from "@/layouts/base-layout/index.vue";
const routes: RouteRecordRaw[] = [
{
path: "/",
component: BaseLayout,
redirect: "/home",
children: [
{
path: "/home",
name: "home",
component: () => import("@/pages/home/index.vue"),
meta: { keepAlive: true }
},
{
path: "/write",
name: "write",
component: () => import("@/pages/write/index.vue"),
meta: { keepAlive: false }
},
{
path: "/test",
component: () => import("@/pages/test/index.vue")
},
{
path: "/setting",
component: () => import("@/pages/setting/index.vue"),
redirect: "/setting/account",
meta: { keepAlive: true },
children: [
{
path: "account",
component: () => import("@/pages/setting/account/index.vue"),
meta: { keepAlive: true }
}
]
}
]
},
{
path: "/login",
component: () => import("@/pages/auth/login.vue")
}
];
export default routes;