chore(codex): 调整 Codex 预设模板与占位符(auth.json/config.toml 与表单占位)

This commit is contained in:
Jason
2025-08-30 23:02:49 +08:00
parent 7b5d5c6ce1
commit 0cb89c8f67
2 changed files with 28 additions and 19 deletions

View File

@@ -48,7 +48,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
const [codexConfig, setCodexConfig] = useState("");
const [codexApiKey, setCodexApiKey] = useState("");
const [selectedCodexPreset, setSelectedCodexPreset] = useState<number | null>(
null,
null
);
// 初始化 Codex 配置
@@ -134,7 +134,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
};
const handleChange = (
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
) => {
const { name, value } = e.target;
@@ -171,7 +171,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
// 更新JSON配置
const updatedConfig = updateCoAuthoredSetting(
formData.settingsConfig,
checked,
checked
);
setFormData({
...formData,
@@ -202,7 +202,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
// Codex: 应用预设
const applyCodexPreset = (
preset: (typeof codexProviderPresets)[0],
index: number,
index: number
) => {
const authString = JSON.stringify(preset.auth || {}, null, 2);
setCodexAuth(authString);
@@ -227,7 +227,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
const configString = setApiKeyInConfig(
formData.settingsConfig,
key.trim(),
{ createIfMissing: selectedPreset !== null },
{ createIfMissing: selectedPreset !== null }
);
// 更新表单配置
@@ -281,7 +281,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
useEffect(() => {
if (initialData) {
const parsedKey = getApiKeyFromConfig(
JSON.stringify(initialData.settingsConfig),
JSON.stringify(initialData.settingsConfig)
);
if (parsedKey) setApiKey(parsedKey);
}
@@ -427,7 +427,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
placeholder={
isCodexOfficialPreset
? "官方无需填写 API Key直接保存即可"
: "只需要填这里,方 auth.json 会自动填充"
: "只需要填这里,方 auth.json 会自动填充"
}
disabled={isCodexOfficialPreset}
autoComplete="off"
@@ -471,14 +471,15 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
setCodexAuth(value);
try {
const auth = JSON.parse(value || "{}");
const key = typeof auth.api_key === "string" ? auth.api_key : "";
const key =
typeof auth.api_key === "string" ? auth.api_key : "";
setCodexApiKey(key);
} catch {
// ignore
}
}}
placeholder={`{
"api_key": "your-codex-api-key"
"OPENAI_API_KEY": "sk-your-api-key-here"
}`}
rows={6}
style={{ fontFamily: "monospace", fontSize: "14px" }}
@@ -493,9 +494,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
id="codexConfig"
value={codexConfig}
onChange={(e) => setCodexConfig(e.target.value)}
placeholder={`# Codex configuration
model = "codex-model"
temperature = 0.7`}
placeholder={``}
rows={8}
style={{ fontFamily: "monospace", fontSize: "14px" }}
required