123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- 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
|