Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
95648353
authored
Apr 30, 2026
by
Calcium-Ion
Committed by
GitHub
Apr 30, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4548 from Micah-Zheng/fix/default-api-key-group
fix: 修复默认主题 API 密钥分组行为
parents
b2232f43
2f863704
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
6 deletions
+25
-6
web/default/src/features/keys/components/api-key-group-combobox.tsx
+6
-1
web/default/src/features/keys/components/api-keys-mutate-drawer.tsx
+7
-4
web/default/src/features/keys/constants.ts
+1
-1
web/default/src/features/keys/lib/api-key-form.ts
+10
-0
web/default/src/features/keys/lib/index.ts
+1
-0
No files found.
web/default/src/features/keys/components/api-key-group-combobox.tsx
View file @
95648353
...
@@ -128,7 +128,12 @@ export function ApiKeyGroupCombobox({
...
@@ -128,7 +128,12 @@ export function ApiKeyGroupCombobox({
<
ChevronsUpDown
className=
'h-4 w-4 shrink-0 opacity-50'
/>
<
ChevronsUpDown
className=
'h-4 w-4 shrink-0 opacity-50'
/>
</
Button
>
</
Button
>
</
PopoverTrigger
>
</
PopoverTrigger
>
<
PopoverContent
className=
'data-[state=closed]:zoom-out-100 data-[state=open]:zoom-in-100 data-[side=bottom]:slide-in-from-top-0 data-[side=left]:slide-in-from-right-0 data-[side=right]:slide-in-from-left-0 data-[side=top]:slide-in-from-bottom-0 w-[var(--radix-popover-trigger-width)] overflow-hidden rounded-xl p-0 shadow-lg data-[state=closed]:duration-75 data-[state=open]:duration-100'
>
<
PopoverContent
className=
'data-[state=closed]:zoom-out-100 data-[state=open]:zoom-in-100 data-[side=bottom]:slide-in-from-top-0 data-[side=left]:slide-in-from-right-0 data-[side=right]:slide-in-from-left-0 data-[side=top]:slide-in-from-bottom-0 w-[var(--radix-popover-trigger-width)] overflow-hidden rounded-xl p-0 shadow-lg data-[state=closed]:duration-75 data-[state=open]:duration-100'
onWheel=
{
(
event
)
=>
event
.
stopPropagation
()
}
onTouchMove=
{
(
event
)
=>
event
.
stopPropagation
()
}
onPointerDown=
{
(
event
)
=>
event
.
stopPropagation
()
}
>
<
Command
shouldFilter=
{
false
}
>
<
Command
shouldFilter=
{
false
}
>
<
CommandInput
<
CommandInput
placeholder=
{
t
(
'Search...'
)
}
placeholder=
{
t
(
'Search...'
)
}
...
...
web/default/src/features/keys/components/api-keys-mutate-drawer.tsx
View file @
95648353
...
@@ -14,6 +14,7 @@ import { toast } from 'sonner'
...
@@ -14,6 +14,7 @@ import { toast } from 'sonner'
import
{
getUserModels
,
getUserGroups
}
from
'@/lib/api'
import
{
getUserModels
,
getUserGroups
}
from
'@/lib/api'
import
{
getCurrencyDisplay
,
getCurrencyLabel
}
from
'@/lib/currency'
import
{
getCurrencyDisplay
,
getCurrencyLabel
}
from
'@/lib/currency'
import
{
cn
}
from
'@/lib/utils'
import
{
cn
}
from
'@/lib/utils'
import
{
useStatus
}
from
'@/hooks/use-status'
import
{
Button
}
from
'@/components/ui/button'
import
{
Button
}
from
'@/components/ui/button'
import
{
import
{
Collapsible
,
Collapsible
,
...
@@ -48,7 +49,7 @@ import { ERROR_MESSAGES, SUCCESS_MESSAGES } from '../constants'
...
@@ -48,7 +49,7 @@ import { ERROR_MESSAGES, SUCCESS_MESSAGES } from '../constants'
import
{
import
{
apiKeyFormSchema
,
apiKeyFormSchema
,
type
ApiKeyFormValues
,
type
ApiKeyFormValues
,
API_KEY_FORM_DEFAULT_VALUES
,
getApiKeyFormDefaultValues
,
transformFormDataToPayload
,
transformFormDataToPayload
,
transformApiKeyToFormDefaults
,
transformApiKeyToFormDefaults
,
}
from
'../lib'
}
from
'../lib'
...
@@ -103,8 +104,10 @@ export function ApiKeysMutateDrawer({
...
@@ -103,8 +104,10 @@ export function ApiKeysMutateDrawer({
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
isUpdate
=
!!
currentRow
const
isUpdate
=
!!
currentRow
const
{
triggerRefresh
}
=
useApiKeys
()
const
{
triggerRefresh
}
=
useApiKeys
()
const
{
status
}
=
useStatus
()
const
[
isSubmitting
,
setIsSubmitting
]
=
useState
(
false
)
const
[
isSubmitting
,
setIsSubmitting
]
=
useState
(
false
)
const
[
advancedOpen
,
setAdvancedOpen
]
=
useState
(
false
)
const
[
advancedOpen
,
setAdvancedOpen
]
=
useState
(
false
)
const
defaultUseAutoGroup
=
status
?.
default_use_auto_group
===
true
// Fetch models
// Fetch models
const
{
data
:
modelsData
}
=
useQuery
({
const
{
data
:
modelsData
}
=
useQuery
({
...
@@ -142,7 +145,7 @@ export function ApiKeysMutateDrawer({
...
@@ -142,7 +145,7 @@ export function ApiKeysMutateDrawer({
const
form
=
useForm
<
ApiKeyFormValues
>
({
const
form
=
useForm
<
ApiKeyFormValues
>
({
resolver
:
zodResolver
(
apiKeyFormSchema
),
resolver
:
zodResolver
(
apiKeyFormSchema
),
defaultValues
:
API_KEY_FORM_DEFAULT_VALUES
,
defaultValues
:
getApiKeyFormDefaultValues
(
defaultUseAutoGroup
)
,
})
})
// Load existing data when updating
// Load existing data when updating
...
@@ -156,9 +159,9 @@ export function ApiKeysMutateDrawer({
...
@@ -156,9 +159,9 @@ export function ApiKeysMutateDrawer({
})
})
}
else
if
(
open
&&
!
isUpdate
)
{
}
else
if
(
open
&&
!
isUpdate
)
{
// For create, reset to defaults
// For create, reset to defaults
form
.
reset
(
API_KEY_FORM_DEFAULT_VALUES
)
form
.
reset
(
getApiKeyFormDefaultValues
(
defaultUseAutoGroup
)
)
}
}
},
[
open
,
isUpdate
,
currentRow
,
form
])
},
[
open
,
isUpdate
,
currentRow
,
form
,
defaultUseAutoGroup
])
const
onSubmit
=
async
(
data
:
ApiKeyFormValues
)
=>
{
const
onSubmit
=
async
(
data
:
ApiKeyFormValues
)
=>
{
setIsSubmitting
(
true
)
setIsSubmitting
(
true
)
...
...
web/default/src/features/keys/constants.ts
View file @
95648353
...
@@ -56,7 +56,7 @@ export const API_KEY_STATUS_OPTIONS = Object.values(API_KEY_STATUSES).map(
...
@@ -56,7 +56,7 @@ export const API_KEY_STATUS_OPTIONS = Object.values(API_KEY_STATUSES).map(
// Default Values
// Default Values
// ============================================================================
// ============================================================================
export
const
DEFAULT_GROUP
=
'
auto
'
as
const
export
const
DEFAULT_GROUP
=
''
as
const
// ============================================================================
// ============================================================================
// Error Messages (i18n keys: use t(ERROR_MESSAGES.xxx) when displaying)
// Error Messages (i18n keys: use t(ERROR_MESSAGES.xxx) when displaying)
...
...
web/default/src/features/keys/lib/api-key-form.ts
View file @
95648353
...
@@ -37,6 +37,16 @@ export const API_KEY_FORM_DEFAULT_VALUES: ApiKeyFormValues = {
...
@@ -37,6 +37,16 @@ export const API_KEY_FORM_DEFAULT_VALUES: ApiKeyFormValues = {
tokenCount
:
1
,
tokenCount
:
1
,
}
}
export
function
getApiKeyFormDefaultValues
(
defaultUseAutoGroup
:
boolean
):
ApiKeyFormValues
{
return
{
...
API_KEY_FORM_DEFAULT_VALUES
,
group
:
defaultUseAutoGroup
?
'auto'
:
DEFAULT_GROUP
,
cross_group_retry
:
defaultUseAutoGroup
,
}
}
// ============================================================================
// ============================================================================
// Form Data Transformation
// Form Data Transformation
// ============================================================================
// ============================================================================
...
...
web/default/src/features/keys/lib/index.ts
View file @
95648353
...
@@ -5,6 +5,7 @@ export {
...
@@ -5,6 +5,7 @@ export {
apiKeyFormSchema
,
apiKeyFormSchema
,
type
ApiKeyFormValues
,
type
ApiKeyFormValues
,
API_KEY_FORM_DEFAULT_VALUES
,
API_KEY_FORM_DEFAULT_VALUES
,
getApiKeyFormDefaultValues
,
transformFormDataToPayload
,
transformFormDataToPayload
,
transformApiKeyToFormDefaults
,
transformApiKeyToFormDefaults
,
}
from
'./api-key-form'
}
from
'./api-key-form'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment