beer-assembly-biz 1.1.2-alpha.9 → 1.1.3-alpha.10

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.
Files changed (183) hide show
  1. package/UploadModals.d.ts +12 -0
  2. package/UploadModals.js +233 -0
  3. package/UserModals.d.ts +7 -3
  4. package/UserModals.js +6 -0
  5. package/auth/AuthPassword.d.ts +2 -3
  6. package/auth/AuthPassword.js +5 -5
  7. package/auth/AuthStyle01.d.ts +3 -4
  8. package/auth/AuthStyle01.js +4 -5
  9. package/auth/AuthStyle02.d.ts +3 -4
  10. package/auth/AuthStyle02.js +4 -5
  11. package/auth/AuthThirdPartyAuth.d.ts +2 -3
  12. package/auth/AuthThirdPartyAuth.js +1 -2
  13. package/content/ParentContext.d.ts +4 -2
  14. package/content/ParentContext.js +4 -2
  15. package/content/PermissionContext.d.ts +4 -2
  16. package/content/PermissionContext.js +4 -2
  17. package/icon/icon/directory.svg +12 -0
  18. package/icon/icon/empty.svg +43 -0
  19. package/icon/icon/media.png +0 -0
  20. package/icon/icon/volc.svg +96 -0
  21. package/images/images/assets_background_01.png +0 -0
  22. package/images/images/avatar.png +0 -0
  23. package/images/images/layout_01.png +0 -0
  24. package/images/images/layout_02.png +0 -0
  25. package/images/images/layout_03.png +0 -0
  26. package/index.d.ts +18 -0
  27. package/index.js +18 -0
  28. package/{AppLayout.d.ts → layout/AppLayout.d.ts} +4 -2
  29. package/{AppLayout.js → layout/AppLayout.js} +7 -5
  30. package/{BackPageContainer.d.ts → layout/BackPageContainer.d.ts} +5 -2
  31. package/{BackPageContainer.js → layout/BackPageContainer.js} +8 -3
  32. package/{MyPageContainer.d.ts → layout/MyPageContainer.d.ts} +4 -2
  33. package/{MyPageContainer.js → layout/MyPageContainer.js} +5 -3
  34. package/{SubMenusContainer.d.ts → layout/SubMenusContainer.d.ts} +5 -5
  35. package/{SubMenusContainer.js → layout/SubMenusContainer.js} +2 -3
  36. package/media/Media.d.ts +84 -0
  37. package/media/Media.js +241 -0
  38. package/media/MediaModals.d.ts +17 -0
  39. package/media/MediaModals.js +172 -0
  40. package/net-disk/DirectoryMenusPanel.d.ts +0 -0
  41. package/net-disk/DirectoryMenusPanel.js +337 -0
  42. package/net-disk/DirectorySelect.d.ts +0 -0
  43. package/net-disk/DirectorySelect.js +240 -0
  44. package/net-disk/FileItemList.d.ts +0 -0
  45. package/net-disk/FileItemList.js +126 -0
  46. package/net-disk/FileItemTable.d.ts +0 -0
  47. package/net-disk/FileItemTable.js +422 -0
  48. package/net-disk/FileNavigation.d.ts +0 -0
  49. package/net-disk/FileNavigation.js +43 -0
  50. package/net-disk/NetDisk.d.ts +0 -0
  51. package/net-disk/NetDisk.js +36 -0
  52. package/net-disk/NetDiskModals.d.ts +0 -0
  53. package/net-disk/NetDiskModals.js +40 -0
  54. package/package.json +30 -19
  55. package/{Permission.d.ts → permission/Permission.d.ts} +4 -2
  56. package/{Permission.js → permission/Permission.js} +5 -3
  57. package/promises.d.ts +48 -0
  58. package/promises.js +141 -0
  59. package/rich/AIEditor.css +1647 -0
  60. package/rich/AIEditor.d.ts +51 -0
  61. package/rich/AIEditor.js +90 -0
  62. package/slider/SliderCode.d.ts +23 -0
  63. package/slider/SliderCode.js +203 -0
  64. package/type.d.ts +3 -0
  65. package/type.js +1 -0
  66. package/InlineContainer.d.ts +0 -6
  67. package/InlineContainer.js +0 -28
  68. package/MediaModals.d.ts +0 -32
  69. package/MediaModals.js +0 -373
  70. package/NetDiskModals.d.ts +0 -15
  71. package/NetDiskModals.js +0 -28
  72. package/Upgrade.d.ts +0 -7
  73. package/Upgrade.js +0 -46
  74. package/fonts/harmony/HarmonyOS_Medium.a.woff2 +0 -0
  75. package/fonts/harmony/HarmonyOS_Medium.a0.woff2 +0 -0
  76. package/fonts/harmony/HarmonyOS_Medium.a1.woff2 +0 -0
  77. package/fonts/harmony/HarmonyOS_Medium.aa.woff2 +0 -0
  78. package/fonts/harmony/HarmonyOS_Medium.ab.woff2 +0 -0
  79. package/fonts/harmony/HarmonyOS_Medium.ac.woff2 +0 -0
  80. package/fonts/harmony/HarmonyOS_Medium.ad.woff2 +0 -0
  81. package/fonts/harmony/HarmonyOS_Medium.ae.woff2 +0 -0
  82. package/fonts/harmony/HarmonyOS_Medium.af.woff2 +0 -0
  83. package/fonts/harmony/HarmonyOS_Medium.ag.woff2 +0 -0
  84. package/fonts/harmony/HarmonyOS_Medium.ah.woff2 +0 -0
  85. package/fonts/harmony/HarmonyOS_Medium.ai.woff2 +0 -0
  86. package/fonts/harmony/HarmonyOS_Medium.aj.woff2 +0 -0
  87. package/fonts/harmony/HarmonyOS_Medium.ak.woff2 +0 -0
  88. package/fonts/harmony/HarmonyOS_Medium.al.woff2 +0 -0
  89. package/fonts/harmony/HarmonyOS_Medium.am.woff2 +0 -0
  90. package/fonts/harmony/HarmonyOS_Medium.an.woff2 +0 -0
  91. package/fonts/harmony/HarmonyOS_Medium.ao.woff2 +0 -0
  92. package/fonts/harmony/HarmonyOS_Medium.ap.woff2 +0 -0
  93. package/fonts/harmony/HarmonyOS_Medium.aq.woff2 +0 -0
  94. package/fonts/harmony/HarmonyOS_Medium.ar.woff2 +0 -0
  95. package/fonts/harmony/HarmonyOS_Medium.as.woff2 +0 -0
  96. package/fonts/harmony/HarmonyOS_Medium.at.woff2 +0 -0
  97. package/fonts/harmony/HarmonyOS_Medium.au.woff2 +0 -0
  98. package/fonts/harmony/HarmonyOS_Medium.av.woff2 +0 -0
  99. package/fonts/harmony/HarmonyOS_Medium.aw.woff2 +0 -0
  100. package/fonts/harmony/HarmonyOS_Medium.ax.woff2 +0 -0
  101. package/fonts/harmony/HarmonyOS_Medium.ay.woff2 +0 -0
  102. package/fonts/harmony/HarmonyOS_Medium.az.woff2 +0 -0
  103. package/fonts/harmony/HarmonyOS_Medium.b.woff2 +0 -0
  104. package/fonts/harmony/HarmonyOS_Medium.c.woff2 +0 -0
  105. package/fonts/harmony/HarmonyOS_Medium.d.woff2 +0 -0
  106. package/fonts/harmony/HarmonyOS_Medium.e.woff2 +0 -0
  107. package/fonts/harmony/HarmonyOS_Medium.f.woff2 +0 -0
  108. package/fonts/harmony/HarmonyOS_Medium.g.woff2 +0 -0
  109. package/fonts/harmony/HarmonyOS_Medium.h.woff2 +0 -0
  110. package/fonts/harmony/HarmonyOS_Medium.i.woff2 +0 -0
  111. package/fonts/harmony/HarmonyOS_Medium.j.woff2 +0 -0
  112. package/fonts/harmony/HarmonyOS_Medium.k.woff2 +0 -0
  113. package/fonts/harmony/HarmonyOS_Medium.l.woff2 +0 -0
  114. package/fonts/harmony/HarmonyOS_Medium.m.woff2 +0 -0
  115. package/fonts/harmony/HarmonyOS_Medium.n.woff2 +0 -0
  116. package/fonts/harmony/HarmonyOS_Medium.o.woff2 +0 -0
  117. package/fonts/harmony/HarmonyOS_Medium.p.woff2 +0 -0
  118. package/fonts/harmony/HarmonyOS_Medium.q.woff2 +0 -0
  119. package/fonts/harmony/HarmonyOS_Medium.r.woff2 +0 -0
  120. package/fonts/harmony/HarmonyOS_Medium.s.woff2 +0 -0
  121. package/fonts/harmony/HarmonyOS_Medium.t.woff2 +0 -0
  122. package/fonts/harmony/HarmonyOS_Medium.u.woff2 +0 -0
  123. package/fonts/harmony/HarmonyOS_Medium.v.woff2 +0 -0
  124. package/fonts/harmony/HarmonyOS_Medium.w.woff2 +0 -0
  125. package/fonts/harmony/HarmonyOS_Medium.x.woff2 +0 -0
  126. package/fonts/harmony/HarmonyOS_Medium.y.woff2 +0 -0
  127. package/fonts/harmony/HarmonyOS_Medium.z.woff2 +0 -0
  128. package/fonts/harmony/HarmonyOS_Regular.a.woff2 +0 -0
  129. package/fonts/harmony/HarmonyOS_Regular.a0.woff2 +0 -0
  130. package/fonts/harmony/HarmonyOS_Regular.a1.woff2 +0 -0
  131. package/fonts/harmony/HarmonyOS_Regular.aa.woff2 +0 -0
  132. package/fonts/harmony/HarmonyOS_Regular.ab.woff2 +0 -0
  133. package/fonts/harmony/HarmonyOS_Regular.ac.woff2 +0 -0
  134. package/fonts/harmony/HarmonyOS_Regular.ad.woff2 +0 -0
  135. package/fonts/harmony/HarmonyOS_Regular.ae.woff2 +0 -0
  136. package/fonts/harmony/HarmonyOS_Regular.af.woff2 +0 -0
  137. package/fonts/harmony/HarmonyOS_Regular.ag.woff2 +0 -0
  138. package/fonts/harmony/HarmonyOS_Regular.ah.woff2 +0 -0
  139. package/fonts/harmony/HarmonyOS_Regular.ai.woff2 +0 -0
  140. package/fonts/harmony/HarmonyOS_Regular.aj.woff2 +0 -0
  141. package/fonts/harmony/HarmonyOS_Regular.ak.woff2 +0 -0
  142. package/fonts/harmony/HarmonyOS_Regular.al.woff2 +0 -0
  143. package/fonts/harmony/HarmonyOS_Regular.am.woff2 +0 -0
  144. package/fonts/harmony/HarmonyOS_Regular.an.woff2 +0 -0
  145. package/fonts/harmony/HarmonyOS_Regular.ao.woff2 +0 -0
  146. package/fonts/harmony/HarmonyOS_Regular.ap.woff2 +0 -0
  147. package/fonts/harmony/HarmonyOS_Regular.aq.woff2 +0 -0
  148. package/fonts/harmony/HarmonyOS_Regular.ar.woff2 +0 -0
  149. package/fonts/harmony/HarmonyOS_Regular.as.woff2 +0 -0
  150. package/fonts/harmony/HarmonyOS_Regular.at.woff2 +0 -0
  151. package/fonts/harmony/HarmonyOS_Regular.au.woff2 +0 -0
  152. package/fonts/harmony/HarmonyOS_Regular.av.woff2 +0 -0
  153. package/fonts/harmony/HarmonyOS_Regular.aw.woff2 +0 -0
  154. package/fonts/harmony/HarmonyOS_Regular.ax.woff2 +0 -0
  155. package/fonts/harmony/HarmonyOS_Regular.ay.woff2 +0 -0
  156. package/fonts/harmony/HarmonyOS_Regular.az.woff2 +0 -0
  157. package/fonts/harmony/HarmonyOS_Regular.b.woff2 +0 -0
  158. package/fonts/harmony/HarmonyOS_Regular.c.woff2 +0 -0
  159. package/fonts/harmony/HarmonyOS_Regular.d.woff2 +0 -0
  160. package/fonts/harmony/HarmonyOS_Regular.e.woff2 +0 -0
  161. package/fonts/harmony/HarmonyOS_Regular.f.woff2 +0 -0
  162. package/fonts/harmony/HarmonyOS_Regular.g.woff2 +0 -0
  163. package/fonts/harmony/HarmonyOS_Regular.h.woff2 +0 -0
  164. package/fonts/harmony/HarmonyOS_Regular.i.woff2 +0 -0
  165. package/fonts/harmony/HarmonyOS_Regular.j.woff2 +0 -0
  166. package/fonts/harmony/HarmonyOS_Regular.k.woff2 +0 -0
  167. package/fonts/harmony/HarmonyOS_Regular.l.woff2 +0 -0
  168. package/fonts/harmony/HarmonyOS_Regular.m.woff2 +0 -0
  169. package/fonts/harmony/HarmonyOS_Regular.n.woff2 +0 -0
  170. package/fonts/harmony/HarmonyOS_Regular.o.woff2 +0 -0
  171. package/fonts/harmony/HarmonyOS_Regular.p.woff2 +0 -0
  172. package/fonts/harmony/HarmonyOS_Regular.q.woff2 +0 -0
  173. package/fonts/harmony/HarmonyOS_Regular.r.woff2 +0 -0
  174. package/fonts/harmony/HarmonyOS_Regular.s.woff2 +0 -0
  175. package/fonts/harmony/HarmonyOS_Regular.t.woff2 +0 -0
  176. package/fonts/harmony/HarmonyOS_Regular.u.woff2 +0 -0
  177. package/fonts/harmony/HarmonyOS_Regular.v.woff2 +0 -0
  178. package/fonts/harmony/HarmonyOS_Regular.w.woff2 +0 -0
  179. package/fonts/harmony/HarmonyOS_Regular.x.woff2 +0 -0
  180. package/fonts/harmony/HarmonyOS_Regular.y.woff2 +0 -0
  181. package/fonts/harmony/HarmonyOS_Regular.z.woff2 +0 -0
  182. package/fonts/harmony/medium.css +0 -485
  183. package/fonts/harmony/regular.css +0 -485
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
+ };
@@ -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
+ }
@@ -0,0 +1,172 @@
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
+ }
File without changes