docking-vue/src/router/index.js

82 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { createRouter, createWebHashHistory } from "vue-router";
import layout from "@/layout/index.vue";
import children from "../components/children/index.vue";
/**
* path 从跟开始每一级都要写
* name 和path一样
* redirect 重定向到哪一个路由子级路由第一个的path没有子级路由不需要填写
* component 路由对应的组件位置必填views下的文件views和.vue不需要填写
* meta参数说明
* title 显示在菜单和面包屑中名称
* model 归类到头部导航哪一级中(最外层路由需要填写)
* activeMenu 当前路由选中状态是哪个导航isSubMenu:false时需要填写设置isSubMenu:false路由的path
* isMenu false 不显示当前菜单
* isLogin false 不需要登录可以访问
* breadcrumb false 当前页不显示在面包屑中
* isBreadcrumb false 当前页不显示面包屑
* isSubMenu false 当前菜单不显示子菜单
* isBack false 当前菜页不显示返回按钮
**/
const routes = [
{
path: "/login",
name: "/login",
meta: { title: "登录", isLogin: false },
component: () => import("@/views/login/index"),
},
{
path: "/",
name: "app",
redirect: "/index",
meta: { title: "首页", isLogin: true },
component: layout,
children: [
{
path: "/index",
name: "/index",
meta: {
title: "首页",
breadcrumb: false,
isMenu: false,
isSubMenu: false,
isBack: false,
},
component: () => import("@/views/index/index"),
},
],
},
{
path: "/404",
name: "/404",
meta: { title: "404", isBreadcrumb: false, isMenu: false },
component: () => import("@/views/404"),
},
{
path: "/api",
name: "/api",
meta: { title: "api", isBreadcrumb: false, isMenu: false },
component: () => import("@/views/api/index"),
},
{
path: "/mobile",
meta: { isBreadcrumb: false, isMenu: false, isLogin: false },
component: children,
children: [],
},
];
const router = createRouter({
history: createWebHashHistory(import.meta.env.BASE_URL),
routes,
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition;
} else {
return { left: 0, top: 0 };
}
},
});
export default router;