chore: apply prettier formatting to component files
This commit is contained in:
@@ -24,14 +24,9 @@ export function BasicFormFields({ form }: BasicFormFieldsProps) {
|
||||
name="name"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>
|
||||
{t("provider.name")}
|
||||
</FormLabel>
|
||||
<FormLabel>{t("provider.name")}</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder={t("provider.namePlaceholder")}
|
||||
/>
|
||||
<Input {...field} placeholder={t("provider.namePlaceholder")} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -43,9 +38,7 @@ export function BasicFormFields({ form }: BasicFormFieldsProps) {
|
||||
name="websiteUrl"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>
|
||||
{t("provider.websiteUrl")}
|
||||
</FormLabel>
|
||||
<FormLabel>{t("provider.websiteUrl")}</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="https://" />
|
||||
</FormControl>
|
||||
|
||||
@@ -38,9 +38,7 @@ export function CommonConfigEditor({
|
||||
<>
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label htmlFor="settingsConfig">
|
||||
{t("provider.configJson")}
|
||||
</Label>
|
||||
<Label htmlFor="settingsConfig">{t("provider.configJson")}</Label>
|
||||
<div className="flex items-center gap-2">
|
||||
<label className="inline-flex items-center gap-2 text-sm text-muted-foreground cursor-pointer">
|
||||
<input
|
||||
|
||||
@@ -259,7 +259,7 @@ const EndpointSpeedTest: React.FC<EndpointSpeedTestProps> = ({
|
||||
}
|
||||
|
||||
// 明确只允许 http: 和 https:
|
||||
const allowedProtocols = ['http:', 'https:'];
|
||||
const allowedProtocols = ["http:", "https:"];
|
||||
if (!errorMsg && parsed && !allowedProtocols.includes(parsed.protocol)) {
|
||||
errorMsg = t("endpointTest.onlyHttps");
|
||||
}
|
||||
@@ -333,15 +333,20 @@ const EndpointSpeedTest: React.FC<EndpointSpeedTestProps> = ({
|
||||
try {
|
||||
await vscodeApi.removeCustomEndpoint(appType, providerId, entry.url);
|
||||
} catch (error) {
|
||||
const errorMsg = error instanceof Error ? error.message : String(error);
|
||||
const errorMsg =
|
||||
error instanceof Error ? error.message : String(error);
|
||||
|
||||
// 只有"端点不存在"时才允许删除本地条目
|
||||
if (errorMsg.includes('not found') || errorMsg.includes('does not exist') || errorMsg.includes('不存在')) {
|
||||
console.warn(t('endpointTest.removeEndpointFailed'), errorMsg);
|
||||
if (
|
||||
errorMsg.includes("not found") ||
|
||||
errorMsg.includes("does not exist") ||
|
||||
errorMsg.includes("不存在")
|
||||
) {
|
||||
console.warn(t("endpointTest.removeEndpointFailed"), errorMsg);
|
||||
// 继续删除本地条目
|
||||
} else {
|
||||
// 其他错误:显示错误提示,阻止删除
|
||||
setLastError(t('endpointTest.removeFailed', { error: errorMsg }));
|
||||
setLastError(t("endpointTest.removeFailed", { error: errorMsg }));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,7 +455,11 @@ export function ProviderForm({
|
||||
|
||||
return (
|
||||
<Form {...form}>
|
||||
<form id="provider-form" onSubmit={form.handleSubmit(handleSubmit)} className="space-y-6">
|
||||
<form
|
||||
id="provider-form"
|
||||
onSubmit={form.handleSubmit(handleSubmit)}
|
||||
className="space-y-6"
|
||||
>
|
||||
{/* 预设供应商选择(仅新增模式显示) */}
|
||||
{!initialData && (
|
||||
<ProviderPresetSelector
|
||||
|
||||
@@ -114,9 +114,7 @@ export function ProviderPresetSelector({
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<FormLabel>
|
||||
{t("providerPreset.label")}
|
||||
</FormLabel>
|
||||
<FormLabel>{t("providerPreset.label")}</FormLabel>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{/* 自定义按钮 */}
|
||||
<button
|
||||
@@ -158,9 +156,7 @@ export function ProviderPresetSelector({
|
||||
});
|
||||
})}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{getCategoryHint()}
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">{getCategoryHint()}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -122,10 +122,11 @@ export function useSpeedTestEndpoints({
|
||||
}
|
||||
|
||||
// 3. 编辑模式:初始数据中的 URL
|
||||
const initialCodexConfig =
|
||||
initialData?.settingsConfig as {
|
||||
config?: string;
|
||||
} | undefined;
|
||||
const initialCodexConfig = initialData?.settingsConfig as
|
||||
| {
|
||||
config?: string;
|
||||
}
|
||||
| undefined;
|
||||
const configStr = initialCodexConfig?.config ?? "";
|
||||
// 从 TOML 中提取 base_url
|
||||
const match = /base_url\s*=\s*["']([^"']+)["']/i.exec(configStr);
|
||||
|
||||
Reference in New Issue
Block a user