From a5a5207f74eaa80fb1919e39fba7b169021c9d55 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 9 Apr 2026 21:13:32 +0800 Subject: [PATCH] style: fix prettier formatting in ProviderCard and ProviderForm --- src/components/providers/ProviderCard.tsx | 6 +- .../providers/forms/ProviderForm.tsx | 948 +++++++++--------- 2 files changed, 484 insertions(+), 470 deletions(-) diff --git a/src/components/providers/ProviderCard.tsx b/src/components/providers/ProviderCard.tsx index 3f999937d..e85973e5b 100644 --- a/src/components/providers/ProviderCard.tsx +++ b/src/components/providers/ProviderCard.tsx @@ -369,7 +369,11 @@ export function ProviderCard({ isCurrent={isCurrent} /> ) : isOfficial ? ( - + ) : hasMultiplePlans ? (
diff --git a/src/components/providers/forms/ProviderForm.tsx b/src/components/providers/forms/ProviderForm.tsx index a49eb1092..35de812d7 100644 --- a/src/components/providers/forms/ProviderForm.tsx +++ b/src/components/providers/forms/ProviderForm.tsx @@ -1362,416 +1362,422 @@ export function ProviderForm({ return ( <>
- - {!initialData && ( - - )} - - - - - opencodeForm.setOpencodeProviderKey( - e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, ""), - ) - } - placeholder={t("opencode.providerKeyPlaceholder")} - disabled={ - isProviderKeyLocked || isProviderKeyLockStateLoading - } - className={ - (additiveExistingProviderKeys.includes( - opencodeForm.opencodeProviderKey, - ) && - !isProviderKeyLocked) || - (opencodeForm.opencodeProviderKey.trim() !== "" && - !/^[a-z0-9]+(-[a-z0-9]+)*$/.test( - opencodeForm.opencodeProviderKey, - )) - ? "border-destructive" - : "" - } - /> - {additiveExistingProviderKeys.includes( - opencodeForm.opencodeProviderKey, - ) && - !isProviderKeyLocked && ( -

- {t("opencode.providerKeyDuplicate")} -

- )} - {opencodeForm.opencodeProviderKey.trim() !== "" && - !/^[a-z0-9]+(-[a-z0-9]+)*$/.test( - opencodeForm.opencodeProviderKey, - ) && ( -

- {t("opencode.providerKeyInvalid")} -

- )} - {!( - additiveExistingProviderKeys.includes( - opencodeForm.opencodeProviderKey, - ) && !isProviderKeyLocked - ) && - (opencodeForm.opencodeProviderKey.trim() === "" || - /^[a-z0-9]+(-[a-z0-9]+)*$/.test( - opencodeForm.opencodeProviderKey, - )) && ( -

- {isProviderKeyLocked - ? t("opencode.providerKeyLockedHint", { - defaultValue: - "该供应商已添加到应用配置中,供应商标识不可修改", - }) - : t("opencode.providerKeyHint")} -

- )} -
- ) : appId === "openclaw" ? ( -
- - - openclawForm.setOpenclawProviderKey( - e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, ""), - ) - } - placeholder={t("openclaw.providerKeyPlaceholder")} - disabled={ - isProviderKeyLocked || isProviderKeyLockStateLoading - } - className={ - (additiveExistingProviderKeys.includes( - openclawForm.openclawProviderKey, - ) && - !isProviderKeyLocked) || - (openclawForm.openclawProviderKey.trim() !== "" && - !/^[a-z0-9]+(-[a-z0-9]+)*$/.test( - openclawForm.openclawProviderKey, - )) - ? "border-destructive" - : "" - } - /> - {additiveExistingProviderKeys.includes( - openclawForm.openclawProviderKey, - ) && - !isProviderKeyLocked && ( -

- {t("openclaw.providerKeyDuplicate")} -

- )} - {openclawForm.openclawProviderKey.trim() !== "" && - !/^[a-z0-9]+(-[a-z0-9]+)*$/.test( - openclawForm.openclawProviderKey, - ) && ( -

- {t("openclaw.providerKeyInvalid")} -

- )} - {!( - additiveExistingProviderKeys.includes( - openclawForm.openclawProviderKey, - ) && !isProviderKeyLocked - ) && - (openclawForm.openclawProviderKey.trim() === "" || - /^[a-z0-9]+(-[a-z0-9]+)*$/.test( - openclawForm.openclawProviderKey, - )) && ( -

- {isProviderKeyLocked - ? t("openclaw.providerKeyLockedHint", { - defaultValue: - "该供应商已添加到应用配置中,供应商标识不可修改", - }) - : t("openclaw.providerKeyHint")} -

- )} -
- ) : undefined - } - /> - - {appId === "claude" && ( - - )} - - {appId === "codex" && ( - - )} - - {appId === "gemini" && ( - - )} - - {appId === "opencode" && !isAnyOmoCategory && ( - - )} - - {appId === "opencode" && - (category === "omo" || category === "omo-slim") && ( - + {!initialData && ( + )} - {/* OpenClaw 专属字段 */} - {appId === "openclaw" && ( - + + + opencodeForm.setOpencodeProviderKey( + e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, ""), + ) + } + placeholder={t("opencode.providerKeyPlaceholder")} + disabled={ + isProviderKeyLocked || isProviderKeyLockStateLoading + } + className={ + (additiveExistingProviderKeys.includes( + opencodeForm.opencodeProviderKey, + ) && + !isProviderKeyLocked) || + (opencodeForm.opencodeProviderKey.trim() !== "" && + !/^[a-z0-9]+(-[a-z0-9]+)*$/.test( + opencodeForm.opencodeProviderKey, + )) + ? "border-destructive" + : "" + } + /> + {additiveExistingProviderKeys.includes( + opencodeForm.opencodeProviderKey, + ) && + !isProviderKeyLocked && ( +

+ {t("opencode.providerKeyDuplicate")} +

+ )} + {opencodeForm.opencodeProviderKey.trim() !== "" && + !/^[a-z0-9]+(-[a-z0-9]+)*$/.test( + opencodeForm.opencodeProviderKey, + ) && ( +

+ {t("opencode.providerKeyInvalid")} +

+ )} + {!( + additiveExistingProviderKeys.includes( + opencodeForm.opencodeProviderKey, + ) && !isProviderKeyLocked + ) && + (opencodeForm.opencodeProviderKey.trim() === "" || + /^[a-z0-9]+(-[a-z0-9]+)*$/.test( + opencodeForm.opencodeProviderKey, + )) && ( +

+ {isProviderKeyLocked + ? t("opencode.providerKeyLockedHint", { + defaultValue: + "该供应商已添加到应用配置中,供应商标识不可修改", + }) + : t("opencode.providerKeyHint")} +

+ )} + + ) : appId === "openclaw" ? ( +
+ + + openclawForm.setOpenclawProviderKey( + e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, ""), + ) + } + placeholder={t("openclaw.providerKeyPlaceholder")} + disabled={ + isProviderKeyLocked || isProviderKeyLockStateLoading + } + className={ + (additiveExistingProviderKeys.includes( + openclawForm.openclawProviderKey, + ) && + !isProviderKeyLocked) || + (openclawForm.openclawProviderKey.trim() !== "" && + !/^[a-z0-9]+(-[a-z0-9]+)*$/.test( + openclawForm.openclawProviderKey, + )) + ? "border-destructive" + : "" + } + /> + {additiveExistingProviderKeys.includes( + openclawForm.openclawProviderKey, + ) && + !isProviderKeyLocked && ( +

+ {t("openclaw.providerKeyDuplicate")} +

+ )} + {openclawForm.openclawProviderKey.trim() !== "" && + !/^[a-z0-9]+(-[a-z0-9]+)*$/.test( + openclawForm.openclawProviderKey, + ) && ( +

+ {t("openclaw.providerKeyInvalid")} +

+ )} + {!( + additiveExistingProviderKeys.includes( + openclawForm.openclawProviderKey, + ) && !isProviderKeyLocked + ) && + (openclawForm.openclawProviderKey.trim() === "" || + /^[a-z0-9]+(-[a-z0-9]+)*$/.test( + openclawForm.openclawProviderKey, + )) && ( +

+ {isProviderKeyLocked + ? t("openclaw.providerKeyLockedHint", { + defaultValue: + "该供应商已添加到应用配置中,供应商标识不可修改", + }) + : t("openclaw.providerKeyHint")} +

+ )} +
+ ) : undefined + } /> - )} - {/* 配置编辑器:Codex、Claude、Gemini 分别使用不同的编辑器 */} - {appId === "codex" ? ( - <> - - {settingsConfigErrorField} - - ) : appId === "gemini" ? ( - <> - - {settingsConfigErrorField} - - ) : appId === "opencode" && - (category === "omo" || category === "omo-slim") ? ( -
- - {}} - rows={14} - showValidation={false} - language="json" + )} + + {appId === "codex" && ( + -
- ) : appId === "opencode" && - category !== "omo" && - category !== "omo-slim" ? ( - <> + )} + + {appId === "gemini" && ( + + )} + + {appId === "opencode" && !isAnyOmoCategory && ( + + )} + + {appId === "opencode" && + (category === "omo" || category === "omo-slim") && ( + + )} + + {/* OpenClaw 专属字段 */} + {appId === "openclaw" && ( + + )} + + {/* 配置编辑器:Codex、Claude、Gemini 分别使用不同的编辑器 */} + {appId === "codex" ? ( + <> + + {settingsConfigErrorField} + + ) : appId === "gemini" ? ( + <> + + {settingsConfigErrorField} + + ) : appId === "opencode" && + (category === "omo" || category === "omo-slim") ? (
- + form.setValue("settingsConfig", config)} - placeholder={`{ + value={omoDraft.mergedOmoJsonPreview} + onChange={() => {}} + rows={14} + showValidation={false} + language="json" + /> +
+ ) : appId === "opencode" && + category !== "omo" && + category !== "omo-slim" ? ( + <> +
+ + form.setValue("settingsConfig", config)} + placeholder={`{ "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "https://your-api-endpoint.com", @@ -1779,82 +1785,86 @@ export function ProviderForm({ }, "models": {} }`} - rows={14} - showValidation={true} - language="json" - /> -
- {settingsConfigErrorField} - - ) : appId === "openclaw" ? ( - <> -
- - form.setValue("settingsConfig", config)} - placeholder={`{ + rows={14} + showValidation={true} + language="json" + /> +
+ {settingsConfigErrorField} + + ) : appId === "openclaw" ? ( + <> +
+ + form.setValue("settingsConfig", config)} + placeholder={`{ "baseUrl": "https://api.example.com/v1", "apiKey": "your-api-key-here", "api": "openai-completions", "models": [] }`} - rows={14} - showValidation={true} - language="json" + rows={14} + showValidation={true} + language="json" + /> +
+ ( + + + + )} /> + + ) : ( + <> + form.setValue("settingsConfig", value)} + useCommonConfig={useCommonConfig} + onCommonConfigToggle={handleCommonConfigToggle} + commonConfigSnippet={commonConfigSnippet} + onCommonConfigSnippetChange={handleCommonConfigSnippetChange} + commonConfigError={commonConfigError} + onEditClick={() => setIsCommonConfigModalOpen(true)} + isModalOpen={isCommonConfigModalOpen} + onModalClose={() => setIsCommonConfigModalOpen(false)} + onExtract={handleClaudeExtract} + isExtracting={isClaudeExtracting} + /> + {settingsConfigErrorField} + + )} + + {!isAnyOmoCategory && + appId !== "opencode" && + appId !== "openclaw" && ( + + )} + + {showButtons && ( +
+ +
- ( - - - - )} - /> - - ) : ( - <> - form.setValue("settingsConfig", value)} - useCommonConfig={useCommonConfig} - onCommonConfigToggle={handleCommonConfigToggle} - commonConfigSnippet={commonConfigSnippet} - onCommonConfigSnippetChange={handleCommonConfigSnippetChange} - commonConfigError={commonConfigError} - onEditClick={() => setIsCommonConfigModalOpen(true)} - isModalOpen={isCommonConfigModalOpen} - onModalClose={() => setIsCommonConfigModalOpen(false)} - onExtract={handleClaudeExtract} - isExtracting={isClaudeExtracting} - /> - {settingsConfigErrorField} - - )} - - {!isAnyOmoCategory && appId !== "opencode" && appId !== "openclaw" && ( - - )} - - {showButtons && ( -
- - -
- )} + )}