pc网页版软测宝
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
9.9 KiB

12 months ago
import Vue from 'vue'
import Router from 'vue-router'
8 months ago
import store from '@/store'
// import { Message,MessageBox } from 'element-ui'
12 months ago
//自定义组件
8 months ago
import login from '@/page/logpage/log/login.vue'
import runEnv from '../util/runEnv'
// import index from "@/page/homepage/index.vue"
8 months ago
const community = () => import('@/page/community/index.vue')
const index = () => import('@/page/homepage/index.vue')
const mobileTip = () => import('@/page/common/mobileTip.vue')
const home = () => import('@/page/homepage/home/home.vue')
const toolmarker = () => import('@/page/homepage/tool/toolmarker.vue')
const tooldetails = () => import('@/page/homepage/tool/tooldetails.vue')
const crowd = () => import('@/page/homepage/crowdsourcing/crowd.vue')
const crowddetails = () => import('@/page/homepage/crowdsourcing/crowddetails.vue')
const userhome = () => import('@/page/homepage/crowdsourcing/userhome.vue')
const publishtasks = () => import('@/page/homepage/crowdsourcing/publishtasks.vue')
const train = () => import('@/page/homepage/traininstitute/train.vue')
const teacherSign = () => import('@/page/homepage/traininstitute/teacherSign.vue')
const teacherDetail = () => import('@/page/homepage/traininstitute/teacherDetail.vue')
const ability = () => import('@/page/homepage/personability/ability.vue')
const abilityUser = () => import('@/page/homepage/personability/abilityUser.vue')
const abilityUserD = () => import('@/page/homepage/personability/abilityUserDetail.vue')
const abilityMore = () => import('@/page/homepage/personability/abilityMore.vue')
const abilityMoreDetail = () => import('@/page/homepage/personability/abilityMoreDetail.vue')
const abilityApply = () => import('@/page/homepage/personability/abilityApply.vue')
const aboutwo = () => import('@/page/homepage/aboutus/aboutwo.vue')
const personal = () => import('@/page/personalpage/index.vue')
const personalcenter = () => import('@/page/personalpage/home/personalcenter.vue')
const resume = () => import('@/page/personalpage/home/resume.vue')
const stationmessage = () => import('@/page/personalpage/home/stationmessage.vue')
const myorder = () => import('@/page/personalpage/testtool/myorder.vue')
const mytask = () => import('@/page/personalpage/testmanagement/mytask.vue')
const mytool = () => import('@/page/personalpage/testmanagement/mytool.vue')
const myparticipate = () => import('@/page/personalpage/testcrowd/myparticipate.vue')
const myrelease = () => import('@/page/personalpage/testcrowd/myrelease.vue')
const edittasks = () => import('@/page/personalpage/testcrowd/edittasks.vue')
const testKit = () => import('@/page/personalpage/testtreasure/testKit.vue')
const demand = () => import('@/page/personalpage/demand/index.vue')
const myreview = () => import('@/page/personalpage/myreview/index.vue')
const myBm = () => import('@/page/personalpage/myBm/index.vue')
const course = () => import('@/page/personalpage/course/index.vue')
8 months ago
const onLineCourse = () => import('@/page/personalpage/course/onLineCourse.vue')
const currentcrowd = () => import('@/page/personalpage/testcrowd/currentcrowd.vue')
const jobM = () => import('@/page/personalpage/jobm/job.vue')
const addJob = () => import('@/page/personalpage/jobm/addjob.vue')
const jobUser = () => import('@/page/personalpage/jobm/jobuser.vue')
const jobuserDetail = () => import('@/page/personalpage/jobm/userdetail.vue')
12 months ago
Vue.use(Router)
//为组件配置路径
const router = new Router({
mode: 'history', // 去掉url中的#
// linkActiveClass:'is-active',
routes: [
{
8 months ago
path: '/community',
component: community,
name: 'community'
},
{
8 months ago
path: '/mobileTip',
component: mobileTip,
name: 'mobileTip'
},
12 months ago
//首页
8 months ago
{
8 months ago
path: '',
component: index,
redirect: '/',
children: [
8 months ago
{ path: '/', component: home, name: 'home' },
{ path: 'login', component: login, name: 'login' },
{ path: 'market', component: toolmarker, name: 'market' },
{ path: 'market/tooldetails', component: tooldetails },
8 months ago
{ path: 'crowdsourcing', component: crowd, name: 'crowd' },
{ path: 'crowdsourcing/crowddetails', component: crowddetails },
{ path: 'crowdsourcing/userhome', component: userhome },
{ path: 'crowdsourcing/publishtasks', component: publishtasks },
{ path: 'college', component: train },
{ path: 'college/teacherSign', component: teacherSign },
{ path: 'college/teacherDetail', component: teacherDetail },
{ path: 'ability', component: ability },
{ path: 'ability/user', component: abilityUser },
{ path: 'ability/detail', component: abilityUserD },
{ path: 'ability/more', component: abilityMore },
{ path: 'ability/more/detail', component: abilityMoreDetail },
{ path: 'ability/apply', component: abilityApply },
8 months ago
{ path: 'about', component: aboutwo }
12 months ago
]
},
// 登录相关
// {path:'/login',component:logpage,
// redirect:'/login',
// children:[
// {path:'login',component:login},
// ]
12 months ago
// },
// 工具市场: market
// 众包市场:crowdsourcing
// 培训学院:college
// 行业动态:news
// 关于我们:about
12 months ago
//个人中心
{
8 months ago
path: '/console',
component: personal,
redirect: '/console/myparticipate',
children: [
{ path: 'profile', component: personalcenter, meta: { title: '个人中心', isAuth: true, type: 1 } },
{ path: 'resume', component: resume, meta: { title: '个人简历', isAuth: true, type: 1 } },
{ path: 'message', component: stationmessage, meta: { title: '站内消息', isAuth: true, type: 1 } },
{ path: 'orders', component: myorder, meta: { title: '我的订单', isAuth: true, type: 2 } },
{ path: 'mytasks', component: mytask, meta: { title: '我的任务', isAuth: true, type: 3 } },
{ path: 'mytools', component: mytool, meta: { title: '我的工具', isAuth: true, type: 3 } },
{ path: 'currentcrowd', component: currentcrowd, meta: { title: '任务详情', isAuth: true, type: 4 } },
{ path: 'myparticipate', component: myparticipate, meta: { title: '我参与的', isAuth: true, type: 4 } },
{ path: 'myrelease', component: myrelease, meta: { title: '我发布的', isAuth: true, type: 4 } },
{ path: 'edittasks', component: edittasks, meta: { title: '重新发布', isAuth: true, type: 4 } },
{ path: 'edittasksFB', component: edittasks, meta: { title: '发布任务', isAuth: true, type: 4 } },
8 months ago
{ path: 'account', component: testKit, meta: { title: '我的软测宝', isAuth: true, type: 5 } },
{ path: 'demand', component: demand, meta: { title: '我要用人', isAuth: true, type: 6 } },
{ path: 'myreview', component: myreview, meta: { title: '我的评价', isAuth: true, type: 5 } },
{ path: 'myBm', component: myBm, meta: { title: '我的培训班', isAuth: true, type: 5 } },
{ path: 'course', component: course, meta: { title: '我的课程', isAuth: true, type: 5 } },
8 months ago
{ path: 'onLineCourse', component: onLineCourse, meta: { title: '线上课程', isAuth: true, type: 5 } },
{ path: 'addJob', component: addJob, meta: { title: '招聘管理', isAuth: true, type: 5 } },
{ path: 'jobUser', component: jobUser, meta: { title: '招聘管理', isAuth: true, type: 5 } },
{ path: 'jobuserDetail', component: jobuserDetail, meta: { title: '招聘管理', isAuth: true, type: 5 } },
8 months ago
{ path: 'jobM', component: jobM, meta: { title: '招聘管理', isAuth: true, type: 5 } }
12 months ago
]
8 months ago
}
]
12 months ago
})
// 全局路由守卫;
router.beforeEach((to, from, next) => {
// 百度统计
const tjarr = ['/market', '/crowdsourcing', '/ability', '/college', '/about']
12 months ago
if (_hmt) {
if (tjarr.some(it => it == to.path)) {
8 months ago
_hmt.push(['_trackPageview', '/' + to.fullPath])
12 months ago
}
}
// 根据角色控制人才服务
if (to.path == '/ability') {
if (store.getters.userinform.companyStatus == 2) {
next()
} else {
next('/ability/user')
}
}
12 months ago
8 months ago
if (to.path == '/') {
if (runEnv()) {
next('/mobileTip')
8 months ago
} else {
next()
}
}
12 months ago
// console.log(store.getters.companyStatus);
8 months ago
let token = store.getters.token
12 months ago
// if(token){
// store.dispatch("SET_KEYSAASDICT")
// }
// chrome
document.body.scrollTop = 0
// firefox
document.documentElement.scrollTop = 0
// const meta = to.meta || {}
12 months ago
// store.dispatch("SET_KEYSAASDICT")
8 months ago
// let currentdata=Date.parse(new Date());
12 months ago
// let logindate=store.getters.logindate;
// let timedifference=currentdata-(parseInt(logindate)+604800000);
// // console.log('当前时间',currentdata,'登录时间',logindate,'时间差',timedifference)
// // console.log('过期时间',timedifference)
8 months ago
// if (timedifference>0) {
12 months ago
// MessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
// confirmButtonText: '重新登录',
// showCancelButton:false,
// showClose:false,
// type: 'warning'
// }).then(() => {
// store.dispatch('LogOut').then(() => {
// next({ path: `/login?type=log` })
// })
// })
// // localStorage.removeItem('access_token');
// // Message.warning('登录状态已过期,请重新登录')
// // store.dispatch('LogOut').then(() => {
// // next({ path: `/login?type=log` })
// // })
// // next()
// // if (meta.isAuth === true) {
// // alert('登录状态失效,请您重新登录')
// // next({ path: `/login?type=log` })
// // } else {
// // next()
8 months ago
// // }
// } else {
next()
12 months ago
// }
})
// 解决这个报错:vue-router.esm.js?ac56:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/login?type=log".
// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
12 months ago
return originalPush.call(this, location).catch(err => err)
}
8 months ago
export default router