提交 e8bd5ee0 authored 作者: pengxiaohui's avatar pengxiaohui

增加白名单,没权限跳转至登录页

上级 fab5ed5c
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<p style="line-height:26px;padding:7px 10px 7px 0">{{details.live_config.live_summary}}</p> <p style="line-height:26px;padding:7px 10px 7px 0">{{details.live_config.live_summary}}</p>
</el-form-item> </el-form-item>
<el-form-item label="参会成员:" v-if="rowData.status === 2 && operatable"> <el-form-item label="参会成员:" v-if="rowData.status === 2 && operatable">
<el-button type="text" @click="handleExport">导出excel</el-button> <el-button type="text" @click="handleExport" :disabled="exportLoading">导出excel</el-button><i class="el-icon-loading" v-show="exportLoading"></i>
</el-form-item> </el-form-item>
<el-form-item label="回放:" v-if="rowData.status === 2 && operatable"> <el-form-item label="回放:" v-if="rowData.status === 2 && operatable">
<el-button type="text" v-if="hasRecord" @click="handleDownload">下载</el-button> <el-button type="text" v-if="hasRecord" @click="handleDownload">下载</el-button>
...@@ -43,6 +43,11 @@ export default { ...@@ -43,6 +43,11 @@ export default {
dialogType: {}, dialogType: {},
operatable: {} operatable: {}
}, },
data() {
return {
exportLoading: false
}
},
computed: { computed: {
hasRecord() { hasRecord() {
if (this.rowData.record_file_ids && Array.isArray(this.rowData.record_file_ids) && this.rowData.record_file_ids.length > 0) { if (this.rowData.record_file_ids && Array.isArray(this.rowData.record_file_ids) && this.rowData.record_file_ids.length > 0) {
...@@ -72,8 +77,9 @@ export default { ...@@ -72,8 +77,9 @@ export default {
if (row.meeting_type === 1) { if (row.meeting_type === 1) {
params.sub_meeting_id = row.sub_meeting_id params.sub_meeting_id = row.sub_meeting_id
} }
this.exportLoading = true
exportParticipants(params).then((res) => { exportParticipants(params).then((res) => {
console.log(res) this.exportLoading = false
if (res && res.type === 'text/xlsx') { if (res && res.type === 'text/xlsx') {
const url = URL.createObjectURL(res) const url = URL.createObjectURL(res)
this.funDownload(url, `参会人员表_${this.nowFormat}.xlsx`) this.funDownload(url, `参会人员表_${this.nowFormat}.xlsx`)
......
...@@ -26,7 +26,7 @@ export default [ ...@@ -26,7 +26,7 @@ export default [
path: '', path: '',
component: () => import('@/pages/meeting/index.vue'), component: () => import('@/pages/meeting/index.vue'),
name: 'MeetingUpdate', name: 'MeetingUpdate',
meta: { title: '创建直播', affix: true } meta: { title: '更新直播', affix: true }
} }
] ]
}, },
...@@ -65,13 +65,13 @@ export default [ ...@@ -65,13 +65,13 @@ export default [
path: 'role', path: 'role',
name: 'Role', name: 'Role',
component: () => import('@/pages/system/role/index'), component: () => import('@/pages/system/role/index'),
meta: { title: '角色管理', icon: 'el-icon-s-check' } meta: { title: '角色管理', icon: 'el-icon-s-check', roles: ['administrator'] }
}, },
{ {
path: 'roleToUser', path: 'roleToUser',
name: 'RoleToUser', name: 'RoleToUser',
component: () => import('@/pages/system/role/role-to-user/index'), component: () => import('@/pages/system/role/role-to-user/index'),
meta: { title: '管理角色用户', icon: '' } meta: { title: '管理角色用户', icon: '', roles: ['administrator'] }
}, },
{ {
path: 'account', path: 'account',
......
...@@ -5,7 +5,8 @@ const user = { ...@@ -5,7 +5,8 @@ const user = {
user: {}, user: {},
roles: [], roles: [],
isLogin: false, isLogin: false,
isSuperAdmin: false isSuperAdmin: false,
hasRoles: false
}, },
mutations: { mutations: {
...@@ -20,6 +21,9 @@ const user = { ...@@ -20,6 +21,9 @@ const user = {
}, },
setSuperAdmin(state, isSuperAdmin) { setSuperAdmin(state, isSuperAdmin) {
state.isSuperAdmin = isSuperAdmin state.isSuperAdmin = isSuperAdmin
},
setHasRoles(state, hasRoles) {
state.hasRoles = hasRoles
} }
}, },
...@@ -69,6 +73,27 @@ const user = { ...@@ -69,6 +73,27 @@ const user = {
}) })
commit('setIsLogin', isLogin) commit('setIsLogin', isLogin)
return isLogin return isLogin
},
// 检测登录状态
async checkRoles({ commit }) {
const hasRoles = await getUserRoles().then(res => {
const roles = res.data.roles
let isSuperAdmin = false
if (roles && Array.isArray(roles)) {
roles.forEach(it => {
if (it.name === 'administrator') isSuperAdmin = true
})
commit('setRoles', roles)
commit('setSuperAdmin', isSuperAdmin)
return true
}
return false
}).catch(() => {
commit('setRoles', [])
return false
})
commit('setHasRoles', hasRoles)
return hasRoles
} }
} }
} }
......
import store from '@/store' import store from '@/store'
/**
* Use meta.role to determine if the current user has permission
* @param roles
* @param routeRoles
*/
function hasPermission(roles, routeRoles) {
if (Array.isArray(routeRoles)) {
return roles.some(role => routeRoles.includes(role))
} else {
return true
}
}
export default class BeforeEnter { export default class BeforeEnter {
constructor(opt) { constructor(opt) {
this.opt = opt || {} this.opt = opt || {}
} }
async update(to, from, next) { async update(to, from, next) {
const isLogin = store.state.isLogin || (await store.dispatch('checkLogin')) const isLogin = store.state.user.isLogin || (await store.dispatch('checkLogin'))
if (to.meta.requiredLogin && !isLogin) { const hasRoles = store.state.user.hasRoles || (await store.dispatch('checkRoles'))
next(`/login?redirect_uri=${encodeURIComponent(window.location.href)}`) const loginUrl = `${webConf.others.loginUrl}?rd=${encodeURIComponent(window.location.href)}`
if (!isLogin || !hasRoles) {
window.location.href = loginUrl
// next(loginUrl)
return return
} else {
const roles = store.state.user.roles.map(item => item.name)
if (!hasPermission(roles, to.meta.roles)) {
// next(loginUrl)
window.location.href = loginUrl
return
}
next()
} }
store.dispatch('setUserRoles') store.dispatch('setUserRoles')
next() next()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论