beer-assembly-biz 1.1.3-alpha.2 → 1.1.3-alpha.20
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/ProgressModal.d.ts +7 -0
- package/ProgressModal.js +34 -0
- package/UploadModals.d.ts +12 -0
- package/UploadModals.js +239 -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/config/index.js +76 -76
- package/index.d.ts +8 -3
- package/index.js +7 -2
- package/layout/AppLayout.d.ts +34 -2
- package/layout/AppLayout.js +46 -29
- package/layout/BackPageContainer.d.ts +1 -0
- package/layout/BackPageContainer.js +4 -1
- package/layout/SubMenusContainer.d.ts +27 -0
- package/layout/SubMenusContainer.js +71 -0
- 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 +36 -33
- package/promises.d.ts +7 -1
- package/promises.js +20 -9
package/layout/AppLayout.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { css } from '@emotion/css';
|
|
3
3
|
import { ProLayout } from '@ant-design/pro-components';
|
|
4
|
-
import { Dropdown, message, theme, Typography } from 'antd';
|
|
4
|
+
import { Alert, Dropdown, message, theme, Typography } from 'antd';
|
|
5
5
|
import { Session } from 'beer-network/session';
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
7
|
+
import Marquee from 'react-fast-marquee';
|
|
8
|
+
import ImageLayout01 from '../images/layout_01.png';
|
|
9
|
+
import ImageLayout02 from '../images/layout_02.png';
|
|
10
|
+
import ImageLayout03 from '../images/layout_03.png';
|
|
10
11
|
dayjs.locale('zh-cn');
|
|
11
12
|
/**
|
|
12
13
|
* 通用布局.
|
|
@@ -103,6 +104,7 @@ export const AppLayout = (props) => {
|
|
|
103
104
|
refreshPath()
|
|
104
105
|
.then();
|
|
105
106
|
}, [menus, props.path]);
|
|
107
|
+
// 更新属性触发: 菜单
|
|
106
108
|
// 更新属性触发: 请求用户信息
|
|
107
109
|
useEffect(() => {
|
|
108
110
|
props.requestUser()
|
|
@@ -118,6 +120,10 @@ export const AppLayout = (props) => {
|
|
|
118
120
|
return React.createElement(React.Fragment, null,
|
|
119
121
|
contextHolder,
|
|
120
122
|
React.createElement(ProLayout, { theme: "light", className: css `
|
|
123
|
+
.ant-pro-global-header-logo {
|
|
124
|
+
margin-inline-end: 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
121
127
|
.ant-pro-sider-logo {
|
|
122
128
|
.ant-pro-layout-apps-icon {
|
|
123
129
|
display: ${collapsed ? 'flex' : 'none'};
|
|
@@ -156,7 +162,9 @@ export const AppLayout = (props) => {
|
|
|
156
162
|
.ant-pro-sider-collapsed-button {
|
|
157
163
|
inset-block-start: 15px;
|
|
158
164
|
}
|
|
159
|
-
`,
|
|
165
|
+
`, style: {
|
|
166
|
+
minWidth: 1000
|
|
167
|
+
}, selectedKeys: pathKeys, locale: "zh-CN", navTheme: "light", fixSiderbar: true, layout: "mix", contentWidth: "Fluid", splitMenus: false, bgLayoutImgList: [
|
|
160
168
|
{
|
|
161
169
|
src: ImageLayout01,
|
|
162
170
|
left: 85,
|
|
@@ -175,26 +183,26 @@ export const AppLayout = (props) => {
|
|
|
175
183
|
left: 0,
|
|
176
184
|
width: '331px'
|
|
177
185
|
}
|
|
178
|
-
], siderWidth:
|
|
179
|
-
bgLayout: '#
|
|
186
|
+
], siderWidth: props?.siderWidth ?? 190, breakpoint: props?.siderMenuType === 'group' ? 'xs' : undefined, token: {
|
|
187
|
+
bgLayout: '#F5F7FA',
|
|
180
188
|
header: {
|
|
181
189
|
heightLayoutHeader: 48
|
|
182
190
|
},
|
|
183
191
|
sider: {
|
|
184
|
-
menuHeight: token.controlHeight
|
|
192
|
+
menuHeight: props?.siderMenusItemHeight ?? token.controlHeight,
|
|
185
193
|
paddingBlockLayoutMenu: 4,
|
|
186
194
|
paddingInlineLayoutMenu: 4,
|
|
187
195
|
colorMenuBackground: '#fff',
|
|
188
|
-
colorTextMenu: '
|
|
189
|
-
colorTextMenuSelected: 'rgba(0,0,0,0.
|
|
196
|
+
colorTextMenu: 'rgba(0,0,0,0.75)',
|
|
197
|
+
colorTextMenuSelected: 'rgba(0,0,0,0.85)',
|
|
190
198
|
colorBgMenuItemSelected: 'rgba(0,0,0,0.08)'
|
|
191
199
|
},
|
|
192
200
|
pageContainer: {
|
|
193
201
|
paddingInlinePageContainerContent: 0,
|
|
194
202
|
paddingBlockPageContainerContent: 0
|
|
195
203
|
}
|
|
196
|
-
}, siderMenuType: 'sub', fixedHeader: true, collapsedButtonRender: (
|
|
197
|
-
return isMobile ? undefined : reactNode;
|
|
204
|
+
}, siderMenuType: props?.siderMenuType ?? 'sub', fixedHeader: true, collapsedButtonRender: (_collapsed, reactNode) => {
|
|
205
|
+
return isMobile || props?.siderMenuType === 'group' ? undefined : reactNode;
|
|
198
206
|
}, appList: (props.apps?.length || 0) > 1 || collapsed ? props.apps?.map(it => {
|
|
199
207
|
return {
|
|
200
208
|
...it,
|
|
@@ -203,7 +211,9 @@ export const AppLayout = (props) => {
|
|
|
203
211
|
desc: it.description,
|
|
204
212
|
url: it.defaultPath || it.path
|
|
205
213
|
};
|
|
206
|
-
}) : [],
|
|
214
|
+
}) : [], headerContentRender: () => {
|
|
215
|
+
return props?.headerContentRender;
|
|
216
|
+
}, menuHeaderRender: (_logo, _title, props) => {
|
|
207
217
|
if (props !== undefined) {
|
|
208
218
|
setTimeout(() => {
|
|
209
219
|
setCollapsed(props?.collapsed === true);
|
|
@@ -215,7 +225,8 @@ export const AppLayout = (props) => {
|
|
|
215
225
|
textIndent: 10,
|
|
216
226
|
fontSize: token.fontSize + 2,
|
|
217
227
|
color: '#333',
|
|
218
|
-
fontWeight:
|
|
228
|
+
fontWeight: 600,
|
|
229
|
+
minWidth: ((props?.siderWidth ?? 190) - 30)
|
|
219
230
|
} }, app?.name));
|
|
220
231
|
}, menu: {
|
|
221
232
|
collapsedShowTitle: false,
|
|
@@ -224,35 +235,40 @@ export const AppLayout = (props) => {
|
|
|
224
235
|
request: async () => {
|
|
225
236
|
return requestMenuItems();
|
|
226
237
|
}
|
|
227
|
-
}, subMenuItemRender: (
|
|
238
|
+
}, subMenuItemRender: (menuDataItemProps, _defaultDom, menuProps) => {
|
|
239
|
+
if (props?.siderMenuType === 'group') {
|
|
240
|
+
return React.createElement("span", { style: {
|
|
241
|
+
marginLeft: 4,
|
|
242
|
+
color: 'rgba(0,0,0,0.55)',
|
|
243
|
+
fontSize: token.fontSize - 2
|
|
244
|
+
} }, menuDataItemProps.name);
|
|
245
|
+
}
|
|
228
246
|
return React.createElement("div", { style: {
|
|
229
|
-
height: token.controlHeight
|
|
247
|
+
height: props?.siderMenusItemHeight ?? token.controlHeight,
|
|
230
248
|
fontSize: token.fontSize,
|
|
231
249
|
display: 'flex',
|
|
232
250
|
alignItems: 'center',
|
|
233
251
|
justifyContent: menuProps.collapsed ? 'center' : undefined,
|
|
234
252
|
cursor: 'pointer',
|
|
235
|
-
width: '100%'
|
|
236
|
-
color: '#0c0d0e'
|
|
253
|
+
width: '100%'
|
|
237
254
|
} },
|
|
238
|
-
React.createElement("img", { src: (
|
|
255
|
+
React.createElement("img", { src: (menuDataItemProps.icon || '') === '' ? undefined : menuDataItemProps.icon?.toString(), style: {
|
|
239
256
|
width: 20,
|
|
240
257
|
display: 'block',
|
|
241
|
-
marginInlineEnd:
|
|
258
|
+
marginInlineEnd: menuDataItemProps.collapsed ? 0 : 4
|
|
242
259
|
}, alt: "" }),
|
|
243
|
-
menuProps.collapsed ? undefined :
|
|
260
|
+
menuProps.collapsed ? undefined : menuDataItemProps.name);
|
|
244
261
|
}, menuItemRender: (props, defaultDom, menuProps) => {
|
|
245
262
|
const isSub = (props.locale?.toString()
|
|
246
263
|
?.split('.') || []).length > 2;
|
|
247
264
|
return React.createElement("a", { style: {
|
|
248
265
|
fontSize: token.fontSize,
|
|
249
266
|
userSelect: 'none',
|
|
250
|
-
height: token.controlHeight
|
|
267
|
+
height: props?.siderMenusItemHeight ?? token.controlHeight,
|
|
251
268
|
display: 'flex',
|
|
252
269
|
alignItems: 'center',
|
|
253
270
|
justifyContent: menuProps.collapsed && !isSub ? 'center' : undefined,
|
|
254
|
-
cursor: 'pointer'
|
|
255
|
-
color: '#0c0d0e'
|
|
271
|
+
cursor: 'pointer'
|
|
256
272
|
}, onClick: (e) => {
|
|
257
273
|
e.preventDefault();
|
|
258
274
|
if (props.isUrl || !props.path) {
|
|
@@ -285,10 +301,7 @@ export const AppLayout = (props) => {
|
|
|
285
301
|
React.createElement("img", { src: props?.logo?.path, alt: "" })), title: false, avatarProps: {
|
|
286
302
|
src: (userInfo?.avatar || '') === '' ? '/avatar.png' : userInfo?.avatar,
|
|
287
303
|
size: 'small',
|
|
288
|
-
title:
|
|
289
|
-
color: '#333',
|
|
290
|
-
fontSize: token.fontSize + 1
|
|
291
|
-
} }, userInfo?.nickName || '系统用户'),
|
|
304
|
+
title: props?.avatarTitle?.(userInfo),
|
|
292
305
|
render: (_props, dom) => {
|
|
293
306
|
return (React.createElement(Dropdown, { menu: {
|
|
294
307
|
items: [
|
|
@@ -336,5 +349,9 @@ export const AppLayout = (props) => {
|
|
|
336
349
|
return [];
|
|
337
350
|
}
|
|
338
351
|
return props?.headerMenus || [];
|
|
339
|
-
} },
|
|
352
|
+
} },
|
|
353
|
+
props?.alter?.enable === true ? React.createElement(Alert, { banner: true, style: {
|
|
354
|
+
paddingInline: 24
|
|
355
|
+
}, message: props?.alter?.marquee === true ? React.createElement(Marquee, { pauseOnHover: true, gradient: false }, props?.alter?.message) : props?.alter?.message }) : undefined,
|
|
356
|
+
props.children));
|
|
340
357
|
};
|
|
@@ -11,7 +11,10 @@ export const BackPageContainer = (props) => {
|
|
|
11
11
|
const navigate = useNavigate();
|
|
12
12
|
return React.createElement(React.Fragment, null,
|
|
13
13
|
React.createElement(PageContainer, { onBack: () => {
|
|
14
|
-
|
|
14
|
+
const defaultBack = () => {
|
|
15
|
+
return navigate(-1);
|
|
16
|
+
};
|
|
17
|
+
(props?.onBack ?? defaultBack)?.();
|
|
15
18
|
}, className: css `
|
|
16
19
|
.ant-page-header-heading {
|
|
17
20
|
padding-block-start: 0 !important;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { CSSProperties, FC } from 'react';
|
|
2
|
+
import type { ComponentToken as MenuComponentToken } from 'antd/es/menu/style';
|
|
3
|
+
export declare type SubMenusItem = {
|
|
4
|
+
key?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
label: string | React.ReactNode;
|
|
7
|
+
children: SubMenusItem[];
|
|
8
|
+
};
|
|
9
|
+
export declare type SubMenusProps = {
|
|
10
|
+
items: SubMenusItem[];
|
|
11
|
+
token?: MenuComponentToken | undefined;
|
|
12
|
+
gap?: number | undefined;
|
|
13
|
+
height?: number | string | undefined;
|
|
14
|
+
width?: number | undefined;
|
|
15
|
+
padding?: number | string | undefined;
|
|
16
|
+
styles?: {
|
|
17
|
+
menus?: CSSProperties | undefined;
|
|
18
|
+
body?: CSSProperties | undefined;
|
|
19
|
+
};
|
|
20
|
+
header?: React.ReactNode | undefined;
|
|
21
|
+
children?: React.ReactNode | undefined;
|
|
22
|
+
value?: string | undefined;
|
|
23
|
+
openKeys?: string[] | undefined;
|
|
24
|
+
onChange?: (key: string) => void;
|
|
25
|
+
onOpenChange?: (keys: string[]) => void;
|
|
26
|
+
};
|
|
27
|
+
export declare const SubMenusContainer: FC<SubMenusProps>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { ConfigProvider, Menu } from 'antd';
|
|
3
|
+
export const SubMenusContainer = (props) => {
|
|
4
|
+
const [selectKeys, setSelectKeys] = useState([]);
|
|
5
|
+
const [openKeys, setOpenKeys] = useState([]);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (props?.value === undefined) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
setSelectKeys([props.value]);
|
|
11
|
+
}, [props?.value]);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (props?.openKeys === undefined) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
setOpenKeys(props.openKeys);
|
|
17
|
+
}, [props?.openKeys]);
|
|
18
|
+
return React.createElement(React.Fragment, null,
|
|
19
|
+
React.createElement(ConfigProvider, { theme: {
|
|
20
|
+
components: {
|
|
21
|
+
Menu: props?.token || {
|
|
22
|
+
itemHeight: 36,
|
|
23
|
+
itemBorderRadius: 0,
|
|
24
|
+
iconMarginInlineEnd: 0,
|
|
25
|
+
itemMarginBlock: 0,
|
|
26
|
+
itemMarginInline: 0,
|
|
27
|
+
itemPaddingInline: 0,
|
|
28
|
+
subMenuItemBg: 'transparent',
|
|
29
|
+
itemHoverBg: 'rgba(22,100,255,.04)',
|
|
30
|
+
itemHoverColor: '#000',
|
|
31
|
+
itemActiveBg: 'rgba(22,100,255,.08)',
|
|
32
|
+
itemSelectedBg: 'rgba(22,100,255,.08)'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
} },
|
|
36
|
+
React.createElement("div", { style: {
|
|
37
|
+
display: 'flex',
|
|
38
|
+
gap: `${props?.gap || 12}px`,
|
|
39
|
+
alignItems: 'flex-start',
|
|
40
|
+
width: '100%'
|
|
41
|
+
} },
|
|
42
|
+
React.createElement("div", { style: {
|
|
43
|
+
width: props?.width || 200,
|
|
44
|
+
backgroundColor: '#fff',
|
|
45
|
+
height: props?.height || '100vh',
|
|
46
|
+
userSelect: 'none',
|
|
47
|
+
overflow: 'hidden',
|
|
48
|
+
...(props?.styles?.menus || {})
|
|
49
|
+
} },
|
|
50
|
+
props?.header !== undefined ? React.createElement("div", { style: {
|
|
51
|
+
padding: '12px 0',
|
|
52
|
+
fontWeight: 500,
|
|
53
|
+
borderInlineEnd: '1px solid rgba(5,5,5,.06)',
|
|
54
|
+
borderBlockEnd: '1px solid rgba(5,5,5,.06)'
|
|
55
|
+
} }, props?.header) : undefined,
|
|
56
|
+
React.createElement(Menu, { style: {
|
|
57
|
+
height: '100%'
|
|
58
|
+
}, onClick: (e) => {
|
|
59
|
+
props?.onChange?.(e.key);
|
|
60
|
+
}, onOpenChange: (e) => {
|
|
61
|
+
props?.onOpenChange?.(e);
|
|
62
|
+
}, subMenuCloseDelay: 0, selectedKeys: selectKeys, openKeys: openKeys, mode: "inline", inlineIndent: 16, items: props?.items })),
|
|
63
|
+
React.createElement("div", { style: {
|
|
64
|
+
width: `calc(100% - ${(props?.width || 200) + (props?.gap || 12) + (props?.gap || 12)}px)`,
|
|
65
|
+
marginRight: (props?.gap || 12),
|
|
66
|
+
height: '100%',
|
|
67
|
+
padding: props?.padding || '12px 0',
|
|
68
|
+
...(props?.styles?.body || {}),
|
|
69
|
+
overflow: 'auto'
|
|
70
|
+
} }, props?.children))));
|
|
71
|
+
};
|
package/media/Media.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { CSSProperties, FC, Key } from 'react';
|
|
2
|
+
import { TreeDataNode } from 'antd';
|
|
3
|
+
export declare type MediaItem = {
|
|
4
|
+
/**
|
|
5
|
+
* 资源唯一标识.
|
|
6
|
+
*/
|
|
7
|
+
key: string;
|
|
8
|
+
/**
|
|
9
|
+
* 文件名称.
|
|
10
|
+
*/
|
|
11
|
+
fileName: string;
|
|
12
|
+
/**
|
|
13
|
+
* 文件长度.
|
|
14
|
+
*/
|
|
15
|
+
fileLength?: string;
|
|
16
|
+
/**
|
|
17
|
+
* 文件属性.
|
|
18
|
+
*/
|
|
19
|
+
attribute?: {
|
|
20
|
+
resolution?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* 文件实际地址.
|
|
24
|
+
*/
|
|
25
|
+
url?: string;
|
|
26
|
+
/**
|
|
27
|
+
* 预览地址 缩略图.
|
|
28
|
+
*/
|
|
29
|
+
preview?: string;
|
|
30
|
+
};
|
|
31
|
+
export declare type DirectoryItem = {
|
|
32
|
+
/**
|
|
33
|
+
* 宽度 (控制是否显示省略号).
|
|
34
|
+
*/
|
|
35
|
+
width?: number;
|
|
36
|
+
children?: DirectoryItem[];
|
|
37
|
+
} & TreeDataNode;
|
|
38
|
+
export declare type MediaProps = {
|
|
39
|
+
/**
|
|
40
|
+
* 已选组件.
|
|
41
|
+
*/
|
|
42
|
+
value?: MediaItem[];
|
|
43
|
+
/**
|
|
44
|
+
* 样式.
|
|
45
|
+
*/
|
|
46
|
+
style?: CSSProperties;
|
|
47
|
+
/**
|
|
48
|
+
* 目录宽度.
|
|
49
|
+
*/
|
|
50
|
+
directoryWidth?: number;
|
|
51
|
+
/**
|
|
52
|
+
* 组件高度.
|
|
53
|
+
*/
|
|
54
|
+
height?: number;
|
|
55
|
+
/**
|
|
56
|
+
* 目录项.
|
|
57
|
+
*/
|
|
58
|
+
directoryItems?: DirectoryItem[];
|
|
59
|
+
/**
|
|
60
|
+
* 资源项.
|
|
61
|
+
*/
|
|
62
|
+
items?: MediaItem[];
|
|
63
|
+
/**
|
|
64
|
+
* 选择目录回执.
|
|
65
|
+
* @param key 目录ID.
|
|
66
|
+
* @param sortType 排序类型.
|
|
67
|
+
* @param callback 异步状态.
|
|
68
|
+
*/
|
|
69
|
+
onDirectoryChange?: (key: Key, sortType: string, callback: (status: boolean) => void) => void;
|
|
70
|
+
/**
|
|
71
|
+
* 选择资源发生变化.
|
|
72
|
+
* @param items 资源列表。
|
|
73
|
+
*/
|
|
74
|
+
onFileChange?: (items: MediaItem[]) => void;
|
|
75
|
+
/**
|
|
76
|
+
* 上传文件.
|
|
77
|
+
*/
|
|
78
|
+
onUpload?: () => void;
|
|
79
|
+
/**
|
|
80
|
+
* 最大长度.
|
|
81
|
+
*/
|
|
82
|
+
maxLength?: number;
|
|
83
|
+
};
|
|
84
|
+
export declare const Media: FC<MediaProps>;
|
package/media/Media.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Button, Checkbox, ConfigProvider, Form, Input, Select, Space, Spin, theme, Tree, Typography } from 'antd';
|
|
3
|
+
import { Flux } from 'beer-assembly-plus';
|
|
4
|
+
import { CaretDownOutlined, CloudUploadOutlined, SearchOutlined, UnorderedListOutlined } from '@ant-design/icons';
|
|
5
|
+
import { css } from '@emotion/css';
|
|
6
|
+
export const Media = (props) => {
|
|
7
|
+
const { token } = theme.useToken();
|
|
8
|
+
const [form] = Form.useForm();
|
|
9
|
+
const [loading, setLoading] = useState(false);
|
|
10
|
+
const [keyword, setKeyword] = useState('');
|
|
11
|
+
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
12
|
+
const [expandedKeys, setExpandedKeys] = useState([]);
|
|
13
|
+
const onChange = (current) => {
|
|
14
|
+
if (current !== undefined && current?.sortType !== undefined) {
|
|
15
|
+
onDirectoryChange();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const values = form.getFieldsValue();
|
|
19
|
+
props?.onFileChange?.(Object.keys(values)
|
|
20
|
+
.filter(key => values[key] === true)
|
|
21
|
+
.map((key) => {
|
|
22
|
+
return (props?.items ?? []).find(it => it.key === key);
|
|
23
|
+
})
|
|
24
|
+
.filter(it => it !== undefined));
|
|
25
|
+
};
|
|
26
|
+
const onDirectoryChange = (key) => {
|
|
27
|
+
key = key === undefined ? selectedKeys?.[0] : key;
|
|
28
|
+
if (key === undefined) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
setSelectedKeys([key]);
|
|
32
|
+
props?.onDirectoryChange?.(key, form.getFieldValue('sortType') ?? 'DEFAULT', (status) => {
|
|
33
|
+
setLoading(status);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const recursion = (items, depth = 3) => {
|
|
37
|
+
if (depth <= 0) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
const result = items.filter(item => (item?.children ?? []).length > 0) ?? [];
|
|
41
|
+
return [...(result.map(item => item.key)), ...recursion(result?.map(item => item?.children ?? [])
|
|
42
|
+
.flat(), depth - 1)];
|
|
43
|
+
};
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const values = {};
|
|
46
|
+
for (const key of (props?.value?.map(item => item.key) ?? [])) {
|
|
47
|
+
values[key] = true;
|
|
48
|
+
}
|
|
49
|
+
form.setFieldsValue(values);
|
|
50
|
+
}, [props?.value]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (selectedKeys.length > 0) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (props?.directoryItems === undefined) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const directoryItem = props?.directoryItems?.[0];
|
|
59
|
+
if (directoryItem === undefined) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const directoryItemKey = directoryItem.key;
|
|
63
|
+
setSelectedKeys([directoryItemKey]);
|
|
64
|
+
setExpandedKeys(recursion(props?.directoryItems?.filter(item => (item.children ?? []).length > 0) ?? []));
|
|
65
|
+
onDirectoryChange(directoryItemKey);
|
|
66
|
+
form.setFieldsValue({ sortType: 'CREATE_TIME_DESC' });
|
|
67
|
+
}, [props?.directoryItems]);
|
|
68
|
+
return React.createElement(ConfigProvider, { theme: {
|
|
69
|
+
algorithm: theme.defaultAlgorithm,
|
|
70
|
+
token: {
|
|
71
|
+
colorBgContainerDisabled: '#fff',
|
|
72
|
+
colorBgTextHover: 'rgba(6,6,6,0.06)'
|
|
73
|
+
},
|
|
74
|
+
components: {
|
|
75
|
+
Tree: {
|
|
76
|
+
paddingXS: 0,
|
|
77
|
+
borderRadius: 2,
|
|
78
|
+
directoryNodeSelectedBg: token.colorPrimaryBg,
|
|
79
|
+
directoryNodeSelectedColor: token.colorPrimary,
|
|
80
|
+
// 屏蔽样式
|
|
81
|
+
nodeHoverColor: 'none',
|
|
82
|
+
nodeSelectedColor: '#333',
|
|
83
|
+
indentSize: 6,
|
|
84
|
+
titleHeight: 20,
|
|
85
|
+
fontSize: 13
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
} },
|
|
89
|
+
React.createElement("div", { style: {
|
|
90
|
+
...(props?.style ?? {}),
|
|
91
|
+
borderRadius: token.borderRadius + 2,
|
|
92
|
+
display: 'flex',
|
|
93
|
+
justifyContent: 'space-between',
|
|
94
|
+
userSelect: 'none',
|
|
95
|
+
alignItems: 'stretch'
|
|
96
|
+
} },
|
|
97
|
+
React.createElement(Tree.DirectoryTree, { className: css `
|
|
98
|
+
.ant-tree-treenode {
|
|
99
|
+
padding-inline: 4px;
|
|
100
|
+
align-items: center;
|
|
101
|
+
}
|
|
102
|
+
`, expandAction: false, style: {
|
|
103
|
+
height: '100%',
|
|
104
|
+
display: 'block',
|
|
105
|
+
minWidth: props?.directoryWidth ?? 180,
|
|
106
|
+
maxWidth: props?.directoryWidth ?? 180,
|
|
107
|
+
paddingBlockStart: 12,
|
|
108
|
+
paddingInlineEnd: 12,
|
|
109
|
+
overflow: 'auto'
|
|
110
|
+
}, onSelect: (selectKeys) => {
|
|
111
|
+
const key = selectKeys[selectKeys.length - 1];
|
|
112
|
+
onDirectoryChange(key);
|
|
113
|
+
}, onExpand: (expandedKeys) => {
|
|
114
|
+
setExpandedKeys(expandedKeys);
|
|
115
|
+
}, treeData: props?.directoryItems ?? [], selectedKeys: selectedKeys, expandedKeys: expandedKeys, icon: false, switcherIcon: () => {
|
|
116
|
+
return React.createElement(CaretDownOutlined, { style: {
|
|
117
|
+
fontSize: 10,
|
|
118
|
+
marginBlockEnd: 2
|
|
119
|
+
} });
|
|
120
|
+
}, titleRender: (data) => {
|
|
121
|
+
return React.createElement("div", { style: {
|
|
122
|
+
display: 'flex',
|
|
123
|
+
alignItems: 'center',
|
|
124
|
+
height: 30
|
|
125
|
+
} },
|
|
126
|
+
React.createElement("div", { style: {
|
|
127
|
+
width: data?.width ?? 100,
|
|
128
|
+
overflow: 'hidden',
|
|
129
|
+
textOverflow: 'ellipsis',
|
|
130
|
+
whiteSpace: 'nowrap'
|
|
131
|
+
} }, data.title));
|
|
132
|
+
} }),
|
|
133
|
+
React.createElement(Form, { style: {
|
|
134
|
+
width: '100%',
|
|
135
|
+
paddingBlockStart: 12,
|
|
136
|
+
paddingLeft: 12,
|
|
137
|
+
borderLeft: '1px solid rgba(0,0,0,0.08)'
|
|
138
|
+
}, form: form, onValuesChange: (current) => onChange(current) },
|
|
139
|
+
React.createElement(Flux, { style: {
|
|
140
|
+
justifyContent: 'space-between',
|
|
141
|
+
paddingInlineStart: 2,
|
|
142
|
+
paddingInlineEnd: 6,
|
|
143
|
+
paddingBlockEnd: 12,
|
|
144
|
+
borderBottom: '1px solid rgba(0,0,0,0.08)'
|
|
145
|
+
} },
|
|
146
|
+
React.createElement(Space, null,
|
|
147
|
+
React.createElement(Form.Item, { noStyle: true, name: "sortType" },
|
|
148
|
+
React.createElement(Select, { options: [{
|
|
149
|
+
label: '文件名称(升序)',
|
|
150
|
+
value: 'NAME_ASC'
|
|
151
|
+
}, {
|
|
152
|
+
label: '文件名称(降序)',
|
|
153
|
+
value: 'NAME_DESC'
|
|
154
|
+
}, {
|
|
155
|
+
label: '上传时间(升序)',
|
|
156
|
+
value: 'CREATE_TIME_ASC'
|
|
157
|
+
}, {
|
|
158
|
+
label: '上传时间(降序)',
|
|
159
|
+
value: 'CREATE_TIME_DESC'
|
|
160
|
+
}], prefix: React.createElement(UnorderedListOutlined, { style: { marginRight: 4 } }) })),
|
|
161
|
+
React.createElement(Input, { placeholder: "\u8BF7\u8F93\u5165\u6587\u4EF6\u540D\u79F0", prefix: React.createElement(SearchOutlined, { style: { marginRight: 4 } }), onChange: (e) => {
|
|
162
|
+
setKeyword(e.target.value);
|
|
163
|
+
} })),
|
|
164
|
+
React.createElement(Button, { icon: React.createElement(CloudUploadOutlined, { style: {
|
|
165
|
+
marginRight: 0,
|
|
166
|
+
fontSize: token.fontSize + 2
|
|
167
|
+
} }), type: "primary", onClick: () => {
|
|
168
|
+
props?.onUpload?.();
|
|
169
|
+
} }, "\u672C\u5730\u4E0A\u4F20")),
|
|
170
|
+
React.createElement(Spin, { spinning: loading },
|
|
171
|
+
React.createElement(Flux, { style: {
|
|
172
|
+
marginBlock: 4,
|
|
173
|
+
paddingBlock: 4,
|
|
174
|
+
paddingInlineStart: 2,
|
|
175
|
+
paddingInlineEnd: 6,
|
|
176
|
+
flexWrap: 'wrap',
|
|
177
|
+
overflow: 'auto',
|
|
178
|
+
height: props?.height ?? 500
|
|
179
|
+
}, size: 12, alignItems: "flex-start" }, props?.items?.filter(item => {
|
|
180
|
+
return item?.fileName?.indexOf(keyword) > -1;
|
|
181
|
+
})
|
|
182
|
+
.map((item, i) => (React.createElement("div", { key: i, style: {
|
|
183
|
+
width: 140,
|
|
184
|
+
borderRadius: token.borderRadius + 2,
|
|
185
|
+
border: '1px solid rgba(0,0,0,0.1)',
|
|
186
|
+
overflow: 'hidden',
|
|
187
|
+
position: 'relative',
|
|
188
|
+
padding: 4,
|
|
189
|
+
cursor: (props?.maxLength ?? 1) <= (props?.value ?? []).length && props?.value?.find(it => it.key === item.key) === undefined ? 'not-allowed' : 'pointer'
|
|
190
|
+
}, className: css `
|
|
191
|
+
&:hover {
|
|
192
|
+
outline: 1px solid ${token.colorPrimary} !important;
|
|
193
|
+
border-color: ${token.colorPrimary} !important;
|
|
194
|
+
}
|
|
195
|
+
` },
|
|
196
|
+
React.createElement(Form.Item, { noStyle: true, name: [item.key], valuePropName: "checked" },
|
|
197
|
+
React.createElement(Checkbox, { style: {
|
|
198
|
+
position: 'absolute',
|
|
199
|
+
top: 8,
|
|
200
|
+
right: 12
|
|
201
|
+
}, disabled: (props?.maxLength ?? 1) <= (props?.value ?? []).length && props?.value?.find(it => it.key === item.key) === undefined })),
|
|
202
|
+
React.createElement("div", { onClick: () => {
|
|
203
|
+
const status = form.getFieldValue([item.key]);
|
|
204
|
+
if ((props?.maxLength ?? 1) <= (props?.value ?? []).length && !(status === true)) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
form.setFieldsValue({
|
|
208
|
+
[item.key]: !form.getFieldValue([item.key])
|
|
209
|
+
});
|
|
210
|
+
onChange();
|
|
211
|
+
} },
|
|
212
|
+
React.createElement("img", { src: item?.preview ?? item?.url, alt: "", style: {
|
|
213
|
+
display: 'block',
|
|
214
|
+
width: 140,
|
|
215
|
+
height: 120,
|
|
216
|
+
objectFit: 'cover',
|
|
217
|
+
userSelect: 'none',
|
|
218
|
+
pointerEvents: 'none',
|
|
219
|
+
borderRadius: token.borderRadius
|
|
220
|
+
} }),
|
|
221
|
+
React.createElement("div", { style: {
|
|
222
|
+
padding: '2px 2px 0 2px'
|
|
223
|
+
} },
|
|
224
|
+
React.createElement(Typography.Paragraph, { ellipsis: true, style: {
|
|
225
|
+
margin: 0,
|
|
226
|
+
padding: 0,
|
|
227
|
+
fontSize: 12,
|
|
228
|
+
lineHeight: 1.6,
|
|
229
|
+
color: '#333'
|
|
230
|
+
} }, item?.fileName),
|
|
231
|
+
React.createElement(Flux, { style: {
|
|
232
|
+
margin: 0,
|
|
233
|
+
padding: 0,
|
|
234
|
+
lineHeight: 1.45,
|
|
235
|
+
fontSize: token.fontSize - 2,
|
|
236
|
+
justifyContent: 'space-between',
|
|
237
|
+
color: '#666'
|
|
238
|
+
} },
|
|
239
|
+
React.createElement("span", null, item?.attribute?.resolution),
|
|
240
|
+
React.createElement("span", null, item?.fileLength))))))))))));
|
|
241
|
+
};
|
package/media/MediaModals.d.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Handler } from '../type';
|
|
3
|
+
import { DirectoryItem, MediaItem } from './Media';
|
|
4
|
+
/**
|
|
5
|
+
* 图片空间模态框.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MediaModals {
|
|
8
|
+
/**
|
|
9
|
+
* 打开图片选择模态框.
|
|
10
|
+
* @param request 请求接口.
|
|
11
|
+
*/
|
|
12
|
+
static use(request: {
|
|
13
|
+
getDirectory: () => Promise<DirectoryItem[]>;
|
|
14
|
+
getItems: (directoryId: string, sortType: string) => Promise<MediaItem[]>;
|
|
15
|
+
uploadFile: (file: File) => Promise<boolean>;
|
|
16
|
+
}): [Handler<MediaItem[]>, ReactNode];
|
|
17
|
+
}
|