message-verify 0.0.23-beta.0 → 0.0.25-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/app.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import '@ant-design/v5-patch-for-react-19';
2
+ interface Props {
3
+ data: {
4
+ mobile: string;
5
+ verifyCodeKey: string;
6
+ sendSuccess: boolean;
7
+ };
8
+ refresh: () => void;
9
+ }
10
+ declare const App: React.FC<Props>;
11
+ export default App;
package/dist/app.js ADDED
@@ -0,0 +1,53 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { Input, Button, Modal, message } from 'antd';
4
+ import Api from './resource.js';
5
+ import '@ant-design/v5-patch-for-react-19';
6
+ const App = ({ data }) => {
7
+ const { mobile } = data || {};
8
+ const [countdown, setCountdown] = useState(3);
9
+ const [visible, setVisible] = useState(false);
10
+ const [captchaImage, setCaptchaImage] = useState('');
11
+ const [captchCode, setCaptchCode] = useState('');
12
+ const [captchaKey, setCaptchaKey] = useState('');
13
+ const getKey = async () => {
14
+ const res = await Api.getCaptchaKey();
15
+ const { body: key } = res.data || {};
16
+ setCaptchaKey(key);
17
+ if (key) {
18
+ console.log('res=>key', key);
19
+ const image = Api.getCaptchaImgUrl(key);
20
+ console.log('image', image);
21
+ setCaptchaImage(image);
22
+ }
23
+ };
24
+ useEffect(() => {
25
+ setVisible(true);
26
+ }, []);
27
+ useEffect(() => {
28
+ let timer = null;
29
+ if (visible && countdown > 0) {
30
+ timer = setInterval(() => {
31
+ setCountdown((prev) => prev - 1);
32
+ }, 1000);
33
+ }
34
+ if (countdown === 0) {
35
+ getKey();
36
+ }
37
+ return () => {
38
+ if (timer)
39
+ clearInterval(timer);
40
+ };
41
+ }, [visible, countdown]);
42
+ const handleResend = async () => {
43
+ setCountdown(60);
44
+ const res = await Api.reSendCode({ captchaKey, captcha: captchCode });
45
+ console.log('handleResend=>res', res);
46
+ message.success('发送成功');
47
+ };
48
+ console.log('captchCode', captchCode);
49
+ return (_jsxs(Modal, { open: visible, onClose: () => setVisible(false), width: 400, footer: _jsx(Button, { onClick: () => { }, children: "\u63D0\u4EA4" }), children: [_jsxs("div", { children: ["\u5DF2\u53D1\u9001\u77ED\u4FE1\u81F3\u60A8\u7684\u624B\u673A\uFF1A", mobile] }), countdown > 0 ? null : _jsxs("div", { style: { marginTop: 8, display: 'flex', alignItems: 'center', width: 300 }, children: [_jsx(Input, { onChange: (e) => {
50
+ setCaptchCode(e.target.value);
51
+ } }), captchaImage && _jsx("img", { src: captchaImage, alt: "\u9A8C\u8BC1\u7801", style: { width: 100, height: 30, marginLeft: 8 }, onClick: getKey })] }), countdown > 0 ? null : _jsx("div", { children: "\u8BF7\u8F93\u5165\u56FE\u5F62\u9A8C\u8BC1\u7801\u540E\uFF0C\u91CD\u65B0\u53D1\u9001\u9A8C\u8BC1\u7801" }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }, children: [_jsx(Input.OTP, { disabled: !captchCode, length: 6, onChange: (val) => { console.log('change', val); } }), _jsx(Button, { disabled: countdown > 0 || !captchCode, onClick: handleResend, children: countdown > 0 ? `${countdown}秒` : '重新发送' })] })] }));
52
+ };
53
+ export default App;
package/dist/index.d.ts CHANGED
@@ -6,5 +6,5 @@ interface Props {
6
6
  };
7
7
  refresh: () => void;
8
8
  }
