import { createRouter, createWebHashHistory } from 'vue-router' import LoginView from "../views/LoginView.vue" import HomeView from '../views/HomeView.vue' import CityOfXishan from '../views/CityOfXishan.vue' import MuseumView from '../views/MuseumView.vue' import CloudSchool from '../views/CloudSchool.vue' import SquareView from '../views/SquareView.vue' import LoveForest from '../views/LoveForest.vue' import CharityHall from '../views/CharityHall.vue' import ShopView from '@/views/ShopView.vue' // import store from '@/store/index.js' const routes = [ { path: '/', redirect: '/home', }, { path: '/login', name: 'LoginView', component: LoginView, }, { path: '/home', name: 'HomeView', component: HomeView, meta: { tabIdx: 1 }, }, { path: '/city-of-xishan', name: 'CityOfXishan', component: CityOfXishan, meta: { tabIdx: 2 } }, { path: '/museum', name: 'MuseumView', component: MuseumView, meta: { tabIdx: 3 } }, { path: '/cloud-school', name: 'CloudSchool', component: CloudSchool, meta: { tabIdx: 4 } }, { path: '/square', name: 'SquareView', component: SquareView, meta: { tabIdx: 5 } }, { path: '/love-forest', name: 'LoveForest', component: LoveForest, meta: { tabIdx: 6 } }, { path: '/charity-hall', name: 'CharityHall', component: CharityHall, meta: { tabIdx: 7 } }, // { // path: '/tab-8', // name: 'HomeView', // component: HomeView, // meta: { // tabIdx: 8 // } // }, { path: '/shop', name: 'ShopView', component: ShopView, meta: { tabIdx: 9 } }, ] const router = createRouter({ history: createWebHashHistory(), routes }) router.beforeEach((to, from) => { // 生产环境下强制每次都从首页进入 if (process.env.NODE_ENV !== 'development' && !from.name && to.name !== 'HomeView') { return '/home' } }) export default router