mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-03 03:10:50 +08:00
feat: update document title and favicon in main.tsx, remove isLocalhost check from OAuthPage for cleaner logic, and enhance overall user experience
This commit is contained in:
15
src/main.tsx
15
src/main.tsx
@@ -1,8 +1,23 @@
|
|||||||
import { StrictMode } from 'react';
|
import { StrictMode } from 'react';
|
||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
import '@/styles/global.scss';
|
import '@/styles/global.scss';
|
||||||
|
import { INLINE_LOGO_JPEG } from '@/assets/logoInline';
|
||||||
import App from './App.tsx';
|
import App from './App.tsx';
|
||||||
|
|
||||||
|
document.title = 'CLI Proxy API Management Center';
|
||||||
|
|
||||||
|
const faviconEl = document.querySelector<HTMLLinkElement>('link[rel="icon"]');
|
||||||
|
if (faviconEl) {
|
||||||
|
faviconEl.href = INLINE_LOGO_JPEG;
|
||||||
|
faviconEl.type = 'image/jpeg';
|
||||||
|
} else {
|
||||||
|
const newFavicon = document.createElement('link');
|
||||||
|
newFavicon.rel = 'icon';
|
||||||
|
newFavicon.type = 'image/jpeg';
|
||||||
|
newFavicon.href = INLINE_LOGO_JPEG;
|
||||||
|
document.head.appendChild(newFavicon);
|
||||||
|
}
|
||||||
|
|
||||||
createRoot(document.getElementById('root')!).render(
|
createRoot(document.getElementById('root')!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<App />
|
<App />
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Card } from '@/components/ui/Card';
|
import { Card } from '@/components/ui/Card';
|
||||||
import { Button } from '@/components/ui/Button';
|
import { Button } from '@/components/ui/Button';
|
||||||
import { useNotificationStore } from '@/stores';
|
import { useNotificationStore } from '@/stores';
|
||||||
import { oauthApi, type OAuthProvider } from '@/services/api/oauth';
|
import { oauthApi, type OAuthProvider } from '@/services/api/oauth';
|
||||||
import { isLocalhost } from '@/utils/connection';
|
|
||||||
|
|
||||||
interface ProviderState {
|
interface ProviderState {
|
||||||
url?: string;
|
url?: string;
|
||||||
@@ -29,8 +28,6 @@ export function OAuthPage() {
|
|||||||
const [states, setStates] = useState<Record<OAuthProvider, ProviderState>>({} as Record<OAuthProvider, ProviderState>);
|
const [states, setStates] = useState<Record<OAuthProvider, ProviderState>>({} as Record<OAuthProvider, ProviderState>);
|
||||||
const timers = useRef<Record<string, number>>({});
|
const timers = useRef<Record<string, number>>({});
|
||||||
|
|
||||||
const isLocal = useMemo(() => isLocalhost(window.location.hostname), []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
Object.values(timers.current).forEach((timer) => window.clearInterval(timer));
|
Object.values(timers.current).forEach((timer) => window.clearInterval(timer));
|
||||||
@@ -106,10 +103,6 @@ export function OAuthPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isLocal) {
|
|
||||||
return <Card title="OAuth">OAuth is only available on localhost.</Card>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="stack">
|
<div className="stack">
|
||||||
{PROVIDERS.map((provider) => {
|
{PROVIDERS.map((provider) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user