cfel-base-components 2.6.1 → 2.6.2
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.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "cfel-base-components",
|
|
5
5
|
"main": "/src/index.tsx",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
},
|
|
16
16
|
"author": "",
|
|
17
17
|
"license": "ISC",
|
|
18
|
+
"config": {
|
|
19
|
+
"registry": "https://registry.npmjs.org/"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"registry": "https://registry.npmjs.org/"
|
|
23
|
+
},
|
|
18
24
|
"devDependencies": {
|
|
19
25
|
"@babel/cli": "^7.22.5",
|
|
20
26
|
"@babel/core": "^7.22.5",
|
package/src/apiRequest/config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosRequestHeaders } from 'axios'
|
|
2
|
-
import { notification } from 'antd'
|
|
2
|
+
import { Modal, notification } from 'antd'
|
|
3
3
|
|
|
4
4
|
let UMI_APP_BASEURL: any = window.location.origin || process.env
|
|
5
5
|
const instance = axios.create({ baseURL: UMI_APP_BASEURL })
|
|
@@ -61,7 +61,24 @@ instance.interceptors.response.use(
|
|
|
61
61
|
notification.error({
|
|
62
62
|
message: response?.data?.errorMsg || CodeMessage[status] || '服务暂不可用,请检查网络',
|
|
63
63
|
})
|
|
64
|
-
|
|
64
|
+
// 如果后端在非2xx响应中也返回了业务 errorCode,处理 PRODUCT_NOT_REGISTRY
|
|
65
|
+
const respData = response?.data || {}
|
|
66
|
+
if (respData && respData.errorCode === 'PRODUCT_NOT_REGISTRY') {
|
|
67
|
+
if (typeof (window as any).showProductNotRegisteredOverlay === 'function') {
|
|
68
|
+
;(window as any).showProductNotRegisteredOverlay({
|
|
69
|
+
onAction: () => {},
|
|
70
|
+
})
|
|
71
|
+
} else {
|
|
72
|
+
if (!(window as any).__PRODUCT_NOT_REGISTRY_SHOWN__) {
|
|
73
|
+
;(window as any).__PRODUCT_NOT_REGISTRY_SHOWN__ = true
|
|
74
|
+
Modal.warning({
|
|
75
|
+
title: '产品未开通',
|
|
76
|
+
content: '当前产品未开通或产品编码错误,请联系管理员或检查产品编码。',
|
|
77
|
+
okText: '知道了',
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
65
82
|
if (status === 401) {
|
|
66
83
|
}
|
|
67
84
|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { Button } from 'antd'
|
|
3
|
+
|
|
4
|
+
type OverlayOptions = {
|
|
5
|
+
title?: string
|
|
6
|
+
message?: string
|
|
7
|
+
actionText?: string
|
|
8
|
+
onAction?: () => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function ProductOverlay() {
|
|
12
|
+
const [visible, setVisible] = useState(false)
|
|
13
|
+
const [options, setOptions] = useState<OverlayOptions | null>(null)
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
// 挂载全局方法,供外部调用
|
|
17
|
+
;(window as any).showProductNotRegisteredOverlay = (opts?: OverlayOptions) => {
|
|
18
|
+
setOptions({
|
|
19
|
+
title: opts?.title || '产品未开通',
|
|
20
|
+
message: opts?.message || '当前产品未开通或产品编码错误,请联系管理员或检查产品编码。',
|
|
21
|
+
actionText: opts?.actionText || '关闭',
|
|
22
|
+
onAction: opts?.onAction,
|
|
23
|
+
})
|
|
24
|
+
setVisible(true)
|
|
25
|
+
}
|
|
26
|
+
;(window as any).hideProductNotRegisteredOverlay = () => {
|
|
27
|
+
setVisible(false)
|
|
28
|
+
setOptions(null)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
// 卸载全局方法
|
|
33
|
+
try {
|
|
34
|
+
delete (window as any).showProductNotRegisteredOverlay
|
|
35
|
+
delete (window as any).hideProductNotRegisteredOverlay
|
|
36
|
+
} catch (e) {}
|
|
37
|
+
}
|
|
38
|
+
}, [])
|
|
39
|
+
|
|
40
|
+
if (!visible) return null
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div
|
|
44
|
+
style={{
|
|
45
|
+
position: 'fixed',
|
|
46
|
+
left: 0,
|
|
47
|
+
top: 0,
|
|
48
|
+
right: 0,
|
|
49
|
+
bottom: 0,
|
|
50
|
+
background: 'rgba(0,0,0,0.6)',
|
|
51
|
+
zIndex: 99999,
|
|
52
|
+
display: 'flex',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
justifyContent: 'center',
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<div
|
|
58
|
+
style={{
|
|
59
|
+
width: 520,
|
|
60
|
+
background: '#fff',
|
|
61
|
+
borderRadius: 8,
|
|
62
|
+
padding: 24,
|
|
63
|
+
boxShadow: '0 4px 24px rgba(0,0,0,0.2)',
|
|
64
|
+
textAlign: 'center',
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
<h3 style={{ marginBottom: 12 }}>{options?.title}</h3>
|
|
68
|
+
<div style={{ color: '#666', marginBottom: 18 }}>{options?.message}</div>
|
|
69
|
+
<div style={{ display: 'flex', justifyContent: 'center', gap: 12 }}>
|
|
70
|
+
<Button
|
|
71
|
+
onClick={() => {
|
|
72
|
+
setVisible(false)
|
|
73
|
+
if (options?.onAction) options.onAction()
|
|
74
|
+
}}
|
|
75
|
+
type="primary"
|
|
76
|
+
>
|
|
77
|
+
{options?.actionText}
|
|
78
|
+
</Button>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
)
|
|
83
|
+
}
|