style: format code with consistent spacing and line breaks

This commit is contained in:
Jason
2025-10-30 15:31:08 +08:00
parent 8e4a0a1bbb
commit 55223bdd46
11 changed files with 37 additions and 34 deletions

View File

@@ -11,7 +11,11 @@ interface UsageFooterProps {
usageEnabled: boolean; // 是否启用了用量查询
}
const UsageFooter: React.FC<UsageFooterProps> = ({ providerId, appId, usageEnabled }) => {
const UsageFooter: React.FC<UsageFooterProps> = ({
providerId,
appId,
usageEnabled,
}) => {
const { t } = useTranslation();
const {
data: usage,

View File

@@ -82,7 +82,13 @@ const PRESET_TEMPLATES: Record<string, string> = {
})`,
};
const UsageScriptModal: React.FC<UsageScriptModalProps> = ({ provider, appId, isOpen, onClose, onSave }) => {
const UsageScriptModal: React.FC<UsageScriptModalProps> = ({
provider,
appId,
isOpen,
onClose,
onSave,
}) => {
const { t } = useTranslation();
const [script, setScript] = useState<UsageScript>(() => {
return (

View File

@@ -110,7 +110,8 @@ const McpFormModal: React.FC<McpFormModalProps> = ({
// 判断是否使用 TOML 格式
const useToml = appId === "codex";
const syncTargetLabel = appId === "claude" ? t("apps.codex") : t("apps.claude");
const syncTargetLabel =
appId === "claude" ? t("apps.codex") : t("apps.claude");
const otherAppType: AppId = appId === "claude" ? "codex" : "claude";
const syncCheckboxId = useMemo(() => `sync-other-side-${appId}`, [appId]);

View File

@@ -38,7 +38,8 @@ const McpPanel: React.FC<McpPanelProps> = ({ open, onOpenChange, appId }) => {
} | null>(null);
// Use MCP actions hook
const { servers, loading, reload, toggleEnabled, saveServer, deleteServer } = useMcpActions(appId);
const { servers, loading, reload, toggleEnabled, saveServer, deleteServer } =
useMcpActions(appId);
useEffect(() => {
const setup = async () => {
@@ -112,7 +113,8 @@ const McpPanel: React.FC<McpPanelProps> = ({ open, onOpenChange, appId }) => {
[serverEntries],
);
const panelTitle = appId === "claude" ? t("mcp.claudeTitle") : t("mcp.codexTitle");
const panelTitle =
appId === "claude" ? t("mcp.claudeTitle") : t("mcp.codexTitle");
return (
<>

View File

@@ -85,9 +85,7 @@ export function AddProviderDialog({
}
} else if (appId === "codex") {
const presets = codexProviderPresets;
const presetIndex = parseInt(
values.presetId.replace("codex-", ""),
);
const presetIndex = parseInt(values.presetId.replace("codex-", ""));
if (
!isNaN(presetIndex) &&
presetIndex >= 0 &&
@@ -109,8 +107,9 @@ export function AddProviderDialog({
} else if (appId === "codex") {
const config = parsedConfig.config as string | undefined;
if (config) {
const baseUrlMatch =
config.match(/base_url\s*=\s*["']([^"']+)["']/);
const baseUrlMatch = config.match(
/base_url\s*=\s*["']([^"']+)["']/,
);
if (baseUrlMatch?.[1]) {
addUrl(baseUrlMatch[1]);
}

View File

@@ -179,7 +179,11 @@ export function ProviderCard({
/>
</div>
<UsageFooter providerId={provider.id} appId={appId} usageEnabled={usageEnabled} />
<UsageFooter
providerId={provider.id}
appId={appId}
usageEnabled={usageEnabled}
/>
</div>
);
}

View File

@@ -313,15 +313,7 @@ const EndpointSpeedTest: React.FC<EndpointSpeedTestProps> = ({
setAddError(message || t("endpointTest.saveFailed"));
console.error(t("endpointTest.addEndpointFailed"), error);
}
}, [
customUrl,
entries,
normalizedSelected,
onChange,
appId,
providerId,
t,
]);
}, [customUrl, entries, normalizedSelected, onChange, appId, providerId, t]);
const handleRemoveEndpoint = useCallback(
async (entry: EndpointEntry) => {

View File

@@ -53,7 +53,12 @@ export function useApiKeyLink({
}, [selectedPresetId, presetEntries, formWebsiteUrl]);
return {
shouldShowApiKeyLink: appId === "claude" ? shouldShowApiKeyLink : appId === "codex" ? shouldShowApiKeyLink : false,
shouldShowApiKeyLink:
appId === "claude"
? shouldShowApiKeyLink
: appId === "codex"
? shouldShowApiKeyLink
: false,
websiteUrl: getWebsiteUrl,
};
}

View File

@@ -13,10 +13,7 @@ import { useTranslation } from "react-i18next";
import type { Provider } from "@/types";
import { providersApi, type AppId } from "@/lib/api";
export function useDragSort(
providers: Record<string, Provider>,
appId: AppId,
) {
export function useDragSort(providers: Record<string, Provider>, appId: AppId) {
const queryClient = useQueryClient();
const { t, i18n } = useTranslation();

View File

@@ -75,11 +75,7 @@ export const mcpApi = {
return await invoke("delete_mcp_server_in_config", payload);
},
async setEnabled(
app: AppId,
id: string,
enabled: boolean,
): Promise<boolean> {
async setEnabled(app: AppId, id: string, enabled: boolean): Promise<boolean> {
return await invoke("set_mcp_enabled", { app, id, enabled });
},

View File

@@ -8,10 +8,7 @@ import type { CustomEndpoint, ProviderMeta } from "@/types";
*/
export function mergeProviderMeta(
initialMeta: ProviderMeta | undefined,
customEndpoints:
| Record<string, CustomEndpoint>
| null
| undefined,
customEndpoints: Record<string, CustomEndpoint> | null | undefined,
): ProviderMeta | undefined {
const hasCustomEndpoints =
!!customEndpoints && Object.keys(customEndpoints).length > 0;