Skip to content

Commit

Permalink
feat: 角色导航权限 (#1398)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri0528 authored Nov 20, 2023
1 parent 1407a29 commit 3fe19d5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
9 changes: 9 additions & 0 deletions src/pages/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ import { Message } from 'bkui-vue';
import {
ref,
} from 'vue';
import { useRoute } from 'vue-router';
import HeaderBox from './views/Header.vue';
import { currentUser } from '@/http/api';
import router from '@/router';
import { useUser } from '@/store/user';
// 加载完用户数据才会展示页面
const isLoading = ref(false);
// 获取用户数据
const user = useUser();
const route = useRoute();
currentUser()
.then((res) => {
if (route.name === 'tenantInfo' && res.data.role === 'tenant_manager') {
router.push({
name: 'organization',
});
}
user.setUser(res.data);
isLoading.value = false;
})
Expand Down
47 changes: 19 additions & 28 deletions src/pages/src/views/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

<script setup lang="ts">
import { DownShape } from 'bkui-vue/lib/icon';
import { computed, reactive } from 'vue';
import { computed, reactive, ref } from 'vue';
import { useRoute } from 'vue-router';
import { logout } from '@/common/auth';
Expand All @@ -107,37 +107,28 @@ const state = reactive({
});
const userStore = useUser();
const userInfo = computed(() => userStore.user);
const headerNav = ref([]);
const userInfo = computed(() => {
const { role } = userStore.user;
const baseNav = [
{ name: '组织架构', path: 'organization' },
{ name: '数据源管理', path: 'dataSource' },
{ name: '认证源管理', path: 'authSource' },
];
if (role === 'super_manager') {
headerNav.value = [...baseNav, { name: '租户管理', path: 'tenant' }, { name: '设置', path: 'setting' }];
} else if (role === 'tenant_manager') {
headerNav.value = [...baseNav, { name: '设置', path: 'setting' }];
} else if (role === 'natural_user') {
router.push({ name: 'personalCenter' });
}
return userStore.user;
});
const route = useRoute();
const isPersonalCenter = computed(() => route.name === 'personalCenter');
const headerNav = reactive([
{
name: '组织架构',
path: 'organization',
},
{
name: '数据源管理',
path: 'dataSource',
},
{
name: '认证源管理',
path: 'authSource',
},
{
name: '租户管理',
path: 'tenant',
},
// {
// name: "审计",
// path: "audit",
// },
{
name: '设置',
path: 'setting',
},
]);
// const languageNav = reactive([
// {
// name: '中文',
Expand Down

0 comments on commit 3fe19d5

Please sign in to comment.