From 7756d02b6a97cd01d01548facb68ffa78ffd41e5 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Wed, 27 Aug 2025 15:10:31 +0800 Subject: [PATCH] feat: Resource management authorization --- .../resource-authorization.ts | 55 +++++++++ ui/src/api/system/resource-authorization.ts | 49 +------- .../api/workspace/resource-authorization.ts | 57 +++++++++ .../component/chat-input-operate/index.vue | 5 +- .../generate-related-dialog/index.vue | 1 - .../resource-authorization-drawer/index.vue | 56 +++++---- ui/src/utils/dynamics-api/shared-api.ts | 8 +- .../XPackDisplaySettingDialog.vue | 2 +- ui/src/views/chat-log/index.vue | 115 +++++++++--------- ui/src/views/chat/component/HistoryPanel.vue | 11 +- ui/src/views/document/UploadDocument.vue | 1 - .../ApplicationResourceIndex.vue | 28 ++++- .../KnowledgeResourceIndex.vue | 24 +++- .../ModelResourceIndex.vue | 79 +++++++----- .../ToolResourceIndex.vue | 42 +++++-- ui/src/views/tool/McpToolFormDrawer.vue | 1 - ui/src/views/tool/ToolFormDrawer.vue | 1 - ui/src/workflow/nodes/ai-chat-node/index.vue | 3 + 18 files changed, 350 insertions(+), 188 deletions(-) create mode 100644 ui/src/api/system-resource-management/resource-authorization.ts create mode 100644 ui/src/api/workspace/resource-authorization.ts diff --git a/ui/src/api/system-resource-management/resource-authorization.ts b/ui/src/api/system-resource-management/resource-authorization.ts new file mode 100644 index 000000000..0ccb71e18 --- /dev/null +++ b/ui/src/api/system-resource-management/resource-authorization.ts @@ -0,0 +1,55 @@ +import { Result } from '@/request/Result' +import { get, put, post, del } from '@/request/index' +import type { Ref } from 'vue' +import type { pageRequest } from '@/api/type/common' +const prefix = 'system/workspace' + +/** + * 系统资源授权获取资源权限 + * @query 参数 + */ +const getResourceAuthorization: ( + workspace_id: string, + target: string, + resource: string, + page: pageRequest, + params?: any, + loading?: Ref, +) => Promise> = (workspace_id, target, resource, page, params, loading) => { + return get( + `${prefix}/${workspace_id}/resource_management/resource/${target}/resource/${resource}/${page.current_page}/${page.page_size}`, + params, + loading, + ) +} +/** + * 系统资源授权修改成员权限 + * @param 参数 member_id + * @param 参数 { + [ + { + "target_id": "string", + "permission": "NOT_AUTH" + } + ] + } + */ +const putResourceAuthorization: ( + workspace_id: string, + target: string, + resource: string, + body: any, + loading?: Ref, +) => Promise> = (workspace_id, target, resource, body, loading) => { + return put( + `${prefix}/${workspace_id}/resource_management/resource/${target}/resource/${resource}`, + body, + {}, + loading, + ) +} + +export default { + getResourceAuthorization, + putResourceAuthorization, +} diff --git a/ui/src/api/system/resource-authorization.ts b/ui/src/api/system/resource-authorization.ts index dc9d3b357..c9efbbd6b 100644 --- a/ui/src/api/system/resource-authorization.ts +++ b/ui/src/api/system/resource-authorization.ts @@ -4,52 +4,6 @@ import type { Ref } from 'vue' import type { pageRequest } from '@/api/type/common' const prefix = '/workspace' -/** - * 工作空间下各资源获取资源权限 - * @query 参数 - */ -const getWorkspaceResourceAuthorization: ( - workspace_id: string, - target: string, - resource: string, - page: pageRequest, - params?: any, - loading?: Ref, -) => Promise> = (workspace_id, target, resource, page, params, loading) => { - return get( - `${prefix}/${workspace_id}/resource_user_permission/resource/${target}/resource/${resource}/${page.current_page}/${page.page_size}`, - params, - loading, - ) -} - -/** - * 工作空间下各资源修改成员权限 - * @param 参数 member_id - * @param 参数 { - [ - { - "user_id": "string", - "permission": "NOT_AUTH" - } - ] - } - */ -const putWorkspaceResourceAuthorization: ( - workspace_id: string, - target: string, - resource: string, - body: any, - loading?: Ref, -) => Promise> = (workspace_id, target, resource, body, loading) => { - return put( - `${prefix}/${workspace_id}/resource_user_permission/resource/${target}/resource/${resource}`, - body, - {}, - loading, - ) -} - /** * 系统资源授权获取资源权限 * @query 参数 @@ -148,6 +102,5 @@ export default { getUserList, getUserMember, getSystemFolder, - getWorkspaceResourceAuthorization, - putWorkspaceResourceAuthorization + } diff --git a/ui/src/api/workspace/resource-authorization.ts b/ui/src/api/workspace/resource-authorization.ts new file mode 100644 index 000000000..6ca07686b --- /dev/null +++ b/ui/src/api/workspace/resource-authorization.ts @@ -0,0 +1,57 @@ +import { Result } from '@/request/Result' +import { get, put, post, del } from '@/request/index' +import type { Ref } from 'vue' +import type { pageRequest } from '@/api/type/common' +const prefix = '/workspace' + + +/** + * 工作空间下各资源获取资源权限 + * @query 参数 + */ +const getResourceAuthorization: ( + workspace_id: string, + target: string, + resource: string, + page: pageRequest, + params?: any, + loading?: Ref, +) => Promise> = (workspace_id, target, resource, page, params, loading) => { + return get( + `${prefix}/${workspace_id}/resource_user_permission/resource/${target}/resource/${resource}/${page.current_page}/${page.page_size}`, + params, + loading, + ) +} + +/** + * 工作空间下各资源修改成员权限 + * @param 参数 member_id + * @param 参数 { + [ + { + "user_id": "string", + "permission": "NOT_AUTH" + } + ] + } + */ +const putResourceAuthorization: ( + workspace_id: string, + target: string, + resource: string, + body: any, + loading?: Ref, +) => Promise> = (workspace_id, target, resource, body, loading) => { + return put( + `${prefix}/${workspace_id}/resource_user_permission/resource/${target}/resource/${resource}`, + body, + {}, + loading, + ) +} + +export default { + getResourceAuthorization, + putResourceAuthorization +} diff --git a/ui/src/components/ai-chat/component/chat-input-operate/index.vue b/ui/src/components/ai-chat/component/chat-input-operate/index.vue index db994c96f..127f0e3e3 100644 --- a/ui/src/components/ai-chat/component/chat-input-operate/index.vue +++ b/ui/src/components/ai-chat/component/chat-input-operate/index.vue @@ -427,11 +427,10 @@ const uploadFile = async (file: any, fileList: any) => { fileList.splice(0, fileList.length, ...fileList.slice(0, maxFiles)) return } - console.log(fileList) if (fileList.filter((f: any) => f.size == 0).length > 0) { // MB - MsgWarning(t('chat.uploadFile.sizeLimit2') + fileLimit + 'MB') - // 只保留未超出大小限制的文件 + MsgWarning(t('chat.uploadFile.sizeLimit2')) + // 空文件上传过滤 fileList.splice(0, fileList.length, ...fileList.filter((f: any) => f.size > 0)) return } diff --git a/ui/src/components/generate-related-dialog/index.vue b/ui/src/components/generate-related-dialog/index.vue index 12baa0229..d41826316 100644 --- a/ui/src/components/generate-related-dialog/index.vue +++ b/ui/src/components/generate-related-dialog/index.vue @@ -77,7 +77,6 @@ import { groupBy } from 'lodash' import { MsgSuccess } from '@/utils/message' import { t } from '@/locales' import type { FormInstance } from 'element-plus' -import modelResourceApi from '@/api/system-resource-management/model' import { loadSharedApi } from '@/utils/dynamics-api/shared-api' const props = defineProps<{ diff --git a/ui/src/components/resource-authorization-drawer/index.vue b/ui/src/components/resource-authorization-drawer/index.vue index 4eb300141..b6213ff18 100644 --- a/ui/src/components/resource-authorization-drawer/index.vue +++ b/ui/src/components/resource-authorization-drawer/index.vue @@ -22,10 +22,7 @@ > - +