style: format code with consistent spacing and line breaks
This commit is contained in:
@@ -11,7 +11,11 @@ interface UsageFooterProps {
|
|||||||
usageEnabled: boolean; // 是否启用了用量查询
|
usageEnabled: boolean; // 是否启用了用量查询
|
||||||
}
|
}
|
||||||
|
|
||||||
const UsageFooter: React.FC<UsageFooterProps> = ({ providerId, appId, usageEnabled }) => {
|
const UsageFooter: React.FC<UsageFooterProps> = ({
|
||||||
|
providerId,
|
||||||
|
appId,
|
||||||
|
usageEnabled,
|
||||||
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const {
|
const {
|
||||||
data: usage,
|
data: usage,
|
||||||
|
|||||||
@@ -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 { t } = useTranslation();
|
||||||
const [script, setScript] = useState<UsageScript>(() => {
|
const [script, setScript] = useState<UsageScript>(() => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ const McpFormModal: React.FC<McpFormModalProps> = ({
|
|||||||
|
|
||||||
// 判断是否使用 TOML 格式
|
// 判断是否使用 TOML 格式
|
||||||
const useToml = appId === "codex";
|
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 otherAppType: AppId = appId === "claude" ? "codex" : "claude";
|
||||||
const syncCheckboxId = useMemo(() => `sync-other-side-${appId}`, [appId]);
|
const syncCheckboxId = useMemo(() => `sync-other-side-${appId}`, [appId]);
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ const McpPanel: React.FC<McpPanelProps> = ({ open, onOpenChange, appId }) => {
|
|||||||
} | null>(null);
|
} | null>(null);
|
||||||
|
|
||||||
// Use MCP actions hook
|
// Use MCP actions hook
|
||||||
const { servers, loading, reload, toggleEnabled, saveServer, deleteServer } = useMcpActions(appId);
|
const { servers, loading, reload, toggleEnabled, saveServer, deleteServer } =
|
||||||
|
useMcpActions(appId);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const setup = async () => {
|
const setup = async () => {
|
||||||
@@ -112,7 +113,8 @@ const McpPanel: React.FC<McpPanelProps> = ({ open, onOpenChange, appId }) => {
|
|||||||
[serverEntries],
|
[serverEntries],
|
||||||
);
|
);
|
||||||
|
|
||||||
const panelTitle = appId === "claude" ? t("mcp.claudeTitle") : t("mcp.codexTitle");
|
const panelTitle =
|
||||||
|
appId === "claude" ? t("mcp.claudeTitle") : t("mcp.codexTitle");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -85,9 +85,7 @@ export function AddProviderDialog({
|
|||||||
}
|
}
|
||||||
} else if (appId === "codex") {
|
} else if (appId === "codex") {
|
||||||
const presets = codexProviderPresets;
|
const presets = codexProviderPresets;
|
||||||
const presetIndex = parseInt(
|
const presetIndex = parseInt(values.presetId.replace("codex-", ""));
|
||||||
values.presetId.replace("codex-", ""),
|
|
||||||
);
|
|
||||||
if (
|
if (
|
||||||
!isNaN(presetIndex) &&
|
!isNaN(presetIndex) &&
|
||||||
presetIndex >= 0 &&
|
presetIndex >= 0 &&
|
||||||
@@ -109,8 +107,9 @@ export function AddProviderDialog({
|
|||||||
} else if (appId === "codex") {
|
} else if (appId === "codex") {
|
||||||
const config = parsedConfig.config as string | undefined;
|
const config = parsedConfig.config as string | undefined;
|
||||||
if (config) {
|
if (config) {
|
||||||
const baseUrlMatch =
|
const baseUrlMatch = config.match(
|
||||||
config.match(/base_url\s*=\s*["']([^"']+)["']/);
|
/base_url\s*=\s*["']([^"']+)["']/,
|
||||||
|
);
|
||||||
if (baseUrlMatch?.[1]) {
|
if (baseUrlMatch?.[1]) {
|
||||||
addUrl(baseUrlMatch[1]);
|
addUrl(baseUrlMatch[1]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,7 +179,11 @@ export function ProviderCard({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UsageFooter providerId={provider.id} appId={appId} usageEnabled={usageEnabled} />
|
<UsageFooter
|
||||||
|
providerId={provider.id}
|
||||||
|
appId={appId}
|
||||||
|
usageEnabled={usageEnabled}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -313,15 +313,7 @@ const EndpointSpeedTest: React.FC<EndpointSpeedTestProps> = ({
|
|||||||
setAddError(message || t("endpointTest.saveFailed"));
|
setAddError(message || t("endpointTest.saveFailed"));
|
||||||
console.error(t("endpointTest.addEndpointFailed"), error);
|
console.error(t("endpointTest.addEndpointFailed"), error);
|
||||||
}
|
}
|
||||||
}, [
|
}, [customUrl, entries, normalizedSelected, onChange, appId, providerId, t]);
|
||||||
customUrl,
|
|
||||||
entries,
|
|
||||||
normalizedSelected,
|
|
||||||
onChange,
|
|
||||||
appId,
|
|
||||||
providerId,
|
|
||||||
t,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const handleRemoveEndpoint = useCallback(
|
const handleRemoveEndpoint = useCallback(
|
||||||
async (entry: EndpointEntry) => {
|
async (entry: EndpointEntry) => {
|
||||||
|
|||||||
@@ -53,7 +53,12 @@ export function useApiKeyLink({
|
|||||||
}, [selectedPresetId, presetEntries, formWebsiteUrl]);
|
}, [selectedPresetId, presetEntries, formWebsiteUrl]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
shouldShowApiKeyLink: appId === "claude" ? shouldShowApiKeyLink : appId === "codex" ? shouldShowApiKeyLink : false,
|
shouldShowApiKeyLink:
|
||||||
|
appId === "claude"
|
||||||
|
? shouldShowApiKeyLink
|
||||||
|
: appId === "codex"
|
||||||
|
? shouldShowApiKeyLink
|
||||||
|
: false,
|
||||||
websiteUrl: getWebsiteUrl,
|
websiteUrl: getWebsiteUrl,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import type { Provider } from "@/types";
|
import type { Provider } from "@/types";
|
||||||
import { providersApi, type AppId } from "@/lib/api";
|
import { providersApi, type AppId } from "@/lib/api";
|
||||||
|
|
||||||
export function useDragSort(
|
export function useDragSort(providers: Record<string, Provider>, appId: AppId) {
|
||||||
providers: Record<string, Provider>,
|
|
||||||
appId: AppId,
|
|
||||||
) {
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
|
|
||||||
|
|||||||
@@ -75,11 +75,7 @@ export const mcpApi = {
|
|||||||
return await invoke("delete_mcp_server_in_config", payload);
|
return await invoke("delete_mcp_server_in_config", payload);
|
||||||
},
|
},
|
||||||
|
|
||||||
async setEnabled(
|
async setEnabled(app: AppId, id: string, enabled: boolean): Promise<boolean> {
|
||||||
app: AppId,
|
|
||||||
id: string,
|
|
||||||
enabled: boolean,
|
|
||||||
): Promise<boolean> {
|
|
||||||
return await invoke("set_mcp_enabled", { app, id, enabled });
|
return await invoke("set_mcp_enabled", { app, id, enabled });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,7 @@ import type { CustomEndpoint, ProviderMeta } from "@/types";
|
|||||||
*/
|
*/
|
||||||
export function mergeProviderMeta(
|
export function mergeProviderMeta(
|
||||||
initialMeta: ProviderMeta | undefined,
|
initialMeta: ProviderMeta | undefined,
|
||||||
customEndpoints:
|
customEndpoints: Record<string, CustomEndpoint> | null | undefined,
|
||||||
| Record<string, CustomEndpoint>
|
|
||||||
| null
|
|
||||||
| undefined,
|
|
||||||
): ProviderMeta | undefined {
|
): ProviderMeta | undefined {
|
||||||
const hasCustomEndpoints =
|
const hasCustomEndpoints =
|
||||||
!!customEndpoints && Object.keys(customEndpoints).length > 0;
|
!!customEndpoints && Object.keys(customEndpoints).length > 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user