Skip to content

Commit

Permalink
add: to all the page ,user must login
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarrettluo committed Dec 26, 2023
1 parent eec4a98 commit 49acaab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
21 changes: 10 additions & 11 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,15 @@ const router = new VueRouter({



// // 设置路由导航卫士,通过判断是否存在token,对网页访问权限进行设置
// router.beforeEach((to, from, next) => {
// // to表示将要访问的地址
// // from表示从哪个路径跳转而来
// // next是放行函数 next()放行 next('/path')强制跳转
// if (to.path === '/login') return next()
// if (to.path.)
// const tokenStr = localStorage.getItem('token')
// if (!tokenStr) return next('/login')
// next()
// })
// 设置路由导航卫士,通过判断是否存在token,对网页访问权限进行设置
router.beforeEach((to, from, next) => {
// to表示将要访问的地址
// from表示从哪个路径跳转而来
// next是放行函数 next()放行 next('/path')强制跳转
if (to.path === '/login') return next()
const tokenStr = localStorage.getItem('token')
if (!tokenStr) return next('/login')
next()
})

export default router
6 changes: 5 additions & 1 deletion src/views/filterDoc/DocPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export default {
pageSize: 24,
tagId: '',
cateId: '',
keyword: ''
keyword: '',
spinShow: true
}
},
props: ["requestType"],
Expand Down Expand Up @@ -68,6 +69,7 @@ export default {
this.total = result.total;
this.pageSize = result.pageSize
}
this.spinShow = false
}).catch(err => {
this.$Message.error("出错:" + (err || '请稍后重试'))
})
Expand All @@ -80,6 +82,7 @@ export default {
this.total = result.total;
this.pageSize = result.pageSize
}
this.spinShow = false
}).catch(err => {
this.$Message.error("出错:" + (err || '请稍后重试'))
})
Expand All @@ -98,6 +101,7 @@ export default {
this.total = result.total;
this.pageSize = result.pageSize
}
this.spinShow = false
}).catch(err => {
this.$Message.error("出错:" + (err || '请稍后重试'))
})
Expand Down
16 changes: 8 additions & 8 deletions src/views/filterDoc/FilterListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<span v-show="flag"> 加载中... </span>
</div>
</div>
<div class="doc-group-page">
<Page
:page-size="pageSize"
:current="pageNum"
:total="total"
@on-change="pageChange"
/>
</div>
<!-- <div class="doc-group-page">-->
<!-- <Page-->
<!-- :page-size="pageSize"-->
<!-- :current="pageNum"-->
<!-- :total="total"-->
<!-- @on-change="pageChange"-->
<!-- />-->
<!-- </div>-->
</div>
</template>

Expand Down

0 comments on commit 49acaab

Please sign in to comment.