cfel-base-components 2.5.75 → 2.5.77

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cfel-base-components",
3
- "version": "2.5.75",
3
+ "version": "2.5.77",
4
4
  "description": "cfel-base-components",
5
5
  "main": "/src/index.tsx",
6
6
  "types": "src/index.d.ts",
@@ -2,7 +2,7 @@
2
2
  // This file is generated by Umi automatically
3
3
  // DO NOT CHANGE IT MANUALLY!
4
4
  import React from 'react';
5
- import { HelmetProvider } from '/Users/wujingang/Desktop/workspace/base-components/node_modules/@umijs/renderer-react';
5
+ import { HelmetProvider } from '/Users/lionaillen/Documents/work/cfel/base-components/node_modules/.pnpm/@umijs+renderer-react@4.0.72_react-dom@18.1.0_react@18.1.0__react@18.1.0/node_modules/@umijs/renderer-react';
6
6
  import { context } from './helmetContext';
7
7
 
8
8
  export const innerProvider = (container) => {
@@ -1,75 +1,93 @@
1
- import axios, { AxiosRequestHeaders } from "axios";
2
- import { notification } from "antd";
1
+ import axios, { AxiosRequestHeaders } from 'axios'
2
+ import { notification } from 'antd'
3
3
 
4
- let UMI_APP_BASEURL: any = window.location.origin || process.env;
5
- const instance = axios.create({ baseURL: UMI_APP_BASEURL });
4
+ let UMI_APP_BASEURL: any = window.location.origin || process.env
5
+ const instance = axios.create({ baseURL: UMI_APP_BASEURL })
6
6
 
7
7
  instance.interceptors.request.use(
8
8
  (config: any) => {
9
9
  config.headers = {
10
10
  ...config.headers,
11
- } as AxiosRequestHeaders;
11
+ } as AxiosRequestHeaders
12
12
 
13
13
  config.params = {
14
14
  ...config.params,
15
15
  productCode: (window as any)?.g_config?.productCode,
16
- };
16
+ }
17
17
 
18
- return config;
18
+ return config
19
19
  },
20
20
  (error: any) => Promise.reject(error)
21
- );
21
+ )
22
22
 
23
23
  instance.interceptors.response.use(
24
24
  //状态码为2xx的时候执行
25
25
  (response: any) => {
26
- const { data = {} } = response;
27
- const { success, content, errorCode, errorMsg } = data;
26
+ const { data = {} } = response
27
+ const { success, content, errorCode, errorMsg } = data
28
28
 
29
29
  if (!success) {
30
30
  notification.error({
31
31
  message: errorMsg,
32
- });
33
- return Promise.reject(data);
32
+ })
33
+ return Promise.reject(data)
34
34
  }
35
35
 
36
- return content;
36
+ return content
37
37
  },
38
38
  //状态码不为2xx的时候执行
39
39
  (error: any) => {
40
- const { response = {} } = error;
41
- const { status } = response;
40
+ const { response = {} } = error
41
+ const { status } = response
42
42
 
43
- if (error.code === "ERR_CANCELED") {
44
- return Promise.reject(error);
43
+ if (error.code === 'ERR_CANCELED') {
44
+ return Promise.reject(error)
45
45
  }
46
46
 
47
47
  enum CodeMessage {
48
- "发出的请求有错误,服务器没有进行新建或修改数据的操作。" = 400,
49
- "用户未登录。" = 401,
50
- "用户未得到授权,访问是被禁止的。" = 403,
51
- "发出的请求针对的是不存在的记录,服务器没有进行操作。" = 404,
52
- "请求的格式不可得。" = 406,
53
- "请求的资源被永久删除,且不会再得到的。" = 410,
54
- "当创建一个对象时,发生一个验证错误。" = 422,
55
- "服务器发生错误,请检查服务器。" = 500,
56
- "网关错误。" = 502,
57
- "服务不可用,服务器暂时过载或维护。" = 503,
58
- "网关超时。" = 504,
48
+ '发出的请求有错误,服务器没有进行新建或修改数据的操作。' = 400,
49
+ '用户未登录。' = 401,
50
+ '用户未得到授权,访问是被禁止的。' = 403,
51
+ '发出的请求针对的是不存在的记录,服务器没有进行操作。' = 404,
52
+ '请求的格式不可得。' = 406,
53
+ '请求的资源被永久删除,且不会再得到的。' = 410,
54
+ '当创建一个对象时,发生一个验证错误。' = 422,
55
+ '服务器发生错误,请检查服务器。' = 500,
56
+ '网关错误。' = 502,
57
+ '服务不可用,服务器暂时过载或维护。' = 503,
58
+ '网关超时。' = 504,
59
59
  }
60
60
 
61
61
  notification.error({
62
- message:
63
- response?.data?.errorMsg ||
64
- CodeMessage[status] ||
65
- "服务暂不可用,请检查网络",
66
- });
62
+ message: response?.data?.errorMsg || CodeMessage[status] || '服务暂不可用,请检查网络',
63
+ })
67
64
 
68
65
  if (status === 401) {
69
66
  }
70
67
 
71
- return Promise.reject(error);
68
+ return Promise.reject(error)
72
69
  }
73
- );
70
+ )
71
+
72
+ export default instance
73
+
74
+ /**
75
+ * 通用请求方法,支持类型推断
76
+ */
77
+ export function request<T = any>(config: Parameters<typeof instance.request>[0]) {
78
+ return instance.request<T, T>(config)
79
+ }
80
+
81
+ /**
82
+ * GET 请求,支持类型推断
83
+ */
84
+ export function get<T = any>(url: string, config?: Omit<Parameters<typeof instance.get>[1], 'url'>) {
85
+ return instance.get<T, T>(url, config)
86
+ }
74
87
 
75
- export default instance;
88
+ /**
89
+ * POST 请求,支持类型推断
90
+ */
91
+ export function post<T = any>(url: string, data?: any, config?: Omit<Parameters<typeof instance.post>[2], 'url' | 'data'>) {
92
+ return instance.post<T, T>(url, data, config)
93
+ }
@@ -138,7 +138,6 @@ export default function LiosLayout(props: LiosLayoutlProps) {
138
138
  tenantId: false,
139
139
  })
140
140
 
141
-
142
141
  useEffect(() => {
143
142
  //在这里找到当前菜单的上层目录
144
143
  const paMenu = findParentMenu(menuList, '/' + location.pathname.split('/')[2])
@@ -155,7 +154,6 @@ export default function LiosLayout(props: LiosLayoutlProps) {
155
154
  setSelectKey(selectedPath)
156
155
  }, [location.pathname])
157
156
 
158
-
159
157
  const onOpenChange: MenuProps['onOpenChange'] = (keys) => {
160
158
  // Find the last opened key
161
159
  const latestOpenKey = keys.find((key) => openKeys.indexOf(key) === -1)
@@ -239,8 +237,7 @@ export default function LiosLayout(props: LiosLayoutlProps) {
239
237
  }}
240
238
  >
241
239
  {!collapsed && <img className={`logo-base current-logo`} src={logo || logoUrl} />}
242
- {collapsed && <img className={`logo-sub`} src={subLogoUrl} />}
243
- {/* {collapsed && <img className={`logo-base sub-logo`} src={logo || subLogoUrl} />} */}
240
+ {collapsed && <img className={`logo-sub`} src={subLogo || subLogoUrl} />}
244
241
  </div>
245
242
  {!collapsed && (
246
243
  <div
@@ -1,3 +0,0 @@
1
- {
2
- "typescript.tsdk": "node_modules/typescript/lib"
3
- }