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).
This commit is contained in:
LTbinglingfeng
2026-06-13 02:27:43 +08:00
Unverified
parent ac9cc45736
commit bbd69ffa81
2 changed files with 12 additions and 26 deletions
+6 -13
View File
@@ -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)}
</button>
);
})}
+6 -13
View File
@@ -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)}
</button>
);
})}