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

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

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