9
- declare const App: React.FC<Props>;
10
- export default App;
9
+ export declare function createMessageVerify(props: Props): import("react/jsx-runtime").JSX.Element;
10
+ export {};
package/dist/index.js CHANGED
@@ -1,54 +1,5 @@
1
- import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useEffect, useState } from 'react';
3
- // import Modal from './components/modal'
4
- // import Input from './components/input'
5
- import { Input, Button, Modal } from 'antd';
6
- import Api from './resource';
7
- import { getEnvironmentFingerprint } from './utils';
8
- const App = ({ data }) => {
9
- const { mobile } = data || {};
10
- const [countdown, setCountdown] = useState(60);
11
- const [visible, setVisible] = useState(false);
12
- const [captchaImage, setCaptchaImage] = useState('');
13
- const getKey = async () => {
14
- const res = await Api.getCaptchaKey();
15
- console.log('res', res);
16
- const image = await Api.getCaptchaImage({ captchaKey: res.data.key });
17
- console.log('image', image);
18
- setCaptchaImage(image);
19
- };
20
- // const retryModal = async(config, http) =>{
21
- // console.log('retryModal=>config', config);
22
- // config.headers['sms-code'] = 'new-value';
23
- // // 3. 重新发起请求
24
- // await http(config);
25
- // // console.log('response', response);
26
- // };
27
- useEffect(() => {
28
- setVisible(true);
29
- getEnvironmentFingerprint();
30
- }, []);
31
- useEffect(() => {
32
- let timer = null;
33
- if (visible && countdown > 0) {
34
- timer = setInterval(() => {
35
- setCountdown((prev) => prev - 1);
36
- }, 1000);
37
- }
38
- if (countdown === 0) {
39
- getKey();
40
- }
41
- return () => {
42
- if (timer)
43
- clearInterval(timer);
44
- };
45
- }, [visible, countdown]);
46
- const handleResend = async () => {
47
- setCountdown(60);
48
- // retryModal()
49
- };
50
- return (_jsx(_Fragment, { children: _jsxs(Modal, { open: visible, onClose: () => setVisible(false),
51
- // cancelButtonProps={false}
52
- okText: '提交', cancelText: false, children: [_jsxs("div", { children: ["\u5DF2\u53D1\u9001\u77ED\u4FE1\u81F3\u60A8\u7684\u624B\u673A\uFF1A", mobile] }), _jsxs("div", { style: { marginTop: 8, display: 'flex', alignItems: 'center', width: 300 }, children: [_jsx(Input, { disabled: countdown > 0 }), _jsx("img", { src: captchaImage, alt: "\u9A8C\u8BC1\u7801", style: { width: 100, height: 30, marginLeft: 8 }, onClick: getKey })] }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }, children: [_jsx(Input.OTP, { length: 6, onChange: (val) => { console.log('change', val); } }), _jsx(Button, { disabled: countdown > 0, onClick: handleResend, style: countdown > 0 ? { marginLeft: 8 } : { marginLeft: 8, backgroundColor: '#1677ff', color: '#fff' }, children: countdown > 0 ? `${countdown}秒` : '重新发送' })] })] }) }));
53
- };
54
- export default App;
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import App from './app';
3
+ export function createMessageVerify(props) {
4
+ return _jsx(App, { ...props });
5
+ }
package/dist/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createRoot } from 'react-dom/client';
3
- import App from './index'; // 或 './index'
3
+ import App from './app.js'; // 或 './index'
4
4
  createRoot(document.getElementById('root')).render(_jsx(App, { data: {
5
5
  mobile: '185****7760',
6
6
  verifyCodeKey: 'e381c5f9-c7f4-4bf1-a948-744334fb0203',
package/dist/resource.js CHANGED
@@ -1,9 +1,47 @@
1
- import { assign, customGet, customPost } from '@yqg/resource';
1
+ import { assign, axios as instance, customPost } from '@yqg/resource';
2
2
  const urlPrefix = '/admin/';
3
+ import { message } from 'antd';
4
+ import { YQG_SUCCESS } from './utils/status';
5
+ // axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
6
+ instance.interceptors.response.use((res) => {
7
+ const { status } = res?.data || {};
8
+ const { code, detail } = status || {};
9
+ if (res?.config?.responseType === 'blob') {
10
+ if (res?.data?.type === 'application/json') {
11
+ // 没有拿到文件时,将拿到的 blob 流转为 js 对象,进而拿到错误信息(detail)并返回 reject 状态
12
+ // 不处理将默认下载一个 json 文件
13
+ const reader = new FileReader();
14
+ reader.readAsText(res.data, 'utf-8');
15
+ reader.onload = () => {
16
+ const parsedObj = JSON.parse(reader.result);
17
+ message.info(parsedObj?.status?.detail);
18
+ };
19
+ return Promise.reject();
20
+ }
21
+ else {
22
+ return res;
23
+ }
24
+ }
25
+ if (res.headers && res.headers['content-type'] === 'image/jpeg') {
26
+ return res;
27
+ }
28
+ switch (code) {
29
+ case YQG_SUCCESS:
30
+ return Promise.resolve(res);
31
+ default: {
32
+ message.error(detail);
33
+ return Promise.reject(res);
34
+ }
35
+ }
36
+ }, (err) => {
37
+ const detail = err?.data?.status?.detail || 'Unknown error';
38
+ message.error(detail);
39
+ return Promise.reject(err);
40
+ });
3
41
  const api = {
4
42
  urlPrefix,
5
43
  getCaptchaKey: customPost('captcha/key'),
6
44
  reSendCode: customPost('sms/send'),
7
- getCaptchaImgUrl: customGet('captcha/image/:captchaKey'),
45
+ getCaptchaImgUrl: (captchaKey) => { return `/admin/captcha/image/${captchaKey}`; },
8
46
  };
9
47
  export default assign(api);
@@ -1 +1 @@
1
- {"root":["../src/index.tsx","../src/main.tsx","../src/resource.ts","../src/vite-env.d.ts","../src/components/input.tsx","../src/components/modal.tsx","../src/utils/getfingerprint.ts","../src/utils/index.ts"],"version":"5.7.3"}
1
+ {"root":["../src/app.tsx","../src/index.tsx","../src/main.tsx","../src/resource.ts","../src/vite-env.d.ts","../src/utils/getfingerprint.ts","../src/utils/index.ts","../src/utils/status.ts"],"version":"5.7.3"}
@@ -0,0 +1,2 @@
1
+ export declare const YQG_SUCCESS = 0;
2
+ export declare const YQG_REVERIFY = 200031;
@@ -0,0 +1,2 @@
1
+ export const YQG_SUCCESS = 0;
2
+ export const YQG_REVERIFY = 200031;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "message-verify",
3
- "version": "0.0.23-beta.0",
3
+ "version": "0.0.25-beta.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
7
+ "@ant-design/v5-patch-for-react-19": "^1.0.3",
7
8
  "@fingerprintjs/fingerprintjs": "^4.6.2",
8
9
  "@yqg/resource": "^1.3.8",
9
10
  "antd": "^5.24.8",
package/src/app.tsx ADDED
@@ -0,0 +1,98 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { Input, Button, Modal, message } from 'antd';
3
+ import Api from './resource.js'
4
+ import '@ant-design/v5-patch-for-react-19';
5
+
6
+ interface Props {
7
+ data: {
8
+ mobile: string;
9
+ verifyCodeKey: string;
10
+ sendSuccess: boolean;
11
+ };
12
+ refresh: () => void;
13
+ }
14
+ const App: React.FC<Props> = ({ data }) => {
15
+ const { mobile } = data || {};
16
+ const [countdown, setCountdown] = useState(3);
17
+ const [visible, setVisible] = useState(false);
18
+ const [captchaImage, setCaptchaImage] = useState<string>('');
19
+ const [captchCode, setCaptchCode] = useState<string>('');
20
+ const [captchaKey, setCaptchaKey] = useState<string>('');
21
+
22
+ const getKey = async () => {
23
+ const res = await Api.getCaptchaKey();
24
+ const { body: key } = res.data || {};
25
+ setCaptchaKey(key);
26
+ if(key) {
27
+ console.log('res=>key', key);
28
+ const image = Api.getCaptchaImgUrl(key) as unknown;
29
+ console.log('image', image);
30
+ setCaptchaImage(image as string);
31
+ }
32
+ }
33
+
34
+ useEffect(() => {
35
+ setVisible(true);
36
+ }, [])
37
+
38
+ useEffect(() => {
39
+ let timer: number | null = null;
40
+ if (visible && countdown > 0) {
41
+ timer = setInterval(() => {
42
+ setCountdown((prev) => prev - 1);
43
+ }, 1000);
44
+ }
45
+ if (countdown === 0) {
46
+ getKey();
47
+ }
48
+ return () => {
49
+ if (timer) clearInterval(timer);
50
+ };
51
+ }, [visible, countdown]);
52
+
53
+ const handleResend = async() => {
54
+ setCountdown(60);
55
+ const res = await Api.reSendCode({captchaKey, captcha: captchCode});
56
+ console.log('handleResend=>res', res);
57
+ message.success('发送成功');
58
+ }
59
+
60
+ console.log('captchCode', captchCode);
61
+ return (
62
+ <Modal
63
+ open={visible}
64
+ onClose={() => setVisible(false)}
65
+ width={400}
66
+ footer={
67
+ <Button onClick={() => {/* 提交逻辑 */}}>
68
+ 提交
69
+ </Button>
70
+ }
71
+ >
72
+ <div>已发送短信至您的手机:{mobile}</div>
73
+ {countdown > 0 ? null : <div style={{ marginTop: 8, display: 'flex', alignItems: 'center', width: 300 }}>
74
+ <Input onChange={(e) => {
75
+ setCaptchCode(e.target.value as string)
76
+ }} />
77
+
78
+ {captchaImage && <img src={captchaImage} alt="验证码" style={{ width: 100, height: 30, marginLeft: 8 }} onClick={getKey} />}
79
+ </div>}
80
+ {countdown > 0 ? null : <div>请输入图形验证码后,重新发送验证码</div>}
81
+ <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }}>
82
+ <Input.OTP
83
+ disabled={!captchCode}
84
+ length={6}
85
+ onChange={(val) => {console.log('change', val)}}
86
+ />
87
+ <Button
88
+ disabled={countdown > 0 || !captchCode}
89
+ onClick={handleResend}
90
+ >
91
+ {countdown > 0 ? `${countdown}秒` : '重新发送'}
92
+ </Button>
93
+ </div>
94
+ </Modal>
95
+ )
96
+ }
97
+
98
+ export default App;
package/src/index.tsx CHANGED
@@ -1,18 +1,4 @@
1
- import { useEffect, useState } from 'react'
2
- // import Modal from './components/modal'
3
- // import Input from './components/input'
4
- import { Input, Button, Modal } from 'antd';
5
- import Api from './resource'
6
- import { getEnvironmentFingerprint } from './utils'
7
- // import Button from './components/button'
8
-
9
- // const buttonStyle: React.CSSProperties = {
10
- // padding: '8px 16px',
11
- // border: 'none',
12
- // borderRadius: 4,
13
- // fontSize: 14,
14
- // cursor: 'pointer',
15
- // };
1
+ import App from './app';
16
2
 
17
3
  interface Props {
18
4
  data: {
@@ -21,84 +7,8 @@ interface Props {
21
7
  sendSuccess: boolean;
22
8
  };
23
9
  refresh: () => void;
24
- // axios: any;
25
- }
26
- const App: React.FC<Props> = ({ data }) => {
27
- const { mobile } = data || {};
28
- const [countdown, setCountdown] = useState(60);
29
- const [visible, setVisible] = useState(false);
30
- const [captchaImage, setCaptchaImage] = useState('');
31
-
32
- const getKey = async () => {
33
- const res = await Api.getCaptchaKey();
34
- console.log('res', res);
35
- const image = await Api.getCaptchaImage({ captchaKey: res.data.key });
36
- console.log('image', image);
37
- setCaptchaImage(image);
38
- }
39
-
40
- // const retryModal = async(config, http) =>{
41
- // console.log('retryModal=>config', config);
42
- // config.headers['sms-code'] = 'new-value';
43
-
44
- // // 3. 重新发起请求
45
- // await http(config);
46
- // // console.log('response', response);
47
- // };
48
-
49
- useEffect(() => {
50
- setVisible(true);
51
- getEnvironmentFingerprint();
52
- }, [])
53
-
54
- useEffect(() => {
55
- let timer: number | null = null;
56
- if (visible && countdown > 0) {
57
- timer = setInterval(() => {
58
- setCountdown((prev) => prev - 1);
59
- }, 1000);
60
- }
61
- if (countdown === 0) {
62
- getKey();
63
- }
64
- return () => {
65
- if (timer) clearInterval(timer);
66
- };
67
- }, [visible, countdown]);
68
-
69
- const handleResend = async() => {
70
- setCountdown(60);
71
- // retryModal()
72
- }
73
-
74
- return (
75
- <>
76
- <Modal
77
- open={visible}
78
- onClose={() => setVisible(false)}
79
- // cancelButtonProps={false}
80
- okText={'提交'}
81
- cancelText={false}
82
- // onOk={() => refresh()}
83
- >
84
- <div>已发送短信至您的手机:{mobile}</div>
85
- <div style={{ marginTop: 8, display: 'flex', alignItems: 'center', width: 300 }}>
86
- <Input disabled={countdown > 0} />
87
- <img src={captchaImage} alt="验证码" style={{ width: 100, height: 30, marginLeft: 8 }} onClick={getKey} />
88
- </div>
89
- <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }}>
90
- {/* <Input placeholder="请输入验证码" onChange={(val) => {console.log('change', val)}} /> */}
91
- <Input.OTP length={6} onChange={(val) => {console.log('change', val)}} />
92
- <Button
93
- disabled={countdown > 0}
94
- onClick={handleResend}
95
- style={countdown > 0 ? { marginLeft: 8 } : { marginLeft: 8, backgroundColor: '#1677ff', color: '#fff' }}
96
- // btnText={countdown > 0 ? `${countdown}秒` : '重新发送'}
97
- >{countdown > 0 ? `${countdown}秒` : '重新发送'}</Button>
98
- </div>
99
- </Modal>
100
- </>
101
- )
102
10
  }
103
11
 
104
- export default App;
12
+ export function createMessageVerify(props: Props) {
13
+ return <App {...props} />;
14
+ }
package/src/main.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRoot } from 'react-dom/client';
2
- import App from './index'; // 或 './index'
2
+ import App from './app.js'; // 或 './index'
3
3
 
