From ea83fd6f0d0c81df8c1a23194f4f4f41c5b770ca Mon Sep 17 00:00:00 2001 From: Kris <2893855659@qq.com> Date: Fri, 2 Jan 2026 23:20:59 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90feat=E3=80=91=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=BF=AB=E7=85=A7=E6=AF=94=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/auth/register/index.vue | 40 ++-- .../setting/center/components/SnapshotTab.vue | 204 +++++++++++++----- 2 files changed, 181 insertions(+), 63 deletions(-) diff --git a/src/views/auth/register/index.vue b/src/views/auth/register/index.vue index 069520b..593c3f1 100644 --- a/src/views/auth/register/index.vue +++ b/src/views/auth/register/index.vue @@ -298,17 +298,25 @@ }); // 处理下拉菜单点击 - const handleLoginUrlPreset = (command) => { - if (command === 'custom') { - // 场景:用户选择了“自定义” - isCustomLoginUrl.value = true; // 解锁输入框 - loginForm.loginUrl = ''; // 可选:清空当前值方便用户输入,或者保留原值 - } else { - // 场景:用户选择了“生产”或“沙盒” - isCustomLoginUrl.value = false; // 锁定输入框 - loginForm.loginUrl = command; // 填入预设 URL +// 处理下拉菜单点击 +const handleLoginUrlPreset = (command) => { + if (command === 'custom') { + isCustomLoginUrl.value = true; + loginForm.value.loginUrl = ''; // 建议加上 .value + } else { + isCustomLoginUrl.value = false; + + // 核心逻辑:如果是沙盒环境且是账密模式,将 login 替换为 test + let targetUrl = command; + if (command === 'https://test.salesforce.com' && loginForm.value.loginType === 'legacy_credential') { + // 确保此处逻辑符合你的后端/API需求 + // 如果后端要求账密模式下沙盒必须用 test.salesforce.com,这里已经正确 + targetUrl = 'https://test.salesforce.com'; } - }; + + loginForm.value.loginUrl = targetUrl; + } +}; // --- 校验规则 --- const rules = computed(() => { @@ -349,10 +357,14 @@ }); // --- 事件处理 --- - const handleLoginTypeChange = () => { - loginForm.value.grantType = 'password'; - resetFormFields(); - }; +const handleLoginTypeChange = () => { + loginForm.value.grantType = 'password'; + resetFormFields(); + + // 默认给一个生产环境地址 + loginForm.value.loginUrl = 'https://login.salesforce.com'; + isCustomLoginUrl.value = false; +}; const handleGrantTypeChange = () => { resetFormFields(); diff --git a/src/views/setting/center/components/SnapshotTab.vue b/src/views/setting/center/components/SnapshotTab.vue index fe2d127..3441966 100644 --- a/src/views/setting/center/components/SnapshotTab.vue +++ b/src/views/setting/center/components/SnapshotTab.vue @@ -7,12 +7,12 @@ - + - + - - + + + + @@ -145,6 +156,7 @@ DocumentCopy, Delete } from '@element-plus/icons-vue'; + import { formatDate } from '@/utils/index'; const props = defineProps({ currentEnvironment: { @@ -156,11 +168,13 @@ const loading = ref(false); const createLoading = ref(false); const compareLoading = ref(false); + const detailLoading = ref(false); const snapshotList = ref([]); const total = ref(0); const environmentList = ref([]); const snapshotConfigList = ref([]); const compareResult = ref([]); + const compareReport = ref(''); const queryParams = ref({ pageNum: 1, @@ -176,13 +190,13 @@ const currentSnapshot = ref({}); const createForm = ref({ - snapshotName: '', + snapshotNumber: '', environmentId: null, - description: '' + snapshotDesc: '' }); const createRules = { - snapshotName: [ + snapshotNumber: [ { required: true, message: '请输入快照名称', trigger: 'blur' } ], environmentId: [ @@ -234,9 +248,9 @@ const resetCreateForm = () => { createForm.value = { - snapshotName: '', + snapshotNumber: '', environmentId: null, - description: '' + snapshotDesc: '' }; createFormRef.value?.clearValidate(); }; @@ -266,23 +280,72 @@ }; const handleViewDetail = async (row) => { + console.log('点击查看详情,row 对象:', row); + console.log('row.id:', row.id); + console.log('row 的所有字段:', Object.keys(row)); + + const snapshotId = row.id || row.snapshotId || row.snapshotNumber; + + if (!row || !snapshotId) { + ElMessage.error('快照ID不存在,无法查看详情'); + console.error('快照数据异常:', row); + return; + } + + detailLoading.value = true; try { - const response = await getSnapshotDetail(row.id); + console.log('获取快照详情,ID:', snapshotId); + const response = await getSnapshotDetail(snapshotId); + console.log('快照详情响应:', response); + if (response.code === 200) { - currentSnapshot.value = response.data.snapshot; - snapshotConfigList.value = response.data.configs || []; - detailDialogVisible.value = true; + const data = response.data; + if (data) { + currentSnapshot.value = data.snapshot || data; + + let configs = []; + if (data.snapshotContent) { + try { + configs = JSON.parse(data.snapshotContent); + } catch (e) { + console.error('解析 snapshotContent 失败:', e); + configs = []; + } + } else if (data.configs) { + configs = data.configs; + } else if (data.snapshotConfigs) { + configs = data.snapshotConfigs; + } + + snapshotConfigList.value = Array.isArray(configs) ? configs : []; + console.log('当前快照:', currentSnapshot.value); + console.log('配置列表:', snapshotConfigList.value); + detailDialogVisible.value = true; + } else { + ElMessage.error('快照详情数据为空'); + } } else { ElMessage.error(response.msg || '获取快照详情失败'); } } catch (error) { - ElMessage.error(error.msg || '获取快照详情失败'); + console.error('获取快照详情失败:', error); + ElMessage.error(error.msg || error.message || '获取快照详情失败'); + } finally { + detailLoading.value = false; } }; const handleRestore = (row) => { + const snapshotId = row.id || row.snapshotId || row.snapshotNumber; + + if (!row || !snapshotId) { + ElMessage.error('快照ID不存在,无法恢复'); + console.error('快照数据异常:', row); + return; + } + ElMessageBox.confirm( - `确定要恢复快照"${row.snapshotName}"吗?此操作将覆盖当前环境配置,请谨慎操作。`, + `确定要恢复快照"${row.snapshotNumber}"吗?此操作将覆盖当前环境配置,请谨慎操作。`, '恢复确认', { confirmButtonText: '确定', @@ -291,7 +354,7 @@ } ).then(async () => { try { - const response = await restoreSnapshot(row.id, {}); + const response = await restoreSnapshot(snapshotId, {}); if (response.code === 200) { ElMessage.success('快照恢复成功'); getList(); @@ -305,7 +368,15 @@ }; const handleCompare = (row) => { - compareForm.value.snapshotId1 = row.id; + const snapshotId = row.id || row.snapshotId || row.snapshotNumber; + + if (!row || !snapshotId) { + ElMessage.error('快照ID不存在,无法对比'); + console.error('快照数据异常:', row); + return; + } + + compareForm.value.snapshotId1 = snapshotId; compareDialogVisible.value = true; }; @@ -321,13 +392,21 @@ } compareLoading.value = true; + compareResult.value = []; + compareReport.value = ''; try { const response = await compareSnapshots( compareForm.value.snapshotId1, compareForm.value.snapshotId2 ); if (response.code === 200) { - compareResult.value = response.data || []; + if (response.data && Array.isArray(response.data)) { + compareResult.value = response.data; + } else if (response.msg) { + compareReport.value = response.msg; + } else { + ElMessage.warning('对比结果格式异常'); + } } else { ElMessage.error(response.msg || '对比快照失败'); } @@ -339,8 +418,16 @@ }; const handleDelete = (row) => { + const snapshotId = row.id || row.snapshotId || row.snapshotNumber; + + if (!row || !snapshotId) { + ElMessage.error('快照ID不存在,无法删除'); + console.error('快照数据异常:', row); + return; + } + ElMessageBox.confirm( - `确定要删除快照"${row.snapshotName}"吗?删除后无法恢复。`, + `确定要删除快照"${row.snapshotNumber}"吗?删除后无法恢复。`, '删除确认', { confirmButtonText: '确定', @@ -349,7 +436,7 @@ } ).then(async () => { try { - const response = await delSnapshot(row.id); + const response = await delSnapshot(snapshotId); if (response.code === 200) { ElMessage.success('删除成功'); getList(); @@ -400,6 +487,25 @@ color: #909399; } +.compare-report { + margin-top: 20px; + padding: 20px; + background-color: #f5f7fa; + border-radius: 4px; + max-height: 500px; + overflow-y: auto; +} + +.compare-report pre { + margin: 0; + white-space: pre-wrap; + word-wrap: break-word; + font-family: 'Courier New', Courier, monospace; + font-size: 14px; + line-height: 1.6; + color: #333; +} + :deep(.el-table) { margin-top: 10px; }