import { createRouter, createWebHashHistory } from 'vue-router' import HomeView from '../views/HomeView.vue' import MoreContent from '../views/MoreContent.vue' import ShuangGou from '../views/ShuangGou.vue' import PaintingDetail from '../views/PaintingDetail' // import store from '@/store/index.js' const routes = [ // { // path: '/', // redirect: '/home', // }, { path: '/', name: 'HomeView', component: HomeView, }, { path: '/more-content', name: 'MoreContent', component: MoreContent, // component: TEXT, }, { path: '/shuang-gou', name: 'ShuangGou', component: ShuangGou, }, { path: '/painting-detail', name: 'PaintingDetail', component: PaintingDetail, // component: TEXT, }, ] 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