import { createRouter, createWebHashHistory, createWebHistory, RouteRecordRaw } from 'vue-router'
import Gantt from '../views/Gantt.vue'
import {getQueryString} from '../utils'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'gantt',
    component: () => import(/* webpackChunkName: "about" */ '../views/Gantt.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes
})

router.beforeEach((to, from, next) => {
  sessionStorage.setItem('taskResultId', getQueryString('id') as string)
  sessionStorage.setItem('token', getQueryString('token') as string)
  next()
})

export default router
