beer-assembly-biz 1.1.3-alpha.3 → 1.1.3-alpha.5
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/UploadModals.d.ts +12 -0
- package/UploadModals.js +233 -0
- package/auth/AuthStyle01.d.ts +2 -2
- package/auth/AuthStyle01.js +1 -1
- package/auth/AuthStyle02.d.ts +2 -2
- package/auth/AuthStyle02.js +1 -1
- package/index.d.ts +5 -2
- package/index.js +5 -2
- package/layout/BackPageContainer.d.ts +1 -0
- package/layout/BackPageContainer.js +4 -1
- package/media/Media.d.ts +84 -0
- package/media/Media.js +241 -0
- package/media/MediaModals.d.ts +17 -0
- package/media/MediaModals.js +172 -461
- package/package.json +2 -1
- package/promises.d.ts +7 -1
- package/promises.js +19 -6
package/media/MediaModals.js
CHANGED
|
@@ -1,461 +1,172 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
//
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// }
|
|
174
|
-
// return result;
|
|
175
|
-
// };
|
|
176
|
-
// const onMove = async (id: string) => {
|
|
177
|
-
// setIsOpenMoveModal(true);
|
|
178
|
-
// setSelectId(id);
|
|
179
|
-
// };
|
|
180
|
-
// const onConfirmMove = async (targetId: string) => {
|
|
181
|
-
// const result = await request?.move(selectId, targetId);
|
|
182
|
-
// if (result === true) {
|
|
183
|
-
// setIsOpenMoveModal(false);
|
|
184
|
-
// refreshData();
|
|
185
|
-
// }
|
|
186
|
-
// };
|
|
187
|
-
// const onRemove = async (id: string) => {
|
|
188
|
-
// setIsOpenConfirmModal(true);
|
|
189
|
-
// setSelectId(id);
|
|
190
|
-
// };
|
|
191
|
-
// const onConfirmRemove = async () => {
|
|
192
|
-
// const result = await request?.remove(selectId);
|
|
193
|
-
// if (result === true) {
|
|
194
|
-
// setIsOpenConfirmModal(false);
|
|
195
|
-
// refreshData();
|
|
196
|
-
// }
|
|
197
|
-
// return result;
|
|
198
|
-
// };
|
|
199
|
-
// const setPaths = (items: { id: string, name: string }[]) => {
|
|
200
|
-
// setPath(items);
|
|
201
|
-
// sessionStorage.setItem('MEDIA_MODALS_PATHS', JSON.stringify(items));
|
|
202
|
-
// };
|
|
203
|
-
// const getPaths = (): { id: string, name: string }[] => {
|
|
204
|
-
// const paths = JSON.parse(sessionStorage.getItem('MEDIA_MODALS_PATHS') || '[]');
|
|
205
|
-
// if (paths.length <= 0) {
|
|
206
|
-
// paths.push({
|
|
207
|
-
// id: '0',
|
|
208
|
-
// name: '根目录'
|
|
209
|
-
// });
|
|
210
|
-
// }
|
|
211
|
-
// return paths;
|
|
212
|
-
// };
|
|
213
|
-
// const Item = (props: {
|
|
214
|
-
// id: string
|
|
215
|
-
// name: string
|
|
216
|
-
// type: 'DIRECTORY' | 'FILE'
|
|
217
|
-
// src?: string,
|
|
218
|
-
// style?: CSSProperties,
|
|
219
|
-
// active?: boolean
|
|
220
|
-
// }) => {
|
|
221
|
-
// const directoryMenusItem = props.type === 'DIRECTORY' ? [
|
|
222
|
-
// {
|
|
223
|
-
// label: <Space style={{ width: 100 }} size={5} onClick={() => onOpenDirectory(props.id, props.name)}><RightCircleOutlined/>打开目录</Space>,
|
|
224
|
-
// key: '0'
|
|
225
|
-
// },
|
|
226
|
-
// {
|
|
227
|
-
// type: 'divider'
|
|
228
|
-
// }
|
|
229
|
-
// ] : [
|
|
230
|
-
// {
|
|
231
|
-
// label: <Space style={{ width: 100 }} size={5} onClick={() => onDownload(props.name, props.src)}><CloudDownloadOutlined/>下载文件</Space>,
|
|
232
|
-
// key: '0'
|
|
233
|
-
// },
|
|
234
|
-
// {
|
|
235
|
-
// type: 'divider'
|
|
236
|
-
// }
|
|
237
|
-
// ];
|
|
238
|
-
// const menusItems = [
|
|
239
|
-
// ...directoryMenusItem,
|
|
240
|
-
// {
|
|
241
|
-
// label: <Space style={{ width: 100 }} size={5} onClick={() => onRename(props.id, props.name)}><HighlightOutlined/>重命名</Space>,
|
|
242
|
-
// key: '1'
|
|
243
|
-
// },
|
|
244
|
-
// {
|
|
245
|
-
// label: <Space style={{ width: 100 }} size={5} onClick={() => onCopy(props.id)}><CopyOutlined/>{props?.type === 'DIRECTORY' ? '复制目录' : '复制文件'}</Space>,
|
|
246
|
-
// key: '2'
|
|
247
|
-
// },
|
|
248
|
-
// {
|
|
249
|
-
// label: <Space style={{ width: 100 }} size={5} onClick={() => onMove(props.id)}><ScissorOutlined/>{props?.type === 'DIRECTORY' ? '移动目录' : '移动文件'}</Space>,
|
|
250
|
-
// key: '3'
|
|
251
|
-
// },
|
|
252
|
-
// {
|
|
253
|
-
// type: 'divider'
|
|
254
|
-
// },
|
|
255
|
-
// {
|
|
256
|
-
// label: <Space style={{ width: 100 }} size={5} onClick={() => onRemove(props.id)}><DeleteOutlined/>{props?.type === 'DIRECTORY' ? '删除目录' : '删除文件'}</Space>,
|
|
257
|
-
// key: '4',
|
|
258
|
-
// danger: true
|
|
259
|
-
// }
|
|
260
|
-
// ];
|
|
261
|
-
// return <Dropdown menu={{
|
|
262
|
-
// items: menusItems as never
|
|
263
|
-
// }} trigger={['contextMenu']}>
|
|
264
|
-
// <div
|
|
265
|
-
// style={{
|
|
266
|
-
// padding: '8px 12px',
|
|
267
|
-
// backgroundColor: props?.active ? '#e6f1ff' : undefined,
|
|
268
|
-
// display: 'block',
|
|
269
|
-
// cursor: 'pointer',
|
|
270
|
-
// userSelect: 'none',
|
|
271
|
-
// position: 'relative',
|
|
272
|
-
// ...props.style
|
|
273
|
-
// }}
|
|
274
|
-
// className={css`
|
|
275
|
-
// border: ${props?.active ? '1px solid #cddef5' : '1px solid #fff'};
|
|
276
|
-
//
|
|
277
|
-
// &:hover {
|
|
278
|
-
// background-color: #eef1f5;
|
|
279
|
-
// border: 1px solid ${props.active ? '#cddef5' : '#e6e6e6'};
|
|
280
|
-
// }
|
|
281
|
-
// `}
|
|
282
|
-
// onClick={() => {
|
|
283
|
-
// setTimeout(() => onActiveItem(props.id), 10);
|
|
284
|
-
// }}
|
|
285
|
-
// onDoubleClick={() => {
|
|
286
|
-
// if (props.type === 'DIRECTORY') {
|
|
287
|
-
// onOpenDirectory(props.id, props.name)
|
|
288
|
-
// .then();
|
|
289
|
-
// return;
|
|
290
|
-
// }
|
|
291
|
-
// onSelectItem(props.id, props.name, props.src)
|
|
292
|
-
// .then();
|
|
293
|
-
// }}>
|
|
294
|
-
// <img src={props?.type === 'DIRECTORY' ? IconDirectory : props?.src} alt="" style={{
|
|
295
|
-
// width: 56,
|
|
296
|
-
// height: 56,
|
|
297
|
-
// margin: 'auto',
|
|
298
|
-
// display: 'block',
|
|
299
|
-
// overflow: 'hidden',
|
|
300
|
-
// objectFit: props?.type === 'DIRECTORY' ? undefined : 'cover'
|
|
301
|
-
// }}/>
|
|
302
|
-
// <Typography.Text style={{
|
|
303
|
-
// width: 70,
|
|
304
|
-
// fontSize: token.fontSize - 2,
|
|
305
|
-
// display: 'block',
|
|
306
|
-
// textAlign: 'center',
|
|
307
|
-
// color: '#323232',
|
|
308
|
-
// marginTop: props?.type === 'DIRECTORY' ? undefined : 1
|
|
309
|
-
// }} ellipsis={true}>{props?.name}</Typography.Text>
|
|
310
|
-
// </div>
|
|
311
|
-
// </Dropdown>;
|
|
312
|
-
// };
|
|
313
|
-
// const handler: Handler<string[]> = {
|
|
314
|
-
// ok: (callback?: (params: string[]) => void) => {
|
|
315
|
-
// setPath(getPaths());
|
|
316
|
-
// setIsOpenModal(true);
|
|
317
|
-
// if (callbackRef !== undefined) {
|
|
318
|
-
// callbackRef.current = callback;
|
|
319
|
-
// }
|
|
320
|
-
// }
|
|
321
|
-
// };
|
|
322
|
-
// useEffect(() => {
|
|
323
|
-
// if ((path || []).length <= 0) {
|
|
324
|
-
// return;
|
|
325
|
-
// }
|
|
326
|
-
// refreshData(true);
|
|
327
|
-
// }, [path]);
|
|
328
|
-
// return [handler, <>
|
|
329
|
-
// <InlineContainer>
|
|
330
|
-
// <Modal
|
|
331
|
-
// width={565}
|
|
332
|
-
// footer={null}
|
|
333
|
-
// styles={{
|
|
334
|
-
// content: { padding: 0 }
|
|
335
|
-
// }}
|
|
336
|
-
// open={isOpenModal}
|
|
337
|
-
// maskClosable={false}
|
|
338
|
-
// onCancel={() => {
|
|
339
|
-
// if (isLoading) {
|
|
340
|
-
// return;
|
|
341
|
-
// }
|
|
342
|
-
// setIsOpenModal(false);
|
|
343
|
-
// }}
|
|
344
|
-
// title={<div style={{
|
|
345
|
-
// padding: '16px 0 0 0'
|
|
346
|
-
// }}>
|
|
347
|
-
// <img style={{
|
|
348
|
-
// marginInlineStart: 20,
|
|
349
|
-
// display: 'block',
|
|
350
|
-
// height: '17px',
|
|
351
|
-
// padding: '2px 0 0 0'
|
|
352
|
-
// }} alt="" src={IconMedia}/>
|
|
353
|
-
// </div>}>
|
|
354
|
-
// <Flux style={{
|
|
355
|
-
// marginBottom: 6,
|
|
356
|
-
// padding: '0 20px 10px 20px',
|
|
357
|
-
// borderBottom: '1px solid #f3f3f3',
|
|
358
|
-
// justifyContent: 'space-between'
|
|
359
|
-
// }}>
|
|
360
|
-
// <Breadcrumb
|
|
361
|
-
// items={path?.map((it, index) => {
|
|
362
|
-
// return {
|
|
363
|
-
// title: (index + 1 === path.length
|
|
364
|
-
// ? <Typography.Text style={{
|
|
365
|
-
// maxWidth: 70,
|
|
366
|
-
// fontSize: token.fontSize - 1
|
|
367
|
-
// }} ellipsis={true}>{it.name}</Typography.Text>
|
|
368
|
-
// : <a onClick={() => onBackDirectory(it.id)}><Typography.Text style={{
|
|
369
|
-
// maxWidth: 70,
|
|
370
|
-
// fontSize: token.fontSize - 1,
|
|
371
|
-
// color: 'rgba(0, 0, 0, 0.45)'
|
|
372
|
-
// }} ellipsis={true}>{it.name}</Typography.Text></a>)
|
|
373
|
-
// };
|
|
374
|
-
// })}
|
|
375
|
-
// />
|
|
376
|
-
// <Space>
|
|
377
|
-
// <Button type="primary" onClick={() => onPutFile()} size="small" style={{
|
|
378
|
-
// height: 24,
|
|
379
|
-
// fontSize: token.fontSize - 1
|
|
380
|
-
// }} loading={isLoading}>上传文件</Button>
|
|
381
|
-
// <Popconfirm
|
|
382
|
-
// title="请输入目录名称"
|
|
383
|
-
// description={<Input value={selectName} onChange={(e) => setSelectName(e.currentTarget.value)}></Input>}
|
|
384
|
-
// onCancel={() => setSelectName('')}
|
|
385
|
-
// onConfirm={() => onCreateDirectory(selectName)}
|
|
386
|
-
// okText="确定"
|
|
387
|
-
// cancelText="取消"
|
|
388
|
-
// >
|
|
389
|
-
// <Button size="small" style={{
|
|
390
|
-
// height: 24,
|
|
391
|
-
// fontSize: token.fontSize - 1
|
|
392
|
-
// }} loading={isLoading}>新建目录</Button>
|
|
393
|
-
// </Popconfirm>
|
|
394
|
-
// </Space>
|
|
395
|
-
// </Flux>
|
|
396
|
-
// <Spin spinning={isLoading}>
|
|
397
|
-
// <div style={{
|
|
398
|
-
// padding: '6px 0 24px 0',
|
|
399
|
-
// height: 333,
|
|
400
|
-
// maxHeight: 333,
|
|
401
|
-
// overflowY: 'auto',
|
|
402
|
-
// overflowX: 'hidden'
|
|
403
|
-
// }}>
|
|
404
|
-
// {dataList?.map((group, index) => (
|
|
405
|
-
// <div key={index} style={{
|
|
406
|
-
// padding: '0 20px 10px 20px',
|
|
407
|
-
// display: 'flex'
|
|
408
|
-
// }}>
|
|
409
|
-
// {group?.map((item) => (
|
|
410
|
-
// <Item
|
|
411
|
-
// id={item.id}
|
|
412
|
-
// key={item.id}
|
|
413
|
-
// active={item.active}
|
|
414
|
-
// style={{ marginRight: 10 }}
|
|
415
|
-
// type={item.type}
|
|
416
|
-
// src={item.url}
|
|
417
|
-
// name={item.name}/>
|
|
418
|
-
// ))}
|
|
419
|
-
// </div>
|
|
420
|
-
// ))}
|
|
421
|
-
// </div>
|
|
422
|
-
// </Spin>
|
|
423
|
-
// </Modal>
|
|
424
|
-
// </InlineContainer>
|
|
425
|
-
// <Modal
|
|
426
|
-
// title="重命名"
|
|
427
|
-
// width={340}
|
|
428
|
-
// open={isOpenRenameModal}
|
|
429
|
-
// onOk={() => onConfirmRename()}
|
|
430
|
-
// onCancel={() => setIsOpenRenameModal(false)}
|
|
431
|
-
// okText="确定"
|
|
432
|
-
// cancelText="取消">
|
|
433
|
-
// <Input value={selectName} onChange={(e) => setSelectName(e.currentTarget.value)}></Input>
|
|
434
|
-
// </Modal>
|
|
435
|
-
// <Modal
|
|
436
|
-
// title={<><ExclamationCircleFilled style={{
|
|
437
|
-
// marginRight: 6,
|
|
438
|
-
// fontSize: token.fontSize + 3,
|
|
439
|
-
// color: '#faad14'
|
|
440
|
-
// }}/>是否确认删除?</>}
|
|
441
|
-
// width={400}
|
|
442
|
-
// open={isOpenConfirmModal}
|
|
443
|
-
// onOk={() => onConfirmRemove()}
|
|
444
|
-
// onCancel={() => setIsOpenConfirmModal(false)}
|
|
445
|
-
// okText="确定"
|
|
446
|
-
// cancelText="取消">
|
|
447
|
-
// 删除操作不能回复,确定要删除选中的文件或文件夹吗?
|
|
448
|
-
// </Modal>
|
|
449
|
-
// <DirectorySelect
|
|
450
|
-
// open={isOpenMoveModal}
|
|
451
|
-
// onCancel={() => {
|
|
452
|
-
// refreshData();
|
|
453
|
-
// setIsOpenMoveModal(false);
|
|
454
|
-
// }}
|
|
455
|
-
// request={request?.directory}
|
|
456
|
-
// onOk={(value) => onConfirmMove(value)}>
|
|
457
|
-
// </DirectorySelect>
|
|
458
|
-
// {contextHolder}
|
|
459
|
-
// </>];
|
|
460
|
-
// }
|
|
461
|
-
// }
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { Button, message, Modal, Progress, Space, theme } from 'antd';
|
|
3
|
+
import { Flux } from 'beer-assembly-plus';
|
|
4
|
+
import { Media } from './Media';
|
|
5
|
+
import { UploadModals } from '../UploadModals';
|
|
6
|
+
/**
|
|
7
|
+
* 图片空间模态框.
|
|
8
|
+
*/
|
|
9
|
+
export class MediaModals {
|
|
10
|
+
/**
|
|
11
|
+
* 打开图片选择模态框.
|
|
12
|
+
* @param request 请求接口.
|
|
13
|
+
*/
|
|
14
|
+
static use(request) {
|
|
15
|
+
const { token } = theme.useToken();
|
|
16
|
+
const directoryGroupRef = useRef({});
|
|
17
|
+
const directoryCurrentRef = useRef('');
|
|
18
|
+
const directoryCurrentSortTypeRef = useRef('');
|
|
19
|
+
const mediaCallbackRef = useRef(null);
|
|
20
|
+
const [messageApi, contextHolder] = message.useMessage();
|
|
21
|
+
const [uploadModal, contextUploadHolder] = UploadModals.useUpload(['IMAGE']);
|
|
22
|
+
const [isOpenModal, setIsOpenModal] = useState(false);
|
|
23
|
+
const [maxLength, setMaxLength] = useState(1);
|
|
24
|
+
const [directorySelectMaxLength, setDirectorySelectMaxLength] = useState(1);
|
|
25
|
+
const [selectItems, setSelectItems] = useState([]);
|
|
26
|
+
const [directoryItem, setDirectoryItem] = useState([]);
|
|
27
|
+
const [mediaItem, setMediaItem] = useState([]);
|
|
28
|
+
const [progress, setProgress] = useState(0);
|
|
29
|
+
const callbackRef = useRef(undefined);
|
|
30
|
+
const getSelectKeyLength = () => {
|
|
31
|
+
const numbers = Object.keys(directoryGroupRef.current)
|
|
32
|
+
.map(it => directoryGroupRef.current[it])
|
|
33
|
+
.map(it => it.length) ?? [];
|
|
34
|
+
return numbers.reduce((value, current) => value + current, 0);
|
|
35
|
+
};
|
|
36
|
+
const refreshMedia = () => {
|
|
37
|
+
mediaCallbackRef?.current?.(true);
|
|
38
|
+
request.getItems(directoryCurrentRef.current, directoryCurrentSortTypeRef.current)
|
|
39
|
+
.then(items => {
|
|
40
|
+
mediaCallbackRef?.current?.(false);
|
|
41
|
+
setMediaItem(items);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const onConfirm = async () => {
|
|
45
|
+
if (callbackRef.current) {
|
|
46
|
+
const selectItems = Object.keys(directoryGroupRef.current)
|
|
47
|
+
.map(key => directoryGroupRef.current[key] ?? [])
|
|
48
|
+
.flat();
|
|
49
|
+
if (await callbackRef.current(selectItems)) {
|
|
50
|
+
setIsOpenModal(false);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
setIsOpenModal(false);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const handler = {
|
|
58
|
+
ok: (callback, args) => {
|
|
59
|
+
setIsOpenModal(true);
|
|
60
|
+
setMaxLength(args?.maxLength ?? 1);
|
|
61
|
+
if (args?.directoryItem !== undefined) {
|
|
62
|
+
setDirectoryItem(args.directoryItem);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
request.getDirectory()
|
|
66
|
+
.then(directoryItems => {
|
|
67
|
+
setDirectoryItem(directoryItems);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
setProgress(0);
|
|
71
|
+
callbackRef.current = callback;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return [handler, React.createElement(React.Fragment, null,
|
|
75
|
+
React.createElement(Modal, { maskClosable: false, title: React.createElement(Space, { size: 24 },
|
|
76
|
+
React.createElement("span", null, "\u56FE\u7247\u7A7A\u95F4"),
|
|
77
|
+
progress > 0 ? React.createElement(Flux, { style: {
|
|
78
|
+
fontSize: token.fontSize - 1,
|
|
79
|
+
fontWeight: 'normal'
|
|
80
|
+
} },
|
|
81
|
+
React.createElement(Progress, { percent: progress, style: { width: 120 } }),
|
|
82
|
+
React.createElement("span", { style: {
|
|
83
|
+
marginBlockStart: 3,
|
|
84
|
+
fontWeight: 500
|
|
85
|
+
} }, "\u6587\u4EF6\u6B63\u5728\u4E0A\u4F20\uFF0C\u8BF7\u4E0D\u8981\u5173\u95ED\u7A97\u53E3")) : undefined), open: isOpenModal, width: 1035, styles: {
|
|
86
|
+
content: {
|
|
87
|
+
padding: 0
|
|
88
|
+
},
|
|
89
|
+
header: {
|
|
90
|
+
paddingBlock: '16px 12px',
|
|
91
|
+
paddingInline: 24,
|
|
92
|
+
marginInlineStart: 0,
|
|
93
|
+
marginBlockEnd: 0,
|
|
94
|
+
borderBottom: '1px solid rgba(0,0,0,0.08)'
|
|
95
|
+
},
|
|
96
|
+
wrapper: {
|
|
97
|
+
padding: 0
|
|
98
|
+
},
|
|
99
|
+
body: {
|
|
100
|
+
paddingInline: 12
|
|
101
|
+
},
|
|
102
|
+
footer: {
|
|
103
|
+
margin: 0
|
|
104
|
+
}
|
|
105
|
+
}, onCancel: () => setIsOpenModal(false), footer: React.createElement(Flux, { style: {
|
|
106
|
+
justifyContent: 'space-between',
|
|
107
|
+
borderTop: '1px solid rgba(0,0,0,0.08)',
|
|
108
|
+
paddingInline: 24,
|
|
109
|
+
paddingBlock: 12
|
|
110
|
+
} },
|
|
111
|
+
React.createElement("a", null, "\u8FDB\u5165\u56FE\u7247\u7A7A\u95F4"),
|
|
112
|
+
React.createElement(Space, { size: 12 },
|
|
113
|
+
React.createElement(Space, { style: {
|
|
114
|
+
fontSize: 12,
|
|
115
|
+
marginInlineEnd: 8,
|
|
116
|
+
color: 'rgba(0,0,0,0.6)'
|
|
117
|
+
}, size: 2 },
|
|
118
|
+
"\u6700\u591A\u9009",
|
|
119
|
+
React.createElement("span", { style: { color: '#FF7700' } }, maxLength),
|
|
120
|
+
"\u5F20\uFF0C\u5DF2\u9009",
|
|
121
|
+
React.createElement("span", { style: { color: '#FF7700' } }, getSelectKeyLength()),
|
|
122
|
+
"\u5F20"),
|
|
123
|
+
React.createElement(Button, { type: "primary", onClick: () => onConfirm() }, "\u786E\u5B9A"),
|
|
124
|
+
React.createElement(Button, { onClick: () => setIsOpenModal(false) }, "\u53D6\u6D88"))) },
|
|
125
|
+
React.createElement(Media, { directoryItems: directoryItem, items: mediaItem, onUpload: () => {
|
|
126
|
+
if (progress > 0) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
uploadModal.ok(async (files) => {
|
|
130
|
+
if (files === undefined || files.length <= 0) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
setProgress(5);
|
|
134
|
+
const async = async () => {
|
|
135
|
+
const total = files.length;
|
|
136
|
+
let index = 0;
|
|
137
|
+
for (const file of files) {
|
|
138
|
+
index += 1;
|
|
139
|
+
// eslint-disable-next-line no-await-in-loop
|
|
140
|
+
await request.uploadFile(file);
|
|
141
|
+
setProgress(Math.min(5 + Math.floor(95 / total) * index, 100));
|
|
142
|
+
}
|
|
143
|
+
messageApi?.success('文件上传成功!');
|
|
144
|
+
setTimeout(() => {
|
|
145
|
+
setProgress(0);
|
|
146
|
+
}, 500);
|
|
147
|
+
// 刷新页面
|
|
148
|
+
refreshMedia();
|
|
149
|
+
};
|
|
150
|
+
async()
|
|
151
|
+
.then();
|
|
152
|
+
return true;
|
|
153
|
+
});
|
|
154
|
+
}, onDirectoryChange: (key, sortType, callback) => {
|
|
155
|
+
directoryCurrentRef.current = key.toString();
|
|
156
|
+
directoryCurrentSortTypeRef.current = sortType;
|
|
157
|
+
mediaCallbackRef.current = callback;
|
|
158
|
+
const selectItems = directoryGroupRef.current?.[directoryCurrentRef.current] ?? [];
|
|
159
|
+
setDirectorySelectMaxLength(maxLength - getSelectKeyLength() + selectItems.length);
|
|
160
|
+
setSelectItems(selectItems);
|
|
161
|
+
refreshMedia();
|
|
162
|
+
}, onFileChange: (items) => {
|
|
163
|
+
directoryGroupRef.current = {
|
|
164
|
+
...(directoryGroupRef.current ?? {}),
|
|
165
|
+
[directoryCurrentRef.current]: items
|
|
166
|
+
};
|
|
167
|
+
setSelectItems(items);
|
|
168
|
+
}, value: selectItems, maxLength: directorySelectMaxLength })),
|
|
169
|
+
contextHolder,
|
|
170
|
+
contextUploadHolder)];
|
|
171
|
+
}
|
|
172
|
+
}
|