This commit is contained in:
oneao committed 2026-03-19 22:15:36 +08:00
1 parent 4aaa93df7d
commit c330e52fd3
66 files changed
+7386 -4

No files matched your search

@@ -0,0 +1,64 @@
import { createRouter, createWebHistory } from "vue-router";
import { routes } from "./routes";
import { useUserStore } from "@/store/user";
import { ElMessage } from "element-plus";
import { useTabStore } from "@/store/tab";
import NProgress from "nprogress";
NProgress.configure({ easing: "ease", speed: 500 });
const router = createRouter({
history: createWebHistory(import.meta.env.PUBLIC_SERVER_PATH || "/"),
routes,
});
router.beforeEach((to) => {
NProgress?.start?.();
const userStore = useUserStore();
// if (!userStore.isLogined() && to.path !== "/login") {
// ElMessage.warning("登录已过期,请先登录");
// return "/login";
// }
handleTabPath(to);
return;
});
router.afterEach(() => {
NProgress?.done?.();
});
function handleTabPath(to) {
const path = to.path;
if (path === "/login") {
return;
}
const meta = to.meta;
const query = to.query;
// 处理标签页
if (meta.title) {
let displayTitle = meta.title;
if (query.id) {
displayTitle = `${meta.title} ${query.id}`;
}
const tabStore = useTabStore();
tabStore.addTab({
path: path,
fullPath: to.fullPath,
title: displayTitle,
params: to.params,
meta: to.meta,
query: to.query,
});
}
}
export default router;
@@ -0,0 +1,40 @@
import BaseLayout from "@/layout/index.vue";
export const routes = [
{
path: "/",
component: BaseLayout,
children: [
{
path: "/",
component: () => import("@/views/index.vue"),
meta: {
title: "首页",
keepAlive: true,
},
},
// ==================== 业务管理 ====================
{
path: "/business",
component: () => import("@/views/business/index.vue"),
meta: {
title: "海运业务",
keepAlive: true,
},
},
// ==================== 系统管理 ====================
{
path: "/system/field",
component: () => import("@/views/system/field/index.vue"),
meta: {
title: "字段配置",
keepAlive: true,
},
},
],
},
{
path: "/login",
component: () => import("@/views/auth/login.vue"),
},
];