mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: 添加菜单权限 (#730)
This commit is contained in:
parent
db34290889
commit
dd924964e8
|
|
@ -12,7 +12,7 @@
|
|||
<span>{{ menu.meta?.title as string }}</span>
|
||||
</template>
|
||||
<sidebar-item
|
||||
v-hasPermission="menu.meta?.permission"
|
||||
v-hasPermission="child.meta?.permission"
|
||||
v-for="(child, index) in menu?.children"
|
||||
:key="index"
|
||||
:menu="child"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { hasPermission } from '@/utils/permission/index'
|
||||
import Layout from '@/layout/layout-template/SystemLayout.vue'
|
||||
import { Role } from '@/utils/permission/type'
|
||||
import { Role, ComplexPermission } from '@/utils/permission/type'
|
||||
const settingRouter = {
|
||||
path: '/setting',
|
||||
name: 'setting',
|
||||
|
|
@ -74,7 +74,7 @@ const settingRouter = {
|
|||
activeMenu: '/setting',
|
||||
parentPath: '/setting',
|
||||
parentName: 'setting',
|
||||
permission: new Role('ADMIN')
|
||||
permission: new ComplexPermission(['ADMIN'], ['x-pack'], 'AND')
|
||||
},
|
||||
component: () => import('@/views/theme/index.vue')
|
||||
},
|
||||
|
|
@ -86,7 +86,7 @@ const settingRouter = {
|
|||
activeMenu: '/setting',
|
||||
parentPath: '/setting',
|
||||
parentName: 'setting',
|
||||
permission: new Role('ADMIN')
|
||||
permission: new ComplexPermission(['ADMIN'], ['x-pack'], 'AND')
|
||||
},
|
||||
component: () => import('@/views/authentication/index.vue')
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ export interface userStateTypes {
|
|||
token: any
|
||||
version?: string
|
||||
accessToken?: string
|
||||
XPACK_LICENSE_IS_VALID: false
|
||||
isXPack: false
|
||||
}
|
||||
|
||||
|
|
@ -18,11 +19,12 @@ const useUserStore = defineStore({
|
|||
userInfo: null,
|
||||
token: '',
|
||||
version: '',
|
||||
XPACK_LICENSE_IS_VALID: false,
|
||||
isXPack: false
|
||||
}),
|
||||
actions: {
|
||||
isEnterprise() {
|
||||
return this.userInfo?.IS_XPACK && this.userInfo?.XPACK_LICENSE_IS_VALID
|
||||
return this.isXPack && this.XPACK_LICENSE_IS_VALID
|
||||
},
|
||||
getToken(): String | null {
|
||||
if (this.token) {
|
||||
|
|
@ -40,7 +42,9 @@ const useUserStore = defineStore({
|
|||
|
||||
getPermissions() {
|
||||
if (this.userInfo) {
|
||||
return this.userInfo?.permissions
|
||||
return this.isXPack && this.XPACK_LICENSE_IS_VALID
|
||||
? [...this.userInfo?.permissions, 'x-pack']
|
||||
: this.userInfo?.permissions
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
|
|
@ -59,6 +63,8 @@ const useUserStore = defineStore({
|
|||
async asyncGetVersion() {
|
||||
return UserApi.getVersion().then((ok) => {
|
||||
this.version = ok.data?.version || '-'
|
||||
this.isXPack = ok.data?.IS_XPACK
|
||||
this.XPACK_LICENSE_IS_VALID = ok.data?.XPACK_LICENSE_IS_VALID
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue