message-verify 1.0.0-beta.14 → 1.0.0-beta.16

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/dist/main.js CHANGED
@@ -7,7 +7,7 @@ const fp = await initFingerprint();
7
7
  console.log(fp);
8
8
  createRoot(document.getElementById('root')).render(_jsx(_Fragment, { children: _jsx("button", { onClick: () => createMessageVerifyModal({
9
9
  data,
10
- config: { headers: {} },
10
+ config: { headers: {}, interceptors: {} },
11
11
  lang: 'en',
12
12
  http: axios,
13
13
  }), children: "Show verify Modal" }) }));
@@ -5,6 +5,7 @@ export type ModalConfig = {
5
5
  headers: {
6
6
  [key: string]: string | undefined;
7
7
  };
8
+ interceptors: any;
8
9
  [key: string]: unknown;
9
10
  };
10
11
  lang: 'zh' | 'en' | 'id';
@@ -63,11 +63,10 @@ const CreateMessageVerifyModal = ({ props }) => {
63
63
  return (_jsxs(Modal, { width: 420, visible: visible, onClose: () => {
64
64
  setVisible(false);
65
65
  props.onClose?.();
66
- }, children: [_jsx("div", { style: { fontSize: 14, color: '#666' }, children: t('alreadySend', lang, { phone: mobile }) }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 12 }, children: [_jsx(Input.OTP, { length: 6, value: otp, onChange: async (val) => {
66
+ }, children: [_jsx("div", { style: { fontSize: 14, color: '#666' }, children: t('alreadySend', lang, { phone: mobile }) }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 12 }, children: [_jsx(Input.OTP, { length: 6, value: otp, onChange: (val) => {
67
67
  setOtp(val);
68
- console.log('打印Content-Type', config.headers['Content-Type']);
69
68
  if (val.length === 6) {
70
- const res = await http({
69
+ http({
71
70
  ...config,
72
71
  headers: {
73
72
  ...http.defaults.headers.common,
@@ -76,8 +75,12 @@ const CreateMessageVerifyModal = ({ props }) => {
76
75
  'Content-Type': config.headers['Content-Type'],
77
76
  }
78
77
  });
79
- console.log('接口返回值', res);
80
- // setVisible(false);
78
+ http.interceptors.response.use((response) => {
79
+ const { data: { status: { code, detail } }, config: { responseType } } = response;
80
+ console.log('打印', detail, code, responseType);
81
+ }, (error) => {
82
+ console.log('打印', error);
83
+ });
81
84
  }
82
85
  } }), _jsx(Button, { disabled: countdown > 0 || !captchCode, onClick: handleResend, style: { padding: '8px' }, children: countdown > 0 ? t('countDownSecound', lang, { countdown }) : t('reSend', lang) })] }), countdown > 0 ? null :
83
86
  _jsxs("div", { style: { marginTop: 12, display: 'flex', alignItems: 'center' }, children: [_jsx(Input, { placeholder: t('pleaseEnterPicVerifyCode', lang), onChange: (e) => {
package/eslint.config.js CHANGED
@@ -23,6 +23,7 @@ export default tseslint.config(
23
23
  'warn',
24
24
  { allowConstantExport: true },
25
25
  ],
26
+ "@typescript-eslint/no-explicit-any": "off"
26
27
  },
27
28
  },
28
29
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "message-verify",
3
- "version": "1.0.0-beta.14",
3
+ "version": "1.0.0-beta.16",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
package/src/main.tsx CHANGED
@@ -11,7 +11,7 @@ createRoot(document.getElementById('root')!).render(
11
11
  <>
12
12
  <button onClick={() => createMessageVerifyModal({
13
13
  data,
14
- config: {headers: {}},
14
+ config: {headers: {}, interceptors: {}},
15
15
  lang: 'en',
16
16
  http: axios,
17
17
  })}>
package/src/utils/type.ts CHANGED
@@ -6,6 +6,7 @@ export type ModalConfig = {
6
6
  headers: {
7
7
  [key: string]: string | undefined;
8
8
  };
9
+ interceptors: any
9
10
  [key: string]: unknown;
10
11
  };
11
12
  lang: 'zh' | 'en' | 'id';
@@ -78,11 +78,10 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
78
78
  <Input.OTP
79
79
  length={6}
80
80
  value={otp}
81
- onChange={async (val) => {
81
+ onChange={(val) => {
82
82
  setOtp(val);
83
- console.log('打印Content-Type', config.headers['Content-Type'])
84
83
  if (val.length === 6) {
85
- const res = await http({
84
+ http({
86
85
  ...config,
87
86
  headers: {
88
87
  ...http.defaults.headers.common,
@@ -91,8 +90,16 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
91
90
  'Content-Type': config.headers['Content-Type'],
92
91
  }
93
92
  });
94
- console.log('接口返回值', res);
95
- // setVisible(false);
93
+ (http as any).interceptors.response.use(
94
+ (response: { data: {status: {code: number, detail: string}}, config: {responseType: string} }) => {
95
+ const {data: {status: {code, detail}}, config: {responseType}} = response;
96
+
97
+ console.log('打印', detail, code, responseType);
98
+ },
99
+ (error: unknown) => {
100
+ console.log('打印', error);
101
+ },
102
+ );
96
103
  }
97
104
  }} />
98
105
  <Button