mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-06-16 21:03:58 +08:00
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:
@@ -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>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user