message-verify 1.0.1-beta.40 → 1.0.1-beta.43

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/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { ModalConfig, LoginModalConfig } from './utils/type.js';
1
+ import { VerifyModalConfig, LoginModalConfig } from './utils/type.js';
2
2
  export declare const initFingerprint: () => Promise<string>;
3
- export declare const createMessageVerifyModal: (modalProps: ModalConfig) => void;
4
3
  export declare const createReLoginModal: (modalProps: LoginModalConfig) => void;
5
- export declare const VerifyHandler: (modalProps: ModalConfig) => Promise<any>;
4
+ export declare const VerifyHandler: (modalProps: VerifyModalConfig) => Promise<any>;
package/dist/index.js CHANGED
@@ -25,9 +25,8 @@ export const initFingerprint = async () => {
25
25
  return fingerprintPromise;
26
26
  };
27
27
  let modalRoot = null;
28
- export const createMessageVerifyModal = (modalProps) => {
28
+ const createMessageVerifyModal = (modalProps) => {
29
29
  const container = document.createElement('div');
30
- container.id = 'antd-modal-container';
31
30
  document.body.appendChild(container);
32
31
  modalRoot = ReactDOM.createRoot(container);
33
32
  modalRoot.render(_jsx(VerifyModal, { props: {
@@ -56,7 +55,7 @@ const destroyModal = () => {
56
55
  }
57
56
  };
58
57
  export const VerifyHandler = (modalProps) => {
59
- const { data, config, http, verifyPromise } = modalProps || {};
58
+ const { data, config, http, verifyPromise, sendApi } = modalProps || {};
60
59
  const toEmpty = () => {
61
60
  verifyPromise.current = null;
62
61
  };
@@ -69,6 +68,7 @@ export const VerifyHandler = (modalProps) => {
69
68
  apiResolve: resolve,
70
69
  apiReject: reject,
71
70
  apiPromiseToEmpty: toEmpty,
71
+ sendApi
72
72
  });
73
73
  }).finally(toEmpty);
74
74
  }
package/dist/main.js CHANGED
@@ -36,9 +36,8 @@ const config = {
36
36
  "data": "{\"id\":1,\"classificationName\":\"个人基本概况信息\",\"classificationLevel\":2}",
37
37
  "baseURL": "http://localhost:62888"
38
38
  };
39
+ const promise = { current: null };
39
40
  createRoot(document.getElementById('root')).render(_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => {
40
- // const new11 = new VerifyHandler();
41
- const promise = { current: null };
42
41
  return VerifyHandler({ data, config, http: axios, verifyPromise: promise });
43
42
  }, children: "Show verify Modal" }), _jsx("button", { onClick: () => createReLoginModal({
44
43
  goLogin: () => {
@@ -1,4 +1,4 @@
1
- export type ModalConfig = {
1
+ export type VerifyModalConfig = {
2
2
  data: string;
3
3
  onClose?: () => void;
4
4
  config: {
@@ -18,7 +18,7 @@ export type ModalConfig = {
18
18
  };
19
19
  };
20
20
  };
21
- api?: string;
21
+ sendApi?: string;
22
22
  apiReject?: any;
23
23
  apiResolve?: any;
24
24
  apiPromiseToEmpty?: () => void;
@@ -1,5 +1,5 @@
1
- import { ModalConfig } from './utils/type.js';
1
+ import { VerifyModalConfig } from './utils/type.js';
2
2
  declare const CreateMessageVerifyModal: ({ props }: {
3
- props: ModalConfig;
3
+ props: VerifyModalConfig;
4
4
  }) => import("react/jsx-runtime.js").JSX.Element;
5
5
  export default CreateMessageVerifyModal;
@@ -11,7 +11,7 @@ const CreateMessageVerifyModal = ({ props }) => {
11
11
  const [captchaImage, setCaptchaImage] = useState('');
12
12
  const [captchCode, setCaptchCode] = useState('');
13
13
  const [captchaKey, setCaptchaKey] = useState('');
14
- const { data, http, lang, api = '/admin/sms/send', config, apiResolve, apiPromiseToEmpty } = props || {};
14
+ const { data, http, lang, sendApi = '/admin/sms/send', config, apiResolve, apiPromiseToEmpty } = props || {};
15
15
  const dataObj = JSON.parse(data || '{}');
16
16
  const { mobile, verifyCodeKey } = dataObj || {};
17
17
  const getKey = async () => {
@@ -51,7 +51,7 @@ const CreateMessageVerifyModal = ({ props }) => {
51
51
  formData.append('captchaKey', captchaKey);
52
52
  formData.append('captcha', captchCode);
53
53
  // 重新发送验证码
54
- const res = await axios.post(api, formData);
54
+ const res = await axios.post(sendApi, formData);
55
55
  const { code, detail } = res.data?.status || {};
56
56
  if (code !== 0) {
57
57
  message.error(detail || t('sendFailed', lang));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "message-verify",
3
- "version": "1.0.1-beta.40",
3
+ "version": "1.0.1-beta.43",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
package/src/index.tsx CHANGED
@@ -2,7 +2,7 @@ import ReactDOM from 'react-dom/client'
2
2
  import VerifyModal from './verify-modal.js'
3
3
  import Fingerprint2 from 'fingerprintjs2';
4
4
  import ReLoginModal from './relogin-modal.js';
5
- import { ModalConfig, LoginModalConfig } from './utils/type.js';
5
+ import { VerifyModalConfig, LoginModalConfig } from './utils/type.js';
6
6
 
7
7
  let fingerprintPromise: Promise<string> | null = null; // 用 Promise 本身作为缓存
8
8
 
@@ -29,9 +29,8 @@ export const initFingerprint = async (): Promise<string> => {
29
29
 
30
30
  let modalRoot: ReactDOM.Root | null = null
31
31
 
32
- export const createMessageVerifyModal = (modalProps: ModalConfig) => {
32
+ const createMessageVerifyModal = (modalProps: VerifyModalConfig) => {
33
33
  const container = document.createElement('div')
34
- container.id = 'antd-modal-container'
35
34
  document.body.appendChild(container)
36
35
 
37
36
  modalRoot = ReactDOM.createRoot(container)
@@ -72,8 +71,8 @@ const destroyModal = () => {
72
71
  }
73
72
  }
74
73
 
75
- export const VerifyHandler = (modalProps: ModalConfig): Promise<any> => {
76
- const {data, config, http, verifyPromise} = modalProps || {};
74
+ export const VerifyHandler = (modalProps: VerifyModalConfig): Promise<any> => {
75
+ const {data, config, http, verifyPromise, sendApi} = modalProps || {};
77
76
  const toEmpty = () => {
78
77
  verifyPromise.current = null;
79
78
  };
@@ -86,6 +85,7 @@ export const VerifyHandler = (modalProps: ModalConfig): Promise<any> => {
86
85
  apiResolve: resolve,
87
86
  apiReject: reject,
88
87
  apiPromiseToEmpty: toEmpty,
88
+ sendApi
89
89
  } as any);
90
90
  }).finally(toEmpty);
91
91
  }
package/src/main.tsx CHANGED
@@ -38,11 +38,11 @@ const config = {
38
38
  "data": "{\"id\":1,\"classificationName\":\"个人基本概况信息\",\"classificationLevel\":2}",
39
39
  "baseURL": "http://localhost:62888"
40
40
  };
41
+
42
+ const promise = {current: null};
41
43
  createRoot(document.getElementById('root')!).render(
42
44
  <>
43
45
  <button onClick={() => {
44
- // const new11 = new VerifyHandler();
45
- const promise = {current: null};
46
46
  return VerifyHandler({data, config, http: axios, verifyPromise: promise});
47
47
  }}>
48
48
  Show verify Modal
package/src/utils/type.ts CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- export type ModalConfig = {
2
+ export type VerifyModalConfig = {
3
3
  data: string;
4
4
  onClose?: () => void
5
5
  config: {
@@ -19,7 +19,7 @@ export type ModalConfig = {
19
19
  }
20
20
  }
21
21
  };
22
- api?: string;
22
+ sendApi?: string;
23
23
  apiReject?: any;
24
24
  apiResolve?: any;
25
25
  apiPromiseToEmpty?: () => void;
@@ -2,17 +2,17 @@ import { useEffect, useState } from 'react'
2
2
  import { Modal, Input, Button, message } from './compoments/index.js'
3
3
  import Api from './resource.js'
4
4
  import t from './utils/i18n.js'
5
- import { ModalConfig } from './utils/type.js';
5
+ import { VerifyModalConfig } from './utils/type.js';
6
6
  import { axios } from '@yqg/resource';
7
7
 
8
- const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
8
+ const CreateMessageVerifyModal = ({ props }: { props: VerifyModalConfig }) => {
9
9
  const [visible, setVisible] = useState(true);
10
10
  const [countdown, setCountdown] = useState(60);
11
11
  const [otp, setOtp] = useState('');
12
12
  const [captchaImage, setCaptchaImage] = useState<string>('');
13
13
  const [captchCode, setCaptchCode] = useState<string>('');
14
14
  const [captchaKey, setCaptchaKey] = useState<string>('');
15
- const { data, http, lang, api = '/admin/sms/send', config, apiResolve, apiPromiseToEmpty } = props || {};
15
+ const { data, http, lang, sendApi = '/admin/sms/send', config, apiResolve, apiPromiseToEmpty } = props || {};
16
16
  const dataObj = JSON.parse(data || '{}');
17
17
  const { mobile, verifyCodeKey } = dataObj || {};
18
18
 
@@ -54,7 +54,7 @@ const CreateMessageVerifyModal = ({ props }: { props: ModalConfig }) => {
54
54
  formData.append('captchaKey', captchaKey);
55
55
  formData.append('captcha', captchCode);
56
56
  // 重新发送验证码
57
- const res = await axios.post(api, formData);
57
+ const res = await axios.post(sendApi, formData);
58
58
  const { code, detail } = res.data?.status || {};
59
59
  if (code !== 0) {
60
60
  message.error(detail || t('sendFailed', lang));