diff --git a/doc/salesforce/auth/DataISfLoginController接口调用说明文档.md b/doc/salesforce/auth/DataISfLoginController接口调用说明文档.md index 736ca6f..ba2ad29 100644 --- a/doc/salesforce/auth/DataISfLoginController接口调用说明文档.md +++ b/doc/salesforce/auth/DataISfLoginController接口调用说明文档.md @@ -47,6 +47,7 @@ OAuth 2.0 登录支持三种授权类型(grant_type),每种类型需要不 **可选参数**: - `securityToken`: Salesforce 安全令牌(如果需要) +- `loginUrl`: 登录系统链接地址(如:`https://login.salesforce.com` 或 `https://test.salesforce.com`) **请求示例**: ```json @@ -55,7 +56,8 @@ OAuth 2.0 登录支持三种授权类型(grant_type),每种类型需要不 "grantType": "password", "username": "user@example.com", "password": "your_password", - "securityToken": "your_security_token" + "securityToken": "your_security_token", + "loginUrl": "https://test.salesforce.com" } ``` @@ -88,13 +90,17 @@ OAuth 2.0 登录支持三种授权类型(grant_type),每种类型需要不 - `clientId`: OAuth 客户端 ID - `clientSecret`: OAuth 客户端密钥 +**可选参数**: +- `loginUrl`: 登录系统链接地址(如:`https://login.salesforce.com` 或 `https://test.salesforce.com`) + **请求示例**: ```json { "loginType": "oauth2", "grantType": "client_credentials", "clientId": "your_client_id", - "clientSecret": "your_client_secret" + "clientSecret": "your_client_secret", + "loginUrl": "https://test.salesforce.com" } ``` @@ -112,6 +118,9 @@ OAuth 2.0 登录支持三种授权类型(grant_type),每种类型需要不 - `code`: OAuth 授权码 - `state`: OAuth state 参数(用于防止 CSRF 攻击) +**可选参数**: +- `loginUrl`: 登录系统链接地址(如:`https://login.salesforce.com` 或 `https://test.salesforce.com`) + **请求示例**: ```json { @@ -120,7 +129,8 @@ OAuth 2.0 登录支持三种授权类型(grant_type),每种类型需要不 "clientId": "your_client_id", "clientSecret": "your_client_secret", "code": "authorization_code_from_salesforce", - "state": "random_state_string" + "state": "random_state_string", + "loginUrl": "https://test.salesforce.com" } ``` @@ -137,6 +147,7 @@ OAuth 2.0 登录支持三种授权类型(grant_type),每种类型需要不 **可选参数**: - `securityToken`: Salesforce 安全令牌(如果需要) +- `loginUrl`: 登录系统链接地址(如:`https://login.salesforce.com` 或 `https://test.salesforce.com`) **请求示例**: ```json @@ -144,7 +155,8 @@ OAuth 2.0 登录支持三种授权类型(grant_type),每种类型需要不 "loginType": "legacy_credential", "username": "user@example.com", "password": "your_password", - "securityToken": "your_security_token" + "securityToken": "your_security_token", + "loginUrl": "https://test.salesforce.com" } ``` @@ -185,11 +197,15 @@ OAuth 2.0 登录支持三种授权类型(grant_type),每种类型需要不 - `loginType`: `"session_id"` - `sessionId`: Salesforce Session ID +**可选参数**: +- `loginUrl`: 登录系统链接地址(如:`https://login.salesforce.com` 或 `https://test.salesforce.com`) + **请求示例**: ```json { "loginType": "session_id", - "sessionId": "00Dxx0000000001!AQoAQH..." + "sessionId": "00Dxx0000000001!AQoAQH...", + "loginUrl": "https://test.salesforce.com" } ``` @@ -348,6 +364,7 @@ curl -X POST http://localhost:8080/salesforce/login/autoLogin | state | String | 条件必填 | OAuth state 参数(`oauth2` + `authorization_code` 登录时必填) | | orgAlias | String | 条件必填 | Salesforce CLI 组织别名(`salesforce_cli` 登录时必填) | | sessionId | String | 条件必填 | Salesforce Session ID(`session_id` 登录时必填) | +| loginUrl | String | 可选 | 登录系统链接地址,用于指定 Salesforce 登录的 API 端点地址(如:`https://login.salesforce.com` 或 `https://test.salesforce.com`) | | privateKeyPath | String | 可选 | 私有密钥路径(预留字段) | | privateKeyPassword | String | 可选 | 私有密钥密码(预留字段) | @@ -379,6 +396,7 @@ curl -X POST http://localhost:8080/salesforce/login/autoLogin | LOGIN_TYPE_EMPTY | 登录类型不能为空 | | MISSING_USERNAME | 用户名不能为空 | | MISSING_PASSWORD | 密码不能为空 | +| INVALID_LOGIN_URL | 登录地址格式错误 | | OAUTH2_UNSUPPORTED_GRANT_TYPE | 不支持的授权类型 | | OAUTH2_CONFIG_ERROR | OAuth 配置错误 | | OAUTH2_MISSING_CLIENT_ID | OAuth 客户端 ID 未配置 | @@ -399,6 +417,12 @@ curl -X POST http://localhost:8080/salesforce/login/autoLogin 5. **会话管理**: 登出时会清理缓存和更新会话状态 6. **安全令牌**: 在生产环境中,建议使用安全令牌增强安全性 7. **环境配置**: 确保 Salesforce 环境配置正确(生产环境、沙盒环境或自定义环境) +8. **自定义登录地址**: `loginUrl` 参数为可选参数,用于指定 Salesforce 登录的 API 端点地址 + - 支持的登录地址示例:`https://login.salesforce.com`(生产环境)、`https://test.salesforce.com`(沙盒环境) + - 如果不提供 `loginUrl`,系统将使用默认配置的登录地址 + - `loginUrl` 参数支持 `oauth2`、`legacy_credential` 和 `session_id` 登录类型 + - `salesforce_cli` 登录类型不支持 `loginUrl` 参数,因为 CLI 工具内部管理登录状态 + - 系统会自动验证 `loginUrl` 的格式,如果格式错误将返回错误信息 --- @@ -468,6 +492,7 @@ curl -X POST http://localhost:8080/salesforce/login/autoLogin |------|------|------| | 1.0 | 2025-12-14 | 初始版本 | | 1.1 | 2025-12-25 | 优化 logout、getCurrentLoginInfo、autoLogin 方法,无需传参 | +| 1.2 | 2025-12-26 | 新增 loginUrl 参数,支持自定义 Salesforce 登录地址 | --- diff --git a/src/views/auth/register/index.vue b/src/views/auth/register/index.vue index 99cb76d..069520b 100644 --- a/src/views/auth/register/index.vue +++ b/src/views/auth/register/index.vue @@ -28,6 +28,33 @@ + + + + + +
留空则使用系统默认配置
+
+ @@ -64,6 +91,7 @@ + 发起登录请求 @@ -79,14 +107,14 @@ - + 刷新信息 - + 登出 @@ -194,7 +222,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'; import { RefreshRight, User, SwitchButton, DocumentCopy, Switch, - Connection, Key, Lock, Ticket, Hide, Monitor, TopRight + Connection, Key, Lock, Ticket, Hide, Monitor, TopRight, ArrowDown, Link } from '@element-plus/icons-vue'; const { proxy } = getCurrentInstance(); @@ -205,6 +233,8 @@ const currentLoading = ref(false); const logoutLoading = ref(false); const loginResult = ref(null); + // 定义一个状态变量,默认设为 false (即默认只读/锁定,或者根据初始值判断) + const isCustomLoginUrl = ref(false); const loginForm = ref({ loginType: 'oauth2', @@ -217,7 +247,8 @@ code: '', state: '', orgAlias: '', - sessionId: '' + sessionId: '', + loginUrl: '' }); // --- 字段显示逻辑 Computed --- @@ -262,6 +293,23 @@ return loginForm.value.loginType === 'session_id'; }); + const showLoginUrl = computed(() => { + return ['oauth2', 'legacy_credential', 'session_id'].includes(loginForm.value.loginType); + }); + + // 处理下拉菜单点击 + const handleLoginUrlPreset = (command) => { + if (command === 'custom') { + // 场景:用户选择了“自定义” + isCustomLoginUrl.value = true; // 解锁输入框 + loginForm.loginUrl = ''; // 可选:清空当前值方便用户输入,或者保留原值 + } else { + // 场景:用户选择了“生产”或“沙盒” + isCustomLoginUrl.value = false; // 锁定输入框 + loginForm.loginUrl = command; // 填入预设 URL + } + }; + // --- 校验规则 --- const rules = computed(() => { const baseRules = { @@ -310,6 +358,7 @@ resetFormFields(); }; + const resetFormFields = () => { loginForm.value.username = ''; loginForm.value.password = ''; @@ -320,6 +369,7 @@ loginForm.value.state = ''; loginForm.value.orgAlias = ''; loginForm.value.sessionId = ''; + loginForm.value.loginUrl = ''; }; const handleLogin = async () => { @@ -564,6 +614,13 @@ margin-top: 10px; } +.form-tip { + font-size: 12px; + color: #909399; + margin-top: 4px; + line-height: 1.4; +} + /* 响应式调整 */ @media screen and (max-width: 768px) { .main-row {