feat: Resource tool permission

This commit is contained in:
zhangzhanwei 2025-07-29 14:47:40 +08:00 committed by zhanweizhang7
parent f13dcbcc3c
commit 53f83d3292
2 changed files with 115 additions and 1 deletions

View File

@ -0,0 +1,106 @@
import {hasPermission} from '@/utils/permission/index'
import {ComplexPermission} from '@/utils/permission/type'
import {EditionConst, PermissionConst, RoleConst} from '@/utils/permission/data'
const systemManage = {
create: () => false,
folderCreate: () => false,
edit: () =>
hasPermission(
[
RoleConst.ADMIN,
PermissionConst.RESOURCE_APPLICATION_EDIT
],
'OR'
),
folderEdit: () => false,
export: () =>
hasPermission(
[
RoleConst.ADMIN,
PermissionConst.RESOURCE_APPLICATION_EXPORT
],
'OR'
),
delete: () =>
hasPermission(
[
RoleConst.ADMIN,
PermissionConst.RESOURCE_APPLICATION_DELETE
],
'OR'
),
folderDelete: () => false,
overview_embed: () =>
hasPermission(
[
RoleConst.ADMIN,
PermissionConst.RESOURCE_APPLICATION_OVERVIEW_EMBED
],
'OR'
),
overview_access: () =>
hasPermission(
[
RoleConst.ADMIN,
PermissionConst.RESOURCE_APPLICATION_OVERVIEW_ACCESS
],
'OR'
),
overview_display: () =>
hasPermission(
[
RoleConst.ADMIN,
PermissionConst.RESOURCE_APPLICATION_OVERVIEW_DISPLAY
],
'OR'
),
overview_api_key: () =>
hasPermission(
[
RoleConst.ADMIN,
PermissionConst.RESOURCE_APPLICATION_OVERVIEW_API_KEY
],
'OR'
),
access_edit: () =>
hasPermission(
[
RoleConst.ADMIN,
PermissionConst.RESOURCE_APPLICATION_ACCESS_EDIT
],
'OR'
),
application_chat_user_edit: () =>
hasPermission(
[
RoleConst.ADMIN,
PermissionConst.RESOURCE_APPLICATION_CHAT_USER_EDIT
],
'OR'
),
chat_log_clear: () =>
hasPermission(
[
RoleConst.ADMIN,
PermissionConst.RESOURCE_APPLICATION_CHAT_LOG_CLEAR_POLICY
],
'OR'
),
chat_log_export: () =>
hasPermission(
[
RoleConst.ADMIN,
PermissionConst.RESOURCE_APPLICATION_CHAT_LOG_EXPORT
],
'OR'
),
chat_log_add_knowledge: () =>
hasPermission(
[
RoleConst.ADMIN,
PermissionConst.RESOURCE_APPLICATION_CHAT_LOG_ADD_KNOWLEDGE
],
'OR'
),
}

View File

@ -227,7 +227,9 @@
</el-button>
</span>
</el-tooltip>
<el-dropdown trigger="click">
<el-dropdown trigger="click"
v-if="MoreFilledPermission(row)"
>
<el-button text @click.stop>
<el-icon>
<MoreFilled />
@ -314,6 +316,12 @@ const permissionPrecise = computed(() => {
return permissionMap['tool']['systemManage']
})
const MoreFilledPermission = (row: any) => {
return permissionPrecise.value.export() ||
permissionPrecise.value.delete() ||
(row.init_field_list?.length > 0 && permissionPrecise.value.edit())
}
function exportTool(row: any) {
ToolResourceApi.exportTool(row.id, row.name, loading).catch((e: any) => {
if (e.response.status !== 403) {