|
|
|
import Vue from 'vue';
|
|
|
|
import VueRouter from 'vue-router';
|
|
|
|
import store from '../store';
|
|
|
|
import HomeView from '../views/HomeView.vue';
|
|
|
|
// import UserPosts from '../views/UserPosts.vue';
|
|
|
|
// import Franchise from '../views/Franchise.vue'
|
|
|
|
|
|
|
|
Vue.use(VueRouter)
|
|
|
|
const whiteSlideList = ['/','/ui','/siteList'];//侧边导航白名单
|
|
|
|
const whiteHeaderList = ['/','/ui','/register','/configureServicePrices','/siteList'];//头部导航白名单
|
|
|
|
const whiteFooterList = ['/','/ui','/configureServicePrices'];//底部白名单
|
|
|
|
const routes = [
|
|
|
|
{
|
|
|
|
path: '/',
|
|
|
|
name: '首页',
|
|
|
|
component: HomeView,
|
|
|
|
// component: Franchise
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/register',
|
|
|
|
name: 'register',
|
|
|
|
// route level code-splitting
|
|
|
|
// this generates a separate chunk (about.[hash].js) for this route
|
|
|
|
// which is lazy-loaded when the route is visited.
|
|
|
|
component: () => import(/* webpackChunkName: "register" */ '../views/Register.vue'),
|
|
|
|
children: [ // 这是子路由的定义开始
|
|
|
|
// {
|
|
|
|
// path: '', // 当访问 /user 时,默认加载 UserProfile 组件
|
|
|
|
// name: 'register',
|
|
|
|
// component: Register
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// path: 'posts', // 当访问 /user/posts 时,加载 UserPosts 组件
|
|
|
|
// name: 'UserPosts',
|
|
|
|
// component: UserPosts,
|
|
|
|
// }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/ui',
|
|
|
|
name: 'ui组件',
|
|
|
|
// route level code-splitting
|
|
|
|
// this generates a separate chunk (about.[hash].js) for this route
|
|
|
|
// which is lazy-loaded when the route is visited.
|
|
|
|
component: () => import(/* webpackChunkName: "ui" */ '../views/elementGroups.vue')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/franchise',
|
|
|
|
name: '加盟',
|
|
|
|
component: () => import(/* webpackChunkName: "franchise" */ '../views/Franchise.vue')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/configureServicePrices',
|
|
|
|
name: '配置服务价格',
|
|
|
|
component: () => import(/* webpackChunkName: "franchise" */ '../views/ConfigureServicePrices.vue')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/siteList',
|
|
|
|
name: '站点列表',
|
|
|
|
component: () => import(/* webpackChunkName: "franchise" */ '../views/SiteList.vue')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/siteBaseSetting',
|
|
|
|
name: '站点基础设置',
|
|
|
|
component: () => import(/* webpackChunkName: "franchise" */ '../views/SiteBaseSetting.vue')
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
const router = new VueRouter({
|
|
|
|
mode: 'history',
|
|
|
|
base: process.env.BASE_URL,
|
|
|
|
routes
|
|
|
|
})
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
console.log(to.path,'to.path-----');
|
|
|
|
if (whiteSlideList.includes(to.path)) {
|
|
|
|
store.commit('SET_SIDEBAR', true); // 登录页面不显示侧边栏
|
|
|
|
} else {
|
|
|
|
store.commit('SET_SIDEBAR', false); // 其他页面显示侧边栏
|
|
|
|
}
|
|
|
|
if (whiteFooterList.includes(to.path)) {
|
|
|
|
store.commit('SET_FOOTER', true); // 登录页面不显示侧边栏
|
|
|
|
} else {
|
|
|
|
store.commit('SET_FOOTER', false); // 其他页面显示侧边栏
|
|
|
|
}
|
|
|
|
if (whiteHeaderList.includes(to.path)) {
|
|
|
|
store.commit('SET_HEADER', true); // 登录页面不显示侧边栏
|
|
|
|
} else {
|
|
|
|
store.commit('SET_HEADER', false); // 其他页面显示侧边栏
|
|
|
|
}
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
|
|
|
|
export default router
|