|
|
@@ -1,30 +1,37 @@
|
|
|
import Vue from 'vue'
|
|
|
import VueRouter from 'vue-router'
|
|
|
import HomeView from '../views/HomeView.vue'
|
|
|
-
|
|
|
+import store from '../store/index'
|
|
|
Vue.use(VueRouter)
|
|
|
|
|
|
// 路由懒加载
|
|
|
-const Login =()=>import('../views/login/login.vue')
|
|
|
-const PoiceMessage = ()=> import('../views/Poice/PoiceMessage.vue')
|
|
|
+const Login = () => import('../views/login/login.vue')
|
|
|
+const PoiceMessage = () => import('../views/Poice/PoiceMessage.vue')
|
|
|
const articles = () => import('../views/article/articles.vue')
|
|
|
|
|
|
|
|
|
|
|
|
-const routes = [
|
|
|
- {
|
|
|
+const routes = [{
|
|
|
path: '/articles/:fileID',
|
|
|
name: 'articles',
|
|
|
component: articles,
|
|
|
- meta:{
|
|
|
- title:'政策文件详情页面',
|
|
|
- keepAlive:false
|
|
|
+ meta: {
|
|
|
+ title: '政策文件详情页面',
|
|
|
+ keepAlive: false,
|
|
|
+ // 需要验证登录才能访问
|
|
|
+ auth: true,
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
path: '/PoiceMessage',
|
|
|
name: 'PoiceMessage',
|
|
|
- component: PoiceMessage
|
|
|
+ component: PoiceMessage,
|
|
|
+ meta: {
|
|
|
+ title: '政策文件详情页面',
|
|
|
+ keepAlive: false,
|
|
|
+ // 需要验证登录才能访问
|
|
|
+ auth: true,
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
path: '/login',
|
|
|
@@ -34,22 +41,51 @@ const routes = [
|
|
|
{
|
|
|
path: '/',
|
|
|
name: 'index',
|
|
|
- component: HomeView
|
|
|
+ component: HomeView,
|
|
|
+ meta: {
|
|
|
+ title: '政策文件详情页面',
|
|
|
+ keepAlive: false,
|
|
|
+ // 需要验证登录才能访问
|
|
|
+ auth: true,
|
|
|
+ }
|
|
|
},
|
|
|
// {
|
|
|
// path: '/about',
|
|
|
// name: 'about',
|
|
|
- // route level code-splitting
|
|
|
- // this generates a separate chunk (about.[hash].js) for this route
|
|
|
- // which is lazy-loaded when the route is visited.
|
|
|
+ // 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: "about" */ '../views/AboutView.vue')
|
|
|
// }
|
|
|
]
|
|
|
|
|
|
const router = new VueRouter({
|
|
|
// mode: 'history',
|
|
|
+
|
|
|
base: process.env.BASE_URL,
|
|
|
- routes
|
|
|
+ routes,
|
|
|
+
|
|
|
+})
|
|
|
+// 登录验证
|
|
|
+router.beforeEach((to, from, next) => {
|
|
|
+ if (to.matched.some(m => m.meta.auth)) {
|
|
|
+ // 对路由进行验证
|
|
|
+ if (store.state.islogin == '100') { // 已经登陆
|
|
|
+ next() // 正常跳转到你设置好的页面
|
|
|
+ } else {
|
|
|
+ // 未登录则跳转到登陆界面,query:{ Rurl: to.fullPath}表示把当前路由信息传递过去方便登录后跳转回来;
|
|
|
+ next({
|
|
|
+ path: '/login',
|
|
|
+ query: {
|
|
|
+ Rurl: to.fullPath
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ next()
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
export default router
|
|
|
+
|
|
|
+
|