根据用户角色集合展示对应的内容
This commit is contained in:
parent
9c6d4fa7cd
commit
618846c73a
|
@ -109,8 +109,10 @@
|
||||||
this.$post("signin", this.form, (response) => {
|
this.$post("signin", this.form, (response) => {
|
||||||
// 登录信息保存 cookie
|
// 登录信息保存 cookie
|
||||||
Cookies.set(TokenKey, response.data);
|
Cookies.set(TokenKey, response.data);
|
||||||
// 保存上次角色
|
let rolesArray = response.data.roles;
|
||||||
localStorage.setItem("lastSourceId", JSON.parse(Cookies.get(TokenKey)).lastSourceId);
|
let roles = rolesArray.map(r => r.id);
|
||||||
|
// 保存角色
|
||||||
|
localStorage.setItem("roles", roles);
|
||||||
window.location.href = "/"
|
window.location.href = "/"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
<el-col v-if="auth">
|
<el-col v-if="auth">
|
||||||
<el-row id="header-top" type="flex" justify="space-between" align="middle">
|
<el-row id="header-top" type="flex" justify="space-between" align="middle">
|
||||||
<a class="logo"/>
|
<a class="logo"/>
|
||||||
<ms-switch-user/>
|
|
||||||
<ms-user/>
|
<ms-user/>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row id="header-bottom" type="flex" justify="space-between" align="middle">
|
<el-row id="header-bottom" type="flex" justify="space-between" align="middle">
|
||||||
|
@ -11,7 +10,7 @@
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="4">
|
<el-col :span="4">
|
||||||
<el-row type="flex" justify="center" align="middle">
|
<el-row type="flex" justify="center" align="middle">
|
||||||
<router-link to="/createTest">
|
<router-link to="/createTest" v-permission="['test_user','test_manager']">
|
||||||
<el-button type="primary" size="small">创建测试</el-button>
|
<el-button type="primary" size="small">创建测试</el-button>
|
||||||
</router-link>
|
</router-link>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
@ -30,7 +29,6 @@
|
||||||
import MsSetting from "./components/HeaderSetting";
|
import MsSetting from "./components/HeaderSetting";
|
||||||
import MsView from "./components/router/View";
|
import MsView from "./components/router/View";
|
||||||
import MsUser from "./components/HeaderUser";
|
import MsUser from "./components/HeaderUser";
|
||||||
import MsSwitchUser from "./components/HeaderSwitchUser";
|
|
||||||
import MsWebSocket from "./components/websocket/WebSocket";
|
import MsWebSocket from "./components/websocket/WebSocket";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -51,7 +49,7 @@
|
||||||
window.location.href = "/login"
|
window.location.href = "/login"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
components: {MsWebSocket, MsUser, MsMenus, MsSetting, MsView, MsSwitchUser},
|
components: {MsWebSocket, MsUser, MsMenus, MsSetting, MsView},
|
||||||
methods: {
|
methods: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<el-menu menu-trigger="click" :default-active="$route.path" router>
|
<el-menu menu-trigger="click" :default-active="$route.path" router>
|
||||||
<el-submenu index="1">
|
<el-submenu index="1" v-permission="['admin']">
|
||||||
<template slot="title">
|
<template slot="title">
|
||||||
<font-awesome-icon class="icon account" :icon="['far', 'address-card']" size="lg"/>
|
<font-awesome-icon class="icon account" :icon="['far', 'address-card']" size="lg"/>
|
||||||
<span>账号</span>
|
<span>账号</span>
|
||||||
</template>
|
</template>
|
||||||
<el-menu-item index="/setting/user">用户</el-menu-item>
|
<el-menu-item index="/setting/user">用户</el-menu-item>
|
||||||
<el-menu-item index="/setting/testresourcepool">测试资源池</el-menu-item>
|
<el-menu-item index="/setting/testresourcepool" v-permission="['test']">测试资源池</el-menu-item>
|
||||||
<el-menu-item index="/setting/organization">组织</el-menu-item>
|
<el-menu-item index="/setting/organization">组织</el-menu-item>
|
||||||
<el-menu-item index="/setting/workspace">工作空间</el-menu-item>
|
<el-menu-item index="/setting/workspace">工作空间</el-menu-item>
|
||||||
<el-menu-item>API Keys</el-menu-item>
|
<el-menu-item>API Keys</el-menu-item>
|
||||||
</el-submenu>
|
</el-submenu>
|
||||||
<el-submenu index=2>
|
<el-submenu index=2 v-permission="['admin','org_admin']">
|
||||||
<template slot="title">
|
<template slot="title">
|
||||||
<font-awesome-icon class="icon workspace" :icon="['far', 'clone']" size="lg"/>
|
<font-awesome-icon class="icon workspace" :icon="['far', 'clone']" size="lg"/>
|
||||||
<span>工作空间</span>
|
<span>工作空间</span>
|
||||||
|
|
|
@ -7,10 +7,13 @@ const whiteList = ['/login']; // no redirect whitelist
|
||||||
export const permission = {
|
export const permission = {
|
||||||
inserted(el, binding) {
|
inserted(el, binding) {
|
||||||
const { value } = binding;
|
const { value } = binding;
|
||||||
const roles = localStorage.getItem("lastSourceId");
|
const rolesString = localStorage.getItem("roles");
|
||||||
|
const roles = rolesString.split(',');
|
||||||
if (value && value instanceof Array && value.length > 0) {
|
if (value && value instanceof Array && value.length > 0) {
|
||||||
const permissionRoles = value;
|
const permissionRoles = value;
|
||||||
const hasPermission = permissionRoles.includes(roles);
|
const hasPermission = roles.some(role => {
|
||||||
|
return permissionRoles.includes(role)
|
||||||
|
});
|
||||||
if (!hasPermission) {
|
if (!hasPermission) {
|
||||||
el.parentNode && el.parentNode.removeChild(el)
|
el.parentNode && el.parentNode.removeChild(el)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue