best-unit 1.0.0 → 1.0.3
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/README.md +1 -0
- package/dist/best-unit.cjs +60 -0
- package/dist/best-unit.js +3988 -0
- package/dist/types/global.d.ts +64 -0
- package/dist/types/index.ts +17 -0
- package/dist/types/preact-custom-element.d.ts +1 -0
- package/index.html +2 -2
- package/package.json +14 -7
- package/src/api/axiosInstance.ts +94 -0
- package/src/api/index.ts +118 -15
- package/src/api/proxy.ts +11 -0
- package/src/components/business/recharge-sdk/components/Button.tsx +42 -0
- package/src/components/business/recharge-sdk/components/OfflineTransferForm.tsx +365 -0
- package/src/components/business/recharge-sdk/components/OnlineRechargeForm.tsx +389 -0
- package/src/components/business/recharge-sdk/components/Recharge.tsx +288 -0
- package/src/components/business/recharge-sdk/index.tsx +39 -0
- package/src/components/business/statistical-balance/index.tsx +206 -0
- package/src/components/common/HoverPopover.tsx +215 -0
- package/src/components/common/Message.tsx +324 -0
- package/src/components/common/Select.tsx +278 -0
- package/src/components/common/Upload.tsx +207 -0
- package/src/demo/App.tsx +429 -0
- package/src/demo/index.tsx +4 -0
- package/src/local/en.ts +61 -0
- package/src/local/index.ts +36 -0
- package/src/local/zh.ts +60 -0
- package/src/main.ts +10 -0
- package/src/types/global.d.ts +64 -0
- package/src/types/index.ts +17 -0
- package/src/types/preact-custom-element.d.ts +1 -0
- package/src/utils/business/index.ts +48 -0
- package/src/utils/common/index.ts +8 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.app.json +31 -0
- package/tsconfig.json +15 -0
- package/tsconfig.node.json +24 -0
- package/vite.config.ts +18 -0
- package/example/index.html +0 -24
- package/public/vite.svg +0 -1
- package/src/App.jsx +0 -6
- package/src/api/define-api.ts +0 -49
- package/src/javascript.svg +0 -1
- package/src/main.jsx +0 -4
- package/src/sdk/index.ts +0 -33
- package/src/style.css +0 -96
- package/src/views/AccountModal.jsx +0 -125
- package/src/views/Home.jsx +0 -53
- package/vite.config.js +0 -31
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { useState } from 'preact/hooks';
|
|
2
|
-
import { submitAccountForm } from '../api';
|
|
3
|
-
|
|
4
|
-
const initialFormData = {
|
|
5
|
-
agent: '',
|
|
6
|
-
requestId: '',
|
|
7
|
-
remark: '',
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export default function AccountModal({ visible, onClose, onSubmit }) {
|
|
11
|
-
const [formData, setFormData] = useState(initialFormData);
|
|
12
|
-
const [loading, setLoading] = useState(false);
|
|
13
|
-
|
|
14
|
-
// 每次弹窗打开时重置表单
|
|
15
|
-
if (!visible) {
|
|
16
|
-
if (formData.agent !== '' || formData.requestId !== '' || formData.remark !== '') {
|
|
17
|
-
setFormData(initialFormData);
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const handleChange = (e) => {
|
|
23
|
-
setFormData({ ...formData, [e.target.name]: e.target.value });
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const handleSubmit = async (e) => {
|
|
27
|
-
e.preventDefault();
|
|
28
|
-
setLoading(true);
|
|
29
|
-
try {
|
|
30
|
-
const token = window.localStorage.getItem('token') || '';
|
|
31
|
-
await submitAccountForm(formData, token);
|
|
32
|
-
onSubmit(formData);
|
|
33
|
-
onClose();
|
|
34
|
-
} catch (err) {
|
|
35
|
-
alert('提交失败');
|
|
36
|
-
} finally {
|
|
37
|
-
setLoading(false);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// 点击遮罩关闭弹窗
|
|
42
|
-
const handleMaskClick = (e) => {
|
|
43
|
-
if (e.target === e.currentTarget) {
|
|
44
|
-
onClose();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<div
|
|
50
|
-
style={{
|
|
51
|
-
position: 'fixed', top: 0, left: 0, width: '100vw', height: '100vh',
|
|
52
|
-
background: 'rgba(0,0,0,0.15)', display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
53
|
-
zIndex: 1000
|
|
54
|
-
}}
|
|
55
|
-
onClick={handleMaskClick}
|
|
56
|
-
>
|
|
57
|
-
<div
|
|
58
|
-
style={{ background: '#fff', padding: '32px 32px 16px 32px', borderRadius: '8px', minWidth: '480px', boxShadow: '0 2px 8px rgba(0,0,0,0.15)', position: 'relative' }}
|
|
59
|
-
onClick={e => e.stopPropagation()}
|
|
60
|
-
>
|
|
61
|
-
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 24 }}>
|
|
62
|
-
<span style={{ fontSize: 20, fontWeight: 600 }}>新建开户申请</span>
|
|
63
|
-
<button onClick={onClose} style={{ background: 'none', border: 'none', fontSize: 22, cursor: 'pointer', color: '#999' }} title="关闭">×</button>
|
|
64
|
-
</div>
|
|
65
|
-
<form onSubmit={handleSubmit} style={{ fontSize: 15, color: '#222', textAlign: 'left' }}>
|
|
66
|
-
<div style={{ border: '1px solid #f0f0f0', borderRadius: 6, padding: '20px 24px 8px 24px', marginBottom: 24 }}>
|
|
67
|
-
<div style={{ marginBottom: 20 }}>
|
|
68
|
-
<label style={{ display: 'block', fontWeight: 600, marginBottom: 6 }}>
|
|
69
|
-
<span style={{ color: '#f5222d', marginRight: 4 }}>*</span>代理商
|
|
70
|
-
</label>
|
|
71
|
-
<select
|
|
72
|
-
name="agent"
|
|
73
|
-
value={formData.agent}
|
|
74
|
-
onChange={handleChange}
|
|
75
|
-
disabled
|
|
76
|
-
style={{ width: '100%', padding: '8px', borderRadius: 4, border: '1px solid #d9d9d9', background: '#f5f5f5', color: '#aaa' }}
|
|
77
|
-
>
|
|
78
|
-
<option value="">请选择代理商</option>
|
|
79
|
-
</select>
|
|
80
|
-
</div>
|
|
81
|
-
<div style={{ marginBottom: 20 }}>
|
|
82
|
-
<label style={{ display: 'block', fontWeight: 600, marginBottom: 6 }}>
|
|
83
|
-
<span style={{ color: '#f5222d', marginRight: 4 }}>*</span>Request ID
|
|
84
|
-
</label>
|
|
85
|
-
<input
|
|
86
|
-
type="text"
|
|
87
|
-
name="requestId"
|
|
88
|
-
value={formData.requestId}
|
|
89
|
-
onChange={handleChange}
|
|
90
|
-
placeholder="请输入Request ID"
|
|
91
|
-
required
|
|
92
|
-
style={{ width: '100%', padding: '8px', borderRadius: 4, border: '1px solid #d9d9d9' }}
|
|
93
|
-
/>
|
|
94
|
-
</div>
|
|
95
|
-
<div style={{ marginBottom: 20 }}>
|
|
96
|
-
<label style={{ display: 'block', fontWeight: 600, marginBottom: 6 }}>备注信息</label>
|
|
97
|
-
<textarea
|
|
98
|
-
name="remark"
|
|
99
|
-
value={formData.remark}
|
|
100
|
-
onChange={handleChange}
|
|
101
|
-
placeholder="请输入备注信息"
|
|
102
|
-
rows={4}
|
|
103
|
-
style={{ width: '100%', padding: '8px', borderRadius: 4, border: '1px solid #1677ff', resize: 'none' }}
|
|
104
|
-
maxLength={200}
|
|
105
|
-
/>
|
|
106
|
-
<div style={{ textAlign: 'right', color: '#aaa', fontSize: 12 }}>{formData.remark.length}/200</div>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: 12, marginTop: 8 }}>
|
|
110
|
-
<button type="button" onClick={onClose} style={{ padding: '6px 18px', border: 'none', background: '#f5f5f5', color: '#222', borderRadius: 4, fontSize: 15, cursor: 'pointer' }} disabled={loading}>
|
|
111
|
-
取消
|
|
112
|
-
</button>
|
|
113
|
-
<button type="submit" style={{ padding: '6px 18px', border: 'none', background: '#1677ff', color: '#fff', borderRadius: 8, fontSize: 16, fontWeight: 600, cursor: 'pointer', boxShadow: '0 1px 2px rgba(22,119,255,0.08)', transition: 'background 0.2s' }}
|
|
114
|
-
onMouseOver={e => (e.currentTarget.style.background = '#145dde')}
|
|
115
|
-
onMouseOut={e => (e.currentTarget.style.background = '#1677ff')}
|
|
116
|
-
disabled={loading}
|
|
117
|
-
>
|
|
118
|
-
{loading ? '提交中...' : '确认'}
|
|
119
|
-
</button>
|
|
120
|
-
</div>
|
|
121
|
-
</form>
|
|
122
|
-
</div>
|
|
123
|
-
</div>
|
|
124
|
-
);
|
|
125
|
-
}
|
package/src/views/Home.jsx
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { useState } from 'preact/hooks';
|
|
2
|
-
import AccountModal from './AccountModal.jsx';
|
|
3
|
-
|
|
4
|
-
export default function Home() {
|
|
5
|
-
const [showModal, setShowModal] = useState(false);
|
|
6
|
-
const [submitted, setSubmitted] = useState(false);
|
|
7
|
-
const [lastRequestId, setLastRequestId] = useState('');
|
|
8
|
-
|
|
9
|
-
const handleOpen = () => {
|
|
10
|
-
setShowModal(true);
|
|
11
|
-
setSubmitted(false);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const handleClose = () => {
|
|
15
|
-
setShowModal(false);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const handleSubmit = (formData) => {
|
|
19
|
-
setSubmitted(true);
|
|
20
|
-
setLastRequestId(formData.requestId);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div style={{ textAlign: 'center', marginTop: '2rem', fontFamily: 'Arial, sans-serif' }}>
|
|
25
|
-
<button onClick={handleOpen} style={{
|
|
26
|
-
padding: '6px 18px',
|
|
27
|
-
border: 'none',
|
|
28
|
-
background: '#1677ff',
|
|
29
|
-
color: '#fff',
|
|
30
|
-
borderRadius: 8,
|
|
31
|
-
fontSize: 16,
|
|
32
|
-
fontWeight: 600,
|
|
33
|
-
cursor: 'pointer',
|
|
34
|
-
boxShadow: '0 1px 2px rgba(22,119,255,0.08)',
|
|
35
|
-
transition: 'background 0.2s',
|
|
36
|
-
}}
|
|
37
|
-
onMouseOver={e => (e.currentTarget.style.background = '#145dde')}
|
|
38
|
-
onMouseOut={e => (e.currentTarget.style.background = '#1677ff')}>
|
|
39
|
-
新建开户申请
|
|
40
|
-
</button>
|
|
41
|
-
<AccountModal
|
|
42
|
-
visible={showModal}
|
|
43
|
-
onClose={handleClose}
|
|
44
|
-
onSubmit={handleSubmit}
|
|
45
|
-
/>
|
|
46
|
-
{submitted && (
|
|
47
|
-
<div style={{ marginTop: '1rem', color: 'green' }}>
|
|
48
|
-
提交成功!Request ID:{lastRequestId}
|
|
49
|
-
</div>
|
|
50
|
-
)}
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
}
|
package/vite.config.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import preact from '@preact/preset-vite';
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
plugins: [preact()],
|
|
6
|
-
server: {
|
|
7
|
-
proxy: {
|
|
8
|
-
'/api': {
|
|
9
|
-
target: 'http://localhost:3000',
|
|
10
|
-
changeOrigin: true,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
build: {
|
|
15
|
-
lib: {
|
|
16
|
-
entry: 'src/sdk/index.ts', // 你的 SDK 入口
|
|
17
|
-
name: 'BestUnit',
|
|
18
|
-
fileName: 'best-unit',
|
|
19
|
-
formats: ['umd', 'es'],
|
|
20
|
-
},
|
|
21
|
-
rollupOptions: {
|
|
22
|
-
// 保证 preact 作为外部依赖或内联
|
|
23
|
-
external: ['preact'],
|
|
24
|
-
output: {
|
|
25
|
-
globals: {
|
|
26
|
-
preact: 'preact'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|