chore: apply prettier formatting to component files
This commit is contained in:
@@ -143,9 +143,7 @@ export function AddProviderDialog({
|
||||
<DialogContent className="max-w-3xl max-h-[85vh] min-h-[600px] flex flex-col">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{submitLabel}</DialogTitle>
|
||||
<DialogDescription>
|
||||
{t("provider.addProviderHint")}
|
||||
</DialogDescription>
|
||||
<DialogDescription>{t("provider.addProviderHint")}</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="flex-1 overflow-y-auto px-6 py-4">
|
||||
|
||||
@@ -67,9 +67,7 @@ export function EditProviderDialog({
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-3xl max-h-[85vh] min-h-[600px] flex flex-col">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
{t("provider.editProvider")}
|
||||
</DialogTitle>
|
||||
<DialogTitle>{t("provider.editProvider")}</DialogTitle>
|
||||
<DialogDescription>
|
||||
{t("provider.editProviderHint")}
|
||||
</DialogDescription>
|
||||
|
||||
@@ -29,7 +29,8 @@ export function ProviderActions({
|
||||
disabled={isCurrent}
|
||||
className={cn(
|
||||
"w-20",
|
||||
isCurrent && "bg-gray-200 text-muted-foreground hover:bg-gray-200 hover:text-muted-foreground dark:bg-gray-700 dark:hover:bg-gray-700",
|
||||
isCurrent &&
|
||||
"bg-gray-200 text-muted-foreground hover:bg-gray-200 hover:text-muted-foreground dark:bg-gray-700 dark:hover:bg-gray-700",
|
||||
)}
|
||||
>
|
||||
{isCurrent ? (
|
||||
|
||||
@@ -14,9 +14,7 @@ export function ProviderEmptyState({ onCreate }: ProviderEmptyStateProps) {
|
||||
<div className="mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-muted">
|
||||
<Users className="h-7 w-7 text-muted-foreground" />
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold">
|
||||
{t("provider.noProviders")}
|
||||
</h3>
|
||||
<h3 className="text-lg font-semibold">{t("provider.noProviders")}</h3>
|
||||
<p className="mt-2 max-w-sm text-sm text-muted-foreground">
|
||||
{t("provider.noProvidersDescription")}
|
||||
</p>
|
||||
|
||||
@@ -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