mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-18 18:50:49 +08:00
fix(ProviderNav): remove unused provider icons and clean up code
This commit is contained in:
@@ -1,4 +1,12 @@
|
|||||||
import { ReactNode, useCallback, useLayoutEffect, useRef, useState } from 'react';
|
import {
|
||||||
|
ReactNode,
|
||||||
|
createContext,
|
||||||
|
useCallback,
|
||||||
|
useContext,
|
||||||
|
useLayoutEffect,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
} from 'react';
|
||||||
import { useLocation, type Location } from 'react-router-dom';
|
import { useLocation, type Location } from 'react-router-dom';
|
||||||
import gsap from 'gsap';
|
import gsap from 'gsap';
|
||||||
import './PageTransition.scss';
|
import './PageTransition.scss';
|
||||||
@@ -31,6 +39,16 @@ type TransitionDirection = 'forward' | 'backward';
|
|||||||
|
|
||||||
type TransitionVariant = 'vertical' | 'ios';
|
type TransitionVariant = 'vertical' | 'ios';
|
||||||
|
|
||||||
|
type PageTransitionLayerContextValue = {
|
||||||
|
status: LayerStatus;
|
||||||
|
};
|
||||||
|
|
||||||
|
const PageTransitionLayerContext = createContext<PageTransitionLayerContextValue | null>(null);
|
||||||
|
|
||||||
|
export function usePageTransitionLayer() {
|
||||||
|
return useContext(PageTransitionLayerContext);
|
||||||
|
}
|
||||||
|
|
||||||
export function PageTransition({
|
export function PageTransition({
|
||||||
render,
|
render,
|
||||||
getRouteOrder,
|
getRouteOrder,
|
||||||
@@ -363,7 +381,9 @@ export function PageTransition({
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
<PageTransitionLayerContext.Provider value={{ status: layer.status }}>
|
||||||
{render(layer.location)}
|
{render(layer.location)}
|
||||||
|
</PageTransitionLayerContext.Provider>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { CSSProperties, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
import { CSSProperties, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
|
import { usePageTransitionLayer } from '@/components/common/PageTransition';
|
||||||
import { useThemeStore } from '@/stores';
|
import { useThemeStore } from '@/stores';
|
||||||
import iconGemini from '@/assets/icons/gemini.svg';
|
import iconGemini from '@/assets/icons/gemini.svg';
|
||||||
import iconOpenaiLight from '@/assets/icons/openai-light.svg';
|
import iconOpenaiLight from '@/assets/icons/openai-light.svg';
|
||||||
@@ -34,6 +35,8 @@ type ScrollContainer = HTMLElement | (Window & typeof globalThis);
|
|||||||
|
|
||||||
export function ProviderNav() {
|
export function ProviderNav() {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
const pageTransitionLayer = usePageTransitionLayer();
|
||||||
|
const isCurrentLayer = pageTransitionLayer ? pageTransitionLayer.status === 'current' : true;
|
||||||
const resolvedTheme = useThemeStore((state) => state.resolvedTheme);
|
const resolvedTheme = useThemeStore((state) => state.resolvedTheme);
|
||||||
const [activeProvider, setActiveProvider] = useState<ProviderId | null>(null);
|
const [activeProvider, setActiveProvider] = useState<ProviderId | null>(null);
|
||||||
const contentScrollerRef = useRef<HTMLElement | null>(null);
|
const contentScrollerRef = useRef<HTMLElement | null>(null);
|
||||||
@@ -62,7 +65,7 @@ export function ProviderNav() {
|
|||||||
location.pathname.length > 1 && location.pathname.endsWith('/')
|
location.pathname.length > 1 && location.pathname.endsWith('/')
|
||||||
? location.pathname.slice(0, -1)
|
? location.pathname.slice(0, -1)
|
||||||
: location.pathname;
|
: location.pathname;
|
||||||
const shouldShow = normalizedPathname === '/ai-providers';
|
const shouldShow = isCurrentLayer && normalizedPathname === '/ai-providers';
|
||||||
|
|
||||||
const getHeaderHeight = useCallback(() => {
|
const getHeaderHeight = useCallback(() => {
|
||||||
const header = document.querySelector('.main-header') as HTMLElement | null;
|
const header = document.querySelector('.main-header') as HTMLElement | null;
|
||||||
|
|||||||
Reference in New Issue
Block a user