54 lines
1023 B
JavaScript
54 lines
1023 B
JavaScript
import { ChatRound, Monitor } from '@element-plus/icons-vue';
|
|
import { createRouter, createWebHistory } from "vue-router";
|
|
|
|
const routes = [
|
|
{
|
|
path: "/",
|
|
component: () => import("@/layouts/MainLayout.vue"),
|
|
children: [
|
|
{
|
|
path: "",
|
|
name: "blank",
|
|
meta: {
|
|
hidden: true,
|
|
},
|
|
component: () => import("@/layouts/blank.vue"),
|
|
},
|
|
],
|
|
},
|
|
{
|
|
path: "/chat",
|
|
name: "chat",
|
|
meta: {
|
|
icon: ChatRound
|
|
},
|
|
component: () => import("@/views/chat/index.vue"),
|
|
},
|
|
{
|
|
path: "/test",
|
|
name: "test",
|
|
meta: {
|
|
icon: Monitor,
|
|
title: "API测试"
|
|
},
|
|
component: () => import("@/views/chat/test/TestApi.vue"),
|
|
},
|
|
];
|
|
|
|
export const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes,
|
|
});
|
|
|
|
// 添加全局前置守卫
|
|
router.beforeEach((to, from, next) => {
|
|
// 如果访问根路径,重定向到/chat
|
|
if (to.path === '/') {
|
|
next('/chat')
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
export default router;
|