File tree Expand file tree Collapse file tree 3 files changed +17
-18
lines changed Expand file tree Collapse file tree 3 files changed +17
-18
lines changed Original file line number Diff line number Diff line change 1
- import type { App } from 'vue'
2
- import { useUserStore } from " @/store/modules/user" ;
1
+ import type { App } from 'vue'
2
+ import { useUserStore } from ' @/store/modules/user'
3
3
4
4
const { t } = useI18n ( ) // 国际化
5
5
6
+ /** 判断权限的指令 directive */
6
7
export function hasPermi ( app : App < Element > ) {
7
8
app . directive ( 'hasPermi' , ( el , binding ) => {
8
9
const { value } = binding
@@ -18,9 +19,13 @@ export function hasPermi(app: App<Element>) {
18
19
}
19
20
} )
20
21
}
21
- const userStore = useUserStore ( ) ;
22
+
23
+ /** 判断权限的方法 function */
24
+ const userStore = useUserStore ( )
22
25
const all_permission = '*:*:*'
23
26
export const hasPermission = ( permission : string [ ] ) => {
24
- return userStore . permissionsSet . has ( all_permission ) ||
25
- permission . some ( permission => userStore . permissionsSet . has ( permission ) )
27
+ return (
28
+ userStore . permissions . has ( all_permission ) ||
29
+ permission . some ( ( permission ) => userStore . permissions . has ( permission ) )
30
+ )
26
31
}
Original file line number Diff line number Diff line change @@ -15,17 +15,15 @@ interface UserVO {
15
15
16
16
interface UserInfoVO {
17
17
// USER 缓存
18
- permissions : string [ ]
19
- permissionsSet : Set < string >
18
+ permissions : Set < string >
20
19
roles : string [ ]
21
20
isSetUser : boolean
22
21
user : UserVO
23
22
}
24
23
25
24
export const useUserStore = defineStore ( 'admin-user' , {
26
25
state : ( ) : UserInfoVO => ( {
27
- permissions : [ ] ,
28
- permissionsSet : new Set < string > ( ) ,
26
+ permissions : new Set < string > ( ) ,
29
27
roles : [ ] ,
30
28
isSetUser : false ,
31
29
user : {
@@ -36,7 +34,7 @@ export const useUserStore = defineStore('admin-user', {
36
34
}
37
35
} ) ,
38
36
getters : {
39
- getPermissions ( ) : string [ ] {
37
+ getPermissions ( ) : Set < string > {
40
38
return this . permissions
41
39
} ,
42
40
getRoles ( ) : string [ ] {
@@ -59,8 +57,7 @@ export const useUserStore = defineStore('admin-user', {
59
57
if ( ! userInfo ) {
60
58
userInfo = await getInfo ( )
61
59
}
62
- this . permissions = userInfo . permissions
63
- this . permissionsSet = new Set ( userInfo . permissions )
60
+ this . permissions = new Set ( userInfo . permissions )
64
61
this . roles = userInfo . roles
65
62
this . user = userInfo . user
66
63
this . isSetUser = true
@@ -88,7 +85,7 @@ export const useUserStore = defineStore('admin-user', {
88
85
this . resetState ( )
89
86
} ,
90
87
resetState ( ) {
91
- this . permissions = [ ]
88
+ this . permissions = new Set < string > ( )
92
89
this . roles = [ ]
93
90
this . isSetUser = false
94
91
this . user = {
Original file line number Diff line number Diff line change 190
190
<el-button type =" primary" link >更多</el-button >
191
191
<template #dropdown >
192
192
<el-dropdown-menu >
193
- <el-dropdown-item
194
- command =" handleDefinitionList"
195
- v-if =" hasPermiPdQuery"
196
- >
193
+ <el-dropdown-item command =" handleDefinitionList" v-if =" hasPermiPdQuery" >
197
194
历史
198
195
</el-dropdown-item >
199
196
<el-dropdown-item
@@ -278,6 +275,7 @@ const originalData: any = ref([]) // 原始数据
278
275
const modelList: any = ref ([]) // 模型列表
279
276
const isExpand = ref (false ) // 是否处于展开状态
280
277
278
+ /** 权限校验:通过 computed 解决列表的卡顿问题 */
281
279
const hasPermiUpdate = computed (() => {
282
280
return checkPermi ([' bpm:model:update' ])
283
281
})
@@ -294,7 +292,6 @@ const hasPermiPdQuery = computed(() => {
294
292
return checkPermi ([' bpm:process-definition:query' ])
295
293
})
296
294
297
-
298
295
/** '更多'操作按钮 */
299
296
const handleModelCommand = (command : string , row : any ) => {
300
297
switch (command ) {
You can’t perform that action at this time.
0 commit comments