diff --git a/static/app/app.js b/static/app/app.js index 5f39562..967d22f 100644 --- a/static/app/app.js +++ b/static/app/app.js @@ -40,7 +40,8 @@ import { loadProviders, openProviderManager, showAuthModal, - executeGenerateAuthUrl + executeGenerateAuthUrl, + handleGenerateAuthUrl } from './provider-manager.js'; import { @@ -226,6 +227,7 @@ window.refreshProviderConfig = refreshProviderConfig; window.fileUploadHandler = fileUploadHandler; window.showAuthModal = showAuthModal; window.executeGenerateAuthUrl = executeGenerateAuthUrl; +window.handleGenerateAuthUrl = handleGenerateAuthUrl; // 配置管理相关全局函数 window.viewConfig = viewConfig; diff --git a/static/app/modal.js b/static/app/modal.js index c20f83d..bc839cc 100644 --- a/static/app/modal.js +++ b/static/app/modal.js @@ -1039,6 +1039,34 @@ function showAddProviderForm(providerType) { return; } + // Codex OAuth 只支持授权添加,不支持手动添加 + if (providerType === 'openai-codex-oauth') { + const form = document.createElement('div'); + form.className = 'add-provider-form'; + form.innerHTML = ` +

添加新提供商配置

+
+
+ + Codex 仅支持 OAuth 授权添加 +
+

+ OpenAI Codex 需要通过 OAuth 授权获取访问令牌,无法手动填写凭据。请点击下方按钮进行授权。 +

+ + +
+ `; + + const providerList = modal.querySelector('.provider-list'); + providerList.parentNode.insertBefore(form, providerList); + return; + } + const form = document.createElement('div'); form.className = 'add-provider-form'; form.innerHTML = ` diff --git a/static/app/provider-manager.js b/static/app/provider-manager.js index 712223d..1d426d8 100644 --- a/static/app/provider-manager.js +++ b/static/app/provider-manager.js @@ -2198,6 +2198,7 @@ export { openProviderManager, showAuthModal, executeGenerateAuthUrl, + handleGenerateAuthUrl, checkUpdate, performUpdate }; \ No newline at end of file diff --git a/static/app/utils.js b/static/app/utils.js index a75f019..6236e2f 100644 --- a/static/app/utils.js +++ b/static/app/utils.js @@ -254,6 +254,12 @@ function getProviderTypeFields(providerType) { } ], 'openai-codex-oauth': [ + { + id: 'CODEX_OAUTH_CREDS_FILE_PATH', + label: isEn ? 'OAuth Credentials File Path' : 'OAuth凭据文件路径', + type: 'text', + placeholder: isEn ? 'e.g.: configs/codex/oauth_creds.json' : '例如: configs/codex/oauth_creds.json' + }, { id: 'CODEX_EMAIL', label: isEn ? 'Email (Optional)' : '邮箱 (选填)', @@ -264,7 +270,7 @@ function getProviderTypeFields(providerType) { id: 'CODEX_BASE_URL', label: `Codex Base URL ${t('config.optional')}`, type: 'text', - placeholder: 'https://chatgpt.com/backend-api/codex' + placeholder: 'https://api.openai.com/v1/codex' } ] };