message-verify 0.0.18-beta.0 → 0.0.20-beta.0

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,9 +1,12 @@
1
+ import { getEnvironmentFingerprint } from './utils';
1
2
  interface Props {
2
3
  data: {
3
4
  mobile: string;
4
5
  verifyCodeKey: string;
5
6
  sendSuccess: boolean;
6
7
  };
8
+ refresh: () => void;
7
9
  }
8
10
  declare const App: React.FC<Props>;
9
11
  export default App;
12
+ export { getEnvironmentFingerprint };
package/dist/index.js CHANGED
@@ -2,10 +2,20 @@ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-run
2
2
  import { useEffect, useState } from 'react';
3
3
  import Modal from './components/modal';
4
4
  import Input from './components/input';
5
+ import Api from './resource';
6
+ import { getEnvironmentFingerprint } from './utils';
5
7
  const App = ({ data }) => {
6
8
  const { mobile } = data || {};
7
9
  const [countdown, setCountdown] = useState(60);
8
10
  const [visible, setVisible] = useState(false);
11
+ const [captchaImage, setCaptchaImage] = useState('');
12
+ const getKey = async () => {
13
+ const res = await Api.getCaptchaKey();
14
+ console.log('res', res);
15
+ const image = await Api.getCaptchaImage({ captchaKey: res.data.key });
16
+ console.log('image', image);
17
+ setCaptchaImage(image);
18
+ };
9
19
  useEffect(() => {
10
20
  setVisible(true);
11
21
  }, []);
@@ -16,15 +26,20 @@ const App = ({ data }) => {
16
26
  setCountdown((prev) => prev - 1);
17
27
  }, 1000);
18
28
  }
29
+ if (countdown === 0) {
30
+ getKey();
31
+ }
19
32
  return () => {
20
33
  if (timer)
21
34
  clearInterval(timer);
22
35
  };
23
36
  }, [visible, countdown]);
24
- const handleResend = () => {
25
- setCountdown(60);
26
- // 这里可以加上重新发送验证码的逻辑
27
- };
28
- return (_jsx(_Fragment, { children: _jsxs(Modal, { visible: visible, onClose: () => setVisible(false), children: [_jsxs("div", { children: ["\u5DF2\u53D1\u9001\u77ED\u4FE1\u81F3\u60A8\u7684\u624B\u673A\uFF1A", mobile] }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8 }, children: [_jsx(Input, { placeholder: "\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801" }), _jsx("button", { disabled: countdown > 0, onClick: handleResend, style: countdown > 0 ? { marginLeft: 8 } : { marginLeft: 8, backgroundColor: '#1677ff', color: '#fff' }, children: countdown > 0 ? `${countdown}秒` : '重新发送' })] })] }) }));
37
+ // const handleResend = async() => {
38
+ // setCountdown(60);
39
+ // await Api.greSendCode({ });
40
+ // // 这里可以加上重新发送验证码的逻辑
41
+ // };
42
+ return (_jsx(_Fragment, { children: _jsxs(Modal, { visible: visible, onClose: () => setVisible(false), children: [_jsxs("div", { children: ["\u5DF2\u53D1\u9001\u77ED\u4FE1\u81F3\u60A8\u7684\u624B\u673A\uFF1A", mobile] }), countdown > 0 ? null : _jsxs("div", { style: { marginTop: 8 }, children: [_jsx(Input, {}), _jsx("img", { src: captchaImage, alt: "\u9A8C\u8BC1\u7801", style: { width: 100, height: 30, marginLeft: 8 }, onClick: getKey })] }), _jsx("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }, children: _jsx(Input, { placeholder: "\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801" }) })] }) }));
29
43
  };
30
44
  export default App;
45
+ export { getEnvironmentFingerprint };
package/dist/main.js CHANGED
@@ -5,4 +5,4 @@ createRoot(document.getElementById('root')).render(_jsx(App, { data: {
5
5
  mobile: '185****7760',
6
6
  verifyCodeKey: 'e381c5f9-c7f4-4bf1-a948-744334fb0203',
7
7
  sendSuccess: true
8
- } }));
8
+ }, refresh: () => { console.log('刷新'); } }));