fix: model list refresh when change credential (#26421)

This commit is contained in:
zxhlyh 2025-09-29 13:51:48 +08:00 committed by GitHub
parent 70bc5ca7f4
commit 595df172a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 7 deletions

View File

@ -323,15 +323,18 @@ export const useRefreshModel = () => {
const { eventEmitter } = useEventEmitterContextContext()
const updateModelProviders = useUpdateModelProviders()
const updateModelList = useUpdateModelList()
const handleRefreshModel = useCallback((provider: ModelProvider, configurationMethod: ConfigurationMethodEnum, CustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields) => {
const handleRefreshModel = useCallback((
provider: ModelProvider,
CustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields,
refreshModelList?: boolean,
) => {
updateModelProviders()
provider.supported_model_types.forEach((type) => {
updateModelList(type)
})
if (configurationMethod === ConfigurationMethodEnum.customizableModel
&& provider.custom_configuration.status === CustomConfigurationStatusEnum.active) {
if (refreshModelList && provider.custom_configuration.status === CustomConfigurationStatusEnum.active) {
eventEmitter?.emit({
type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST,
payload: provider.provider,

View File

@ -90,7 +90,7 @@ export const useAuth = (
type: 'success',
message: t('common.api.actionSuccess'),
})
handleRefreshModel(provider, configurationMethod, undefined)
handleRefreshModel(provider, undefined, true)
}
finally {
handleSetDoingAction(false)
@ -125,7 +125,7 @@ export const useAuth = (
type: 'success',
message: t('common.api.actionSuccess'),
})
handleRefreshModel(provider, configurationMethod, undefined)
handleRefreshModel(provider, undefined, true)
onRemove?.(pendingOperationCredentialId.current ?? '')
closeConfirmDelete()
}
@ -147,7 +147,7 @@ export const useAuth = (
if (res.result === 'success') {
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
handleRefreshModel(provider, configurationMethod, undefined)
handleRefreshModel(provider, undefined, !payload.credential_id)
}
}
finally {

View File

@ -159,7 +159,7 @@ const ModelLoadBalancingModal = ({
)
if (res.result === 'success') {
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
handleRefreshModel(provider, configurateMethod, currentCustomConfigurationModelFixedFields)
handleRefreshModel(provider, currentCustomConfigurationModelFixedFields, false)
onSave?.(provider.provider)
onClose?.()
}