create-bubbles 0.0.8 → 0.0.11
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/package.json +1 -1
- package/template-react-rsbuild/biome.json +102 -101
- package/template-react-rsbuild/commitlint.config.js +1 -1
- package/template-react-rsbuild/package.json +16 -16
- package/template-react-rsbuild/postcss.config.mjs +5 -5
- package/template-react-rsbuild/rsbuild.config.ts +28 -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 +26 -26
- package/template-react-rsbuild/src/router/index.tsx +27 -27
- package/template-react-rsbuild/src/store/index.ts +0 -0
- package/template-react-rsbuild/src/store/modules/user.ts +11 -0
- package/template-react-rsbuild/src/types/auto-import.d.ts +47 -47
- package/template-react-rsbuild/src/utils/request/axios.ts +82 -93
- package/template-react-rsbuild/src/utils/request/index.ts +43 -26
- package/template-react-rsbuild/tsconfig.json +29 -29
- package/template-react-rsbuild/uno.config.ts +8 -8
- package/template-vue-rsbuild/biome.json +2 -1
- package/template-vue-rsbuild/package.json +7 -6
- package/template-vue-rsbuild/rsbuild.config.ts +4 -4
- package/template-vue-rsbuild/src/env.d.ts +17 -9
- package/template-vue-rsbuild/src/index.ts +9 -1
- package/template-vue-rsbuild/src/router/guard/index.tsx +6 -0
- package/template-vue-rsbuild/src/router/guard/permissionGuard.ts +8 -0
- package/template-vue-rsbuild/src/router/index.tsx +14 -0
- package/template-vue-rsbuild/src/router/modules/index.tsx +10 -0
- package/template-vue-rsbuild/src/store/index.ts +7 -0
- package/template-vue-rsbuild/src/store/modules/user.ts +17 -0
- package/template-vue-rsbuild/src/utils/request/axios.ts +83 -0
- package/template-vue-rsbuild/src/utils/request/index.ts +77 -0
- package/template-vue-rsbuild/src/views/home/index.vue +13 -0
- package/template-react-rsbuild/pnpm-lock.yaml +0 -3615
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { AxiosRequestConfig } from 'axios'
|
|
2
|
+
|
|
3
|
+
import request, { type CustomConfig } from './axios'
|
|
4
|
+
|
|
5
|
+
interface createAxiosType {
|
|
6
|
+
get: <T = any>(
|
|
7
|
+
config: {
|
|
8
|
+
url: string
|
|
9
|
+
params?: AxiosRequestConfig['params']
|
|
10
|
+
config?: AxiosRequestConfig<any>
|
|
11
|
+
},
|
|
12
|
+
option?: CustomConfig,
|
|
13
|
+
) => Promise<T>
|
|
14
|
+
post: <T = any>(
|
|
15
|
+
config: {
|
|
16
|
+
url: string
|
|
17
|
+
data?: AxiosRequestConfig['data']
|
|
18
|
+
params?: AxiosRequestConfig['params']
|
|
19
|
+
config?: AxiosRequestConfig<any>
|
|
20
|
+
},
|
|
21
|
+
option?: CustomConfig,
|
|
22
|
+
) => Promise<T>
|
|
23
|
+
put: <T = any>(
|
|
24
|
+
config: {
|
|
25
|
+
url: string
|
|
26
|
+
data?: AxiosRequestConfig['data']
|
|
27
|
+
config?: AxiosRequestConfig<any>
|
|
28
|
+
},
|
|
29
|
+
option?: CustomConfig,
|
|
30
|
+
) => Promise<T>
|
|
31
|
+
delete: <T = any>(
|
|
32
|
+
config: {
|
|
33
|
+
url: string
|
|
34
|
+
data?: AxiosRequestConfig['data']
|
|
35
|
+
config?: AxiosRequestConfig<any>
|
|
36
|
+
},
|
|
37
|
+
option?: CustomConfig,
|
|
38
|
+
) => Promise<T>
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const createAxios: createAxiosType = {
|
|
42
|
+
get: (config, option) =>
|
|
43
|
+
request(option).get(config.url, {
|
|
44
|
+
params: config.params,
|
|
45
|
+
...config?.config,
|
|
46
|
+
}),
|
|
47
|
+
post: (
|
|
48
|
+
config: {
|
|
49
|
+
url: string
|
|
50
|
+
params?: Record<string, string>
|
|
51
|
+
data?: any
|
|
52
|
+
config?: AxiosRequestConfig<any>
|
|
53
|
+
},
|
|
54
|
+
option?: CustomConfig,
|
|
55
|
+
) => {
|
|
56
|
+
let url = config.url
|
|
57
|
+
if (config.params instanceof Object) {
|
|
58
|
+
url += '?'
|
|
59
|
+
const entries = Object.entries(config.params)
|
|
60
|
+
for (let i = 0; i < entries.length; i++) {
|
|
61
|
+
const [key, value] = entries[i]
|
|
62
|
+
url += `${key}=${value}${i < entries.length - 1 ? '&' : ''}`
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return request(option).post(url, config?.data, config?.config)
|
|
66
|
+
},
|
|
67
|
+
put: (
|
|
68
|
+
config: { url: string; data?: any; config?: AxiosRequestConfig<any> },
|
|
69
|
+
option?: CustomConfig,
|
|
70
|
+
) => request(option).put(config.url, config?.data, config?.config),
|
|
71
|
+
delete: (
|
|
72
|
+
config: { url: string; config?: AxiosRequestConfig<any> },
|
|
73
|
+
customConfig?: CustomConfig,
|
|
74
|
+
) => request(customConfig).delete(config.url, config?.config),
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default createAxios
|