From 9e42a0fac801c0854f65da03da61052ecc5a3309 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Thu, 22 Oct 2026 16:02:01 +0800 Subject: [PATCH] feat: authorize workspace --- ui/src/api/API_README.md | 8 + .../system/shared-resources/authorization.ts | 16 ++ ui/src/api/types/index.ts | 2 + ui/src/api/types/shared-authorization.ts | 10 + .../business/workspace-dropdown/index.vue | 2 +- .../mk-table-filter/TableFilterMultiple.vue | 22 +- ui/src/styles/STYLE_README.md | 3 + ui/src/styles/app.scss | 19 ++ ui/src/views/VIEW_README.md | 5 +- .../display-setting/DisplaySettingDialog.vue | 209 ++++++++---------- ui/src/views/login/index.vue | 1 + .../AuthorizedWorkspaceDialog.vue | 151 +++++++++++++ .../authorized-workspace-action/index.vue | 27 +++ .../shared-resources/knowledge/index.vue | 8 +- .../system/shared-resources/model/index.vue | 29 ++- .../system/shared-resources/tool/index.vue | 22 +- 16 files changed, 389 insertions(+), 145 deletions(-) create mode 100644 ui/src/api/admin/system/shared-resources/authorization.ts create mode 100644 ui/src/api/types/shared-authorization.ts create mode 100644 ui/src/views/system/shared-resources/authorized-workspace-action/AuthorizedWorkspaceDialog.vue create mode 100644 ui/src/views/system/shared-resources/authorized-workspace-action/index.vue diff --git a/ui/src/api/API_README.md b/ui/src/api/API_README.md index 2b7a1ca3945..5f3ab0a8b28 100644 --- a/ui/src/api/API_README.md +++ b/ui/src/api/API_README.md @@ -241,6 +241,14 @@ System 不传 Workspace 文件夹条件;System 共享不提供智能体选择 将响应的 `tools` 与 `shared_tools` 合并为 `ToolItem[]`,用于包含已授权共享工具的选项查询; 按工具类型筛选时使用 `tool_type`。`workspace/shared/tool.ts` 的 `getAllTool(query)` 仅查询共享工具。 +### System 共享资源工作空间授权 + +`system/shared-resources/authorization.ts` 通过 GET、POST +`/system/shared///authorization` 查询和保存工作空间授权, +沿用 v2 System 共享授权协议,依赖部署端提供对应接口。配置类型为 `SharedWorkspaceAuthorization`, +包含 `authentication_type`(`WHITE_LIST`/`BLACK_LIST`)和 `workspace_id_list`;请求层直接解包配置。 +弹窗通过 System Workspace API 查询工作空间,不读取路由中的工作空间 ID。 + ### System 共享工具 `system/shared-resources/tool/tool.ts` 使用 `/system/shared/tool`,维护分页、详情、创建、更新、删除、 diff --git a/ui/src/api/admin/system/shared-resources/authorization.ts b/ui/src/api/admin/system/shared-resources/authorization.ts new file mode 100644 index 00000000000..886d8ee5aae --- /dev/null +++ b/ui/src/api/admin/system/shared-resources/authorization.ts @@ -0,0 +1,16 @@ +import { get, post } from '../../core/request' +import type { SharedResourceType, SharedWorkspaceAuthorization } from '@/api/types' + +const prefix = '/system/shared' + +/** 获取共享资源的工作空间授权配置。 */ +const getSharedAuthorization = (resourceType: SharedResourceType, resourceId: string) => { + return get(`${prefix}/${resourceType.toLowerCase()}/${resourceId}/authorization`) +} + +/** 保存共享资源的工作空间授权配置。 */ +const postSharedAuthorization = (resourceType: SharedResourceType, resourceId: string, payload: SharedWorkspaceAuthorization) => { + return post(`${prefix}/${resourceType.toLowerCase()}/${resourceId}/authorization`, payload) +} + +export default { getSharedAuthorization, postSharedAuthorization } diff --git a/ui/src/api/types/index.ts b/ui/src/api/types/index.ts index 01dffb04a9d..3f23361052d 100644 --- a/ui/src/api/types/index.ts +++ b/ui/src/api/types/index.ts @@ -36,3 +36,5 @@ export type * from './document' export type * from './paragraph' export type * from './termbase' export type * from './chat-log' + +export type * from './shared-authorization' diff --git a/ui/src/api/types/shared-authorization.ts b/ui/src/api/types/shared-authorization.ts new file mode 100644 index 00000000000..f979ae14bbe --- /dev/null +++ b/ui/src/api/types/shared-authorization.ts @@ -0,0 +1,10 @@ +/** System 共享资源授权 API 与页面共用的业务类型。 */ +import type { RESOURCE_TYPE } from '@/api/enums' +import type { ResourceType } from './resource-authorization' + +export type SharedResourceType = Exclude + +export interface SharedWorkspaceAuthorization { + authentication_type: 'WHITE_LIST' | 'BLACK_LIST' + workspace_id_list: string[] +} diff --git a/ui/src/components/business/workspace-dropdown/index.vue b/ui/src/components/business/workspace-dropdown/index.vue index e58ae3e1711..5db93ddb68f 100644 --- a/ui/src/components/business/workspace-dropdown/index.vue +++ b/ui/src/components/business/workspace-dropdown/index.vue @@ -27,7 +27,7 @@ const emit = defineEmits<{ select: [option: WorkspaceItem] }>() - + diff --git a/ui/src/styles/STYLE_README.md b/ui/src/styles/STYLE_README.md index 71749261111..4eb2f0c6059 100644 --- a/ui/src/styles/STYLE_README.md +++ b/ui/src/styles/STYLE_README.md @@ -211,6 +211,9 @@ CSS 自定义属性同样按变量名排序。嵌套选择器、伪类和媒体 ## 常用交互工具类 +纵向复选框组在 `el-checkbox-group` 上添加 `mk-checkbox-group-vertical`,由 `app.scss` 统一 +设置纵向排列、8px 间距、选项整行宽度及长标签省略;标签文本需提供原生 `title`。 + 纵向单选组在 `el-radio-group` 上添加 `mk-radio-group-vertical`,统一整行宽度、8px 间距及 多行选项的顶部对齐;普通单行和带描述的选项均可使用。 diff --git a/ui/src/styles/app.scss b/ui/src/styles/app.scss index b3f22010e41..d24d581715b 100644 --- a/ui/src/styles/app.scss +++ b/ui/src/styles/app.scss @@ -124,6 +124,25 @@ h6 { z-index: 1; } +/* checkbox */ +.mk-checkbox-group-vertical { + display: flex; + flex-direction: column; + + .el-checkbox { + margin-right: 0; + min-width: 0; + width: 100%; + } + + .el-checkbox__label { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } +} + /* dot */ // 状态圆点 .mk-dot-danger { diff --git a/ui/src/views/VIEW_README.md b/ui/src/views/VIEW_README.md index 1ed64b07342..c0ff09a2045 100644 --- a/ui/src/views/VIEW_README.md +++ b/ui/src/views/VIEW_README.md @@ -45,7 +45,7 @@ | `knowledge-detail/library/document/`、`tags/` | 文档及标签维护 | | `knowledge-detail/library/image/` | 图片列表,复用文档操作 | | `knowledge-detail/hit-test/` | 召回测试参数、文本/图片查询及结果展示 | -| `knowledge-detail/problem/` | 问题查询、维护与分段关联 | +| `knowledge-detail/problem/` | 问题查询、维护与分段关联 | | `knowledge-detail/termbase/` | 知识库自定义分词维护 | | `knowledge-detail/chat-user/`、`external-retrieval/` | 对话授权与外部检索配置 | | `knowledge-detail/setting/base/`、`document-strategy/`、`scheduled-sync/` | 基础设置、文档策略、定时同步与日志 | @@ -96,6 +96,9 @@ - System 模型/工具使用表格,保留既有权限、引用数量删除提示和末页回退;不新增不存在的创建/导入能力。 工作空间列与选项仅企业版显示,筛选 `workspace_ids` 使用 JSON 数组字符串。 - Workspace 共享知识库只读;System 共享资源页面按自身 API 维护,不组合 Workspace 文件夹移动等操作。 +- System 共享知识库、模型、工具菜单复用功能本地 `authorized-workspace-action/index.vue`,打开同目录的 + `AuthorizedWorkspaceDialog` 配置工作空间白名单/黑名单;保留弹窗实例,关闭动画结束后清空本次数据, + 保存失败保留草稿。 资源授权和关联资源入口按需挂载公共抽屉,关闭动画结束后卸载。授权使用资源数据的 `workspace_id`;关联资源抽屉的查询与工作空间展示规则见组件和 API 文档。 diff --git a/ui/src/views/application-detail/overview/display-setting/DisplaySettingDialog.vue b/ui/src/views/application-detail/overview/display-setting/DisplaySettingDialog.vue index d42eaf77689..edb1c13bfb7 100644 --- a/ui/src/views/application-detail/overview/display-setting/DisplaySettingDialog.vue +++ b/ui/src/views/application-detail/overview/display-setting/DisplaySettingDialog.vue @@ -176,30 +176,10 @@ defineExpose({ open }) diff --git a/ui/src/views/login/index.vue b/ui/src/views/login/index.vue index 92b6d653691..489d4765365 100644 --- a/ui/src/views/login/index.vue +++ b/ui/src/views/login/index.vue @@ -38,6 +38,7 @@ const qrCodeLoginConfig = computed(() => ({ const showLoginModeSwitch = computed(() => accountLoginMethods.value.length > 0 && qrCodeProviders.value.length > 0) onBeforeMount(() => { + // TODO 根据默认跳转 isLoading.value = true auth .loadPlatformProfile() diff --git a/ui/src/views/system/shared-resources/authorized-workspace-action/AuthorizedWorkspaceDialog.vue b/ui/src/views/system/shared-resources/authorized-workspace-action/AuthorizedWorkspaceDialog.vue new file mode 100644 index 00000000000..17d20a7e746 --- /dev/null +++ b/ui/src/views/system/shared-resources/authorized-workspace-action/AuthorizedWorkspaceDialog.vue @@ -0,0 +1,151 @@ + + + diff --git a/ui/src/views/system/shared-resources/authorized-workspace-action/index.vue b/ui/src/views/system/shared-resources/authorized-workspace-action/index.vue new file mode 100644 index 00000000000..a91556eeb4a --- /dev/null +++ b/ui/src/views/system/shared-resources/authorized-workspace-action/index.vue @@ -0,0 +1,27 @@ + + + diff --git a/ui/src/views/system/shared-resources/knowledge/index.vue b/ui/src/views/system/shared-resources/knowledge/index.vue index ee78154cac7..da8c9e0b47d 100644 --- a/ui/src/views/system/shared-resources/knowledge/index.vue +++ b/ui/src/views/system/shared-resources/knowledge/index.vue @@ -1,4 +1,5 @@