adasdasdasdas
This commit is contained in:
@@ -16,165 +16,183 @@ import personalHomePage from "@/components/setting/home/PersonalHomePage.vue";
|
||||
import onSiteSetting from "@/components/setting/onsite/OnSiteSetting.vue";
|
||||
import baseSettings from "@/components/setting/onsite/BaseSettings.vue";
|
||||
import importExport from "@/components/setting/onsite/ImportExport.vue";
|
||||
import categoryManage from "@/components/setting/category/CategoryManage.vue";
|
||||
import bannerManage from "@/components/setting/banner/BannerManage.vue";
|
||||
import userManage from "@/components/setting/user/UserManage.vue";
|
||||
import noticeManage from "@/components/setting/notice/NoticeManage.vue";
|
||||
import attachmentManage from "@/components/setting/attachment/AttachmentManage.vue";
|
||||
|
||||
const originalPush = VueRouter.prototype.push
|
||||
VueRouter.prototype.push = function push(location) {
|
||||
return originalPush.call(this, location).catch(err => err)
|
||||
return originalPush.call(this, location).catch(err => err)
|
||||
}
|
||||
Vue.use(VueRouter)
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
redirect: '/index'
|
||||
},
|
||||
{
|
||||
path: '/index',
|
||||
redirect: '/home',
|
||||
name: 'index',
|
||||
component: index,
|
||||
children: [
|
||||
{
|
||||
path: '/home',
|
||||
name: 'home',
|
||||
component: home
|
||||
},
|
||||
{
|
||||
path: '/news',
|
||||
name: 'news',
|
||||
component: news
|
||||
},{
|
||||
path: '/nav',
|
||||
name: 'nav',
|
||||
component: navDetail
|
||||
},
|
||||
{
|
||||
path: '/myNav',
|
||||
name: 'myNav',
|
||||
component: myNav
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/settings',
|
||||
redirect: '/admin',
|
||||
name: '/settings',
|
||||
component: settings,
|
||||
|
||||
children: [
|
||||
{
|
||||
path: '/admin',
|
||||
name: '/admin',
|
||||
component: personalHomePage,
|
||||
|
||||
{
|
||||
path: '/',
|
||||
redirect: '/index'
|
||||
},
|
||||
{
|
||||
path: '/index',
|
||||
redirect: '/home',
|
||||
name: 'index',
|
||||
component: index,
|
||||
children: [
|
||||
{
|
||||
path: '/home',
|
||||
name: 'home',
|
||||
component: home
|
||||
},
|
||||
{
|
||||
path: '/news',
|
||||
name: 'news',
|
||||
component: news
|
||||
}, {
|
||||
path: '/nav',
|
||||
name: 'nav',
|
||||
component: navDetail
|
||||
},
|
||||
{
|
||||
path: '/myNav',
|
||||
name: 'myNav',
|
||||
component: myNav
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/settings',
|
||||
redirect: '/admin',
|
||||
name: '/settings',
|
||||
component: settings,
|
||||
|
||||
},
|
||||
{
|
||||
path: '/system',
|
||||
name: '/system',
|
||||
redirect: '/appearance',
|
||||
component: systemSettings,
|
||||
|
||||
|
||||
children:[
|
||||
{
|
||||
path: '/appearance',
|
||||
name: '/appearance',
|
||||
component: appearanceSettings,
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
path: '/information',
|
||||
name: '/information',
|
||||
component: informationSettings,
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
path: '/function',
|
||||
name: '/function',
|
||||
component: functionSettings,
|
||||
|
||||
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/website',
|
||||
name: '/website',
|
||||
component: websiteManage,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
path: '/onSite',
|
||||
name: '/onSite',
|
||||
redirect:'/baseSettings',
|
||||
component: onSiteSetting,
|
||||
|
||||
|
||||
children:[
|
||||
{
|
||||
path: '/baseSettings',
|
||||
name: '/baseSettings',
|
||||
component: baseSettings,
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
path: '/importExport',
|
||||
name: '/importExport',
|
||||
component: importExport,
|
||||
|
||||
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/admin',
|
||||
name: '/admin',
|
||||
component: personalHomePage,
|
||||
},
|
||||
{
|
||||
path: '/system',
|
||||
name: '/system',
|
||||
redirect: '/appearance',
|
||||
component: systemSettings,
|
||||
children: [
|
||||
{
|
||||
path: '/appearance',
|
||||
name: '/appearance',
|
||||
component: appearanceSettings,
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
path: '/information',
|
||||
name: '/information',
|
||||
component: informationSettings,
|
||||
|
||||
|
||||
{
|
||||
path: '/404',
|
||||
name: 'NoPage404',
|
||||
component: notFound,
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)',
|
||||
redirect: '/404',
|
||||
hidden: true
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/function',
|
||||
name: '/function',
|
||||
component: functionSettings,
|
||||
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/website',
|
||||
name: '/website',
|
||||
component: websiteManage,
|
||||
},
|
||||
{
|
||||
path: '/onSite',
|
||||
name: '/onSite',
|
||||
redirect: '/baseSettings',
|
||||
component: onSiteSetting,
|
||||
children: [
|
||||
{
|
||||
path: '/baseSettings',
|
||||
name: '/baseSettings',
|
||||
component: baseSettings,
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
path: '/importExport',
|
||||
name: '/importExport',
|
||||
component: importExport,
|
||||
|
||||
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/category',
|
||||
name: '/category',
|
||||
component: categoryManage,
|
||||
},
|
||||
{
|
||||
path: '/banner',
|
||||
name: '/banner',
|
||||
component: bannerManage,
|
||||
},
|
||||
{
|
||||
path: '/user',
|
||||
name: '/user',
|
||||
component: userManage,
|
||||
},
|
||||
{
|
||||
path: '/notice',
|
||||
name: '/notice',
|
||||
component: noticeManage,
|
||||
},
|
||||
{
|
||||
path: '/attachment',
|
||||
name: '/attachment',
|
||||
component: attachmentManage,
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
path: '/404',
|
||||
name: 'NoPage404',
|
||||
component: notFound,
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)',
|
||||
redirect: '/404',
|
||||
hidden: true
|
||||
},
|
||||
|
||||
|
||||
]
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
routes
|
||||
mode: 'history',
|
||||
routes
|
||||
})
|
||||
// // 导航守卫:使用 router.beforeEach 注册一个全局前置守卫,判断用户是否登陆
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.path === '/home') {
|
||||
next();
|
||||
} else {
|
||||
let token = localStorage.getItem('Authorization');
|
||||
if (token === null || token === '' || token === undefined) {
|
||||
next('/home');
|
||||
Vue.prototype.$notify.error({
|
||||
title: '权限不够',
|
||||
message: "请先登录!",
|
||||
offset: 0
|
||||
});
|
||||
if (to.path === '/home') {
|
||||
next();
|
||||
} else {
|
||||
next();
|
||||
let token = localStorage.getItem('Authorization');
|
||||
if (token === null || token === '' || token === undefined) {
|
||||
next('/home');
|
||||
Vue.prototype.$notify.error({
|
||||
title: '权限不够',
|
||||
message: "请先登录!",
|
||||
offset: 0
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default router
|
||||
|
Reference in New Issue
Block a user