4
4
  createRoot(document.getElementById('root')!).render(
5
5
  <App
package/src/resource.ts CHANGED
@@ -1,12 +1,56 @@
1
- import { assign, customGet, customPost } from '@yqg/resource';
1
+ import { assign, axios as instance, customPost } from '@yqg/resource';
2
2
  const urlPrefix = '/admin/';
3
+ import { message } from 'antd';
4
+ import { YQG_SUCCESS } from './utils/status';
3
5
 
6
+ // axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
7
+ instance.interceptors.response.use(
8
+ (res) => {
9
+ const { status } = res?.data || {};
10
+ const { code, detail } = status || {};
11
+ if (res?.config?.responseType === 'blob') {
12
+ if (res?.data?.type === 'application/json') {
13
+ // 没有拿到文件时,将拿到的 blob 流转为 js 对象,进而拿到错误信息(detail)并返回 reject 状态
14
+ // 不处理将默认下载一个 json 文件
15
+ const reader = new FileReader();
16
+ reader.readAsText(res.data, 'utf-8');
17
+ reader.onload = () => {
18
+ const parsedObj = JSON.parse(reader.result as string);
19
+ message.info(parsedObj?.status?.detail);
20
+ };
21
+
22
+ return Promise.reject();
23
+ } else {
24
+ return res;
25
+ }
26
+ }
27
+
28
+ if (res.headers && res.headers['content-type'] === 'image/jpeg') {
29
+ return res;
30
+ }
31
+
32
+ switch (code) {
33
+ case YQG_SUCCESS:
34
+ return Promise.resolve(res);
35
+ default: {
36
+ message.error(detail);
37
+ return Promise.reject(res);
38
+ }
39
+ }
40
+ },
41
+ (err: {data: {status: {detail: string}}}) => {
42
+ const detail = err?.data?.status?.detail || 'Unknown error';
43
+ message.error(detail);
44
+
45
+ return Promise.reject(err);
46
+ },
47
+ );
4
48
  const api = {
5
49
  urlPrefix,
6
50
 
7
51
  getCaptchaKey: customPost('captcha/key'),
8
52
  reSendCode: customPost('sms/send'),
9
- getCaptchaImgUrl: customGet('captcha/image/:captchaKey'),
53
+ getCaptchaImgUrl: (captchaKey: string) => {return `/admin/captcha/image/${captchaKey}`},
10
54
  };
11
55
 
12
56
  export default assign(api);
@@ -0,0 +1,2 @@
1
+ export const YQG_SUCCESS = 0;
2
+ export const YQG_REVERIFY = 200031;
package/vite.config.ts CHANGED
@@ -11,7 +11,11 @@ export default defineConfig({
11
11
  '/admin': {
12
12
  target: 'https://chidori-admin-test.yangqianguan.com',
13
13
  changeOrigin: true,
14
- secure: false,
14
+ headers: {
15
+ host: 'chidori-admin-test.yangqianguan.com', // 和转发url一样 host不带协议头 origin带上
16
+ origin: 'http://chidori-admin-test.yangqianguan.com'
17
+ },
18
+
15
19
  },
16
20
  },
17
21
  },
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
-
3
- interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
4
- placeholder?: string;
5
- }
6
-
7
- const inputStyle: React.CSSProperties = {
8
- padding: '8px 12px',
9
- border: '1px solid #ccc',
10
- borderRadius: 4,
11
- fontSize: 16,
12
- outline: 'none',
13
- transition: 'border-color 0.2s',
14
- };
15
-
16
- const Input: React.FC<InputProps> = (props) => {
17
- const { placeholder = '请输入' } = props;
18
- return (
19
- <input
20
- style={inputStyle}
21
- placeholder={placeholder}
22
- {...props}
23
- onFocus={e => {
24
- props.onFocus?.(e);
25
- (e.target as HTMLInputElement).style.borderColor = '#1677ff';
26
- }}
27
- onBlur={e => {
28
- props.onBlur?.(e);
29
- (e.target as HTMLInputElement).style.borderColor = '#ccc';
30
- }}
31
- />
32
- );
33
- };
34
-
35
- export default Input;
@@ -1,60 +0,0 @@
1
- import React from 'react';
2
-
3
- interface ModalProps {
4
- visible: boolean;
5
- onClose: () => void;
6
- children: React.ReactNode;
7
- }
8
-
9
- const modalStyle: React.CSSProperties = {
10
- position: 'fixed',
11
- top: 0,
12
- left: 0,
13
- width: '100vw',
14
- height: '100vh',
15
- background: 'rgba(0,0,0,0.3)',
16
- display: 'flex',
17
- alignItems: 'center',
18
- justifyContent: 'center',
19
- zIndex: 1000,
20
- };
21
-
22
- const contentStyle: React.CSSProperties = {
23
- position: 'relative',
24
- background: '#fff',
25
- borderRadius: 8,
26
- padding: 24,
27
- minWidth: 320,
28
- minHeight: 120,
29
- boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
30
- };
31
-
32
- const closeBtnStyle: React.CSSProperties = {
33
- position: 'absolute',
34
- top: 12,
35
- right: 12,
36
- width: 24,
37
- height: 24,
38
- border: 'none',
39
- background: 'transparent',
40
- fontSize: 20,
41
- cursor: 'pointer',
42
- lineHeight: 1,
43
- };
44
-
45
- const Modal: React.FC<ModalProps> = ({ visible, onClose, children }) => {
46
- if (!visible) return null;
47
-
48
- return (
49
- <div style={modalStyle}>
50
- <div style={contentStyle}>
51
- <button style={closeBtnStyle} onClick={onClose} aria-label="关闭">
52
- ×
53
- </button>
54
- {children}
55
- </div>
56
- </div>
57
- );
58
- };
59
-
60
- export default Modal;