best-unit 1.2.17 → 1.2.19
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/best-unit.cjs +1 -1
- package/dist/best-unit.js +1 -1
- package/package.json +4 -1
- package/BEST_UNIT_USAGE.md +0 -402
- package/index.html +0 -13
- package/src/api/axiosInstance.ts +0 -111
- package/src/api/index.ts +0 -136
- package/src/api/proxy.ts +0 -11
- package/src/components/business/recharge-sdk/components/offline-transfer-form/index.tsx +0 -158
- package/src/components/business/recharge-sdk/components/offline-transfer-form/theme.tsx +0 -238
- package/src/components/business/recharge-sdk/components/online-recharge-form/index.tsx +0 -199
- package/src/components/business/recharge-sdk/components/online-recharge-form/theme.tsx +0 -151
- package/src/components/business/recharge-sdk/components/recharge/index.tsx +0 -152
- package/src/components/business/recharge-sdk/components/recharge/theme.tsx +0 -64
- package/src/components/business/recharge-sdk/index.tsx +0 -37
- package/src/components/business/refresh-button/index.tsx +0 -99
- package/src/components/business/refresh-button/theme.tsx +0 -58
- package/src/components/business/statistical-balance/index.tsx +0 -190
- package/src/components/business/statistical-balance/theme.tsx +0 -110
- package/src/components/common/button/index.tsx +0 -17
- package/src/components/common/button/theme.tsx +0 -48
- package/src/components/common/hover-popover/index.tsx +0 -179
- package/src/components/common/hover-popover/theme.tsx +0 -39
- package/src/components/common/message/index.tsx +0 -321
- package/src/components/common/message/theme.tsx +0 -25
- package/src/components/common/modal/index.tsx +0 -99
- package/src/components/common/modal/theme.tsx +0 -91
- package/src/components/common/select/index.tsx +0 -229
- package/src/components/common/select/theme.tsx +0 -104
- package/src/components/common/upload/index.tsx +0 -140
- package/src/components/common/upload/theme.tsx +0 -89
- package/src/demo/App.tsx +0 -685
- package/src/demo/index.tsx +0 -4
- package/src/demo/testBalanceData.tsx +0 -79
- package/src/demo/theme-config-example.tsx +0 -1
- package/src/local/en.ts +0 -63
- package/src/local/index.ts +0 -36
- package/src/local/zh.ts +0 -62
- package/src/main.ts +0 -26
- package/src/types/global.d.ts +0 -146
- package/src/types/index.ts +0 -31
- package/src/types/preact-custom-element.d.ts +0 -1
- package/src/utils/business/index.ts +0 -132
- package/src/utils/common/index.ts +0 -8
- package/src/vite-env.d.ts +0 -8
- package/tsconfig.app.json +0 -33
- package/tsconfig.json +0 -15
- package/tsconfig.node.json +0 -24
- package/vite.config.ts +0 -24
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
import type { FunctionalComponent } from "preact";
|
|
2
|
-
import { useState, useEffect } from "preact/hooks";
|
|
3
|
-
import { getMessageTheme } from "./theme";
|
|
4
|
-
|
|
5
|
-
export type MessageType = "success" | "error" | "warning" | "info";
|
|
6
|
-
|
|
7
|
-
interface MessageProps {
|
|
8
|
-
type: MessageType;
|
|
9
|
-
content: string;
|
|
10
|
-
duration?: number;
|
|
11
|
-
onClose?: () => void;
|
|
12
|
-
closable?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const MessageItem: FunctionalComponent<MessageProps> = ({
|
|
16
|
-
type,
|
|
17
|
-
content,
|
|
18
|
-
duration = 3000,
|
|
19
|
-
onClose,
|
|
20
|
-
closable = false,
|
|
21
|
-
}) => {
|
|
22
|
-
const [visible, setVisible] = useState(true);
|
|
23
|
-
const theme = getMessageTheme();
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (duration > 0) {
|
|
27
|
-
const timer = setTimeout(() => {
|
|
28
|
-
setVisible(false);
|
|
29
|
-
setTimeout(() => onClose?.(), 300);
|
|
30
|
-
}, duration);
|
|
31
|
-
return () => clearTimeout(timer);
|
|
32
|
-
}
|
|
33
|
-
}, [duration, onClose]);
|
|
34
|
-
|
|
35
|
-
const getIcon = () => {
|
|
36
|
-
switch (type) {
|
|
37
|
-
case "error":
|
|
38
|
-
return (
|
|
39
|
-
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
40
|
-
<circle cx="8" cy="8" r="8" fill="#ff4d4f" />
|
|
41
|
-
<path
|
|
42
|
-
d="M10.5 5.5l-5 5m0-5l5 5"
|
|
43
|
-
stroke="white"
|
|
44
|
-
strokeWidth="1.5"
|
|
45
|
-
strokeLinecap="round"
|
|
46
|
-
/>
|
|
47
|
-
</svg>
|
|
48
|
-
);
|
|
49
|
-
case "success":
|
|
50
|
-
return (
|
|
51
|
-
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
52
|
-
<circle cx="8" cy="8" r="8" fill="#52c41a" />
|
|
53
|
-
<path
|
|
54
|
-
d="M5 8.5l2.2 2.2 3.8-3.4"
|
|
55
|
-
stroke="white"
|
|
56
|
-
strokeWidth="1.8"
|
|
57
|
-
strokeLinecap="round"
|
|
58
|
-
strokeLinejoin="round"
|
|
59
|
-
fill="none"
|
|
60
|
-
/>
|
|
61
|
-
</svg>
|
|
62
|
-
);
|
|
63
|
-
case "warning":
|
|
64
|
-
return (
|
|
65
|
-
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
66
|
-
<circle cx="8" cy="8" r="8" fill="#faad14" />
|
|
67
|
-
<path
|
|
68
|
-
d="M8 4.5v5"
|
|
69
|
-
stroke="white"
|
|
70
|
-
strokeWidth="1.5"
|
|
71
|
-
strokeLinecap="round"
|
|
72
|
-
/>
|
|
73
|
-
<circle cx="8" cy="12.5" r="1" fill="white" />
|
|
74
|
-
</svg>
|
|
75
|
-
);
|
|
76
|
-
case "info":
|
|
77
|
-
return (
|
|
78
|
-
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
79
|
-
<circle cx="8" cy="8" r="8" fill="#1677ff" />
|
|
80
|
-
<rect
|
|
81
|
-
x="7.25"
|
|
82
|
-
y="7"
|
|
83
|
-
width="1.5"
|
|
84
|
-
height="6"
|
|
85
|
-
rx="0.75"
|
|
86
|
-
fill="white"
|
|
87
|
-
/>
|
|
88
|
-
<rect
|
|
89
|
-
x="7.25"
|
|
90
|
-
y="5"
|
|
91
|
-
width="1.5"
|
|
92
|
-
height="1.5"
|
|
93
|
-
rx="0.75"
|
|
94
|
-
fill="white"
|
|
95
|
-
/>
|
|
96
|
-
</svg>
|
|
97
|
-
);
|
|
98
|
-
default:
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<div
|
|
105
|
-
style={{
|
|
106
|
-
position: "fixed",
|
|
107
|
-
top: "20px",
|
|
108
|
-
left: "50%",
|
|
109
|
-
zIndex: 9999,
|
|
110
|
-
background: theme.background,
|
|
111
|
-
border: `1px solid ${theme.border}`,
|
|
112
|
-
borderRadius: "12px",
|
|
113
|
-
padding: "8px 16px",
|
|
114
|
-
display: "flex",
|
|
115
|
-
alignItems: "center",
|
|
116
|
-
gap: "8px",
|
|
117
|
-
boxShadow: theme.boxShadow,
|
|
118
|
-
minWidth: content.length < 20 ? "auto" : "300px",
|
|
119
|
-
maxWidth: "500px",
|
|
120
|
-
opacity: visible ? 1 : 0,
|
|
121
|
-
color: theme.color,
|
|
122
|
-
transform: visible
|
|
123
|
-
? "translateX(-50%) translateY(0)"
|
|
124
|
-
: "translateX(-50%) translateY(-20px)",
|
|
125
|
-
transition: "all 0.3s ease",
|
|
126
|
-
}}
|
|
127
|
-
>
|
|
128
|
-
<div style={{ flexShrink: 0 }}>{getIcon()}</div>
|
|
129
|
-
<div
|
|
130
|
-
style={{
|
|
131
|
-
color: theme.color,
|
|
132
|
-
fontSize: "14px",
|
|
133
|
-
lineHeight: "1.5",
|
|
134
|
-
flex: 1,
|
|
135
|
-
}}
|
|
136
|
-
>
|
|
137
|
-
{content}
|
|
138
|
-
</div>
|
|
139
|
-
{closable && (
|
|
140
|
-
<button
|
|
141
|
-
onClick={() => {
|
|
142
|
-
setVisible(false);
|
|
143
|
-
setTimeout(() => onClose?.(), 300);
|
|
144
|
-
}}
|
|
145
|
-
style={{
|
|
146
|
-
background: "none",
|
|
147
|
-
border: "none",
|
|
148
|
-
cursor: "pointer",
|
|
149
|
-
padding: "4px",
|
|
150
|
-
color: theme.closeColor,
|
|
151
|
-
fontSize: "12px",
|
|
152
|
-
flexShrink: 0,
|
|
153
|
-
}}
|
|
154
|
-
>
|
|
155
|
-
✕
|
|
156
|
-
</button>
|
|
157
|
-
)}
|
|
158
|
-
</div>
|
|
159
|
-
);
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
// 支持对象参数
|
|
163
|
-
interface MessageOptions {
|
|
164
|
-
content: string;
|
|
165
|
-
duration?: number;
|
|
166
|
-
closable?: boolean;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
type MessageArg = string | MessageOptions;
|
|
170
|
-
|
|
171
|
-
// 简单的消息管理器
|
|
172
|
-
class MessageManager {
|
|
173
|
-
private parseArg(arg: MessageArg): MessageOptions {
|
|
174
|
-
if (typeof arg === "string") {
|
|
175
|
-
return { content: arg };
|
|
176
|
-
}
|
|
177
|
-
return arg;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
show(type: MessageType, arg: MessageArg) {
|
|
181
|
-
const { content, duration, closable } = this.parseArg(arg);
|
|
182
|
-
// 创建消息元素
|
|
183
|
-
const theme = getMessageTheme();
|
|
184
|
-
const messageDiv = document.createElement("div");
|
|
185
|
-
messageDiv.style.cssText = `
|
|
186
|
-
position: fixed;
|
|
187
|
-
top: 20px;
|
|
188
|
-
left: 50%;
|
|
189
|
-
transform: translateX(-50%);
|
|
190
|
-
z-index: 9999;
|
|
191
|
-
background: ${theme.background};
|
|
192
|
-
border: 1px solid ${theme.border};
|
|
193
|
-
border-radius: 12px;
|
|
194
|
-
padding: 8px 16px;
|
|
195
|
-
box-shadow: ${theme.boxShadow};
|
|
196
|
-
min-width: ${content.length < 20 ? "auto" : "300px"};
|
|
197
|
-
max-width: 500px;
|
|
198
|
-
display: flex;
|
|
199
|
-
align-items: center;
|
|
200
|
-
gap: 8px;
|
|
201
|
-
font-size: 14px;
|
|
202
|
-
color: ${theme.color};
|
|
203
|
-
`;
|
|
204
|
-
|
|
205
|
-
// 添加图标
|
|
206
|
-
if (type === "error") {
|
|
207
|
-
const iconSvg = document.createElementNS(
|
|
208
|
-
"http://www.w3.org/2000/svg",
|
|
209
|
-
"svg"
|
|
210
|
-
);
|
|
211
|
-
iconSvg.setAttribute("width", "16");
|
|
212
|
-
iconSvg.setAttribute("height", "16");
|
|
213
|
-
iconSvg.setAttribute("viewBox", "0 0 16 16");
|
|
214
|
-
iconSvg.innerHTML = `
|
|
215
|
-
<circle cx="8" cy="8" r="8" fill="#ff4d4f"/>
|
|
216
|
-
<path d="M10.5 5.5l-5 5m0-5l5 5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
|
|
217
|
-
`;
|
|
218
|
-
messageDiv.appendChild(iconSvg);
|
|
219
|
-
}
|
|
220
|
-
if (type === "success") {
|
|
221
|
-
const iconSvg = document.createElementNS(
|
|
222
|
-
"http://www.w3.org/2000/svg",
|
|
223
|
-
"svg"
|
|
224
|
-
);
|
|
225
|
-
iconSvg.setAttribute("width", "16");
|
|
226
|
-
iconSvg.setAttribute("height", "16");
|
|
227
|
-
iconSvg.setAttribute("viewBox", "0 0 16 16");
|
|
228
|
-
iconSvg.innerHTML = `
|
|
229
|
-
<circle cx="8" cy="8" r="8" fill="#52c41a"/>
|
|
230
|
-
<path d="M5 8.5l2.2 2.2 3.8-3.4" stroke="white" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
|
231
|
-
`;
|
|
232
|
-
messageDiv.appendChild(iconSvg);
|
|
233
|
-
}
|
|
234
|
-
if (type === "warning") {
|
|
235
|
-
const iconSvg = document.createElementNS(
|
|
236
|
-
"http://www.w3.org/2000/svg",
|
|
237
|
-
"svg"
|
|
238
|
-
);
|
|
239
|
-
iconSvg.setAttribute("width", "16");
|
|
240
|
-
iconSvg.setAttribute("height", "16");
|
|
241
|
-
iconSvg.setAttribute("viewBox", "0 0 16 16");
|
|
242
|
-
iconSvg.innerHTML = `
|
|
243
|
-
<circle cx="8" cy="8" r="8" fill="#faad14"/>
|
|
244
|
-
<path d="M8 4.5v5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
|
|
245
|
-
<circle cx="8" cy="12.5" r="1" fill="white"/>
|
|
246
|
-
`;
|
|
247
|
-
messageDiv.appendChild(iconSvg);
|
|
248
|
-
}
|
|
249
|
-
if (type === "info") {
|
|
250
|
-
const iconSvg = document.createElementNS(
|
|
251
|
-
"http://www.w3.org/2000/svg",
|
|
252
|
-
"svg"
|
|
253
|
-
);
|
|
254
|
-
iconSvg.setAttribute("width", "16");
|
|
255
|
-
iconSvg.setAttribute("height", "16");
|
|
256
|
-
iconSvg.setAttribute("viewBox", "0 0 16 16");
|
|
257
|
-
iconSvg.innerHTML = `
|
|
258
|
-
<circle cx="8" cy="8" r="8" fill="#1677ff"/>
|
|
259
|
-
<rect x="7.25" y="7" width="1.5" height="6" rx="0.75" fill="white"/>
|
|
260
|
-
<rect x="7.25" y="5" width="1.5" height="1.5" rx="0.75" fill="white"/>
|
|
261
|
-
`;
|
|
262
|
-
messageDiv.appendChild(iconSvg);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// 添加文本
|
|
266
|
-
const textDiv = document.createElement("div");
|
|
267
|
-
textDiv.textContent = content;
|
|
268
|
-
textDiv.style.flex = "1";
|
|
269
|
-
textDiv.style.color = theme.color;
|
|
270
|
-
messageDiv.appendChild(textDiv);
|
|
271
|
-
|
|
272
|
-
// 添加关闭按钮(如果启用)
|
|
273
|
-
if (closable) {
|
|
274
|
-
const closeBtn = document.createElement("button");
|
|
275
|
-
closeBtn.textContent = "✕";
|
|
276
|
-
closeBtn.style.cssText = `
|
|
277
|
-
background: none;
|
|
278
|
-
border: none;
|
|
279
|
-
cursor: pointer;
|
|
280
|
-
padding: 4px;
|
|
281
|
-
color: ${theme.closeColor};
|
|
282
|
-
font-size: 12px;
|
|
283
|
-
`;
|
|
284
|
-
closeBtn.onclick = () => {
|
|
285
|
-
document.body.removeChild(messageDiv);
|
|
286
|
-
};
|
|
287
|
-
messageDiv.appendChild(closeBtn);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// 添加到页面
|
|
291
|
-
document.body.appendChild(messageDiv);
|
|
292
|
-
|
|
293
|
-
// 自动关闭
|
|
294
|
-
if (duration !== 0) {
|
|
295
|
-
setTimeout(() => {
|
|
296
|
-
if (document.body.contains(messageDiv)) {
|
|
297
|
-
document.body.removeChild(messageDiv);
|
|
298
|
-
}
|
|
299
|
-
}, duration || 3000);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
success(arg: MessageArg) {
|
|
304
|
-
this.show("success", arg);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
error(arg: MessageArg) {
|
|
308
|
-
this.show("error", arg);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
warning(arg: MessageArg) {
|
|
312
|
-
this.show("warning", arg);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
info(arg: MessageArg) {
|
|
316
|
-
this.show("info", arg);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
export const message = new MessageManager();
|
|
321
|
-
export default MessageItem;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Theme } from "@/types";
|
|
2
|
-
import { getInitParams } from "@/utils/business";
|
|
3
|
-
|
|
4
|
-
export const messageThemes = {
|
|
5
|
-
white: {
|
|
6
|
-
background: "#fff",
|
|
7
|
-
border: "#d9d9d9",
|
|
8
|
-
color: "#222",
|
|
9
|
-
boxShadow: "0 6px 16px rgba(0, 0, 0, 0.12)",
|
|
10
|
-
closeColor: "#999",
|
|
11
|
-
},
|
|
12
|
-
dark: {
|
|
13
|
-
background: "#23262F",
|
|
14
|
-
border: "#444C5C",
|
|
15
|
-
color: "#F5F6FA",
|
|
16
|
-
boxShadow: "0 6px 16px rgba(0,0,0,0.32)",
|
|
17
|
-
closeColor: "#B5B8BE",
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export function getMessageTheme() {
|
|
22
|
-
const theme = getInitParams<Theme>("theme");
|
|
23
|
-
const whiteTheme = theme === Theme.WHITE;
|
|
24
|
-
return whiteTheme ? messageThemes.white : messageThemes.dark;
|
|
25
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import type { ComponentChildren } from "preact";
|
|
2
|
-
import { useState } from "preact/hooks";
|
|
3
|
-
import { getModalTheme } from "./theme";
|
|
4
|
-
import { getInitParams } from "@/utils/business";
|
|
5
|
-
import { Size } from "@/types";
|
|
6
|
-
const size = getInitParams<Size>("size");
|
|
7
|
-
interface ModalProps {
|
|
8
|
-
visible: boolean;
|
|
9
|
-
onClose: () => void;
|
|
10
|
-
title?: string;
|
|
11
|
-
children: ComponentChildren;
|
|
12
|
-
width?: number | string;
|
|
13
|
-
maxWidth?: number | string;
|
|
14
|
-
showClose?: boolean;
|
|
15
|
-
maskClosable?: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function Modal({
|
|
19
|
-
visible,
|
|
20
|
-
onClose,
|
|
21
|
-
title,
|
|
22
|
-
children,
|
|
23
|
-
width = size === Size.SMALL ? 300 : 400,
|
|
24
|
-
maxWidth = size === Size.SMALL ? 300 : 400,
|
|
25
|
-
showClose = true,
|
|
26
|
-
maskClosable = true,
|
|
27
|
-
}: ModalProps) {
|
|
28
|
-
const [maskMouseDown, setMaskMouseDown] = useState(false);
|
|
29
|
-
const theme = getModalTheme();
|
|
30
|
-
|
|
31
|
-
// 只有mousedown和mouseup都在mask上才关闭弹窗
|
|
32
|
-
const handleMaskMouseDown = (e: any) => {
|
|
33
|
-
if (e.target === e.currentTarget) {
|
|
34
|
-
setMaskMouseDown(true);
|
|
35
|
-
} else {
|
|
36
|
-
setMaskMouseDown(false);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const handleMaskMouseUp = (e: any) => {
|
|
41
|
-
if (e.target === e.currentTarget && maskMouseDown && maskClosable) {
|
|
42
|
-
onClose();
|
|
43
|
-
}
|
|
44
|
-
setMaskMouseDown(false);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
if (!visible) return null;
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<div
|
|
51
|
-
style={{
|
|
52
|
-
position: "fixed",
|
|
53
|
-
top: 0,
|
|
54
|
-
left: 0,
|
|
55
|
-
right: 0,
|
|
56
|
-
bottom: 0,
|
|
57
|
-
background: theme.mask,
|
|
58
|
-
display: "flex",
|
|
59
|
-
alignItems: "center",
|
|
60
|
-
justifyContent: "center",
|
|
61
|
-
zIndex: 9999,
|
|
62
|
-
}}
|
|
63
|
-
onMouseDown={handleMaskMouseDown}
|
|
64
|
-
onMouseUp={handleMaskMouseUp}
|
|
65
|
-
>
|
|
66
|
-
<div
|
|
67
|
-
style={{
|
|
68
|
-
background: theme.modalBg,
|
|
69
|
-
padding: size === Size.SMALL ? 24 : 32,
|
|
70
|
-
borderRadius: size === Size.SMALL ? 8 : 12,
|
|
71
|
-
minWidth: width,
|
|
72
|
-
maxWidth: maxWidth,
|
|
73
|
-
color: theme.modalColor,
|
|
74
|
-
boxShadow: theme.modalBoxShadow,
|
|
75
|
-
position: "relative",
|
|
76
|
-
}}
|
|
77
|
-
onClick={(e) => e.stopPropagation()}
|
|
78
|
-
>
|
|
79
|
-
{/* 关闭按钮 */}
|
|
80
|
-
{showClose && (
|
|
81
|
-
<button
|
|
82
|
-
type="button"
|
|
83
|
-
onClick={onClose}
|
|
84
|
-
style={theme.closeBtn}
|
|
85
|
-
aria-label="关闭"
|
|
86
|
-
>
|
|
87
|
-
×
|
|
88
|
-
</button>
|
|
89
|
-
)}
|
|
90
|
-
|
|
91
|
-
{/* 标题 */}
|
|
92
|
-
{title && <div style={theme.title}>{title}</div>}
|
|
93
|
-
|
|
94
|
-
{/* 内容 */}
|
|
95
|
-
{children}
|
|
96
|
-
</div>
|
|
97
|
-
</div>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Size, Theme } from "@/types";
|
|
2
|
-
import { getInitParams } from "@/utils/business";
|
|
3
|
-
const size = getInitParams<Size>("size");
|
|
4
|
-
export const modalThemes = {
|
|
5
|
-
white: {
|
|
6
|
-
mask: "rgba(0, 0, 0, 0.45)",
|
|
7
|
-
modalBg: "#fff",
|
|
8
|
-
modalColor: "#222",
|
|
9
|
-
modalBoxShadow: "0 6px 16px rgba(0, 0, 0, 0.12)",
|
|
10
|
-
closeBtn: {
|
|
11
|
-
position: "absolute",
|
|
12
|
-
top: "16px",
|
|
13
|
-
right: "16px",
|
|
14
|
-
background: "none",
|
|
15
|
-
border: "none",
|
|
16
|
-
fontSize: size === Size.SMALL ? 16 : 24,
|
|
17
|
-
cursor: "pointer",
|
|
18
|
-
color: "#999",
|
|
19
|
-
padding: "0",
|
|
20
|
-
width: size === Size.SMALL ? 16 : 24,
|
|
21
|
-
height: size === Size.SMALL ? 16 : 24,
|
|
22
|
-
display: "flex",
|
|
23
|
-
alignItems: "center",
|
|
24
|
-
justifyContent: "center",
|
|
25
|
-
},
|
|
26
|
-
title: {
|
|
27
|
-
fontSize: size === Size.SMALL ? 16 : 18,
|
|
28
|
-
fontWeight: "600",
|
|
29
|
-
marginBottom: size === Size.SMALL ? 16 : 24,
|
|
30
|
-
color: "#222",
|
|
31
|
-
},
|
|
32
|
-
tabBtn: (active: boolean, isFirst: boolean) => ({
|
|
33
|
-
flex: 1,
|
|
34
|
-
padding: size === Size.SMALL ? "8px 10px" : "12px 16px",
|
|
35
|
-
background: active ? "#1890ff" : "transparent",
|
|
36
|
-
color: active ? "#fff" : "#666",
|
|
37
|
-
border: "1px solid #d9d9d9",
|
|
38
|
-
borderRight: isFirst ? "none" : "1px solid #d9d9d9",
|
|
39
|
-
cursor: "pointer",
|
|
40
|
-
fontSize: size === Size.SMALL ? 12 : 14,
|
|
41
|
-
fontWeight: active ? "600" : "400",
|
|
42
|
-
borderRadius: isFirst ? "6px 0 0 6px" : "0 6px 6px 0",
|
|
43
|
-
}),
|
|
44
|
-
},
|
|
45
|
-
dark: {
|
|
46
|
-
mask: "rgba(0, 0, 0, 0.65)",
|
|
47
|
-
modalBg: "#23262F",
|
|
48
|
-
modalColor: "#F5F6FA",
|
|
49
|
-
modalBoxShadow: "0 6px 16px rgba(0,0,0,0.32)",
|
|
50
|
-
closeBtn: {
|
|
51
|
-
position: "absolute",
|
|
52
|
-
top: size === Size.SMALL ? "12px" : "16px",
|
|
53
|
-
right: size === Size.SMALL ? "12px" : "16px",
|
|
54
|
-
background: "none",
|
|
55
|
-
border: "none",
|
|
56
|
-
fontSize: size === Size.SMALL ? 16 : 24,
|
|
57
|
-
cursor: "pointer",
|
|
58
|
-
color: "#B5B8BE",
|
|
59
|
-
padding: "0",
|
|
60
|
-
width: size === Size.SMALL ? 16 : 24,
|
|
61
|
-
height: size === Size.SMALL ? 16 : 24,
|
|
62
|
-
display: "flex",
|
|
63
|
-
alignItems: "center",
|
|
64
|
-
justifyContent: "center",
|
|
65
|
-
},
|
|
66
|
-
title: {
|
|
67
|
-
fontSize: size === Size.SMALL ? 16 : 18,
|
|
68
|
-
fontWeight: "600",
|
|
69
|
-
marginBottom: size === Size.SMALL ? 16 : 24,
|
|
70
|
-
color: "#F5F6FA",
|
|
71
|
-
},
|
|
72
|
-
tabBtn: (active: boolean, isFirst: boolean) => ({
|
|
73
|
-
flex: 1,
|
|
74
|
-
padding: size === Size.SMALL ? "8px 10px" : "12px 16px",
|
|
75
|
-
background: active ? "#00E8C6" : "transparent",
|
|
76
|
-
color: active ? "#fff" : "#B5B8BE",
|
|
77
|
-
border: "1px solid #444C5C",
|
|
78
|
-
borderRight: isFirst ? "none" : "1px solid #444C5C",
|
|
79
|
-
cursor: "pointer",
|
|
80
|
-
fontSize: size === Size.SMALL ? 12 : 14,
|
|
81
|
-
fontWeight: active ? "600" : "400",
|
|
82
|
-
borderRadius: isFirst ? "6px 0 0 6px" : "0 6px 6px 0",
|
|
83
|
-
}),
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export function getModalTheme() {
|
|
88
|
-
const theme = getInitParams<Theme>("theme");
|
|
89
|
-
const whiteTheme = theme === Theme.WHITE;
|
|
90
|
-
return whiteTheme ? modalThemes.white : modalThemes.dark;
|
|
91
|
-
}
|