message-verify 0.0.11-beta.0 → 0.0.13-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 +10 -0
- package/dist/App.js +31 -0
- package/dist/components/input.d.ts +6 -0
- package/dist/components/input.js +20 -0
- package/dist/components/modal.d.ts +8 -0
- package/dist/components/modal.js +40 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.js +12 -0
- package/package.json +2 -2
- package/src/main.tsx +1 -1
- package/tsconfig.json +22 -9
package/dist/App.d.ts
ADDED
package/dist/App.js
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
2
|
+
import { useEffect, useState } from 'react';
|
3
|
+
import './App.css';
|
4
|
+
import Modal from './components/modal';
|
5
|
+
import Input from './components/input';
|
6
|
+
const App = ({ data }) => {
|
7
|
+
const { mobile } = data || {};
|
8
|
+
const [countdown, setCountdown] = useState(60);
|
9
|
+
const [visible, setVisible] = useState(false);
|
10
|
+
useEffect(() => {
|
11
|
+
setVisible(true);
|
12
|
+
}, []);
|
13
|
+
useEffect(() => {
|
14
|
+
let timer = null;
|
15
|
+
if (visible && countdown > 0) {
|
16
|
+
timer = setInterval(() => {
|
17
|
+
setCountdown((prev) => prev - 1);
|
18
|
+
}, 1000);
|
19
|
+
}
|
20
|
+
return () => {
|
21
|
+
if (timer)
|
22
|
+
clearInterval(timer);
|
23
|
+
};
|
24
|
+
}, [visible, countdown]);
|
25
|
+
const handleResend = () => {
|
26
|
+
setCountdown(60);
|
27
|
+
// 这里可以加上重新发送验证码的逻辑
|
28
|
+
};
|
29
|
+
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}秒` : '重新发送' })] })] }) }));
|
30
|
+
};
|
31
|
+
export default App;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
const inputStyle = {
|
3
|
+
padding: '8px 12px',
|
4
|
+
border: '1px solid #ccc',
|
5
|
+
borderRadius: 4,
|
6
|
+
fontSize: 16,
|
7
|
+
outline: 'none',
|
8
|
+
transition: 'border-color 0.2s',
|
9
|
+
};
|
10
|
+
const Input = (props) => {
|
11
|
+
const { placeholder = '请输入' } = props;
|
12
|
+
return (_jsx("input", { style: inputStyle, placeholder: placeholder, ...props, onFocus: e => {
|
13
|
+
props.onFocus?.(e);
|
14
|
+
e.target.style.borderColor = '#1677ff';
|
15
|
+
}, onBlur: e => {
|
16
|
+
props.onBlur?.(e);
|
17
|
+
e.target.style.borderColor = '#ccc';
|
18
|
+
} }));
|
19
|
+
};
|
20
|
+
export default Input;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
const modalStyle = {
|
3
|
+
position: 'fixed',
|
4
|
+
top: 0,
|
5
|
+
left: 0,
|
6
|
+
width: '100vw',
|
7
|
+
height: '100vh',
|
8
|
+
background: 'rgba(0,0,0,0.3)',
|
9
|
+
display: 'flex',
|
10
|
+
alignItems: 'center',
|
11
|
+
justifyContent: 'center',
|
12
|
+
zIndex: 1000,
|
13
|
+
};
|
14
|
+
const contentStyle = {
|
15
|
+
position: 'relative',
|
16
|
+
background: '#fff',
|
17
|
+
borderRadius: 8,
|
18
|
+
padding: 24,
|
19
|
+
minWidth: 320,
|
20
|
+
minHeight: 120,
|
21
|
+
boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
|
22
|
+
};
|
23
|
+
const closeBtnStyle = {
|
24
|
+
position: 'absolute',
|
25
|
+
top: 12,
|
26
|
+
right: 12,
|
27
|
+
width: 24,
|
28
|
+
height: 24,
|
29
|
+
border: 'none',
|
30
|
+
background: 'transparent',
|
31
|
+
fontSize: 20,
|
32
|
+
cursor: 'pointer',
|
33
|
+
lineHeight: 1,
|
34
|
+
};
|
35
|
+
const Modal = ({ visible, onClose, children }) => {
|
36
|
+
if (!visible)
|
37
|
+
return null;
|
38
|
+
return (_jsx("div", { style: modalStyle, children: _jsxs("div", { style: contentStyle, children: [_jsx("button", { style: closeBtnStyle, onClick: onClose, "aria-label": "\u5173\u95ED", children: "\u00D7" }), children] }) }));
|
39
|
+
};
|
40
|
+
export default Modal;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { StrictMode } from 'react';
|
3
|
+
import { createRoot } from 'react-dom/client';
|
4
|
+
import './index.css';
|
5
|
+
import App from './App';
|
6
|
+
const data = {
|
7
|
+
mobile: '185****7760',
|
8
|
+
verifyCodeKey: 'e381c5f9-c7f4-4bf1-a948-744334fb0203',
|
9
|
+
sendSuccess: true
|
10
|
+
};
|
11
|
+
createRoot(document.getElementById('root')).render(_jsx(StrictMode, { children: _jsx(App, { data: data }) }));
|
12
|
+
export default App;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "message-verify",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.13-beta.0",
|
4
4
|
"type": "module",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"dependencies": {
|
@@ -22,7 +22,7 @@
|
|
22
22
|
},
|
23
23
|
"scripts": {
|
24
24
|
"dev": "vite",
|
25
|
-
"build": "tsc -
|
25
|
+
"build": "tsc -p tsconfig.json",
|
26
26
|
"lint": "eslint .",
|
27
27
|
"preview": "vite preview"
|
28
28
|
}
|
package/src/main.tsx
CHANGED
package/tsconfig.json
CHANGED
@@ -1,12 +1,25 @@
|
|
1
1
|
{
|
2
|
-
"files": [],
|
3
|
-
"references": [
|
4
|
-
|
5
|
-
|
6
|
-
],
|
2
|
+
// "files": [],
|
3
|
+
// "references": [
|
4
|
+
// { "path": "./tsconfig.app.json" },
|
5
|
+
// { "path": "./tsconfig.node.json" }
|
6
|
+
// ],
|
7
|
+
// "compilerOptions": {
|
8
|
+
// "declaration": true,
|
9
|
+
// "outDir": "dist"
|
10
|
+
// }
|
7
11
|
"compilerOptions": {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
"outDir": "dist",
|
13
|
+
"declaration": true,
|
14
|
+
"declarationDir": "dist",
|
15
|
+
"module": "ESNext",
|
16
|
+
"target": "ESNext",
|
17
|
+
"jsx": "react-jsx",
|
18
|
+
"esModuleInterop": true,
|
19
|
+
"moduleResolution": "node",
|
20
|
+
"allowSyntheticDefaultImports": true,
|
21
|
+
"skipLibCheck": true,
|
22
|
+
"strict": true
|
23
|
+
},
|
24
|
+
"include": ["src"]
|
12
25
|
}
|