@pnt-team/pnt-component-frontend 0.0.45 → 0.0.51
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/lib/cjs/api/index.d.ts +4 -0
- package/lib/cjs/api/index.js +46 -0
- package/lib/cjs/api/types/index.d.ts +80 -0
- package/lib/cjs/api/types/index.js +17 -0
- package/lib/cjs/components/PntBusinessSelect/index.d.ts +1 -21
- package/lib/cjs/components/PntBusinessSelect/index.js +2 -3
- package/lib/cjs/components/PntSecureBox/index.d.ts +1 -23
- package/lib/cjs/components/PntSecureBox/index.js +2 -4
- package/lib/cjs/configs/host.d.ts +12 -0
- package/lib/cjs/configs/host.js +39 -0
- package/lib/cjs/configs/token.d.ts +2 -0
- package/lib/cjs/configs/token.js +25 -0
- package/lib/cjs/utils/request.d.ts +8 -0
- package/lib/cjs/utils/request.js +82 -0
- package/lib/esm/api/index.d.ts +4 -0
- package/lib/esm/api/index.js +11 -0
- package/lib/esm/api/types/index.d.ts +80 -0
- package/lib/esm/api/types/index.js +0 -0
- package/lib/esm/components/PntBusinessSelect/index.d.ts +1 -21
- package/lib/esm/components/PntBusinessSelect/index.js +2 -3
- package/lib/esm/components/PntSecureBox/index.d.ts +1 -23
- package/lib/esm/components/PntSecureBox/index.js +3 -7
- package/lib/esm/configs/host.d.ts +12 -0
- package/lib/esm/configs/host.js +19 -0
- package/lib/esm/configs/token.d.ts +2 -0
- package/lib/esm/configs/token.js +5 -0
- package/lib/esm/utils/request.d.ts +8 -0
- package/lib/esm/utils/request.js +52 -0
- package/lib/umd/pnt-component-frontend.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type HighSecurityFetcher } from "../../hooks/useHighSecurity";
|
|
2
1
|
import React, { FC } from 'react';
|
|
3
2
|
import './index.scss';
|
|
4
3
|
interface PntSecureBoxProps {
|
|
@@ -39,19 +38,11 @@ interface PntSecureBoxProps {
|
|
|
39
38
|
* @description 用于记录操作日志和权限验证
|
|
40
39
|
*/
|
|
41
40
|
pageId?: string;
|
|
42
|
-
/**
|
|
43
|
-
* 高敏数据请求函数
|
|
44
|
-
* @description 不传时使用组件库内置的 `businessGameInfoHighSecurityDecrypt` API
|
|
45
|
-
* (对接 `/api/v3/business/game_info/high-security-decrypt`);
|
|
46
|
-
* 需要覆盖时传入自定义请求函数(如各项目自己的 http 封装)
|
|
47
|
-
*/
|
|
48
|
-
fetcher?: HighSecurityFetcher;
|
|
49
41
|
}
|
|
50
42
|
/**
|
|
51
43
|
* 高敏信息展示统一组件
|
|
52
44
|
* @description 用于统一处理和展示高敏信息,支持脱敏显示和按需获取真实数据。
|
|
53
|
-
*
|
|
54
|
-
* 各项目如需覆盖请求逻辑,传入自定义 `fetcher` 即可。
|
|
45
|
+
* 内置对接组件库 `businessGameInfoHighSecurityDecrypt` API(`/api/v3/business/game_info/high-security-decrypt`)。
|
|
55
46
|
*
|
|
56
47
|
* @param {PntSecureBoxProps} props - 组件属性
|
|
57
48
|
* @param {string} props.dataKey - 高敏信息的唯一标识 key
|
|
@@ -61,13 +52,11 @@ interface PntSecureBoxProps {
|
|
|
61
52
|
* @param {(content: string) => React.ReactNode} props.renderDom - 自定义渲染函数
|
|
62
53
|
* @param {string} [props.viewText] - 自定义查看按钮文案
|
|
63
54
|
* @param {string} [props.pageId] - 页面 ID
|
|
64
|
-
* @param {HighSecurityFetcher} [props.fetcher] - 高敏数据请求函数(可选,不传用内置 API)
|
|
65
55
|
*
|
|
66
56
|
* @example
|
|
67
57
|
* ```tsx
|
|
68
58
|
* import { PntSecureBox } from '@pnt-team/pnt-component-frontend';
|
|
69
59
|
*
|
|
70
|
-
* // 最简用法(内置 API,无需传 fetcher)
|
|
71
60
|
* <PntSecureBox
|
|
72
61
|
* dataKey="userPhone"
|
|
73
62
|
* dataValue="_high_security_:AAAA...:6542"
|
|
@@ -76,17 +65,6 @@ interface PntSecureBoxProps {
|
|
|
76
65
|
* renderDom={(content) => <span>{content}</span>}
|
|
77
66
|
* viewText="查看"
|
|
78
67
|
* />
|
|
79
|
-
*
|
|
80
|
-
* // 注入自定义 fetcher(覆盖内置 API)
|
|
81
|
-
* import http from '@/utils/request';
|
|
82
|
-
* <PntSecureBox
|
|
83
|
-
* dataKey="userPhone"
|
|
84
|
-
* dataValue="_high_security_:AAAA...:6542"
|
|
85
|
-
* env={2}
|
|
86
|
-
* gameId={12345}
|
|
87
|
-
* fetcher={(params) => http.post('/api/v3/business/game_info/high-security-decrypt', params)}
|
|
88
|
-
* renderDom={(content) => <span>{content}</span>}
|
|
89
|
-
* />
|
|
90
68
|
* ```
|
|
91
69
|
*
|
|
92
70
|
* @returns {ReactElement} 高敏信息展示组件
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// src/components/PntSecureBox/index.tsx
|
|
2
2
|
import { businessGameInfoHighSecurityDecrypt } from "../../api";
|
|
3
|
-
import {
|
|
4
|
-
useHighSecurity
|
|
5
|
-
} from "../../hooks/useHighSecurity";
|
|
3
|
+
import { useHighSecurity } from "../../hooks/useHighSecurity";
|
|
6
4
|
import { isSecurityData } from "../../utils";
|
|
7
5
|
import "./index.scss";
|
|
8
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -14,11 +12,9 @@ var PntSecureBox = (prop) => {
|
|
|
14
12
|
gameId,
|
|
15
13
|
renderDom,
|
|
16
14
|
viewText,
|
|
17
|
-
pageId
|
|
18
|
-
fetcher
|
|
15
|
+
pageId
|
|
19
16
|
} = prop;
|
|
20
|
-
const
|
|
21
|
-
const { securityData, requestSecurityData } = useHighSecurity(requestFn);
|
|
17
|
+
const { securityData, requestSecurityData } = useHighSecurity(businessGameInfoHighSecurityDecrypt);
|
|
22
18
|
return /* @__PURE__ */ jsx("div", { className: "pnt-secure-box", children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
23
19
|
renderDom(
|
|
24
20
|
isSecurityData(dataValue) ? securityData[dataKey] || "******" : dataValue
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/configs/host.ts
|
|
2
|
+
var host_default = {
|
|
3
|
+
development: {
|
|
4
|
+
// 开发环境接口请求
|
|
5
|
+
API: "/api"
|
|
6
|
+
},
|
|
7
|
+
test: {
|
|
8
|
+
// 测试环境接口地址
|
|
9
|
+
API: "http://43.134.150.67"
|
|
10
|
+
},
|
|
11
|
+
production: {
|
|
12
|
+
// 正式环境接口地址
|
|
13
|
+
API: "http://43.134.150.67"
|
|
14
|
+
// 任意ip即可, pnt主应用会自动替换,
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
host_default as default
|
|
19
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOiJ1cy0xMDRmZTliNDZmZGY0NTM0YmU2NjNlYzllYWE5ZWEyZSIsImFjY291bnROYW1lIjoidl9id3dlaXdhbmciLCJleHAiOjE3ODkwNTIzODEsImV4cFRva2VuIjoxNzg5MDUxNTgxLCJqdGkiOiJjM2M3NDFiZC0wYzUwLTRlMGQtODUyNy1lMTFhMjljNTk0OGEifQ.9pXGqQeActEb2GOnrKQCkOgfyiUb2B8-uD3colfArdM";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// src/configs/token.ts
|
|
2
|
+
var token_default = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOiJ1cy0xMDRmZTliNDZmZGY0NTM0YmU2NjNlYzllYWE5ZWEyZSIsImFjY291bnROYW1lIjoidl9id3dlaXdhbmciLCJleHAiOjE3ODkwNTIzODEsImV4cFRva2VuIjoxNzg5MDUxNTgxLCJqdGkiOiJjM2M3NDFiZC0wYzUwLTRlMGQtODUyNy1lMTFhMjljNTk0OGEifQ.9pXGqQeActEb2GOnrKQCkOgfyiUb2B8-uD3colfArdM";
|
|
3
|
+
export {
|
|
4
|
+
token_default as default
|
|
5
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/utils/request.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import host from "../configs/host";
|
|
4
|
+
import TOKEN from "../configs/token";
|
|
5
|
+
import { AUDIENCE_MAPPING, SUB_APP_PATHNAME } from "./const";
|
|
6
|
+
var env = process.env.MODE || "development";
|
|
7
|
+
var API_HOST = host[env].API;
|
|
8
|
+
var http = axios.create({
|
|
9
|
+
baseURL: API_HOST,
|
|
10
|
+
timeout: 100 * 1e3,
|
|
11
|
+
withCredentials: true
|
|
12
|
+
});
|
|
13
|
+
http.interceptors.request.use(
|
|
14
|
+
(config) => {
|
|
15
|
+
var _a;
|
|
16
|
+
const conf = { ...config };
|
|
17
|
+
const matchPath = Object.values(SUB_APP_PATHNAME).filter(
|
|
18
|
+
(path) => window.location.pathname.includes(path)
|
|
19
|
+
)[0] || "";
|
|
20
|
+
if (true) {
|
|
21
|
+
conf.baseURL = matchPath ? "/subapi" : conf.baseURL;
|
|
22
|
+
conf.headers["X-Service-Type"] = ((_a = conf.headers) == null ? void 0 : _a["x-service-type"]) || "11";
|
|
23
|
+
conf.headers["X-User-Id"] = "us-104fe9b46fdf4534be663ec9eaa9ea2e";
|
|
24
|
+
conf.headers["X-User-Name"] = "v_bwweiwang";
|
|
25
|
+
conf.headers.authorization = TOKEN;
|
|
26
|
+
} else {
|
|
27
|
+
conf.baseURL = "/";
|
|
28
|
+
}
|
|
29
|
+
if (!conf.url.includes("audience=")) {
|
|
30
|
+
conf.url = `${conf.url}?audience=${matchPath ? AUDIENCE_MAPPING[matchPath] : "/player-network"}`;
|
|
31
|
+
}
|
|
32
|
+
return conf;
|
|
33
|
+
},
|
|
34
|
+
(err) => Promise.reject(err)
|
|
35
|
+
);
|
|
36
|
+
http.interceptors.response.use(
|
|
37
|
+
(response) => {
|
|
38
|
+
if (response.status === 200) {
|
|
39
|
+
const { data } = response;
|
|
40
|
+
if (data.code === 0) {
|
|
41
|
+
return Promise.resolve(data);
|
|
42
|
+
}
|
|
43
|
+
return Promise.resolve(data);
|
|
44
|
+
}
|
|
45
|
+
return Promise.reject(response == null ? void 0 : response.data);
|
|
46
|
+
},
|
|
47
|
+
(e) => Promise.reject(e)
|
|
48
|
+
);
|
|
49
|
+
var request_default = http;
|
|
50
|
+
export {
|
|
51
|
+
request_default as default
|
|
52
|
+
};
|