From 3915c63a9db5a7997709c2d17e96a656d7f4fc9f Mon Sep 17 00:00:00 2001 From: "sam.p" <102567930@qq.com> Date: Thu, 6 Aug 2026 14:42:45 +0800 Subject: [PATCH] =?UTF-8?q?feat(group-export):=20=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=8A=A0=E3=80=8C=E7=A7=BB=E9=99=A4=E6=95=8F?= =?UTF-8?q?=E6=84=9F=E4=BF=A1=E6=81=AF=E3=80=8D=E5=8B=BE=E9=80=89=EF=BC=8C?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=BF=9D=E7=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 把后端 ES-2 的分流开关接到界面上:FILE 给勾选框、默认不勾(=保真包,能直接 搬到另一个环境用);GIT 不给这个开关——后端强制脱敏,给了就是假开关,只留一句说明。 - ExportGroupInfoBatchParams 加 removeSensitiveData?,三态语义与后端 ExportGroupRequest 对齐 - 未勾选时用告警色显形「包内将含明文凭据」(ADR-0034 接受的代价要求 UI 看得见) - 仅 FILE 分支发送该字段;GIT 分支刻意不发——发 false 会换回一条「你的请求被 覆盖了」的告警,而界面从未给过这个选择 - i18n: en / zh-CN / zh-TW 各加 4 个 key --- apps/daas/src/i18n/langs/en.js | 7 ++++ apps/daas/src/i18n/langs/zh-CN.js | 7 ++++ apps/daas/src/i18n/langs/zh-TW.js | 7 ++++ .../data-import-export/GroupExportDialog.vue | 34 ++++++++++++++++++- packages/api/src/core/group-info.ts | 8 +++++ 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/apps/daas/src/i18n/langs/en.js b/apps/daas/src/i18n/langs/en.js index f307d04cb..614a4bb06 100644 --- a/apps/daas/src/i18n/langs/en.js +++ b/apps/daas/src/i18n/langs/en.js @@ -133,6 +133,13 @@ export default { data_import_export_transfer_type: 'Export Type', data_import_export_file_export: 'File Export', data_import_export_git_export: 'Git Export', + data_import_export_remove_sensitive_data: 'Remove sensitive data', + data_import_export_remove_sensitive_data_on_tip: + 'The package carries no connection credentials. On import, credentials already configured in the target environment are kept instead of being cleared.', + data_import_export_remove_sensitive_data_off_tip: + 'The package will contain plaintext database credentials (host, username, password). Do not share it or commit it to a code repository.', + data_import_export_git_always_masked_tip: + 'Git export always removes connection credentials and cannot be turned off — repository history cannot be taken back.', data_import_export_git_config_required: 'Git configuration is required for this project', data_import_export_config_git: 'Configure Git', diff --git a/apps/daas/src/i18n/langs/zh-CN.js b/apps/daas/src/i18n/langs/zh-CN.js index ba7cd99d9..c80604235 100644 --- a/apps/daas/src/i18n/langs/zh-CN.js +++ b/apps/daas/src/i18n/langs/zh-CN.js @@ -130,6 +130,13 @@ export default { data_import_export_transfer_type: '导出类型', data_import_export_file_export: '文件导出', data_import_export_git_export: 'Git 导出', + data_import_export_remove_sensitive_data: '移除敏感信息', + data_import_export_remove_sensitive_data_on_tip: + '包内不含连接凭据。导入时目标环境已配置的凭据将被保留,不会被清空。', + data_import_export_remove_sensitive_data_off_tip: + '导出包内将含数据库连接的明文凭据(地址、账号、密码),请勿外发或提交到代码仓库。', + data_import_export_git_always_masked_tip: + 'Git 导出一律移除连接凭据,不可关闭 —— 提交进仓库的历史无法撤回。', data_import_export_git_config_required: '该项目尚未配置 Git 信息', data_import_export_config_git: '配置 Git', data_import_export_latest_tag: '最新 Tag', diff --git a/apps/daas/src/i18n/langs/zh-TW.js b/apps/daas/src/i18n/langs/zh-TW.js index cb948c386..fca5e5a7f 100644 --- a/apps/daas/src/i18n/langs/zh-TW.js +++ b/apps/daas/src/i18n/langs/zh-TW.js @@ -130,6 +130,13 @@ export default { data_import_export_transfer_type: '導出類型', data_import_export_file_export: '文件導出', data_import_export_git_export: 'Git 導出', + data_import_export_remove_sensitive_data: '移除敏感信息', + data_import_export_remove_sensitive_data_on_tip: + '包內不含連接憑據。導入時目標環境已配置的憑據將被保留,不會被清空。', + data_import_export_remove_sensitive_data_off_tip: + '導出包內將含數據庫連接的明文憑據(地址、賬號、密碼),請勿外發或提交到代碼倉庫。', + data_import_export_git_always_masked_tip: + 'Git 導出一律移除連接憑據,不可關閉 —— 提交進倉庫的歷史無法撤回。', data_import_export_git_config_required: '該項目尚未配置 Git 信息', data_import_export_config_git: '配置 Git', data_import_export_latest_tag: '最新 Tag', diff --git a/apps/daas/src/views/data-import-export/GroupExportDialog.vue b/apps/daas/src/views/data-import-export/GroupExportDialog.vue index 68cc8dafa..79151849c 100644 --- a/apps/daas/src/views/data-import-export/GroupExportDialog.vue +++ b/apps/daas/src/views/data-import-export/GroupExportDialog.vue @@ -34,6 +34,9 @@ const searchKeyword = ref('') // 搜索关键词 // 导出状态 const exporting = ref(false) const groupTransferType = ref<'FILE' | 'GIT'>('FILE') // 导出类型 +// 是否移除包内敏感信息(连接凭据)。默认 false = 保真,本地导出的包能直接搬到另一个环境用。 +// 仅对 FILE 生效:GIT 由后端强制脱敏,界面不给这个假开关。 +const removeSensitiveData = ref(false) const gitBranchName = ref('') // 分支名 const gitPrTitle = ref('') // PR 标题 const gitPrDescription = ref('') // PR 描述 @@ -180,6 +183,7 @@ watch(visible, async (val) => { // 重置导出类型和字段 groupTransferType.value = 'FILE' + removeSensitiveData.value = false gitBranchName.value = generateBranchName() gitPrTitle.value = '' gitPrDescription.value = '' @@ -280,11 +284,13 @@ const handleExport = async () => { const res = await exportGroupInfoBatch({ groupIds: selectedGroupIds.value, groupTransferType: groupTransferType.value, + removeSensitiveData: removeSensitiveData.value, groupResetTask: rerunData, }) downloadBlob(res) } else { - // 调用导出接口 + // 调用导出接口。GIT 不带 removeSensitiveData:后端强制脱敏, + // 显式发 false 只会换回一条「你的请求被覆盖了」的告警,而界面从未给过这个选择。 await exportGroupInfoBatchGit({ groupIds: selectedGroupIds.value, groupTransferType: groupTransferType.value, @@ -459,6 +465,32 @@ const handleCreateProject = () => { + +
+ +
+ {{ $t('data_import_export_git_always_masked_tip') }} +
+
+
diff --git a/packages/api/src/core/group-info.ts b/packages/api/src/core/group-info.ts index 6e99509fa..38d70d59a 100644 --- a/packages/api/src/core/group-info.ts +++ b/packages/api/src/core/group-info.ts @@ -126,6 +126,14 @@ export function deleteGroupInfo(id: string) { export interface ExportGroupInfoBatchParams { groupIds: string[] groupTransferType: 'FILE' | 'GIT' + /** + * 是否移除包内的敏感信息(连接凭据)。三态语义与后端 ExportGroupRequest 对齐: + * 省略 = 未指定(FILE 按保真、GIT 按脱敏)、true = 要求脱敏、false = 要求保真。 + * + * GIT 路径后端强制脱敏、本字段一律不生效,所以 GIT 导出**不要发送它**: + * 发 false 会被后端当成「用户明确要保真却被覆盖」而回告一条告警,而界面上从未给过这个选择。 + */ + removeSensitiveData?: boolean groupResetTask: { [groupId: string]: string[] }