mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-09 22:26:09 +00:00
bc309ed9f8
Drop the axios (and qs) dependencies in favor of a native fetch wrapper.
axios only ever handled same-origin JSON/form calls, a CSRF header, a 401
redirect, and a 403-retry, all of which the platform now provides directly.
- New src/api/http-init.ts (replaces axios-init.ts) reimplements the
request/response interceptors on fetch: base-path prefixing,
X-Requested-With, same-origin credentials, the CSRF token on unsafe
methods, a single 403 retry with token refresh, and the 401
redirect-and-latch. A small encodeForm() reproduces qs's
arrayFormat:'repeat' encoding, so the request wire format is unchanged.
- HttpUtil (src/utils/index.ts) keeps its public signatures and the Msg
envelope, so the ~49 API call sites are untouched. HttpOptions is now
hand-rolled instead of extending AxiosRequestConfig.
- PanelUpdateModal drops its lone direct axios.get in favor of HttpUtil.get
with { silent, timeout }.
- Add tests for the fetch core (CSRF header, form/JSON/FormData bodies,
base-path prefix, 403 retry, 401 redirect, tolerant body parse) and for
HttpUtil's envelope unwrap / toast / error mapping; this logic was
previously untested.
- Remove the vendor-axios manualChunks branch and the qs type shim, and
reword stale "axios" mentions in docs and route comments.
34 lines
916 B
TypeScript
34 lines
916 B
TypeScript
import { createRoot } from 'react-dom/client';
|
|
import { RouterProvider } from 'react-router-dom';
|
|
import { message } from 'antd';
|
|
import 'antd/dist/reset.css';
|
|
import '@/styles/utils.css';
|
|
import '@/styles/page-shell.css';
|
|
import '@/styles/page-cards.css';
|
|
|
|
import { setupHttp } from '@/api/http-init';
|
|
import { readyI18n } from '@/i18n/react';
|
|
import { ThemeProvider } from '@/hooks/useTheme';
|
|
import { QueryProvider } from '@/api/QueryProvider';
|
|
import { router } from '@/routes';
|
|
|
|
setupHttp();
|
|
|
|
const messageContainer = document.getElementById('message');
|
|
if (messageContainer) {
|
|
message.config({ getContainer: () => messageContainer });
|
|
}
|
|
|
|
readyI18n().then(() => {
|
|
const root = document.getElementById('app');
|
|
if (root) {
|
|
createRoot(root).render(
|
|
<ThemeProvider>
|
|
<QueryProvider>
|
|
<RouterProvider router={router} />
|
|
</QueryProvider>
|
|
</ThemeProvider>,
|
|
);
|
|
}
|
|
});
|