diff --git a/biome.json b/biome.json
index 87362d2ac..107110c0f 100644
--- a/biome.json
+++ b/biome.json
@@ -1,5 +1,5 @@
{
- "$schema": "https://biomejs.dev/schemas/2.3.10/schema.json",
+ "$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
diff --git a/src/app/[locale]/dashboard/_components/user/forms/add-key-form.tsx b/src/app/[locale]/dashboard/_components/user/forms/add-key-form.tsx
index c63eea78c..218493c9e 100644
--- a/src/app/[locale]/dashboard/_components/user/forms/add-key-form.tsx
+++ b/src/app/[locale]/dashboard/_components/user/forms/add-key-form.tsx
@@ -1,7 +1,7 @@
"use client";
import { useRouter } from "next/navigation";
import { useTranslations } from "next-intl";
-import { useEffect, useState, useTransition } from "react";
+import { useCallback, useEffect, useState, useTransition } from "react";
import { toast } from "sonner";
import { addKey } from "@/actions/keys";
import { getAvailableProviderGroups } from "@/actions/providers";
@@ -119,6 +119,23 @@ export function AddKeyForm({ userId, user, isAdmin = false, onSuccess }: AddKeyF
},
});
+ // 选择分组时,自动移除 default(当有多个分组时)
+ const handleProviderGroupChange = useCallback(
+ (newValue: string) => {
+ const groups = newValue
+ .split(",")
+ .map((g) => g.trim())
+ .filter(Boolean);
+ if (groups.length > 1 && groups.includes(PROVIDER_GROUP.DEFAULT)) {
+ const withoutDefault = groups.filter((g) => g !== PROVIDER_GROUP.DEFAULT);
+ form.setValue("providerGroup", withoutDefault.join(","));
+ } else {
+ form.setValue("providerGroup", newValue);
+ }
+ },
+ [form]
+ );
+
return (
diff --git a/src/app/[locale]/dashboard/_components/user/forms/edit-key-form.tsx b/src/app/[locale]/dashboard/_components/user/forms/edit-key-form.tsx
index cabddee3e..a3a569601 100644
--- a/src/app/[locale]/dashboard/_components/user/forms/edit-key-form.tsx
+++ b/src/app/[locale]/dashboard/_components/user/forms/edit-key-form.tsx
@@ -1,7 +1,7 @@
"use client";
import { useRouter } from "next/navigation";
import { useTranslations } from "next-intl";
-import { useEffect, useState, useTransition } from "react";
+import { useCallback, useEffect, useState, useTransition } from "react";
import { toast } from "sonner";
import { editKey } from "@/actions/keys";
import { getAvailableProviderGroups } from "@/actions/providers";
@@ -138,6 +138,23 @@ export function EditKeyForm({ keyData, user, isAdmin = false, onSuccess }: EditK
},
});
+ // 选择分组时,自动移除 default(当有多个分组时)
+ const handleProviderGroupChange = useCallback(
+ (newValue: string) => {
+ const groups = newValue
+ .split(",")
+ .map((g) => g.trim())
+ .filter(Boolean);
+ if (groups.length > 1 && groups.includes(PROVIDER_GROUP.DEFAULT)) {
+ const withoutDefault = groups.filter((g) => g !== PROVIDER_GROUP.DEFAULT);
+ form.setValue("providerGroup", withoutDefault.join(","));
+ } else {
+ form.setValue("providerGroup", newValue);
+ }
+ },
+ [form]
+ );
+
return (
{config.description}}
-