Skip to content

Commit 3ca8c6e

Browse files
committed
perf: Morefilled system and model
1 parent f6b271e commit 3ca8c6e

File tree

4 files changed

+64
-67
lines changed

4 files changed

+64
-67
lines changed

ui/src/views/model/component/ModelCard.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
</div>
6565
</div>
6666

67-
<template #mouseEnter>
67+
<template #mouseEnter
68+
v-if="MoreFilledPermission(model.id)"
69+
>
6870
<el-dropdown trigger="click" v-if="!isShared">
6971
<el-button text @click.stop>
7072
<el-icon>
@@ -147,10 +149,21 @@ const props = defineProps<{
147149
apiType: 'systemShare' | 'workspace' | 'systemManage'
148150
}>()
149151
152+
const apiType = props.apiType
153+
154+
const isSystemShare = computed(() => {
155+
return apiType==='systemShare'
156+
})
157+
150158
const permissionPrecise = computed(() => {
151159
return permissionMap['model'][props.apiType]
152160
})
153161
162+
const MoreFilledPermission = (id: any) => {
163+
return permissionPrecise.value.modify(id) ||
164+
permissionPrecise.value.delete(id) || isSystemShare.value
165+
}
166+
154167
const downModel = ref<Model>()
155168
156169
const currentModel = computed(() => {

ui/src/views/system-chat-user/group/index.vue

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363
<div class="flex-between">
6464
<span class="ellipsis" :title="row.name">{{ row.name }}</span>
6565
<div @click.stop v-show="mouseId === row.id">
66-
<el-dropdown :teleported="false" trigger="click">
66+
<el-dropdown :teleported="false" trigger="click"
67+
v-if="editPermission() || dlePermission()"
68+
>
6769
<el-button text>
6870
<el-icon class="color-secondary">
6971
<MoreFilled />
@@ -74,20 +76,7 @@
7476
<el-dropdown-item
7577
@click.stop="createOrUpdate(row)"
7678
class="p-8"
77-
v-if="
78-
hasPermission(
79-
new ComplexPermission(
80-
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
81-
[
82-
PermissionConst.WORKSPACE_USER_GROUP_EDIT,
83-
PermissionConst.USER_GROUP_EDIT,
84-
],
85-
[],
86-
'OR',
87-
),
88-
'OR',
89-
)
90-
"
79+
v-if="editPermission()"
9180
>
9281
<el-icon>
9382
<EditPen />
@@ -97,20 +86,7 @@
9786
<el-dropdown-item
9887
@click.stop="deleteGroup(row)"
9988
class="border-t p-8"
100-
v-if="
101-
hasPermission(
102-
new ComplexPermission(
103-
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
104-
[
105-
PermissionConst.WORKSPACE_USER_GROUP_DELETE,
106-
PermissionConst.USER_GROUP_DELETE,
107-
],
108-
[],
109-
'OR',
110-
),
111-
'OR',
112-
)
113-
"
89+
v-if="dlePermission()"
11490
>
11591
<el-icon>
11692
<Delete />
@@ -307,6 +283,22 @@ async function getUserGroupList() {
307283
}
308284
}
309285
286+
const editPermission = () => {
287+
return hasPermission(new ComplexPermission(
288+
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
289+
[PermissionConst.WORKSPACE_USER_GROUP_EDIT,
290+
PermissionConst.USER_GROUP_EDIT,],[],
291+
'OR',),'OR',)
292+
}
293+
294+
const dlePermission = () => {
295+
return hasPermission(new ComplexPermission(
296+
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
297+
[PermissionConst.WORKSPACE_USER_GROUP_DELETE,
298+
PermissionConst.USER_GROUP_DELETE,],[],
299+
'OR',),'OR',)
300+
}
301+
310302
onMounted(async () => {
311303
await getUserGroupList()
312304
current.value = list.value[0]

ui/src/views/system/role/index.vue

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
>({{ roleTypeMap[row.type as RoleTypeEnum] }})</span
7373
>
7474
</span>
75-
<div @click.stop v-show="mouseId === row.id">
75+
<div @click.stop v-show="mouseId === row.id"
76+
v-if="editPermission() || delPermission()">
7677
<el-dropdown :teleported="false" trigger="click">
7778
<el-button text>
7879
<el-icon class="color-secondary">
@@ -84,35 +85,15 @@
8485
<el-dropdown-item
8586
@click.stop="createOrUpdateRole(row)"
8687
class="p-8"
87-
v-if="
88-
hasPermission(
89-
new ComplexPermission(
90-
[RoleConst.ADMIN],
91-
[PermissionConst.ROLE_EDIT],
92-
[],
93-
'OR',
94-
),
95-
'OR',
96-
)
97-
"
88+
v-if="editPermission()"
9889
>
9990
<el-icon><EditPen /></el-icon>
10091
{{ $t('common.rename') }}
10192
</el-dropdown-item>
10293
<el-dropdown-item
10394
@click.stop="deleteRole(row)"
10495
class="border-t p-8"
105-
v-if="
106-
hasPermission(
107-
new ComplexPermission(
108-
[RoleConst.ADMIN],
109-
[PermissionConst.ROLE_DELETE],
110-
[],
111-
'OR',
112-
),
113-
'OR',
114-
)
115-
"
96+
v-if="delPermission()"
11697
>
11798
<el-icon><Delete /></el-icon>
11899
{{ $t('common.delete') }}
@@ -205,6 +186,16 @@ async function getRole() {
205186
}
206187
}
207188
189+
const editPermission = () => {
190+
return hasPermission(new ComplexPermission([RoleConst.ADMIN],
191+
[PermissionConst.ROLE_EDIT],[],'OR',),'OR',)
192+
}
193+
194+
const delPermission = () => {
195+
return hasPermission(new ComplexPermission([RoleConst.ADMIN],
196+
[PermissionConst.ROLE_DELETE],[],'OR',),'OR',)
197+
}
198+
208199
onMounted(async () => {
209200
await getRole()
210201
currentRole.value = internalRoleList.value[0]

ui/src/views/system/workspace/index.vue

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
<div class="flex-between">
4444
<span class="ellipsis" :title="row.name">{{ row.name }}</span>
4545
<div @click.stop v-show="mouseId === row.id">
46-
<el-dropdown :teleported="false" trigger="click">
46+
<el-dropdown :teleported="false" trigger="click"
47+
v-if="editPermission() || dlePermission()"
48+
>
4749
<el-button text>
4850
<el-icon class="color-secondary">
4951
<MoreFilled />
@@ -54,26 +56,15 @@
5456
<el-dropdown-item
5557
@click.stop="createOrUpdateWorkspace(row)"
5658
class="p-8"
57-
v-if="
58-
hasPermission(
59-
[RoleConst.ADMIN, PermissionConst.WORKSPACE_EDIT],
60-
'OR',
61-
)
62-
"
59+
v-if="editPermission()"
6360
>
6461
<el-icon><EditPen /></el-icon>
6562
{{ $t('common.rename') }}
6663
</el-dropdown-item>
6764
<el-dropdown-item
6865
@click.stop="deleteWorkspace(row)"
6966
class="border-t p-8"
70-
v-if="
71-
row.id !== 'default' &&
72-
hasPermission(
73-
[RoleConst.ADMIN, PermissionConst.WORKSPACE_DELETE],
74-
'OR',
75-
)
76-
"
67+
v-if="dlePermission()"
7768
>
7869
<el-icon><Delete /></el-icon>
7970
{{ $t('common.delete') }}
@@ -144,6 +135,16 @@ onMounted(async () => {
144135
currentWorkspace.value = list.value[0]
145136
})
146137
138+
const editPermission = () => {
139+
return hasPermission([RoleConst.ADMIN,
140+
PermissionConst.WORKSPACE_EDIT],'OR',)
141+
}
142+
143+
const dlePermission = () => {
144+
return hasPermission([RoleConst.ADMIN,
145+
PermissionConst.WORKSPACE_DELETE],'OR',)
146+
}
147+
147148
async function refresh(workspace?: WorkspaceItem) {
148149
await getWorkspace()
149150
// 创建后选中新建的

0 commit comments

Comments
 (0)