message-verify 1.0.1-beta.60 → 1.0.1-beta.61

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.js CHANGED
@@ -54,24 +54,60 @@ export const createReLoginModal = (modalProps) => {
54
54
  const reLoginModalId = 'relogin-modal-container';
55
55
  creatModal(modalProps, reLoginModalId, ReLoginModal);
56
56
  };
57
+ let cachedResolve = null;
58
+ let cachedReject = null;
57
59
  export const VerifyHandler = ({ data, config, http, verifyPromise, sendApi, response }) => {
58
60
  console.log('VerifyHandler =>', response);
59
61
  const toEmpty = () => {
60
62
  verifyPromise.current = null;
63
+ cachedResolve = null;
64
+ cachedReject = null;
61
65
  };
66
+ // if (!verifyPromise.current) {
67
+ // verifyPromise.current = new Promise((resolve, reject) => {
68
+ // createMessageVerifyModal({
69
+ // data,
70
+ // config,
71
+ // http,
72
+ // apiResolve: resolve,
73
+ // apiReject: reject,
74
+ // apiPromiseToEmpty: toEmpty,
75
+ // sendApi,
76
+ // response
77
+ // } as VerifyModalConfig);
78
+ // }).finally(toEmpty);
79
+ // }
62
80
  if (!verifyPromise.current) {
63
81
  verifyPromise.current = new Promise((resolve, reject) => {
82
+ // 只缓存第一次的 resolve/reject
83
+ if (!cachedResolve)
84
+ cachedResolve = resolve;
85
+ if (!cachedReject)
86
+ cachedReject = reject;
64
87
  createMessageVerifyModal({
65
88
  data,
66
89
  config,
67
90
  http,
68
- apiResolve: resolve,
69
- apiReject: reject,
91
+ apiResolve: cachedResolve,
92
+ apiReject: cachedReject,
70
93
  apiPromiseToEmpty: toEmpty,
71
94
  sendApi,
72
95
  response
73
96
  });
74
97
  }).finally(toEmpty);
75
98
  }
99
+ else {
100
+ // 已有 modal,更新其余参数(假设 modal 支持 props 更新)
101
+ createMessageVerifyModal({
102
+ data,
103
+ config,
104
+ http,
105
+ apiResolve: cachedResolve,
106
+ apiReject: cachedReject,
107
+ apiPromiseToEmpty: toEmpty,
108
+ sendApi,
109
+ response
110
+ });
111
+ }
76
112
  return verifyPromise.current;
77
113
  };
@@ -107,6 +107,7 @@ const CreateMessageVerifyModal = ({ props }) => {
107
107
  console.warn('catch=>error', error);
108
108
  message.error(t('verifyFail', lang));
109
109
  setOtp('');
110
+ setVisible(false);
110
111
  }
111
112
  }
112
113
  } }), _jsx(Button, { disabled: countdown > 0 || !captchCode, onClick: handleResend, style: { padding: '8px' }, children: countdown > 0 ? t('countDownSecound', lang, { countdown }) : t('reSend', lang) })] }), countdown > 0 ? null :
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "message-verify",
3
- "version": "1.0.1-beta.60",
3
+ "version": "1.0.1-beta.61",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
package/src/index.tsx CHANGED
@@ -63,25 +63,57 @@ export const createReLoginModal = (modalProps: LoginModalConfig) => {
63
63
  const reLoginModalId = 'relogin-modal-container';
64
64
  creatModal(modalProps, reLoginModalId, ReLoginModal);
65
65
  }
66
-
66
+ let cachedResolve: ((value: any) => void) | null = null;
67
+ let cachedReject: ((reason?: any) => void) | null = null;
67
68
  export const VerifyHandler = ({data, config, http, verifyPromise, sendApi, response}: VerifyModalConfig): Promise<any> => {
68
69
  console.log('VerifyHandler =>', response);
69
70
  const toEmpty = () => {
70
71
  verifyPromise.current = null;
72
+ cachedResolve = null;
73
+ cachedReject = null;
71
74
  };
75
+ // if (!verifyPromise.current) {
76
+ // verifyPromise.current = new Promise((resolve, reject) => {
77
+ // createMessageVerifyModal({
78
+ // data,
79
+ // config,
80
+ // http,
81
+ // apiResolve: resolve,
82
+ // apiReject: reject,
83
+ // apiPromiseToEmpty: toEmpty,
84
+ // sendApi,
85
+ // response
86
+ // } as VerifyModalConfig);
87
+ // }).finally(toEmpty);
88
+ // }
72
89
  if (!verifyPromise.current) {
73
90
  verifyPromise.current = new Promise((resolve, reject) => {
91
+ // 只缓存第一次的 resolve/reject
92
+ if (!cachedResolve) cachedResolve = resolve;
93
+ if (!cachedReject) cachedReject = reject;
94
+ createMessageVerifyModal({
95
+ data,
96
+ config,
97
+ http,
98
+ apiResolve: cachedResolve,
99
+ apiReject: cachedReject,
100
+ apiPromiseToEmpty: toEmpty,
101
+ sendApi,
102
+ response
103
+ } as VerifyModalConfig);
104
+ }).finally(toEmpty);
105
+ } else {
106
+ // 已有 modal,更新其余参数(假设 modal 支持 props 更新)
74
107
  createMessageVerifyModal({
75
108
  data,
76
109
  config,
77
110
  http,
78
- apiResolve: resolve,
79
- apiReject: reject,
111
+ apiResolve: cachedResolve!,
112
+ apiReject: cachedReject!,
80
113
  apiPromiseToEmpty: toEmpty,
81
114
  sendApi,
82
115
  response
83
116
  } as VerifyModalConfig);
84
- }).finally(toEmpty);
85
117
  }
86
118
  return verifyPromise.current;
87
119
  };
@@ -121,6 +121,7 @@ const CreateMessageVerifyModal = ({ props }: { props: VerifyModalConfig }) => {
121
121
  console.warn('catch=>error', error);
122
122
  message.error(t('verifyFail', lang));
123
123
  setOtp('');
124
+ setVisible(false);
124
125
  }
125
126
  }
126
127
  }} />