- Remove CodexQuickWizardModal component (~300 lines) - Add "Custom (Blank Template)" preset with annotated TOML template - Unify configuration experience across Claude/Codex/Gemini - Remove wizard-related i18n keys, keep apiUrlLabel for CodexFormFields - Simplify component integration by removing wizard state management This change reduces code complexity by ~250 lines while providing better user education through commented configuration templates in Chinese. Users can now: 1. Select "Custom (Blank Template)" preset 2. See annotated TOML template with inline documentation 3. Follow step-by-step comments to configure custom providers BREAKING CHANGE: Configuration wizard UI removed, replaced with template-based approach
88 lines
2.2 KiB
TypeScript
88 lines
2.2 KiB
TypeScript
import React, { useState, useEffect } from "react";
|
|
import { CodexAuthSection, CodexConfigSection } from "./CodexConfigSections";
|
|
import { CodexCommonConfigModal } from "./CodexCommonConfigModal";
|
|
|
|
interface CodexConfigEditorProps {
|
|
authValue: string;
|
|
|
|
configValue: string;
|
|
|
|
onAuthChange: (value: string) => void;
|
|
|
|
onConfigChange: (value: string) => void;
|
|
|
|
onAuthBlur?: () => void;
|
|
|
|
useCommonConfig: boolean;
|
|
|
|
onCommonConfigToggle: (checked: boolean) => void;
|
|
|
|
commonConfigSnippet: string;
|
|
|
|
onCommonConfigSnippetChange: (value: string) => void;
|
|
|
|
commonConfigError: string;
|
|
|
|
authError: string;
|
|
|
|
configError: string; // config.toml 错误提示
|
|
}
|
|
|
|
const CodexConfigEditor: React.FC<CodexConfigEditorProps> = ({
|
|
authValue,
|
|
configValue,
|
|
onAuthChange,
|
|
onConfigChange,
|
|
onAuthBlur,
|
|
useCommonConfig,
|
|
onCommonConfigToggle,
|
|
commonConfigSnippet,
|
|
onCommonConfigSnippetChange,
|
|
commonConfigError,
|
|
authError,
|
|
configError,
|
|
}) => {
|
|
const [isCommonConfigModalOpen, setIsCommonConfigModalOpen] = useState(false);
|
|
|
|
// Auto-open common config modal if there's an error
|
|
useEffect(() => {
|
|
if (commonConfigError && !isCommonConfigModalOpen) {
|
|
setIsCommonConfigModalOpen(true);
|
|
}
|
|
}, [commonConfigError, isCommonConfigModalOpen]);
|
|
|
|
return (
|
|
<div className="space-y-6">
|
|
{/* Auth JSON Section */}
|
|
<CodexAuthSection
|
|
value={authValue}
|
|
onChange={onAuthChange}
|
|
onBlur={onAuthBlur}
|
|
error={authError}
|
|
/>
|
|
|
|
{/* Config TOML Section */}
|
|
<CodexConfigSection
|
|
value={configValue}
|
|
onChange={onConfigChange}
|
|
useCommonConfig={useCommonConfig}
|
|
onCommonConfigToggle={onCommonConfigToggle}
|
|
onEditCommonConfig={() => setIsCommonConfigModalOpen(true)}
|
|
commonConfigError={commonConfigError}
|
|
configError={configError}
|
|
/>
|
|
|
|
{/* Common Config Modal */}
|
|
<CodexCommonConfigModal
|
|
isOpen={isCommonConfigModalOpen}
|
|
onClose={() => setIsCommonConfigModalOpen(false)}
|
|
value={commonConfigSnippet}
|
|
onChange={onCommonConfigSnippetChange}
|
|
error={commonConfigError}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default CodexConfigEditor;
|