import { createRouter, createWebHashHistory } from 'vue-router'
import HomeView from "@/views/HomeView.vue"
import StartView from "@/views/StartView.vue"
import DrawView from "@/views/DrawView.vue"
import EntryList from "@/views/EntryList.vue"
import CommonDrawList from "@/views/CommonDrawList.vue"

// import store from '@/store/index.js'

const routes = [
  {
    path: '/',
    redirect: '/home',
  },
  {
    path: '/home',
    name: 'HomeView',
    component: HomeView,
    meta: {
      windowOrientation: 'landscape',
    }
  },
  {
    path: '/entry-list',
    name: 'EntryList',
    component: EntryList,
    meta: {
      windowOrientation: 'landscape',
    }
  },
  {
    path: '/common-draw-list',
    name: 'CommonDrawList',
    component: CommonDrawList,
    meta: {
      windowOrientation: 'landscape',
    }
  },
  {
    path: '/start',
    name: 'StartView',
    component: StartView,
    meta: {
      windowOrientation: 'portrait',
    }
  },
  {
    path: '/draw',
    name: 'DrawView',
    component: DrawView,
    meta: {
      windowOrientation: 'portrait',
    }
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

router.beforeEach((to, from) => {
  // 生产环境下强制每次都从首页进入
  if (process.env.NODE_ENV === 'production' && !from.name && to.name !== 'HomeView') {
    return '/'
  }
})

export default router
