权限控制

dev
truthhun 1 year ago
parent d9150b7152
commit 8885e2c534

@ -437,6 +437,9 @@ export default {
this.handleResize()
window.addEventListener('resize', this.handleResize)
},
beforeDestroy() {
window.removeEventListener('resize', this.handleResize)
},
methods: {
...mapActions('category', ['getCategories']),
...mapActions('setting', ['getSettings']),

@ -7,4 +7,9 @@ export default function ({ store, route, redirect }) {
if (requireLogin(settings, user, route, permissions)) {
return redirect('/login')
}
// 如果访问的路由前缀是 /me但是用户没有登录那么跳转到 /login
if (route.path.startsWith('/me') && !user.id) {
return redirect('/login')
}
}

@ -498,7 +498,7 @@ export default {
methods: {
formatDatetime,
formatBytes,
...mapActions('user', ['getUser']),
...mapActions('user', ['getUser', 'refreshUser']),
async getDocument() {
const res = await getDocument({
id: this.documentId,
@ -662,6 +662,8 @@ export default {
this.$refs.commentList.getComments()
},
async downloadDocument() {
await this.refreshUser()
this.downloading = true
const res = await downloadDocument({
id: this.documentId,

@ -32,15 +32,6 @@ service.interceptors.response.use(
return response
},
(error) => {
if (error.response.status === 401) {
store().commit('user/logout')
}
// let message = error.response.data.message || error.response.statusText
// Message({
// showClose: true,
// message: message,
// type: 'error',
// })
return error.response
}
)

Loading…
Cancel
Save