feat: 初始化
This commit is contained in:
commit
13970b6062
62 files changed
+1854
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { createWebHashHistory, createRouter } from "vue-router";
|
||||
import routes from "./routes";
|
||||
import pinia from "../store/pinia";
|
||||
import { baseInfo } from "../store";
|
||||
|
||||
const baseInfoStore = baseInfo(pinia);
|
||||
const history = createWebHashHistory();
|
||||
|
||||
|
||||
const router = createRouter({
|
||||
history,
|
||||
routes: routes
|
||||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta && to.meta.power) {
|
||||
const user = baseInfoStore.userInfo.value;
|
||||
if (user.uin) {
|
||||
next();
|
||||
} else {
|
||||
next({
|
||||
path: "/loginfo",
|
||||
query: {
|
||||
rediret: to.fullPath
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
@@ -0,0 +1,15 @@
|
||||
const routes = [
|
||||
{ path: "/", name: "root", redirect: "/home" },
|
||||
{ path: "/home", name: "home", meta: { power: true }, component: () => import("../pages/Home.vue") },
|
||||
{ path: "/loginfo", name: "loginfo", component: () => import("../pages/Login.vue") },
|
||||
{ path: "/nonetwork:text?", name: "nonetwork", props: true, component: () => import("../pages/error/NoNetwork.vue") },
|
||||
{ path: "/noaccess/:text?", name: "noaccess", props: true, component: () => import("../pages/error/NoAccess.vue") },
|
||||
{ path: "/empty/:text?", name: "empty", props: true, component: () => import("../pages/error/NoData.vue") },
|
||||
{ path: "/deviceabnormal/:text?", name: "deviceabnormal", props: true, component: () => import("../pages/error/DeviceAbnormal.vue") },
|
||||
{ path: "/failed/:text?", name: "failed", props: true, component: () => import("../pages/error/Failed.vue") },
|
||||
{ path: "/500/:text?", name: "500", props: true, component: () => import("../pages/error/500.vue") },
|
||||
{ path: "/404", name: "404", component: () => import("../pages/error/404.vue") },
|
||||
{ path: "/:catchAll(.*)", redirect: "/404", hidden: true }
|
||||
];
|
||||
|
||||
export default routes;
|
||||
Reference in new issue
Block a user