create-bubbles 0.0.11 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -3
- package/package.json +41 -38
- package/template-react-rsbuild/.env +2 -2
- package/template-react-rsbuild/.gitignore +7 -0
- package/template-react-rsbuild/.npmrc +1 -0
- package/template-react-rsbuild/.prettierignore +33 -33
- package/template-react-rsbuild/.prettierrc +17 -17
- package/template-react-rsbuild/.vscode/settings.json +21 -0
- package/template-react-rsbuild/README.md +29 -29
- package/template-react-rsbuild/biome.json +102 -102
- package/template-react-rsbuild/commitlint.config.js +1 -1
- package/template-react-rsbuild/index.html +6 -6
- package/template-react-rsbuild/lefthook.yml +14 -14
- package/template-react-rsbuild/package.json +40 -39
- package/template-react-rsbuild/rsbuild.config.ts +34 -28
- package/template-react-rsbuild/src/App.tsx +9 -9
- package/template-react-rsbuild/src/components/Loading/PageLoading.tsx +11 -11
- package/template-react-rsbuild/src/env.d.ts +1 -1
- package/template-react-rsbuild/src/index.tsx +20 -20
- package/template-react-rsbuild/src/pages/home/index.tsx +5 -26
- package/template-react-rsbuild/src/router/index.tsx +27 -27
- package/template-react-rsbuild/src/store/modules/user.ts +11 -11
- package/template-react-rsbuild/src/styles/index.css +16 -16
- package/template-react-rsbuild/src/types/auto-import.d.ts +47 -47
- package/template-react-rsbuild/src/utils/request/axios.ts +82 -82
- package/template-react-rsbuild/src/utils/request/index.ts +77 -77
- package/template-react-rsbuild/tsconfig.json +29 -29
- package/template-react-rsbuild/uno.config.ts +8 -8
- package/template-vue-rsbuild/.env +2 -2
- package/template-vue-rsbuild/.gitignore +10 -0
- package/template-vue-rsbuild/.npmrc +1 -0
- package/template-vue-rsbuild/.prettierignore +4 -4
- package/template-vue-rsbuild/.prettierrc +18 -17
- package/template-vue-rsbuild/.vscode/settings.json +7 -0
- package/template-vue-rsbuild/README.md +29 -29
- package/template-vue-rsbuild/biome.json +102 -113
- package/template-vue-rsbuild/index.html +6 -6
- package/template-vue-rsbuild/lefthook.yml +11 -0
- package/template-vue-rsbuild/package.json +32 -31
- package/template-vue-rsbuild/rsbuild.config.ts +35 -28
- package/template-vue-rsbuild/src/App.vue +3 -29
- package/template-vue-rsbuild/src/index.ts +15 -15
- package/template-vue-rsbuild/src/router/modules/index.tsx +2 -2
- package/template-vue-rsbuild/src/store/index.ts +7 -7
- package/template-vue-rsbuild/src/store/modules/user.ts +16 -16
- package/template-vue-rsbuild/src/styles/index.css +16 -16
- package/template-vue-rsbuild/src/types/auto-import.d.ts +91 -91
- package/template-vue-rsbuild/src/types/env.d.ts +17 -0
- package/template-vue-rsbuild/src/utils/request/axios.ts +83 -83
- package/template-vue-rsbuild/src/utils/request/index.ts +77 -77
- package/template-vue-rsbuild/src/views/home/index.vue +11 -13
- package/template-vue-rsbuild/tsconfig.json +29 -29
- package/template-vue-rsbuild/uno.config.ts +9 -9
- package/template-vue-rsbuild-eslint/.env +3 -0
- package/template-vue-rsbuild-eslint/.gitignore +13 -0
- package/template-vue-rsbuild-eslint/.prettierignore +4 -0
- package/template-vue-rsbuild-eslint/.prettierrc +17 -0
- package/{template-vue-rsbuild → template-vue-rsbuild-eslint}/.vscode/extensions.json +3 -3
- package/template-vue-rsbuild-eslint/README.md +29 -0
- package/template-vue-rsbuild-eslint/biome.json +110 -0
- package/template-vue-rsbuild-eslint/index.html +7 -0
- package/template-vue-rsbuild-eslint/package.json +31 -0
- package/template-vue-rsbuild-eslint/postcss.config.mjs +5 -0
- package/template-vue-rsbuild-eslint/public/.gitkeep +0 -0
- package/template-vue-rsbuild-eslint/rsbuild.config.ts +28 -0
- package/template-vue-rsbuild-eslint/src/App.vue +29 -0
- package/{template-vue-rsbuild → template-vue-rsbuild-eslint}/src/env.d.ts +5 -5
- package/{template-vue-rsbuild → template-vue-rsbuild-eslint}/src/index.css +6 -6
- package/template-vue-rsbuild-eslint/src/index.ts +15 -0
- package/template-vue-rsbuild-eslint/src/router/guard/index.tsx +6 -0
- package/template-vue-rsbuild-eslint/src/router/guard/permissionGuard.ts +8 -0
- package/template-vue-rsbuild-eslint/src/router/index.tsx +14 -0
- package/template-vue-rsbuild-eslint/src/router/modules/index.tsx +10 -0
- package/template-vue-rsbuild-eslint/src/store/index.ts +7 -0
- package/template-vue-rsbuild-eslint/src/store/modules/user.ts +16 -0
- package/template-vue-rsbuild-eslint/src/styles/index.css +16 -0
- package/template-vue-rsbuild-eslint/src/types/auto-import.d.ts +91 -0
- package/template-vue-rsbuild-eslint/src/utils/request/axios.ts +83 -0
- package/template-vue-rsbuild-eslint/src/utils/request/index.ts +77 -0
- package/template-vue-rsbuild-eslint/src/views/home/index.vue +13 -0
- package/template-vue-rsbuild-eslint/tsconfig.json +29 -0
- package/template-vue-rsbuild-eslint/uno.config.ts +9 -0
- package/template-react-rsbuild/postcss.config.mjs +0 -5
- package/template-vue-rsbuild/postcss.config.mjs +0 -5
- /package/{template-react-rsbuild/index.en-US.md → template-vue-rsbuild-eslint/.env.development} +0 -0
- /package/{template-react-rsbuild/index.zh-CN.md → template-vue-rsbuild-eslint/.env.production} +0 -0
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
import { defineConfig } from '@rsbuild/core'
|
|
2
|
-
import { pluginReact } from '@rsbuild/plugin-react'
|
|
3
|
-
import AutoImport from 'unplugin-auto-import/rspack'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import { defineConfig } from '@rsbuild/core'
|
|
2
|
+
import { pluginReact } from '@rsbuild/plugin-react'
|
|
3
|
+
import AutoImport from 'unplugin-auto-import/rspack'
|
|
4
|
+
import UnoCSS from '@unocss/postcss'
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
html: {
|
|
8
|
+
template: './index.html',
|
|
9
|
+
},
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: {
|
|
12
|
+
'@': './src',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
server: {
|
|
16
|
+
port: Number(process.env.PUBLIC_PORT),
|
|
17
|
+
},
|
|
18
|
+
plugins: [pluginReact()],
|
|
19
|
+
tools: {
|
|
20
|
+
rspack: {
|
|
21
|
+
plugins: [
|
|
22
|
+
AutoImport({
|
|
23
|
+
imports: ['react', 'react-router', 'react-router-dom'],
|
|
24
|
+
dts: './src/types/auto-import.d.ts',
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
postcss: {
|
|
29
|
+
postcssOptions: {
|
|
30
|
+
plugins: [UnoCSS()],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
})
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { RouterProvider } from 'react-router';
|
|
2
|
-
|
|
3
|
-
import router from './router';
|
|
4
|
-
|
|
5
|
-
const App = () => {
|
|
6
|
-
return <RouterProvider router={router} />;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default App;
|
|
1
|
+
import { RouterProvider } from 'react-router';
|
|
2
|
+
|
|
3
|
+
import router from './router';
|
|
4
|
+
|
|
5
|
+
const App = () => {
|
|
6
|
+
return <RouterProvider router={router} />;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default App;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Spin } from 'antd';
|
|
2
|
-
|
|
3
|
-
const Loading = () => {
|
|
4
|
-
return (
|
|
5
|
-
<div className="flex justify-center items-center w-full h-100%">
|
|
6
|
-
<Spin size="large" />
|
|
7
|
-
</div>
|
|
8
|
-
);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default Loading;
|
|
1
|
+
import { Spin } from 'antd';
|
|
2
|
+
|
|
3
|
+
const Loading = () => {
|
|
4
|
+
return (
|
|
5
|
+
<div className="flex justify-center items-center w-full h-100%">
|
|
6
|
+
<Spin size="large" />
|
|
7
|
+
</div>
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default Loading;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/// <reference types="@rsbuild/core/types" />
|
|
1
|
+
/// <reference types="@rsbuild/core/types" />
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import React, { Suspense } from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom/client';
|
|
3
|
-
|
|
4
|
-
import App from './App';
|
|
5
|
-
|
|
6
|
-
import '@/styles/index.css';
|
|
7
|
-
|
|
8
|
-
import Loading from './components/Loading/PageLoading';
|
|
9
|
-
|
|
10
|
-
const rootEl = document.getElementById('root');
|
|
11
|
-
if (rootEl) {
|
|
12
|
-
const root = ReactDOM.createRoot(rootEl);
|
|
13
|
-
root.render(
|
|
14
|
-
<React.StrictMode>
|
|
15
|
-
<Suspense fallback={<Loading />}>
|
|
16
|
-
<App />
|
|
17
|
-
</Suspense>
|
|
18
|
-
</React.StrictMode>,
|
|
19
|
-
);
|
|
20
|
-
}
|
|
1
|
+
import React, { Suspense } from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
|
|
4
|
+
import App from './App';
|
|
5
|
+
|
|
6
|
+
import '@/styles/index.css';
|
|
7
|
+
|
|
8
|
+
import Loading from './components/Loading/PageLoading';
|
|
9
|
+
|
|
10
|
+
const rootEl = document.getElementById('root');
|
|
11
|
+
if (rootEl) {
|
|
12
|
+
const root = ReactDOM.createRoot(rootEl);
|
|
13
|
+
root.render(
|
|
14
|
+
<React.StrictMode>
|
|
15
|
+
<Suspense fallback={<Loading />}>
|
|
16
|
+
<App />
|
|
17
|
+
</Suspense>
|
|
18
|
+
</React.StrictMode>,
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -1,26 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
resolve({
|
|
7
|
-
data: [
|
|
8
|
-
{
|
|
9
|
-
id: 1,
|
|
10
|
-
title: 'Album 1',
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
id: 2,
|
|
14
|
-
title: 'Album 2',
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
});
|
|
18
|
-
}, 1000);
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const Home = () => {
|
|
23
|
-
return <h1>111</h1>;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default Home;
|
|
1
|
+
const Home = () => {
|
|
2
|
+
return <h1 className="text-red text-30px">111</h1>
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export default Home
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { Suspense } from 'react';
|
|
2
|
-
import { createBrowserRouter, type RouteObject } from 'react-router';
|
|
3
|
-
|
|
4
|
-
import Loading from '@/components/Loading/PageLoading';
|
|
5
|
-
|
|
6
|
-
export const lazyLoad = (path: string) => {
|
|
7
|
-
const Module = lazy(() => import(`@/pages/${path}.tsx`));
|
|
8
|
-
return (
|
|
9
|
-
<Suspense fallback={<Loading />}>
|
|
10
|
-
<Module />
|
|
11
|
-
</Suspense>
|
|
12
|
-
);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const routes: RouteObject[] = [
|
|
16
|
-
{
|
|
17
|
-
path: '/',
|
|
18
|
-
id: 'home',
|
|
19
|
-
element: lazyLoad('home/index'),
|
|
20
|
-
},
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
export const router = createBrowserRouter(routes, {
|
|
24
|
-
basename: import.meta.env.PUBLIC_PATH,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export default router;
|
|
1
|
+
import { Suspense } from 'react';
|
|
2
|
+
import { createBrowserRouter, type RouteObject } from 'react-router';
|
|
3
|
+
|
|
4
|
+
import Loading from '@/components/Loading/PageLoading';
|
|
5
|
+
|
|
6
|
+
export const lazyLoad = (path: string) => {
|
|
7
|
+
const Module = lazy(() => import(`@/pages/${path}.tsx`));
|
|
8
|
+
return (
|
|
9
|
+
<Suspense fallback={<Loading />}>
|
|
10
|
+
<Module />
|
|
11
|
+
</Suspense>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const routes: RouteObject[] = [
|
|
16
|
+
{
|
|
17
|
+
path: '/',
|
|
18
|
+
id: 'home',
|
|
19
|
+
element: lazyLoad('home/index'),
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export const router = createBrowserRouter(routes, {
|
|
24
|
+
basename: import.meta.env.PUBLIC_PATH,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export default router;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { create } from 'zustand'
|
|
2
|
-
|
|
3
|
-
interface searchFormState {
|
|
4
|
-
token?: string
|
|
5
|
-
setToken: (token?: string) => void
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const useUserStore = create<searchFormState>((set) => ({
|
|
9
|
-
token: undefined,
|
|
10
|
-
setToken: (token) => set(() => ({ token })),
|
|
11
|
-
}))
|
|
1
|
+
import { create } from 'zustand'
|
|
2
|
+
|
|
3
|
+
interface searchFormState {
|
|
4
|
+
token?: string
|
|
5
|
+
setToken: (token?: string) => void
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const useUserStore = create<searchFormState>((set) => ({
|
|
9
|
+
token: undefined,
|
|
10
|
+
setToken: (token) => set(() => ({ token })),
|
|
11
|
+
}))
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
@unocss;
|
|
2
|
-
|
|
3
|
-
html,
|
|
4
|
-
body,
|
|
5
|
-
#root {
|
|
6
|
-
width: 100%;
|
|
7
|
-
height: 100%;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
*,
|
|
11
|
-
*::before,
|
|
12
|
-
*::after {
|
|
13
|
-
margin: 0;
|
|
14
|
-
padding: 0;
|
|
15
|
-
box-sizing: border-box;
|
|
16
|
-
}
|
|
1
|
+
@unocss;
|
|
2
|
+
|
|
3
|
+
html,
|
|
4
|
+
body,
|
|
5
|
+
#root {
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: 100%;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
*,
|
|
11
|
+
*::before,
|
|
12
|
+
*::after {
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding: 0;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/* prettier-ignore */
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
// noinspection JSUnusedGlobalSymbols
|
|
5
|
-
// Generated by unplugin-auto-import
|
|
6
|
-
// biome-ignore lint: disable
|
|
7
|
-
export {}
|
|
8
|
-
declare global {
|
|
9
|
-
const Link: typeof import('react-router-dom')['Link']
|
|
10
|
-
const NavLink: typeof import('react-router-dom')['NavLink']
|
|
11
|
-
const Navigate: typeof import('react-router-dom')['Navigate']
|
|
12
|
-
const Outlet: typeof import('react-router-dom')['Outlet']
|
|
13
|
-
const Route: typeof import('react-router-dom')['Route']
|
|
14
|
-
const Routes: typeof import('react-router-dom')['Routes']
|
|
15
|
-
const createRef: typeof import('react')['createRef']
|
|
16
|
-
const forwardRef: typeof import('react')['forwardRef']
|
|
17
|
-
const lazy: typeof import('react')['lazy']
|
|
18
|
-
const memo: typeof import('react')['memo']
|
|
19
|
-
const startTransition: typeof import('react')['startTransition']
|
|
20
|
-
const useCallback: typeof import('react')['useCallback']
|
|
21
|
-
const useContext: typeof import('react')['useContext']
|
|
22
|
-
const useDebugValue: typeof import('react')['useDebugValue']
|
|
23
|
-
const useDeferredValue: typeof import('react')['useDeferredValue']
|
|
24
|
-
const useEffect: typeof import('react')['useEffect']
|
|
25
|
-
const useHref: typeof import('react-router-dom')['useHref']
|
|
26
|
-
const useId: typeof import('react')['useId']
|
|
27
|
-
const useImperativeHandle: typeof import('react')['useImperativeHandle']
|
|
28
|
-
const useInRouterContext: typeof import('react-router-dom')['useInRouterContext']
|
|
29
|
-
const useInsertionEffect: typeof import('react')['useInsertionEffect']
|
|
30
|
-
const useLayoutEffect: typeof import('react')['useLayoutEffect']
|
|
31
|
-
const useLinkClickHandler: typeof import('react-router-dom')['useLinkClickHandler']
|
|
32
|
-
const useLocation: typeof import('react-router-dom')['useLocation']
|
|
33
|
-
const useMemo: typeof import('react')['useMemo']
|
|
34
|
-
const useNavigate: typeof import('react-router-dom')['useNavigate']
|
|
35
|
-
const useNavigationType: typeof import('react-router-dom')['useNavigationType']
|
|
36
|
-
const useOutlet: typeof import('react-router-dom')['useOutlet']
|
|
37
|
-
const useOutletContext: typeof import('react-router-dom')['useOutletContext']
|
|
38
|
-
const useParams: typeof import('react-router-dom')['useParams']
|
|
39
|
-
const useReducer: typeof import('react')['useReducer']
|
|
40
|
-
const useRef: typeof import('react')['useRef']
|
|
41
|
-
const useResolvedPath: typeof import('react-router-dom')['useResolvedPath']
|
|
42
|
-
const useRoutes: typeof import('react-router-dom')['useRoutes']
|
|
43
|
-
const useSearchParams: typeof import('react-router-dom')['useSearchParams']
|
|
44
|
-
const useState: typeof import('react')['useState']
|
|
45
|
-
const useSyncExternalStore: typeof import('react')['useSyncExternalStore']
|
|
46
|
-
const useTransition: typeof import('react')['useTransition']
|
|
47
|
-
}
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* prettier-ignore */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
// noinspection JSUnusedGlobalSymbols
|
|
5
|
+
// Generated by unplugin-auto-import
|
|
6
|
+
// biome-ignore lint: disable
|
|
7
|
+
export {}
|
|
8
|
+
declare global {
|
|
9
|
+
const Link: typeof import('react-router-dom')['Link']
|
|
10
|
+
const NavLink: typeof import('react-router-dom')['NavLink']
|
|
11
|
+
const Navigate: typeof import('react-router-dom')['Navigate']
|
|
12
|
+
const Outlet: typeof import('react-router-dom')['Outlet']
|
|
13
|
+
const Route: typeof import('react-router-dom')['Route']
|
|
14
|
+
const Routes: typeof import('react-router-dom')['Routes']
|
|
15
|
+
const createRef: typeof import('react')['createRef']
|
|
16
|
+
const forwardRef: typeof import('react')['forwardRef']
|
|
17
|
+
const lazy: typeof import('react')['lazy']
|
|
18
|
+
const memo: typeof import('react')['memo']
|
|
19
|
+
const startTransition: typeof import('react')['startTransition']
|
|
20
|
+
const useCallback: typeof import('react')['useCallback']
|
|
21
|
+
const useContext: typeof import('react')['useContext']
|
|
22
|
+
const useDebugValue: typeof import('react')['useDebugValue']
|
|
23
|
+
const useDeferredValue: typeof import('react')['useDeferredValue']
|
|
24
|
+
const useEffect: typeof import('react')['useEffect']
|
|
25
|
+
const useHref: typeof import('react-router-dom')['useHref']
|
|
26
|
+
const useId: typeof import('react')['useId']
|
|
27
|
+
const useImperativeHandle: typeof import('react')['useImperativeHandle']
|
|
28
|
+
const useInRouterContext: typeof import('react-router-dom')['useInRouterContext']
|
|
29
|
+
const useInsertionEffect: typeof import('react')['useInsertionEffect']
|
|
30
|
+
const useLayoutEffect: typeof import('react')['useLayoutEffect']
|
|
31
|
+
const useLinkClickHandler: typeof import('react-router-dom')['useLinkClickHandler']
|
|
32
|
+
const useLocation: typeof import('react-router-dom')['useLocation']
|
|
33
|
+
const useMemo: typeof import('react')['useMemo']
|
|
34
|
+
const useNavigate: typeof import('react-router-dom')['useNavigate']
|
|
35
|
+
const useNavigationType: typeof import('react-router-dom')['useNavigationType']
|
|
36
|
+
const useOutlet: typeof import('react-router-dom')['useOutlet']
|
|
37
|
+
const useOutletContext: typeof import('react-router-dom')['useOutletContext']
|
|
38
|
+
const useParams: typeof import('react-router-dom')['useParams']
|
|
39
|
+
const useReducer: typeof import('react')['useReducer']
|
|
40
|
+
const useRef: typeof import('react')['useRef']
|
|
41
|
+
const useResolvedPath: typeof import('react-router-dom')['useResolvedPath']
|
|
42
|
+
const useRoutes: typeof import('react-router-dom')['useRoutes']
|
|
43
|
+
const useSearchParams: typeof import('react-router-dom')['useSearchParams']
|
|
44
|
+
const useState: typeof import('react')['useState']
|
|
45
|
+
const useSyncExternalStore: typeof import('react')['useSyncExternalStore']
|
|
46
|
+
const useTransition: typeof import('react')['useTransition']
|
|
47
|
+
}
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import { message } from 'antd'
|
|
2
|
-
import axios, { type AxiosResponse } from 'axios'
|
|
3
|
-
|
|
4
|
-
import { router } from '@/router'
|
|
5
|
-
import { useUserStore } from '@/store/modules/user'
|
|
6
|
-
|
|
7
|
-
export interface CustomConfig {
|
|
8
|
-
/** 直接返回响应体 */
|
|
9
|
-
isTransformResponse?: boolean
|
|
10
|
-
// 成功需要提示
|
|
11
|
-
isShowSuccessMsg?: boolean
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export enum CodeEnum {
|
|
15
|
-
SUCCESS = 200,
|
|
16
|
-
UNAUTHORIZED = 401,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const unAuthFunc = () => {
|
|
20
|
-
message.error('暂未登录或登录已过期,请重新登录')
|
|
21
|
-
router.navigate('/login')
|
|
22
|
-
}
|
|
23
|
-
export default (customConfig?: CustomConfig) => {
|
|
24
|
-
const token = useUserStore((state) => state.token)
|
|
25
|
-
|
|
26
|
-
const instance = axios.create({
|
|
27
|
-
baseURL: import.meta.env.PUBLIC_API_AFFIX,
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
instance.interceptors.request.use(
|
|
31
|
-
(config) => {
|
|
32
|
-
config.headers.set('X-Access-Token', token)
|
|
33
|
-
config.headers.set('Allow-Control-Allow-Origin', '*')
|
|
34
|
-
return config
|
|
35
|
-
},
|
|
36
|
-
(error) => {
|
|
37
|
-
message.error('请求错误')
|
|
38
|
-
return Promise.reject(error)
|
|
39
|
-
},
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
interface ResponseData<T = any> {
|
|
43
|
-
code: number
|
|
44
|
-
message: string
|
|
45
|
-
requestId: string
|
|
46
|
-
responseTime: number
|
|
47
|
-
result: T
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
instance.interceptors.response.use(
|
|
51
|
-
(response: AxiosResponse<ResponseData>) => {
|
|
52
|
-
const { status, data } = response
|
|
53
|
-
if (status === 200) {
|
|
54
|
-
if (customConfig?.isTransformResponse === false) return data
|
|
55
|
-
const { code, message: msg } = data
|
|
56
|
-
if (code === CodeEnum.SUCCESS) {
|
|
57
|
-
if (customConfig?.isShowSuccessMsg) {
|
|
58
|
-
message.success(msg)
|
|
59
|
-
}
|
|
60
|
-
return data.result
|
|
61
|
-
}
|
|
62
|
-
message.error(msg)
|
|
63
|
-
return Promise.reject(data)
|
|
64
|
-
}
|
|
65
|
-
if (status === CodeEnum.UNAUTHORIZED) {
|
|
66
|
-
unAuthFunc()
|
|
67
|
-
} else return Promise.reject(data.message)
|
|
68
|
-
},
|
|
69
|
-
(error) => {
|
|
70
|
-
const response = error.response
|
|
71
|
-
const { status, data } = response
|
|
72
|
-
if (status === CodeEnum.UNAUTHORIZED) {
|
|
73
|
-
unAuthFunc()
|
|
74
|
-
} else {
|
|
75
|
-
message.error(data?.message || '系统异常')
|
|
76
|
-
return Promise.reject(error)
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
return instance
|
|
82
|
-
}
|
|
1
|
+
import { message } from 'antd'
|
|
2
|
+
import axios, { type AxiosResponse } from 'axios'
|
|
3
|
+
|
|
4
|
+
import { router } from '@/router'
|
|
5
|
+
import { useUserStore } from '@/store/modules/user'
|
|
6
|
+
|
|
7
|
+
export interface CustomConfig {
|
|
8
|
+
/** 直接返回响应体 */
|
|
9
|
+
isTransformResponse?: boolean
|
|
10
|
+
// 成功需要提示
|
|
11
|
+
isShowSuccessMsg?: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export enum CodeEnum {
|
|
15
|
+
SUCCESS = 200,
|
|
16
|
+
UNAUTHORIZED = 401,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const unAuthFunc = () => {
|
|
20
|
+
message.error('暂未登录或登录已过期,请重新登录')
|
|
21
|
+
router.navigate('/login')
|
|
22
|
+
}
|
|
23
|
+
export default (customConfig?: CustomConfig) => {
|
|
24
|
+
const token = useUserStore((state) => state.token)
|
|
25
|
+
|
|
26
|
+
const instance = axios.create({
|
|
27
|
+
baseURL: import.meta.env.PUBLIC_API_AFFIX,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
instance.interceptors.request.use(
|
|
31
|
+
(config) => {
|
|
32
|
+
config.headers.set('X-Access-Token', token)
|
|
33
|
+
config.headers.set('Allow-Control-Allow-Origin', '*')
|
|
34
|
+
return config
|
|
35
|
+
},
|
|
36
|
+
(error) => {
|
|
37
|
+
message.error('请求错误')
|
|
38
|
+
return Promise.reject(error)
|
|
39
|
+
},
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
interface ResponseData<T = any> {
|
|
43
|
+
code: number
|
|
44
|
+
message: string
|
|
45
|
+
requestId: string
|
|
46
|
+
responseTime: number
|
|
47
|
+
result: T
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
instance.interceptors.response.use(
|
|
51
|
+
(response: AxiosResponse<ResponseData>) => {
|
|
52
|
+
const { status, data } = response
|
|
53
|
+
if (status === 200) {
|
|
54
|
+
if (customConfig?.isTransformResponse === false) return data
|
|
55
|
+
const { code, message: msg } = data
|
|
56
|
+
if (code === CodeEnum.SUCCESS) {
|
|
57
|
+
if (customConfig?.isShowSuccessMsg) {
|
|
58
|
+
message.success(msg)
|
|
59
|
+
}
|
|
60
|
+
return data.result
|
|
61
|
+
}
|
|
62
|
+
message.error(msg)
|
|
63
|
+
return Promise.reject(data)
|
|
64
|
+
}
|
|
65
|
+
if (status === CodeEnum.UNAUTHORIZED) {
|
|
66
|
+
unAuthFunc()
|
|
67
|
+
} else return Promise.reject(data.message)
|
|
68
|
+
},
|
|
69
|
+
(error) => {
|
|
70
|
+
const response = error.response
|
|
71
|
+
const { status, data } = response
|
|
72
|
+
if (status === CodeEnum.UNAUTHORIZED) {
|
|
73
|
+
unAuthFunc()
|
|
74
|
+
} else {
|
|
75
|
+
message.error(data?.message || '系统异常')
|
|
76
|
+
return Promise.reject(error)
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
return instance
|
|
82
|
+
}
|