From bbd69ffa8180db02c271ad089174e80d0cdb3c5a Mon Sep 17 00:00:00 2001 From: LTbinglingfeng Date: Sat, 13 Jun 2026 02:27:43 +0800 Subject: [PATCH] refactor(auth-files): reuse shared provider type label in OAuth edit pages Both edit pages re-implemented getTypeLabel locally although the authFiles constants module already exports it (with provider-key normalization on top). --- src/pages/AuthFilesOAuthExcludedEditPage.tsx | 19 ++++++------------- .../AuthFilesOAuthModelAliasEditPage.tsx | 19 ++++++------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/pages/AuthFilesOAuthExcludedEditPage.tsx b/src/pages/AuthFilesOAuthExcludedEditPage.tsx index 503ee6c..9e27c8d 100644 --- a/src/pages/AuthFilesOAuthExcludedEditPage.tsx +++ b/src/pages/AuthFilesOAuthExcludedEditPage.tsx @@ -12,7 +12,11 @@ import { SecondaryScreenShell } from '@/components/common/SecondaryScreenShell'; import { useEdgeSwipeBack } from '@/hooks/useEdgeSwipeBack'; import { useAuthStore, useNotificationStore } from '@/stores'; import { authFilesApi } from '@/services/api'; -import { buildOAuthProviderOptions, normalizeProviderKey } from '@/features/authFiles/constants'; +import { + buildOAuthProviderOptions, + getTypeLabel, + normalizeProviderKey, +} from '@/features/authFiles/constants'; import type { AuthFileItem, OAuthModelAliasEntry } from '@/types'; import styles from './AuthFilesOAuthExcludedEditPage.module.scss'; @@ -64,17 +68,6 @@ export function AuthFilesOAuthExcludedEditPage() { return buildOAuthProviderOptions(extraProviders); }, [excluded, files, modelAlias]); - const getTypeLabel = useCallback( - (type: string): string => { - const key = `auth_files.filter_${type}`; - const translated = t(key); - if (translated !== key) return translated; - if (type.toLowerCase() === 'iflow') return 'iFlow'; - return type.charAt(0).toUpperCase() + type.slice(1); - }, - [t] - ); - const resolvedProviderKey = useMemo(() => normalizeProviderKey(provider), [provider]); const isEditing = useMemo(() => { if (!resolvedProviderKey) return false; @@ -338,7 +331,7 @@ export function AuthFilesOAuthExcludedEditPage() { onClick={() => updateProvider(option)} disabled={disableControls || saving} > - {getTypeLabel(option)} + {getTypeLabel(t, option)} ); })} diff --git a/src/pages/AuthFilesOAuthModelAliasEditPage.tsx b/src/pages/AuthFilesOAuthModelAliasEditPage.tsx index d8e6a01..a878e32 100644 --- a/src/pages/AuthFilesOAuthModelAliasEditPage.tsx +++ b/src/pages/AuthFilesOAuthModelAliasEditPage.tsx @@ -11,7 +11,11 @@ import { SecondaryScreenShell } from '@/components/common/SecondaryScreenShell'; import { useEdgeSwipeBack } from '@/hooks/useEdgeSwipeBack'; import { useAuthStore, useNotificationStore } from '@/stores'; import { authFilesApi } from '@/services/api'; -import { buildOAuthProviderOptions, normalizeProviderKey } from '@/features/authFiles/constants'; +import { + buildOAuthProviderOptions, + getTypeLabel, + normalizeProviderKey, +} from '@/features/authFiles/constants'; import type { AuthFileItem, OAuthModelAliasEntry } from '@/types'; import { generateId } from '@/utils/helpers'; import styles from './AuthFilesOAuthModelAliasEditPage.module.scss'; @@ -89,17 +93,6 @@ export function AuthFilesOAuthModelAliasEditPage() { return buildOAuthProviderOptions(extraProviders); }, [excluded, files, modelAlias]); - const getTypeLabel = useCallback( - (type: string): string => { - const key = `auth_files.filter_${type}`; - const translated = t(key); - if (translated !== key) return translated; - if (type.toLowerCase() === 'iflow') return 'iFlow'; - return type.charAt(0).toUpperCase() + type.slice(1); - }, - [t] - ); - const resolvedProviderKey = useMemo(() => normalizeProviderKey(provider), [provider]); const isEditing = useMemo(() => { if (!resolvedProviderKey) return false; @@ -400,7 +393,7 @@ export function AuthFilesOAuthModelAliasEditPage() { onClick={() => updateProvider(option)} disabled={disableControls || saving} > - {getTypeLabel(option)} + {getTypeLabel(t, option)} ); })}