refactor: 优化eslint配置,提升代码质量 (#1341)
* feat: 统一并标准化eslint * lint: napcat.webui * lint: napcat.webui * lint: napcat.core * build: fix * lint: napcat.webui * refactor: 重构eslint * Update README.md
This commit is contained in:
651 files changed
+37978
-37584
No files matched your search
+50
-50
@@ -1,33 +1,33 @@
|
||||
import { Suspense, lazy, useEffect } from 'react'
|
||||
import { Provider } from 'react-redux'
|
||||
import { Route, Routes, useNavigate } from 'react-router-dom'
|
||||
import { Suspense, lazy, useEffect } from 'react';
|
||||
import { Provider } from 'react-redux';
|
||||
import { Route, Routes, useNavigate } from 'react-router-dom';
|
||||
|
||||
import PageBackground from '@/components/page_background'
|
||||
import PageLoading from '@/components/page_loading'
|
||||
import Toaster from '@/components/toaster'
|
||||
import PageBackground from '@/components/page_background';
|
||||
import PageLoading from '@/components/page_loading';
|
||||
import Toaster from '@/components/toaster';
|
||||
|
||||
import DialogProvider from '@/contexts/dialog'
|
||||
import AudioProvider from '@/contexts/songs'
|
||||
import DialogProvider from '@/contexts/dialog';
|
||||
import AudioProvider from '@/contexts/songs';
|
||||
|
||||
import useAuth from '@/hooks/auth'
|
||||
import useAuth from '@/hooks/auth';
|
||||
|
||||
import store from '@/store'
|
||||
import store from '@/store';
|
||||
|
||||
const WebLoginPage = lazy(() => import('@/pages/web_login'))
|
||||
const IndexPage = lazy(() => import('@/pages/index'))
|
||||
const QQLoginPage = lazy(() => import('@/pages/qq_login'))
|
||||
const DashboardIndexPage = lazy(() => import('@/pages/dashboard'))
|
||||
const AboutPage = lazy(() => import('@/pages/dashboard/about'))
|
||||
const ConfigPage = lazy(() => import('@/pages/dashboard/config'))
|
||||
const DebugPage = lazy(() => import('@/pages/dashboard/debug'))
|
||||
const HttpDebug = lazy(() => import('@/pages/dashboard/debug/http'))
|
||||
const WSDebug = lazy(() => import('@/pages/dashboard/debug/websocket'))
|
||||
const FileManagerPage = lazy(() => import('@/pages/dashboard/file_manager'))
|
||||
const LogsPage = lazy(() => import('@/pages/dashboard/logs'))
|
||||
const NetworkPage = lazy(() => import('@/pages/dashboard/network'))
|
||||
const TerminalPage = lazy(() => import('@/pages/dashboard/terminal'))
|
||||
const WebLoginPage = lazy(() => import('@/pages/web_login'));
|
||||
const IndexPage = lazy(() => import('@/pages/index'));
|
||||
const QQLoginPage = lazy(() => import('@/pages/qq_login'));
|
||||
const DashboardIndexPage = lazy(() => import('@/pages/dashboard'));
|
||||
const AboutPage = lazy(() => import('@/pages/dashboard/about'));
|
||||
const ConfigPage = lazy(() => import('@/pages/dashboard/config'));
|
||||
const DebugPage = lazy(() => import('@/pages/dashboard/debug'));
|
||||
const HttpDebug = lazy(() => import('@/pages/dashboard/debug/http'));
|
||||
const WSDebug = lazy(() => import('@/pages/dashboard/debug/websocket'));
|
||||
const FileManagerPage = lazy(() => import('@/pages/dashboard/file_manager'));
|
||||
const LogsPage = lazy(() => import('@/pages/dashboard/logs'));
|
||||
const NetworkPage = lazy(() => import('@/pages/dashboard/network'));
|
||||
const TerminalPage = lazy(() => import('@/pages/dashboard/terminal'));
|
||||
|
||||
function App() {
|
||||
function App () {
|
||||
return (
|
||||
<DialogProvider>
|
||||
<Provider store={store}>
|
||||
@@ -42,49 +42,49 @@ function App() {
|
||||
</AudioProvider>
|
||||
</Provider>
|
||||
</DialogProvider>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function AuthChecker({ children }: { children: React.ReactNode }) {
|
||||
const { isAuth } = useAuth()
|
||||
const navigate = useNavigate()
|
||||
function AuthChecker ({ children }: { children: React.ReactNode }) {
|
||||
const { isAuth } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isAuth) {
|
||||
const search = new URLSearchParams(window.location.search)
|
||||
const token = search.get('token')
|
||||
let url = '/web_login'
|
||||
const search = new URLSearchParams(window.location.search);
|
||||
const token = search.get('token');
|
||||
let url = '/web_login';
|
||||
|
||||
if (token) {
|
||||
url += `?token=${token}`
|
||||
url += `?token=${token}`;
|
||||
}
|
||||
navigate(url, { replace: true })
|
||||
navigate(url, { replace: true });
|
||||
}
|
||||
}, [isAuth, navigate])
|
||||
}, [isAuth, navigate]);
|
||||
|
||||
return <>{children}</>
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
function AppRoutes() {
|
||||
function AppRoutes () {
|
||||
return (
|
||||
<Routes>
|
||||
<Route path="/" element={<IndexPage />}>
|
||||
<Route path='/' element={<IndexPage />}>
|
||||
<Route index element={<DashboardIndexPage />} />
|
||||
<Route path="network" element={<NetworkPage />} />
|
||||
<Route path="config" element={<ConfigPage />} />
|
||||
<Route path="logs" element={<LogsPage />} />
|
||||
<Route path="debug" element={<DebugPage />}>
|
||||
<Route path="ws" element={<WSDebug />} />
|
||||
<Route path="http" element={<HttpDebug />} />
|
||||
<Route path='network' element={<NetworkPage />} />
|
||||
<Route path='config' element={<ConfigPage />} />
|
||||
<Route path='logs' element={<LogsPage />} />
|
||||
<Route path='debug' element={<DebugPage />}>
|
||||
<Route path='ws' element={<WSDebug />} />
|
||||
<Route path='http' element={<HttpDebug />} />
|
||||
</Route>
|
||||
<Route path="file_manager" element={<FileManagerPage />} />
|
||||
<Route path="terminal" element={<TerminalPage />} />
|
||||
<Route path="about" element={<AboutPage />} />
|
||||
<Route path='file_manager' element={<FileManagerPage />} />
|
||||
<Route path='terminal' element={<TerminalPage />} />
|
||||
<Route path='about' element={<AboutPage />} />
|
||||
</Route>
|
||||
<Route path="/qq_login" element={<QQLoginPage />} />
|
||||
<Route path="/web_login" element={<WebLoginPage />} />
|
||||
<Route path='/qq_login' element={<QQLoginPage />} />
|
||||
<Route path='/web_login' element={<WebLoginPage />} />
|
||||
</Routes>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export default App
|
||||
export default App;
|
||||
Reference in new issue
Block a user