beer-assembly-biz 1.1.1-alpha.9 → 1.1.2-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.
- package/AppLayout.d.ts +13 -5
- package/AppLayout.js +37 -22
- package/BackPageContainer.d.ts +7 -0
- package/BackPageContainer.js +35 -0
- package/InlineContainer.d.ts +6 -0
- package/InlineContainer.js +28 -0
- package/MediaModals.d.ts +32 -0
- package/MediaModals.js +373 -0
- package/MyPageContainer.d.ts +18 -0
- package/MyPageContainer.js +72 -0
- package/Permission.d.ts +8 -0
- package/Permission.js +7 -0
- package/SubMenusContainer.d.ts +28 -0
- package/SubMenusContainer.js +72 -0
- package/Upgrade.d.ts +7 -0
- package/Upgrade.js +46 -0
- package/UserModals.js +1 -1
- package/auth/AuthPassword.d.ts +5 -0
- package/auth/AuthPassword.js +11 -5
- package/auth/AuthStyle01.d.ts +10 -1
- package/auth/AuthStyle01.js +7 -2
- package/auth/AuthStyle02.d.ts +10 -1
- package/auth/AuthStyle02.js +7 -2
- package/content/ParentContext.d.ts +8 -0
- package/content/ParentContext.js +9 -0
- package/content/PermissionContext.d.ts +4 -0
- package/content/PermissionContext.js +12 -0
- package/icon/directory.svg +11 -8
- package/icon/empty.svg +40 -40
- package/icon/media.png +0 -0
- package/icon/volc.svg +96 -0
- package/package.json +6 -6
package/MediaModals.js
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { css } from '@emotion/css';
|
|
3
|
+
import { Breadcrumb, Button, Dropdown, Input, message, Modal, Popconfirm, Space, Spin, theme, Typography } from 'antd';
|
|
4
|
+
import ElementUtils from 'beer-network/elementUtils';
|
|
5
|
+
import Flux from 'beer-assembly/Flux';
|
|
6
|
+
import { CloudDownloadOutlined, CopyOutlined, DeleteOutlined, ExclamationCircleFilled, HighlightOutlined, RightCircleOutlined, ScissorOutlined } from '@ant-design/icons';
|
|
7
|
+
import DirectorySelect from 'beer-assembly/DirectorySelect';
|
|
8
|
+
import InlineContainer from './InlineContainer';
|
|
9
|
+
import IconDirectory from './icon/directory.svg';
|
|
10
|
+
import IconMedia from './icon/media.png';
|
|
11
|
+
export class MediaModals {
|
|
12
|
+
static useMedia(request) {
|
|
13
|
+
const [messageApi, contextHolder] = message.useMessage();
|
|
14
|
+
const { token } = theme.useToken();
|
|
15
|
+
const [isOpenModal, setIsOpenModal] = useState(false);
|
|
16
|
+
const [isOpenMoveModal, setIsOpenMoveModal] = useState(false);
|
|
17
|
+
const [isOpenRenameModal, setIsOpenRenameModal] = useState(false);
|
|
18
|
+
const [isOpenConfirmModal, setIsOpenConfirmModal] = useState(false);
|
|
19
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
20
|
+
const [path, setPath] = useState([]);
|
|
21
|
+
const [dataList, setDataList] = useState([]);
|
|
22
|
+
const [selectId, setSelectId] = useState('');
|
|
23
|
+
const [selectName, setSelectName] = useState('');
|
|
24
|
+
const callbackRef = useRef(undefined);
|
|
25
|
+
const refreshData = (force) => {
|
|
26
|
+
const item = path[path.length - 1];
|
|
27
|
+
const chunkArray = (array, size) => {
|
|
28
|
+
const result = [];
|
|
29
|
+
for (let i = 0; i < array.length; i += size) {
|
|
30
|
+
result.push(array.slice(i, i + size));
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
setIsLoading(true);
|
|
35
|
+
if (force === true) {
|
|
36
|
+
setDataList([]);
|
|
37
|
+
}
|
|
38
|
+
request?.requestList?.(item.id)
|
|
39
|
+
.then(result => {
|
|
40
|
+
setIsLoading(false);
|
|
41
|
+
setDataList(chunkArray(result || [], 5));
|
|
42
|
+
})
|
|
43
|
+
.catch(() => {
|
|
44
|
+
setIsLoading(false);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const onActiveItem = (id) => {
|
|
48
|
+
setDataList(dataList?.map(item => {
|
|
49
|
+
return item.map(it => {
|
|
50
|
+
return {
|
|
51
|
+
...it,
|
|
52
|
+
active: it.id === id
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
const onDownload = async (name, url) => {
|
|
58
|
+
if ((url || '').trim() === '') {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
ElementUtils.download(url || '', name);
|
|
62
|
+
};
|
|
63
|
+
const onPutFile = async () => {
|
|
64
|
+
const files = await ElementUtils.selectFile();
|
|
65
|
+
if (files === null) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
for (let i = 0; i < files.length; i += 1) {
|
|
69
|
+
const file = files[i];
|
|
70
|
+
if (file.size > (1048576 * 15)) {
|
|
71
|
+
messageApi.error(`文件 ${file.name} 太大,不能超过 15MB`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!['image/jpeg', 'image/png', 'image/gif', 'image/webp'].includes(file.type)) {
|
|
75
|
+
messageApi.error(`文件 ${file.name} 不是有效的图片格式`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const parentId = path[path.length - 1]?.id;
|
|
80
|
+
setIsLoading(true);
|
|
81
|
+
const result = await request?.putFile(parentId, files);
|
|
82
|
+
setIsLoading(false);
|
|
83
|
+
if (result === true) {
|
|
84
|
+
refreshData();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const onCreateDirectory = async (name) => {
|
|
88
|
+
const parentId = path[path.length - 1]?.id;
|
|
89
|
+
setIsLoading(true);
|
|
90
|
+
const result = await request?.createDirectory(parentId, name);
|
|
91
|
+
setIsLoading(false);
|
|
92
|
+
if (result === true) {
|
|
93
|
+
refreshData();
|
|
94
|
+
}
|
|
95
|
+
setSelectName('');
|
|
96
|
+
return true;
|
|
97
|
+
};
|
|
98
|
+
const onOpenDirectory = async (id, name) => {
|
|
99
|
+
if (isLoading) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const paths = [...getPaths(), {
|
|
103
|
+
id,
|
|
104
|
+
name
|
|
105
|
+
}];
|
|
106
|
+
setPaths(paths);
|
|
107
|
+
};
|
|
108
|
+
const onBackDirectory = async (id) => {
|
|
109
|
+
if (isLoading) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const paths = getPaths();
|
|
113
|
+
const index = paths.findIndex(it => it.id === id);
|
|
114
|
+
if (index < 0) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
paths.splice(index + 1);
|
|
118
|
+
setPaths(paths);
|
|
119
|
+
};
|
|
120
|
+
const onSelectItem = async (id, name, url) => {
|
|
121
|
+
const current = callbackRef?.current;
|
|
122
|
+
if (current === undefined) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
current?.([url || '']);
|
|
126
|
+
setIsOpenModal(false);
|
|
127
|
+
};
|
|
128
|
+
const onRename = async (id, name) => {
|
|
129
|
+
setIsOpenRenameModal(true);
|
|
130
|
+
setSelectId(id);
|
|
131
|
+
setSelectName(name);
|
|
132
|
+
};
|
|
133
|
+
const onConfirmRename = async () => {
|
|
134
|
+
if (await request?.rename(selectId, selectName)) {
|
|
135
|
+
refreshData();
|
|
136
|
+
setSelectName('');
|
|
137
|
+
setIsOpenRenameModal(false);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const onCopy = async (id) => {
|
|
141
|
+
const result = await request?.copy(id);
|
|
142
|
+
if (result === true) {
|
|
143
|
+
refreshData();
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
};
|
|
147
|
+
const onMove = async (id) => {
|
|
148
|
+
setIsOpenMoveModal(true);
|
|
149
|
+
setSelectId(id);
|
|
150
|
+
};
|
|
151
|
+
const onConfirmMove = async (targetId) => {
|
|
152
|
+
const result = await request?.move(selectId, targetId);
|
|
153
|
+
if (result === true) {
|
|
154
|
+
setIsOpenMoveModal(false);
|
|
155
|
+
refreshData();
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const onRemove = async (id) => {
|
|
159
|
+
setIsOpenConfirmModal(true);
|
|
160
|
+
setSelectId(id);
|
|
161
|
+
};
|
|
162
|
+
const onConfirmRemove = async () => {
|
|
163
|
+
const result = await request?.remove(selectId);
|
|
164
|
+
if (result === true) {
|
|
165
|
+
setIsOpenConfirmModal(false);
|
|
166
|
+
refreshData();
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
};
|
|
170
|
+
const setPaths = (items) => {
|
|
171
|
+
setPath(items);
|
|
172
|
+
sessionStorage.setItem('MEDIA_MODALS_PATHS', JSON.stringify(items));
|
|
173
|
+
};
|
|
174
|
+
const getPaths = () => {
|
|
175
|
+
const paths = JSON.parse(sessionStorage.getItem('MEDIA_MODALS_PATHS') || '[]');
|
|
176
|
+
if (paths.length <= 0) {
|
|
177
|
+
paths.push({
|
|
178
|
+
id: '0',
|
|
179
|
+
name: '根目录'
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return paths;
|
|
183
|
+
};
|
|
184
|
+
const Item = (props) => {
|
|
185
|
+
const directoryMenusItem = props.type === 'DIRECTORY' ? [
|
|
186
|
+
{
|
|
187
|
+
label: React.createElement(Space, { style: { width: 100 }, size: 5, onClick: () => onOpenDirectory(props.id, props.name) },
|
|
188
|
+
React.createElement(RightCircleOutlined, null),
|
|
189
|
+
"\u6253\u5F00\u76EE\u5F55"),
|
|
190
|
+
key: '0'
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
type: 'divider'
|
|
194
|
+
}
|
|
195
|
+
] : [
|
|
196
|
+
{
|
|
197
|
+
label: React.createElement(Space, { style: { width: 100 }, size: 5, onClick: () => onDownload(props.name, props.src) },
|
|
198
|
+
React.createElement(CloudDownloadOutlined, null),
|
|
199
|
+
"\u4E0B\u8F7D\u6587\u4EF6"),
|
|
200
|
+
key: '0'
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
type: 'divider'
|
|
204
|
+
}
|
|
205
|
+
];
|
|
206
|
+
const menusItems = [
|
|
207
|
+
...directoryMenusItem,
|
|
208
|
+
{
|
|
209
|
+
label: React.createElement(Space, { style: { width: 100 }, size: 5, onClick: () => onRename(props.id, props.name) },
|
|
210
|
+
React.createElement(HighlightOutlined, null),
|
|
211
|
+
"\u91CD\u547D\u540D"),
|
|
212
|
+
key: '1'
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
label: React.createElement(Space, { style: { width: 100 }, size: 5, onClick: () => onCopy(props.id) },
|
|
216
|
+
React.createElement(CopyOutlined, null),
|
|
217
|
+
props?.type === 'DIRECTORY' ? '复制目录' : '复制文件'),
|
|
218
|
+
key: '2'
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
label: React.createElement(Space, { style: { width: 100 }, size: 5, onClick: () => onMove(props.id) },
|
|
222
|
+
React.createElement(ScissorOutlined, null),
|
|
223
|
+
props?.type === 'DIRECTORY' ? '移动目录' : '移动文件'),
|
|
224
|
+
key: '3'
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
type: 'divider'
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
label: React.createElement(Space, { style: { width: 100 }, size: 5, onClick: () => onRemove(props.id) },
|
|
231
|
+
React.createElement(DeleteOutlined, null),
|
|
232
|
+
props?.type === 'DIRECTORY' ? '删除目录' : '删除文件'),
|
|
233
|
+
key: '4',
|
|
234
|
+
danger: true
|
|
235
|
+
}
|
|
236
|
+
];
|
|
237
|
+
return React.createElement(Dropdown, { menu: {
|
|
238
|
+
items: menusItems
|
|
239
|
+
}, trigger: ['contextMenu'] },
|
|
240
|
+
React.createElement("div", { style: {
|
|
241
|
+
padding: '8px 12px',
|
|
242
|
+
backgroundColor: props?.active ? '#e6f1ff' : undefined,
|
|
243
|
+
display: 'block',
|
|
244
|
+
cursor: 'pointer',
|
|
245
|
+
userSelect: 'none',
|
|
246
|
+
position: 'relative',
|
|
247
|
+
...props.style
|
|
248
|
+
}, className: css `
|
|
249
|
+
border: ${props?.active ? '1px solid #cddef5' : '1px solid #fff'};
|
|
250
|
+
|
|
251
|
+
&:hover {
|
|
252
|
+
background-color: #eef1f5;
|
|
253
|
+
border: 1px solid ${props.active ? '#cddef5' : '#e6e6e6'};
|
|
254
|
+
}
|
|
255
|
+
`, onClick: () => {
|
|
256
|
+
setTimeout(() => onActiveItem(props.id), 10);
|
|
257
|
+
}, onDoubleClick: () => {
|
|
258
|
+
if (props.type === 'DIRECTORY') {
|
|
259
|
+
onOpenDirectory(props.id, props.name)
|
|
260
|
+
.then();
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
onSelectItem(props.id, props.name, props.src)
|
|
264
|
+
.then();
|
|
265
|
+
} },
|
|
266
|
+
React.createElement("img", { src: props?.type === 'DIRECTORY' ? IconDirectory : props?.src, alt: "", style: {
|
|
267
|
+
width: 56,
|
|
268
|
+
height: 56,
|
|
269
|
+
margin: 'auto',
|
|
270
|
+
display: 'block',
|
|
271
|
+
overflow: 'hidden',
|
|
272
|
+
objectFit: props?.type === 'DIRECTORY' ? undefined : 'cover'
|
|
273
|
+
} }),
|
|
274
|
+
React.createElement(Typography.Text, { style: {
|
|
275
|
+
width: 70,
|
|
276
|
+
fontSize: 11,
|
|
277
|
+
display: 'block',
|
|
278
|
+
textAlign: 'center',
|
|
279
|
+
color: '#323232',
|
|
280
|
+
marginTop: props?.type === 'DIRECTORY' ? undefined : 1
|
|
281
|
+
}, ellipsis: true }, props?.name)));
|
|
282
|
+
};
|
|
283
|
+
const handler = {
|
|
284
|
+
ok: (callback) => {
|
|
285
|
+
setPath(getPaths());
|
|
286
|
+
setIsOpenModal(true);
|
|
287
|
+
if (callbackRef !== undefined) {
|
|
288
|
+
callbackRef.current = callback;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
useEffect(() => {
|
|
293
|
+
if ((path || []).length <= 0) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
refreshData(true);
|
|
297
|
+
}, [path]);
|
|
298
|
+
return [handler, React.createElement(React.Fragment, null,
|
|
299
|
+
React.createElement(InlineContainer, null,
|
|
300
|
+
React.createElement(Modal, { width: 565, footer: null, styles: {
|
|
301
|
+
content: { padding: 0 }
|
|
302
|
+
}, open: isOpenModal, maskClosable: false, onCancel: () => {
|
|
303
|
+
if (isLoading) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
setIsOpenModal(false);
|
|
307
|
+
}, title: React.createElement("div", { style: {
|
|
308
|
+
padding: '16px 0 0 0'
|
|
309
|
+
} },
|
|
310
|
+
React.createElement("img", { style: {
|
|
311
|
+
marginInlineStart: 20,
|
|
312
|
+
display: 'block',
|
|
313
|
+
height: '17px',
|
|
314
|
+
padding: '2px 0 0 0'
|
|
315
|
+
}, alt: "", src: IconMedia })) },
|
|
316
|
+
React.createElement(Flux, { style: {
|
|
317
|
+
marginBottom: 6,
|
|
318
|
+
padding: '0 20px 10px 20px',
|
|
319
|
+
borderBottom: '1px solid #f3f3f3',
|
|
320
|
+
justifyContent: 'space-between'
|
|
321
|
+
} },
|
|
322
|
+
React.createElement(Breadcrumb, { items: path?.map((it, index) => {
|
|
323
|
+
return {
|
|
324
|
+
title: (index + 1 === path.length
|
|
325
|
+
? React.createElement(Typography.Text, { style: {
|
|
326
|
+
maxWidth: 70,
|
|
327
|
+
fontSize: 12
|
|
328
|
+
}, ellipsis: true }, it.name)
|
|
329
|
+
: React.createElement("a", { onClick: () => onBackDirectory(it.id) },
|
|
330
|
+
React.createElement(Typography.Text, { style: {
|
|
331
|
+
maxWidth: 70,
|
|
332
|
+
fontSize: 12,
|
|
333
|
+
color: 'rgba(0, 0, 0, 0.45)'
|
|
334
|
+
}, ellipsis: true }, it.name)))
|
|
335
|
+
};
|
|
336
|
+
}) }),
|
|
337
|
+
React.createElement(Space, null,
|
|
338
|
+
React.createElement(Button, { type: "primary", onClick: () => onPutFile(), size: "small", style: {
|
|
339
|
+
height: 24,
|
|
340
|
+
fontSize: token.fontSize - 1
|
|
341
|
+
}, loading: isLoading }, "\u4E0A\u4F20\u6587\u4EF6"),
|
|
342
|
+
React.createElement(Popconfirm, { title: "\u8BF7\u8F93\u5165\u76EE\u5F55\u540D\u79F0", description: React.createElement(Input, { value: selectName, onChange: (e) => setSelectName(e.currentTarget.value) }), onCancel: () => setSelectName(''), onConfirm: () => onCreateDirectory(selectName), okText: "\u786E\u5B9A", cancelText: "\u53D6\u6D88" },
|
|
343
|
+
React.createElement(Button, { size: "small", style: {
|
|
344
|
+
height: 24,
|
|
345
|
+
fontSize: 12
|
|
346
|
+
}, loading: isLoading }, "\u65B0\u5EFA\u76EE\u5F55")))),
|
|
347
|
+
React.createElement(Spin, { spinning: isLoading },
|
|
348
|
+
React.createElement("div", { style: {
|
|
349
|
+
padding: '6px 0 24px 0',
|
|
350
|
+
height: 333,
|
|
351
|
+
maxHeight: 333,
|
|
352
|
+
overflowY: 'auto',
|
|
353
|
+
overflowX: 'hidden'
|
|
354
|
+
} }, dataList?.map((group, index) => (React.createElement("div", { key: index, style: {
|
|
355
|
+
padding: '0 20px 10px 20px',
|
|
356
|
+
display: 'flex'
|
|
357
|
+
} }, group?.map((item) => (React.createElement(Item, { id: item.id, key: item.id, active: item.active, style: { marginRight: 10 }, type: item.type, src: item.url, name: item.name })))))))))),
|
|
358
|
+
React.createElement(Modal, { title: "\u91CD\u547D\u540D", width: 340, open: isOpenRenameModal, onOk: () => onConfirmRename(), onCancel: () => setIsOpenRenameModal(false), okText: "\u786E\u5B9A", cancelText: "\u53D6\u6D88" },
|
|
359
|
+
React.createElement(Input, { value: selectName, onChange: (e) => setSelectName(e.currentTarget.value) })),
|
|
360
|
+
React.createElement(Modal, { title: React.createElement(React.Fragment, null,
|
|
361
|
+
React.createElement(ExclamationCircleFilled, { style: {
|
|
362
|
+
marginRight: 6,
|
|
363
|
+
fontSize: 16,
|
|
364
|
+
color: '#faad14'
|
|
365
|
+
} }),
|
|
366
|
+
"\u662F\u5426\u786E\u8BA4\u5220\u9664?"), width: 400, open: isOpenConfirmModal, onOk: () => onConfirmRemove(), onCancel: () => setIsOpenConfirmModal(false), okText: "\u786E\u5B9A", cancelText: "\u53D6\u6D88" }, "\u5220\u9664\u64CD\u4F5C\u4E0D\u80FD\u56DE\u590D\uFF0C\u786E\u5B9A\u8981\u5220\u9664\u9009\u4E2D\u7684\u6587\u4EF6\u6216\u6587\u4EF6\u5939\u5417\uFF1F"),
|
|
367
|
+
React.createElement(DirectorySelect, { open: isOpenMoveModal, onCancel: () => {
|
|
368
|
+
refreshData();
|
|
369
|
+
setIsOpenMoveModal(false);
|
|
370
|
+
}, request: request?.directory, onOk: (value) => onConfirmMove(value) }),
|
|
371
|
+
contextHolder)];
|
|
372
|
+
}
|
|
373
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { CSSProperties, FC } from 'react';
|
|
2
|
+
import { TabPaneProps } from 'antd';
|
|
3
|
+
export interface Tab extends Omit<TabPaneProps, 'tab'> {
|
|
4
|
+
key: string;
|
|
5
|
+
label: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare type MyPageContainerProps = {
|
|
8
|
+
title?: string | undefined;
|
|
9
|
+
padding?: string | number | undefined;
|
|
10
|
+
style?: CSSProperties | undefined;
|
|
11
|
+
children?: React.ReactNode | undefined;
|
|
12
|
+
tabList?: Tab[];
|
|
13
|
+
onTabChange?: (e: string) => void;
|
|
14
|
+
onRefresh?: () => void;
|
|
15
|
+
banner?: React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
export declare const Component: FC<MyPageContainerProps>;
|
|
18
|
+
export default Component;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { css } from '@emotion/css';
|
|
3
|
+
import { PageContainer } from '@ant-design/pro-components';
|
|
4
|
+
import { message, Modal, Tabs, theme } from 'antd';
|
|
5
|
+
import { Outlet, useLocation } from 'react-router-dom';
|
|
6
|
+
import ParentContext from './content/ParentContext';
|
|
7
|
+
const pathPartition = (sessionStorage.getItem('DETAIL_PARTITION') || '') === ''
|
|
8
|
+
? ['CREATE', 'EDIT', 'COPY', 'AUDIT', 'PREVIEW', 'DETAIL', 'READ', 'IN', 'INPUT', 'OUTPUT']
|
|
9
|
+
: JSON.parse(sessionStorage.getItem('DETAIL_PARTITION') || '[]');
|
|
10
|
+
export const Component = (props) => {
|
|
11
|
+
const { token } = theme.useToken();
|
|
12
|
+
const location = useLocation();
|
|
13
|
+
const [messageApi, contextHolder] = message.useMessage();
|
|
14
|
+
const [modal, contextModalHolder] = Modal.useModal();
|
|
15
|
+
const [isSubpage, setIsSubpage] = useState(false);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const partition = pathPartition.find(path => {
|
|
18
|
+
return location.pathname.toUpperCase()
|
|
19
|
+
.indexOf(`/${path}/`) > -1;
|
|
20
|
+
});
|
|
21
|
+
if (partition !== undefined) {
|
|
22
|
+
setIsSubpage(true);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
setIsSubpage(false);
|
|
26
|
+
}
|
|
27
|
+
}, [location]);
|
|
28
|
+
return React.createElement(React.Fragment, null,
|
|
29
|
+
React.createElement(ParentContext.Provider, { value: {
|
|
30
|
+
messageApi,
|
|
31
|
+
modal,
|
|
32
|
+
active: () => {
|
|
33
|
+
props?.onRefresh?.();
|
|
34
|
+
}
|
|
35
|
+
} },
|
|
36
|
+
contextHolder,
|
|
37
|
+
contextModalHolder,
|
|
38
|
+
React.createElement(PageContainer, { style: { display: isSubpage ? 'none' : 'block' }, className: css `
|
|
39
|
+
.ant-page-header-heading {
|
|
40
|
+
padding-block-start: 0 !important;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.ant-page-header-heading-title {
|
|
44
|
+
font-size: ${token.fontSize + 2}px;
|
|
45
|
+
line-height: 1.5;
|
|
46
|
+
color: #333;
|
|
47
|
+
}
|
|
48
|
+
`, header: {
|
|
49
|
+
style: {
|
|
50
|
+
background: '#fff',
|
|
51
|
+
padding: (props?.tabList?.length || 0) <= 0 ? '10px 24px 10px 24px' : '10px 24px 2px 24px',
|
|
52
|
+
borderBottom: (props?.tabList?.length || 0) <= 0 ? '1px solid rgba(0, 0, 0, 0.06)' : undefined
|
|
53
|
+
}
|
|
54
|
+
}, title: props.title, ghost: true, childrenContentStyle: {
|
|
55
|
+
padding: '0'
|
|
56
|
+
} },
|
|
57
|
+
(props?.tabList?.length || 0) > 0 ? React.createElement(React.Fragment, null,
|
|
58
|
+
React.createElement(Tabs, { size: "small", items: props?.tabList, className: css `
|
|
59
|
+
background: #fff;
|
|
60
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
|
|
61
|
+
|
|
62
|
+
.ant-tabs-nav::before {
|
|
63
|
+
display: none;
|
|
64
|
+
}
|
|
65
|
+
`, tabBarStyle: { margin: '0 24px' }, onChange: (e) => props?.onTabChange?.(e) })) : undefined,
|
|
66
|
+
props?.banner,
|
|
67
|
+
React.createElement("div", { className: css `
|
|
68
|
+
padding: ${props?.padding || '12px 16px'};
|
|
69
|
+
`, style: props?.style }, props.children)),
|
|
70
|
+
React.createElement(Outlet, null)));
|
|
71
|
+
};
|
|
72
|
+
export default Component;
|
package/Permission.d.ts
ADDED
package/Permission.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import PermissionContext from './content/PermissionContext';
|
|
3
|
+
export const Component = (props) => {
|
|
4
|
+
const { isPermission } = useContext(PermissionContext);
|
|
5
|
+
return React.createElement(React.Fragment, null, isPermission(props.domain, props.permission) ? props?.children : undefined);
|
|
6
|
+
};
|
|
7
|
+
export default Component;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { CSSProperties, FC } from 'react';
|
|
2
|
+
import type { ComponentToken as MenuComponentToken } from 'antd/es/menu/style';
|
|
3
|
+
export declare type MenusItem = {
|
|
4
|
+
key?: string;
|
|
5
|
+
value?: string;
|
|
6
|
+
label: string | React.ReactNode;
|
|
7
|
+
children: MenusItem[];
|
|
8
|
+
};
|
|
9
|
+
export declare type SubMenusProps = {
|
|
10
|
+
items: MenusItem[];
|
|
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 Component: FC<SubMenusProps>;
|
|
28
|
+
export default Component;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { ConfigProvider, Menu } from 'antd';
|
|
3
|
+
export const Component = (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
|
+
};
|
|
72
|
+
export default Component;
|
package/Upgrade.d.ts
ADDED
package/Upgrade.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { Modal } from 'antd';
|
|
3
|
+
const TIME_KEY = 'VERSION_TIME';
|
|
4
|
+
const App = (props) => {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
// 每5分钟执行一次
|
|
7
|
+
setTimeout(async () => {
|
|
8
|
+
// 读取缓存的上次弹出更新时间
|
|
9
|
+
const lastTime = Number(localStorage.getItem(TIME_KEY) || 0);
|
|
10
|
+
if (Number.isNaN(lastTime)) {
|
|
11
|
+
localStorage.removeItem(TIME_KEY);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
// 30分钟执行一次
|
|
15
|
+
if (new Date().getTime() <= lastTime + 1800000) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// 更新刷新时间
|
|
19
|
+
localStorage.setItem(TIME_KEY, new Date().getTime()
|
|
20
|
+
.toString());
|
|
21
|
+
const newVersion = await props.request?.();
|
|
22
|
+
if (newVersion === undefined || newVersion === '') {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (newVersion === props.localVersion) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// 弹出提示框
|
|
29
|
+
Modal.confirm({
|
|
30
|
+
title: '版本更新提示',
|
|
31
|
+
content: React.createElement(React.Fragment, null,
|
|
32
|
+
React.createElement("p", { style: {
|
|
33
|
+
fontSize: '15px',
|
|
34
|
+
lineHeight: '26px'
|
|
35
|
+
} }, "\u60A8\u5DF2\u7ECF\u957F\u65F6\u95F4\u672A\u4F7F\u7528\u6B64\u9875\u9762\uFF0C\u5728\u6B64\u671F\u95F4\u5E73\u53F0\u6709\u8FC7\u66F4\u65B0\uFF0C\u5982\u60A8\u6B64\u65F6\u5728\u9875\u9762\u4E2D\u6CA1\u6709\u586B\u5199\u76F8\u5173\u4FE1\u606F\u7B49\u64CD\u4F5C\uFF0C\u8BF7\u70B9\u51FB\u5237\u65B0\u9875\u9762\u4F7F\u7528\u6700\u65B0\u7248\u672C\uFF01")),
|
|
36
|
+
okText: '确定',
|
|
37
|
+
cancelText: '取消',
|
|
38
|
+
onOk: () => {
|
|
39
|
+
window.location.reload();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}, 5000);
|
|
43
|
+
}, []);
|
|
44
|
+
return React.createElement(React.Fragment, null);
|
|
45
|
+
};
|
|
46
|
+
export default App;
|
package/UserModals.js
CHANGED
|
@@ -28,7 +28,7 @@ export class UserModals {
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
return [handler, React.createElement(React.Fragment, null,
|
|
31
|
-
React.createElement(Modal, { title: "\u91CD\u7F6E\u5BC6\u7801", width:
|
|
31
|
+
React.createElement(Modal, { title: "\u91CD\u7F6E\u5BC6\u7801", width: 340, open: isOpenModal, onOk: () => onConfirm(), onCancel: () => setIsOpenModal(false), styles: { body: { padding: '6px 0' } } },
|
|
32
32
|
React.createElement(Form, { form: form, labelCol: { span: 5 } },
|
|
33
33
|
React.createElement(Form.Item, { name: "password", style: { margin: 0 }, rules: [{
|
|
34
34
|
required: true,
|
package/auth/AuthPassword.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Slider, SliderCodeToken } from 'beer-assembly/SliderCode';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export declare type AuthPasswordProps = {
|
|
4
|
+
/**
|
|
5
|
+
* 是否启用企业登录.
|
|
6
|
+
*/
|
|
7
|
+
companyStatus?: boolean;
|
|
4
8
|
/**
|
|
5
9
|
* HTML 协议.
|
|
6
10
|
*/
|
|
@@ -22,6 +26,7 @@ export declare type AuthPasswordProps = {
|
|
|
22
26
|
requestLogin?: (code: string | undefined, slider: Slider | undefined, params: {
|
|
23
27
|
username: string;
|
|
24
28
|
password: string;
|
|
29
|
+
companyName: string | undefined;
|
|
25
30
|
}) => Promise<boolean>;
|
|
26
31
|
/**
|
|
27
32
|
* 发出错误消息
|