@pnt-team/pnt-component-frontend 0.0.72 → 0.0.74
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/README.md +51 -10
- package/lib/cjs/api/index.d.ts +15 -0
- package/lib/cjs/api/types/index.d.ts +80 -0
- package/lib/cjs/components/PntBusinessSelect/index.d.ts +191 -0
- package/lib/cjs/components/PntGeneralLayout/index.d.ts +82 -0
- package/lib/cjs/components/PntImagePreview/index.d.ts +75 -0
- package/lib/cjs/components/PntSecureBox/index.d.ts +73 -0
- package/lib/cjs/config.d.ts +36 -0
- package/lib/cjs/hooks/useHighSecurity.d.ts +22 -0
- package/lib/cjs/index.d.ts +5 -0
- package/lib/cjs/utils/const.d.ts +13 -0
- package/lib/cjs/utils/index.d.ts +6 -0
- package/lib/esm/api/index.js +13 -10
- package/lib/esm/api/types/index.js +1 -0
- package/lib/esm/components/PntBusinessSelect/index.js +250 -195
- package/lib/esm/components/PntGeneralLayout/index.js +74 -40
- package/lib/esm/components/PntImagePreview/index.js +111 -59
- package/lib/esm/components/PntSecureBox/index.js +63 -26
- package/lib/esm/config.js +33 -13
- package/lib/esm/hooks/useHighSecurity.js +29 -25
- package/lib/esm/index.js +18 -17
- package/lib/esm/utils/const.js +14 -17
- package/lib/esm/utils/index.js +15 -12
- package/package.json +1 -1
|
@@ -1,9 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
import { ArrowLeftIcon } from
|
|
3
|
-
import { Layout } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ArrowLeftIcon } from 'tdesign-icons-react';
|
|
3
|
+
import { Layout } from 'tdesign-react';
|
|
4
4
|
import "./index.scss";
|
|
5
|
-
import { jsx
|
|
6
|
-
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
/**
|
|
8
|
+
* 通用页面布局组件(L3 布局组件)
|
|
9
|
+
* @description 提供标准的「头部 + 子头部 + 内容区 + 底部」页面布局结构,
|
|
10
|
+
* 基于 TDesign Layout 封装,适用于后台管理系统的详情页、表单页等场景。
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* // 基础用法:仅内容区
|
|
15
|
+
* <PntGeneralLayout>
|
|
16
|
+
* <div>页面内容</div>
|
|
17
|
+
* </PntGeneralLayout>
|
|
18
|
+
*
|
|
19
|
+
* // 带标题和操作按钮
|
|
20
|
+
* <PntGeneralLayout
|
|
21
|
+
* headerTitle="页面标题"
|
|
22
|
+
* operation={<><Button>保存</Button><Button>取消</Button></>}
|
|
23
|
+
* >
|
|
24
|
+
* <Form />
|
|
25
|
+
* </PntGeneralLayout>
|
|
26
|
+
*
|
|
27
|
+
* // 带返回按钮和底部
|
|
28
|
+
* <PntGeneralLayout
|
|
29
|
+
* headerTitle="详情页"
|
|
30
|
+
* showBackButton
|
|
31
|
+
* onBackButtonClick={() => history.back()}
|
|
32
|
+
* footer={<><Button>提交</Button><Button>重置</Button></>}
|
|
33
|
+
* >
|
|
34
|
+
* <Detail />
|
|
35
|
+
* </PntGeneralLayout>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
const PntGeneralLayout = prop => {
|
|
7
39
|
const {
|
|
8
40
|
className,
|
|
9
41
|
headerTitle,
|
|
@@ -16,39 +48,41 @@ var PntGeneralLayout = (prop) => {
|
|
|
16
48
|
bodyStyle,
|
|
17
49
|
footer
|
|
18
50
|
} = prop;
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
const {
|
|
52
|
+
Header,
|
|
53
|
+
Footer
|
|
54
|
+
} = Layout;
|
|
55
|
+
return /*#__PURE__*/_jsxs(Layout, {
|
|
56
|
+
className: `pnt-general-layout${className ? ' ' + className : ''}`,
|
|
57
|
+
children: [headerTitle && /*#__PURE__*/_jsxs(Header, {
|
|
58
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
59
|
+
className: "header-title",
|
|
60
|
+
children: [showBackButton && /*#__PURE__*/_jsx(ArrowLeftIcon, {
|
|
61
|
+
className: "goback-icon",
|
|
62
|
+
size: "24px",
|
|
63
|
+
onClick: onBackButtonClick
|
|
64
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
65
|
+
className: "title",
|
|
66
|
+
children: headerTitle
|
|
67
|
+
})]
|
|
68
|
+
}), operation && /*#__PURE__*/_jsx("span", {
|
|
69
|
+
className: "header-operation",
|
|
70
|
+
children: operation
|
|
71
|
+
})]
|
|
72
|
+
}), subHeaderContent && /*#__PURE__*/_jsx("div", {
|
|
73
|
+
className: "general-layout-sub-header",
|
|
74
|
+
children: subHeaderContent
|
|
75
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
76
|
+
className: "general-layout-body",
|
|
77
|
+
ref: bodyRef,
|
|
78
|
+
style: {
|
|
79
|
+
height: `calc(100%${headerTitle && ' - 72px'}${footer && ' - 72px'})`,
|
|
80
|
+
...bodyStyle
|
|
81
|
+
},
|
|
82
|
+
children: children
|
|
83
|
+
}), footer && /*#__PURE__*/_jsx(Footer, {
|
|
84
|
+
children: footer
|
|
85
|
+
})]
|
|
86
|
+
});
|
|
54
87
|
};
|
|
88
|
+
export default PntGeneralLayout;
|
|
@@ -1,68 +1,120 @@
|
|
|
1
|
-
// src/components/PntImagePreview/index.tsx
|
|
2
1
|
import uploadImg from "../../assets/images/uploadImg.png";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { BrowseIcon, DeleteIcon, LoadingIcon } from 'tdesign-icons-react';
|
|
4
|
+
import { Image, ImageViewer } from 'tdesign-react';
|
|
5
5
|
import "./index.scss";
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
+
/**
|
|
10
|
+
* 上传图片查看器组件
|
|
11
|
+
* @description 用于展示上传的图片,支持预览、删除功能和上传状态显示
|
|
12
|
+
* @param {PntImagePreviewProps} props - 组件属性
|
|
13
|
+
* @param {string | undefined} props.iconUrl - 当前图片组件 URL
|
|
14
|
+
* @param {boolean} props.loading - 上传加载状态
|
|
15
|
+
* @param {string} [props.defaultImg] - 默认图片
|
|
16
|
+
* @param {object} [props.params] - 自定义扩展参数
|
|
17
|
+
* @param {function} [props.onRemove] - 删除回调函数
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* // 基础用法
|
|
22
|
+
* <UploadImageViewer
|
|
23
|
+
* iconUrl={imageUrl}
|
|
24
|
+
* loading={uploading}
|
|
25
|
+
* onRemove={handleRemove}
|
|
26
|
+
* />
|
|
27
|
+
*
|
|
28
|
+
* // 带默认图片
|
|
29
|
+
* <UploadImageViewer
|
|
30
|
+
* iconUrl={imageUrl}
|
|
31
|
+
* loading={false}
|
|
32
|
+
* defaultImg="/path/to/default.png"
|
|
33
|
+
* onRemove={handleRemove}
|
|
34
|
+
* />
|
|
35
|
+
*
|
|
36
|
+
* // 自定义样式
|
|
37
|
+
* <UploadImageViewer
|
|
38
|
+
* iconUrl={imageUrl}
|
|
39
|
+
* loading={uploading}
|
|
40
|
+
* params={{ style: { width: '200px', height: '200px' } }}
|
|
41
|
+
* onRemove={handleRemove}
|
|
42
|
+
* />
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @returns {ReactElement} 上传图片查看器组件
|
|
46
|
+
*/
|
|
47
|
+
const PntImagePreview = ({
|
|
8
48
|
iconUrl,
|
|
9
49
|
loading,
|
|
10
50
|
defaultImg,
|
|
11
51
|
params,
|
|
12
52
|
onRemove
|
|
13
53
|
}) => {
|
|
14
|
-
const src =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
const src = iconUrl?.length ? iconUrl : defaultImg || uploadImg;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 加载中组件
|
|
58
|
+
* @param isImageLoading - 是否为图片加载状态
|
|
59
|
+
* @description 统一使用一种loading效果,避免两种加载风格
|
|
60
|
+
* @returns 加载状态的 JSX 元素
|
|
61
|
+
*/
|
|
62
|
+
const LoadingContent = isImageLoading => /*#__PURE__*/_jsx("div", {
|
|
63
|
+
className: isImageLoading ? 'pnt-image-preview-progress' : 'pnt-image-preview-upload-progress',
|
|
64
|
+
style: params?.style,
|
|
65
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
66
|
+
className: "pnt-image-preview-loading",
|
|
67
|
+
children: [/*#__PURE__*/_jsx(LoadingIcon, {
|
|
68
|
+
size: "18px",
|
|
69
|
+
name: 'loading'
|
|
70
|
+
}), /*#__PURE__*/_jsx("p", {
|
|
71
|
+
children: "\u4E0A\u4F20\u4E2D"
|
|
72
|
+
})]
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
return /*#__PURE__*/_jsx("div", {
|
|
76
|
+
className: "pnt-image-preview-wrapper",
|
|
77
|
+
onClick: e => {
|
|
78
|
+
if (iconUrl?.length || loading) {
|
|
79
|
+
e.stopPropagation(); // 图片已上传 或 加载中 阻止上传行为
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
children: loading ? LoadingContent(false) : /*#__PURE__*/_jsx(ImageViewer, {
|
|
83
|
+
images: [src],
|
|
84
|
+
closeOnOverlay: true,
|
|
85
|
+
trigger: ({
|
|
86
|
+
open
|
|
87
|
+
}) => {
|
|
88
|
+
const mask = /*#__PURE__*/_jsxs("div", {
|
|
89
|
+
className: "pnt-image-preview-mask",
|
|
90
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
91
|
+
children: /*#__PURE__*/_jsx(BrowseIcon, {
|
|
92
|
+
onClick: open,
|
|
93
|
+
size: "16px",
|
|
94
|
+
name: 'browse'
|
|
95
|
+
})
|
|
96
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
97
|
+
className: "pnt-image-preview-divider"
|
|
98
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
99
|
+
children: /*#__PURE__*/_jsx(DeleteIcon, {
|
|
100
|
+
onClick: onRemove,
|
|
101
|
+
size: "16px",
|
|
102
|
+
name: 'delete'
|
|
103
|
+
})
|
|
104
|
+
})]
|
|
105
|
+
});
|
|
106
|
+
return /*#__PURE__*/_jsx(Image, {
|
|
107
|
+
alt: '',
|
|
108
|
+
src: src,
|
|
109
|
+
loading: LoadingContent(true),
|
|
110
|
+
overlayContent: iconUrl ? mask : /*#__PURE__*/_jsx(_Fragment, {}),
|
|
111
|
+
overlayTrigger: "hover",
|
|
112
|
+
fit: "contain",
|
|
113
|
+
className: "pnt-image-preview",
|
|
114
|
+
style: params?.style
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
});
|
|
68
119
|
};
|
|
120
|
+
export default PntImagePreview;
|
|
@@ -1,38 +1,75 @@
|
|
|
1
|
-
// src/components/PntSecureBox/index.tsx
|
|
2
1
|
import { useHighSecurity } from "../../hooks/useHighSecurity";
|
|
3
2
|
import { isSecurityData } from "../../utils";
|
|
3
|
+
import React from 'react';
|
|
4
4
|
import "./index.scss";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
/**
|
|
9
|
+
* 高敏信息展示统一组件
|
|
10
|
+
* @description 用于统一处理和展示高敏信息,支持脱敏显示和按需获取真实数据。
|
|
11
|
+
* 通过 PntProvider 注入 http 实例,对接 `/api/v3/business/game_info/high-security-decrypt`。
|
|
12
|
+
*
|
|
13
|
+
* @param {PntSecureBoxProps} props - 组件属性
|
|
14
|
+
* @param {string} props.dataKey - 高敏信息的唯一标识 key
|
|
15
|
+
* @param {string} props.dataValue - 高敏信息的实际值
|
|
16
|
+
* @param {string | number} props.env - 环境标识
|
|
17
|
+
* @param {string | number} props.gameId - 游戏 ID
|
|
18
|
+
* @param {(content: string) => React.ReactNode} props.renderDom - 自定义渲染函数
|
|
19
|
+
* @param {string} [props.viewText] - 自定义查看按钮文案
|
|
20
|
+
* @param {string} [props.pageId] - 页面 ID
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* import { PntSecureBox } from '@pnt-team/pnt-component-frontend';
|
|
25
|
+
*
|
|
26
|
+
* <PntSecureBox
|
|
27
|
+
* dataKey="userPhone"
|
|
28
|
+
* dataValue="_high_security_:AAAA...:6542"
|
|
29
|
+
* env={2}
|
|
30
|
+
* gameId={12345}
|
|
31
|
+
* renderDom={(content) => <span>{content}</span>}
|
|
32
|
+
* viewText="查看"
|
|
33
|
+
* />
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @returns {ReactElement} 高敏信息展示组件
|
|
37
|
+
*/
|
|
38
|
+
const PntSecureBox = prop => {
|
|
39
|
+
const {
|
|
40
|
+
dataKey,
|
|
41
|
+
dataValue,
|
|
42
|
+
env,
|
|
43
|
+
gameId,
|
|
44
|
+
renderDom,
|
|
45
|
+
viewText,
|
|
46
|
+
pageId
|
|
47
|
+
} = prop;
|
|
48
|
+
|
|
49
|
+
// 通过 PntProvider 注入的 http 实例请求高敏数据
|
|
50
|
+
const {
|
|
51
|
+
securityData,
|
|
52
|
+
requestSecurityData
|
|
53
|
+
} = useHighSecurity();
|
|
54
|
+
return /*#__PURE__*/_jsx("div", {
|
|
55
|
+
className: "pnt-secure-box",
|
|
56
|
+
children: /*#__PURE__*/_jsxs(_Fragment, {
|
|
57
|
+
children: [renderDom(isSecurityData(dataValue) ? securityData[dataKey] || '******' : dataValue), isSecurityData(dataValue) && !securityData.hasOwnProperty(dataKey) && /*#__PURE__*/_jsx("span", {
|
|
16
58
|
className: "view-icon",
|
|
17
59
|
onClick: () => {
|
|
18
60
|
requestSecurityData({
|
|
19
61
|
env,
|
|
20
62
|
gameId,
|
|
21
63
|
pageId,
|
|
22
|
-
param: [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
]
|
|
64
|
+
param: [{
|
|
65
|
+
key: dataKey,
|
|
66
|
+
value: dataValue
|
|
67
|
+
}]
|
|
28
68
|
});
|
|
29
69
|
},
|
|
30
|
-
children: viewText ||
|
|
31
|
-
}
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
var PntSecureBox_default = PntSecureBox;
|
|
36
|
-
export {
|
|
37
|
-
PntSecureBox_default as default
|
|
70
|
+
children: viewText || 'View'
|
|
71
|
+
})]
|
|
72
|
+
})
|
|
73
|
+
});
|
|
38
74
|
};
|
|
75
|
+
export default PntSecureBox;
|
package/lib/esm/config.js
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 统一响应结构(与后端 commonEesType 对齐)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 组件库运行时配置:由消费方通过 PntProvider 注入
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const PntContext = /*#__PURE__*/createContext(null);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 配置 Provider:消费方在应用根入口包裹一次即可
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* import { PntProvider } from '@pnt-team/pnt-component-frontend';
|
|
18
|
+
* import http from './utils/request';
|
|
19
|
+
*
|
|
20
|
+
* <PntProvider value={{ http }}>
|
|
21
|
+
* <App />
|
|
22
|
+
* </PntProvider>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export const PntProvider = PntContext.Provider;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 获取组件库运行时配置(内部使用)
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export const usePntConfig = () => {
|
|
6
32
|
const cfg = useContext(PntContext);
|
|
7
33
|
if (!cfg) {
|
|
8
|
-
throw new Error(
|
|
9
|
-
"[pnt-component-frontend] 未注入配置:请在应用根入口用 <PntProvider value={{ http }}> 包裹"
|
|
10
|
-
);
|
|
34
|
+
throw new Error('[pnt-component-frontend] 未注入配置:请在应用根入口用 <PntProvider value={{ http }}> 包裹');
|
|
11
35
|
}
|
|
12
36
|
return cfg;
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
PntProvider,
|
|
16
|
-
usePntConfig
|
|
17
|
-
};
|
|
37
|
+
};
|
|
@@ -1,40 +1,47 @@
|
|
|
1
|
-
// src/hooks/useHighSecurity.ts
|
|
2
1
|
import { businessGameInfoHighSecurityDecrypt } from "../api";
|
|
3
2
|
import { usePntConfig } from "../config";
|
|
4
|
-
import { useState } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
/** 高敏数据请求参数(组件层友好命名) */
|
|
6
|
+
|
|
7
|
+
const securityCache = new Map();
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 高敏数据解锁 Hook(PntSecureBox 内部依赖)
|
|
11
|
+
* @internal 不对外导出,归 PntSecureBox 组件内部使用
|
|
12
|
+
*/
|
|
13
|
+
export const useHighSecurity = () => {
|
|
14
|
+
const {
|
|
15
|
+
http
|
|
16
|
+
} = usePntConfig();
|
|
17
|
+
const [securityData, setSecurityData] = useState(() => {
|
|
18
|
+
const cached = {};
|
|
19
|
+
securityCache.forEach((value, key) => {
|
|
20
|
+
cached[key] = value;
|
|
21
|
+
});
|
|
22
|
+
return cached;
|
|
23
|
+
});
|
|
17
24
|
const requestSecurityData = async ({
|
|
18
25
|
gameId,
|
|
19
26
|
param,
|
|
20
27
|
env,
|
|
21
28
|
pageId
|
|
22
29
|
}) => {
|
|
30
|
+
// 适配后端 BusinessGameInfoHighSecurityDecryptBody 结构
|
|
23
31
|
const body = {
|
|
24
32
|
game_id: Number(gameId),
|
|
25
33
|
env: Number(env),
|
|
26
34
|
page_id: pageId || location.pathname,
|
|
27
|
-
param: param.map(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
32
|
-
)
|
|
35
|
+
param: param.map(i => ({
|
|
36
|
+
key: i.key,
|
|
37
|
+
value: i.value
|
|
38
|
+
}))
|
|
33
39
|
};
|
|
34
40
|
const result = await businessGameInfoHighSecurityDecrypt(http, body);
|
|
41
|
+
// 适配 commonEesType:code === 0 视为成功
|
|
35
42
|
if (result.code === 0 && result.data) {
|
|
36
43
|
const data = result.data;
|
|
37
|
-
data.forEach(
|
|
44
|
+
data.forEach(item => {
|
|
38
45
|
securityCache.set(item.key, item.value);
|
|
39
46
|
});
|
|
40
47
|
setSecurityData(Object.fromEntries(securityCache));
|
|
@@ -44,7 +51,4 @@ var useHighSecurity = () => {
|
|
|
44
51
|
securityData,
|
|
45
52
|
requestSecurityData
|
|
46
53
|
};
|
|
47
|
-
};
|
|
48
|
-
export {
|
|
49
|
-
useHighSecurity
|
|
50
|
-
};
|
|
54
|
+
};
|
package/lib/esm/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
// ==========================================
|
|
2
|
+
// pnt-component-frontend 统一出口
|
|
3
|
+
// 只保留业务语义组件:有视觉、有交互、有业务含义
|
|
4
|
+
// hooks / 纯工具 / API wrapper 归各项目自己维护
|
|
5
|
+
// ==========================================
|
|
6
|
+
|
|
7
|
+
// ---------- 配置 Provider(消费方根入口注入 http 实例) ----------
|
|
8
|
+
export { PntProvider, usePntConfig } from "./config";
|
|
9
|
+
|
|
10
|
+
// ---------- L1 基础展示组件 ----------
|
|
11
|
+
export { default as PntImagePreview } from "./components/PntImagePreview";
|
|
12
|
+
|
|
13
|
+
// ---------- L2 业务复合组件 ----------
|
|
14
|
+
export { default as PntBusinessSelect } from "./components/PntBusinessSelect";
|
|
15
|
+
export { default as PntSecureBox } from "./components/PntSecureBox";
|
|
16
|
+
|
|
17
|
+
// ---------- L3 布局组件 ----------
|
|
18
|
+
export { default as PntGeneralLayout } from "./components/PntGeneralLayout";
|
package/lib/esm/utils/const.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
ACCOUNT:
|
|
4
|
-
SDK:
|
|
5
|
-
NOTICE:
|
|
6
|
-
CONFIGFROM:
|
|
7
|
-
CONFIGTHEME:
|
|
8
|
-
REVIEWLIST:
|
|
9
|
-
INTERNALTOOLS:
|
|
10
|
-
REPORTS:
|
|
1
|
+
// 子系统页面的路由
|
|
2
|
+
export const SUB_APP_PATHNAME = {
|
|
3
|
+
ACCOUNT: '/laas',
|
|
4
|
+
SDK: '/intlsdk',
|
|
5
|
+
NOTICE: '/notice',
|
|
6
|
+
CONFIGFROM: '/configform',
|
|
7
|
+
CONFIGTHEME: '/configtheme',
|
|
8
|
+
REVIEWLIST: '/approvalservices',
|
|
9
|
+
INTERNALTOOLS: '/internaltools',
|
|
10
|
+
REPORTS: '/reports'
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const audienceSuffix = '-pnt';
|
|
13
|
+
// 子系统的audienceMapping
|
|
14
|
+
export const AUDIENCE_MAPPING = {
|
|
14
15
|
[SUB_APP_PATHNAME.ACCOUNT]: `/laas${audienceSuffix}`,
|
|
15
16
|
[SUB_APP_PATHNAME.SDK]: `/intl-sdk${audienceSuffix}`,
|
|
16
17
|
[SUB_APP_PATHNAME.NOTICE]: `/notice${audienceSuffix}`,
|
|
@@ -19,8 +20,4 @@ var AUDIENCE_MAPPING = {
|
|
|
19
20
|
[SUB_APP_PATHNAME.REVIEWLIST]: `/approval-services${audienceSuffix}`,
|
|
20
21
|
[SUB_APP_PATHNAME.INTERNALTOOLS]: `/internaltools${audienceSuffix}`,
|
|
21
22
|
[SUB_APP_PATHNAME.REPORTS]: `/reports${audienceSuffix}`
|
|
22
|
-
};
|
|
23
|
-
export {
|
|
24
|
-
AUDIENCE_MAPPING,
|
|
25
|
-
SUB_APP_PATHNAME
|
|
26
|
-
};
|
|
23
|
+
};
|
package/lib/esm/utils/index.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 判断是否是高敏信息逻辑
|
|
3
|
+
* @param {*} val
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
export const isSecurityData = val => {
|
|
3
7
|
const str = String(val);
|
|
4
|
-
if (!str.includes(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
+
if (!str.includes('_high_security_:')) return false;
|
|
9
|
+
|
|
10
|
+
// 符合加密条件 开始解密
|
|
11
|
+
const rsp = str.split(':');
|
|
12
|
+
const calcStr = rsp.slice(0, -1).join(':');
|
|
8
13
|
const calcNum = parseInt(rsp[rsp.length - 1], 10);
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
|
|
15
|
+
// 错误处理
|
|
16
|
+
if (isNaN(calcNum)) return false;
|
|
11
17
|
let num = 0;
|
|
12
18
|
for (const item of calcStr) {
|
|
13
19
|
num += item.charCodeAt(0);
|
|
14
20
|
}
|
|
15
21
|
return num === calcNum;
|
|
16
|
-
};
|
|
17
|
-
export {
|
|
18
|
-
isSecurityData
|
|
19
|
-
};
|
|
22
|
+
};
|