254 lines
8.1 KiB
TypeScript
254 lines
8.1 KiB
TypeScript
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
|
|
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
|
|
import test from './module/test'
|
|
import myInfo from './module/myInfo'
|
|
|
|
import { useStore } from 'store/main'
|
|
|
|
|
|
|
|
const routes: Array<RouteRecordRaw> = [
|
|
{
|
|
path: '/index',
|
|
name: 'index',
|
|
component: () => import('views/Index.vue'),
|
|
meta: {
|
|
title: '目录页',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
}
|
|
},
|
|
{
|
|
path: '/login',
|
|
name: 'login',
|
|
component: () => import('views/Login.vue'),
|
|
meta: {
|
|
title: '登录页',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
}
|
|
},
|
|
{
|
|
path: '/test', // 主路由地址
|
|
name: 'testIndex',
|
|
component: () => import('views/test/Index.vue'), // 组件加载
|
|
meta: {
|
|
title: '测试',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
children: [...test]
|
|
},
|
|
{
|
|
path: '/myInfo', // 主路由地址
|
|
name: 'myInfo',
|
|
component: () => import('views/myInfo/Index.vue'), // 组件加载
|
|
meta: {
|
|
title: '我的',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
children: [...myInfo]
|
|
},
|
|
|
|
|
|
|
|
|
|
// 首页
|
|
{
|
|
path: '/',
|
|
component: () => import('views/AppMain.vue'),
|
|
redirect: '/home',
|
|
meta: {
|
|
title: '首页',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
|
|
children: [
|
|
// 首页
|
|
{
|
|
path: 'home',
|
|
name: 'home',
|
|
component: () => import('views/home/index.vue'),
|
|
meta: {
|
|
title: '首页',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
// 自选直租
|
|
{
|
|
path: '/equipList',
|
|
name: 'equipList',
|
|
component: () => import('@/views/equip/list.vue'),
|
|
meta: {
|
|
title: ''
|
|
}
|
|
},
|
|
//装备详情
|
|
{
|
|
path: '/equipDetail/:id',
|
|
name: 'equipDetail',
|
|
component: () => import('views/equip/detail.vue'),
|
|
meta: {
|
|
title: ''
|
|
}
|
|
},
|
|
// 资讯详情
|
|
{
|
|
path: '/consultationDetails',
|
|
name: 'consultationDetails',
|
|
component: () => (import('views/consultationDetails/index.vue'))
|
|
},
|
|
// 收藏夹页面
|
|
{
|
|
path: '/collect',
|
|
name: 'collect',
|
|
component: () => import('views/collect/index.vue')
|
|
},
|
|
// 个人中心
|
|
{
|
|
path: '/myuser', // 主路由地址
|
|
name: 'myuser',
|
|
component: () => import('views/user/index.vue'), // 组件加载
|
|
meta: {
|
|
title: '个人中心',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
redirect: '/myuser/baseInfo',
|
|
children: [
|
|
{
|
|
path: 'baseInfo',
|
|
name: 'baseInfo',
|
|
component: () => import('views/user/baseInfo/index.vue'),
|
|
meta: {
|
|
title: '基础信息',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
{
|
|
path: 'orderManagement',
|
|
name: 'orderManagement',
|
|
component: () => import('views/user/orderManagement/index.vue'),
|
|
meta: {
|
|
title: '基础信息',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
{
|
|
path: 'subAccount',
|
|
name: 'subAccount',
|
|
component: () => import('views/user/subAccount/index.vue'),
|
|
meta: {
|
|
title: '基础信息',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
{
|
|
path: 'orderManagementCz',
|
|
name: 'orderManagementCz',
|
|
component: () => import('views/user/orderManagementCz/index.vue'),
|
|
meta: {
|
|
title: '订单管理(承租)',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
/* 订单管理(结算) */
|
|
{
|
|
path: 'settlement',
|
|
name: 'settlement',
|
|
component: () => import('views/user/orderManagementCz/settlement/index.vue'),
|
|
meta: {
|
|
title: '订单管理(结算)',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
{
|
|
path: 'goodsManagement',
|
|
name: 'goodsManagement',
|
|
component: () => import('views/user/goodsManagement/index.vue'),
|
|
meta: {
|
|
title: '基础信息',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
{
|
|
path: 'goodsUpdown',
|
|
name: 'goodsUpdown',
|
|
component: () => import('views/user/goodsUpdown/index.vue'),
|
|
meta: {
|
|
title: '基础信息',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
{
|
|
path: 'operatorManagement',
|
|
name: 'operatorManagement',
|
|
component: () => import('views/user/operatorManagement/index.vue'),
|
|
meta: {
|
|
title: '基础信息',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
{
|
|
path: 'orderDetails',
|
|
name: 'orderDetails',
|
|
component: () => import('views/user/orderManagement/orderCom/orderDetails.vue'),
|
|
meta: {
|
|
title: '订单详情',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
},
|
|
{
|
|
path: 'orderConfirm',
|
|
name: 'orderConfirm',
|
|
component: () => import('views/user/orderManagement/orderCom/orderConfirm.vue'),
|
|
meta: {
|
|
title: '订单确认',
|
|
keepAlive: true,
|
|
AuthFlag: false
|
|
},
|
|
}
|
|
]
|
|
},
|
|
]
|
|
|
|
},
|
|
|
|
|
|
]
|
|
|
|
|
|
const router = createRouter({
|
|
// 路由模式
|
|
history: createWebHashHistory(),
|
|
routes
|
|
})
|
|
|
|
// 使页面跳转后滚动条恢复至顶部
|
|
router.beforeEach((to, from, next) => {
|
|
const store = useStore()
|
|
|
|
if (store.token || to.path == '/login') {
|
|
next()
|
|
} else {
|
|
next('/login')
|
|
}
|
|
// chrome
|
|
document.body.scrollTop = 0;
|
|
// firefox 兼容火狐
|
|
document.documentElement.scrollTop = 0;
|
|
})
|
|
export default router
|