beer-assembly-biz 1.1.1-alpha.2 → 1.1.1-alpha.21

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 (144) hide show
  1. package/AppLayout.d.ts +10 -10
  2. package/AppLayout.js +10 -11
  3. package/BackPageContainer.d.ts +7 -0
  4. package/BackPageContainer.js +33 -0
  5. package/InlineContainer.d.ts +6 -0
  6. package/InlineContainer.js +28 -0
  7. package/MediaModals.d.ts +32 -0
  8. package/MediaModals.js +372 -0
  9. package/MyPageContainer.d.ts +16 -0
  10. package/MyPageContainer.js +71 -0
  11. package/Permission.d.ts +8 -0
  12. package/Permission.js +7 -0
  13. package/Upgrade.d.ts +7 -0
  14. package/Upgrade.js +46 -0
  15. package/UserModals.js +2 -2
  16. package/auth/AuthPassword.d.ts +8 -4
  17. package/auth/AuthPassword.js +25 -11
  18. package/auth/AuthStyle01.d.ts +23 -6
  19. package/auth/AuthStyle01.js +10 -6
  20. package/auth/AuthStyle02.d.ts +23 -6
  21. package/auth/AuthStyle02.js +10 -6
  22. package/content/ParentContext.d.ts +8 -0
  23. package/content/ParentContext.js +9 -0
  24. package/content/PermissionContext.d.ts +4 -0
  25. package/content/PermissionContext.js +12 -0
  26. package/fonts/harmony/HarmonyOS_Medium.a.woff2 +0 -0
  27. package/fonts/harmony/HarmonyOS_Medium.a0.woff2 +0 -0
  28. package/fonts/harmony/HarmonyOS_Medium.a1.woff2 +0 -0
  29. package/fonts/harmony/HarmonyOS_Medium.aa.woff2 +0 -0
  30. package/fonts/harmony/HarmonyOS_Medium.ab.woff2 +0 -0
  31. package/fonts/harmony/HarmonyOS_Medium.ac.woff2 +0 -0
  32. package/fonts/harmony/HarmonyOS_Medium.ad.woff2 +0 -0
  33. package/fonts/harmony/HarmonyOS_Medium.ae.woff2 +0 -0
  34. package/fonts/harmony/HarmonyOS_Medium.af.woff2 +0 -0
  35. package/fonts/harmony/HarmonyOS_Medium.ag.woff2 +0 -0
  36. package/fonts/harmony/HarmonyOS_Medium.ah.woff2 +0 -0
  37. package/fonts/harmony/HarmonyOS_Medium.ai.woff2 +0 -0
  38. package/fonts/harmony/HarmonyOS_Medium.aj.woff2 +0 -0
  39. package/fonts/harmony/HarmonyOS_Medium.ak.woff2 +0 -0
  40. package/fonts/harmony/HarmonyOS_Medium.al.woff2 +0 -0
  41. package/fonts/harmony/HarmonyOS_Medium.am.woff2 +0 -0
  42. package/fonts/harmony/HarmonyOS_Medium.an.woff2 +0 -0
  43. package/fonts/harmony/HarmonyOS_Medium.ao.woff2 +0 -0
  44. package/fonts/harmony/HarmonyOS_Medium.ap.woff2 +0 -0
  45. package/fonts/harmony/HarmonyOS_Medium.aq.woff2 +0 -0
  46. package/fonts/harmony/HarmonyOS_Medium.ar.woff2 +0 -0
  47. package/fonts/harmony/HarmonyOS_Medium.as.woff2 +0 -0
  48. package/fonts/harmony/HarmonyOS_Medium.at.woff2 +0 -0
  49. package/fonts/harmony/HarmonyOS_Medium.au.woff2 +0 -0
  50. package/fonts/harmony/HarmonyOS_Medium.av.woff2 +0 -0
  51. package/fonts/harmony/HarmonyOS_Medium.aw.woff2 +0 -0
  52. package/fonts/harmony/HarmonyOS_Medium.ax.woff2 +0 -0
  53. package/fonts/harmony/HarmonyOS_Medium.ay.woff2 +0 -0
  54. package/fonts/harmony/HarmonyOS_Medium.az.woff2 +0 -0
  55. package/fonts/harmony/HarmonyOS_Medium.b.woff2 +0 -0
  56. package/fonts/harmony/HarmonyOS_Medium.c.woff2 +0 -0
  57. package/fonts/harmony/HarmonyOS_Medium.d.woff2 +0 -0
  58. package/fonts/harmony/HarmonyOS_Medium.e.woff2 +0 -0
  59. package/fonts/harmony/HarmonyOS_Medium.f.woff2 +0 -0
  60. package/fonts/harmony/HarmonyOS_Medium.g.woff2 +0 -0
  61. package/fonts/harmony/HarmonyOS_Medium.h.woff2 +0 -0
  62. package/fonts/harmony/HarmonyOS_Medium.i.woff2 +0 -0
  63. package/fonts/harmony/HarmonyOS_Medium.j.woff2 +0 -0
  64. package/fonts/harmony/HarmonyOS_Medium.k.woff2 +0 -0
  65. package/fonts/harmony/HarmonyOS_Medium.l.woff2 +0 -0
  66. package/fonts/harmony/HarmonyOS_Medium.m.woff2 +0 -0
  67. package/fonts/harmony/HarmonyOS_Medium.n.woff2 +0 -0
  68. package/fonts/harmony/HarmonyOS_Medium.o.woff2 +0 -0
  69. package/fonts/harmony/HarmonyOS_Medium.p.woff2 +0 -0
  70. package/fonts/harmony/HarmonyOS_Medium.q.woff2 +0 -0
  71. package/fonts/harmony/HarmonyOS_Medium.r.woff2 +0 -0
  72. package/fonts/harmony/HarmonyOS_Medium.s.woff2 +0 -0
  73. package/fonts/harmony/HarmonyOS_Medium.t.woff2 +0 -0
  74. package/fonts/harmony/HarmonyOS_Medium.u.woff2 +0 -0
  75. package/fonts/harmony/HarmonyOS_Medium.v.woff2 +0 -0
  76. package/fonts/harmony/HarmonyOS_Medium.w.woff2 +0 -0
  77. package/fonts/harmony/HarmonyOS_Medium.x.woff2 +0 -0
  78. package/fonts/harmony/HarmonyOS_Medium.y.woff2 +0 -0
  79. package/fonts/harmony/HarmonyOS_Medium.z.woff2 +0 -0
  80. package/fonts/harmony/HarmonyOS_Regular.a.woff2 +0 -0
  81. package/fonts/harmony/HarmonyOS_Regular.a0.woff2 +0 -0
  82. package/fonts/harmony/HarmonyOS_Regular.a1.woff2 +0 -0
  83. package/fonts/harmony/HarmonyOS_Regular.aa.woff2 +0 -0
  84. package/fonts/harmony/HarmonyOS_Regular.ab.woff2 +0 -0
  85. package/fonts/harmony/HarmonyOS_Regular.ac.woff2 +0 -0
  86. package/fonts/harmony/HarmonyOS_Regular.ad.woff2 +0 -0
  87. package/fonts/harmony/HarmonyOS_Regular.ae.woff2 +0 -0
  88. package/fonts/harmony/HarmonyOS_Regular.af.woff2 +0 -0
  89. package/fonts/harmony/HarmonyOS_Regular.ag.woff2 +0 -0
  90. package/fonts/harmony/HarmonyOS_Regular.ah.woff2 +0 -0
  91. package/fonts/harmony/HarmonyOS_Regular.ai.woff2 +0 -0
  92. package/fonts/harmony/HarmonyOS_Regular.aj.woff2 +0 -0
  93. package/fonts/harmony/HarmonyOS_Regular.ak.woff2 +0 -0
  94. package/fonts/harmony/HarmonyOS_Regular.al.woff2 +0 -0
  95. package/fonts/harmony/HarmonyOS_Regular.am.woff2 +0 -0
  96. package/fonts/harmony/HarmonyOS_Regular.an.woff2 +0 -0
  97. package/fonts/harmony/HarmonyOS_Regular.ao.woff2 +0 -0
  98. package/fonts/harmony/HarmonyOS_Regular.ap.woff2 +0 -0
  99. package/fonts/harmony/HarmonyOS_Regular.aq.woff2 +0 -0
  100. package/fonts/harmony/HarmonyOS_Regular.ar.woff2 +0 -0
  101. package/fonts/harmony/HarmonyOS_Regular.as.woff2 +0 -0
  102. package/fonts/harmony/HarmonyOS_Regular.at.woff2 +0 -0
  103. package/fonts/harmony/HarmonyOS_Regular.au.woff2 +0 -0
  104. package/fonts/harmony/HarmonyOS_Regular.av.woff2 +0 -0
  105. package/fonts/harmony/HarmonyOS_Regular.aw.woff2 +0 -0
  106. package/fonts/harmony/HarmonyOS_Regular.ax.woff2 +0 -0
  107. package/fonts/harmony/HarmonyOS_Regular.ay.woff2 +0 -0
  108. package/fonts/harmony/HarmonyOS_Regular.az.woff2 +0 -0
  109. package/fonts/harmony/HarmonyOS_Regular.b.woff2 +0 -0
  110. package/fonts/harmony/HarmonyOS_Regular.c.woff2 +0 -0
  111. package/fonts/harmony/HarmonyOS_Regular.d.woff2 +0 -0
  112. package/fonts/harmony/HarmonyOS_Regular.e.woff2 +0 -0
  113. package/fonts/harmony/HarmonyOS_Regular.f.woff2 +0 -0
  114. package/fonts/harmony/HarmonyOS_Regular.g.woff2 +0 -0
  115. package/fonts/harmony/HarmonyOS_Regular.h.woff2 +0 -0
  116. package/fonts/harmony/HarmonyOS_Regular.i.woff2 +0 -0
  117. package/fonts/harmony/HarmonyOS_Regular.j.woff2 +0 -0
  118. package/fonts/harmony/HarmonyOS_Regular.k.woff2 +0 -0
  119. package/fonts/harmony/HarmonyOS_Regular.l.woff2 +0 -0
  120. package/fonts/harmony/HarmonyOS_Regular.m.woff2 +0 -0
  121. package/fonts/harmony/HarmonyOS_Regular.n.woff2 +0 -0
  122. package/fonts/harmony/HarmonyOS_Regular.o.woff2 +0 -0
  123. package/fonts/harmony/HarmonyOS_Regular.p.woff2 +0 -0
  124. package/fonts/harmony/HarmonyOS_Regular.q.woff2 +0 -0
  125. package/fonts/harmony/HarmonyOS_Regular.r.woff2 +0 -0
  126. package/fonts/harmony/HarmonyOS_Regular.s.woff2 +0 -0
  127. package/fonts/harmony/HarmonyOS_Regular.t.woff2 +0 -0
  128. package/fonts/harmony/HarmonyOS_Regular.u.woff2 +0 -0
  129. package/fonts/harmony/HarmonyOS_Regular.v.woff2 +0 -0
  130. package/fonts/harmony/HarmonyOS_Regular.w.woff2 +0 -0
  131. package/fonts/harmony/HarmonyOS_Regular.x.woff2 +0 -0
  132. package/fonts/harmony/HarmonyOS_Regular.y.woff2 +0 -0
  133. package/fonts/harmony/HarmonyOS_Regular.z.woff2 +0 -0
  134. package/fonts/harmony/medium.css +485 -0
  135. package/fonts/harmony/regular.css +485 -0
  136. package/icon/media.png +0 -0
  137. package/icon/volc.svg +96 -0
  138. package/images/assets_background_01.png +0 -0
  139. package/images/avatar.png +0 -0
  140. package/images/layout_01.png +0 -0
  141. package/images/layout_02.png +0 -0
  142. package/images/layout_03.png +0 -0
  143. package/package.json +4 -4
  144. package/fonts/harmony/harmony.txt +0 -0
package/AppLayout.d.ts CHANGED
@@ -69,7 +69,7 @@ export declare type LayoutProps = {
69
69
  /**
70
70
  * 布局内容
71
71
  */
72
- children: ReactNode;
72
+ children?: ReactNode;
73
73
  /**
74
74
  * 路径
75
75
  */
@@ -78,18 +78,22 @@ export declare type LayoutProps = {
78
78
  * 子路径路径分割符号, 用去区分是否子路径判断子路径的菜单归属
79
79
  */
80
80
  pathPartition: string[];
81
+ /**
82
+ * 请求获取用户信息
83
+ */
84
+ requestUser: () => Promise<UserInfo>;
81
85
  /**
82
86
  * 左侧: Logo样式
83
87
  */
84
88
  logo?: {
85
- /**
86
- * 高度
87
- */
88
- height: number;
89
89
  /**
90
90
  * Logo 路径
91
91
  */
92
92
  path: string;
93
+ /**
94
+ * 高度
95
+ */
96
+ height?: number;
93
97
  };
94
98
  /**
95
99
  * 右侧: 用户下拉选菜单
@@ -97,7 +101,7 @@ export declare type LayoutProps = {
97
101
  userMenus?: {
98
102
  key: string;
99
103
  type?: string;
100
- label: string;
104
+ label: ReactNode;
101
105
  }[];
102
106
  /**
103
107
  * 头部: 从右到左菜单
@@ -108,10 +112,6 @@ export declare type LayoutProps = {
108
112
  * @param path 路径.
109
113
  */
110
114
  toLink?: (path: string) => void;
111
- /**
112
- * 请求获取用户信息
113
- */
114
- requestUser?: () => Promise<UserInfo>;
115
115
  /**
116
116
  * 请求获取菜单信息
117
117
  * @param appCode 应用代码
package/AppLayout.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { css } from '@emotion/css';
3
- import { ProConfigProvider, ProLayout } from '@ant-design/pro-components';
3
+ import { ProLayout } from '@ant-design/pro-components';
4
4
  import { Dropdown, message, Typography } from 'antd';
5
5
  import { Session } from 'beer-network/session';
6
6
  import dayjs from 'dayjs';
@@ -99,8 +99,8 @@ const Component = (props) => {
99
99
  }, [menus, props.path]);
100
100
  // 更新属性触发: 请求用户信息
101
101
  useEffect(() => {
102
- props?.requestUser?.()
103
- ?.then(userInfo => {
102
+ props.requestUser()
103
+ .then(userInfo => {
104
104
  // 更新缓存到Session
105
105
  if (userInfo === undefined || userInfo?.id === undefined) {
106
106
  return;
@@ -108,8 +108,8 @@ const Component = (props) => {
108
108
  setUserInfo(userInfo);
109
109
  sessionStorage.setItem('SESSION', JSON.stringify(userInfo));
110
110
  });
111
- }, [props?.requestUser]);
112
- return React.createElement(ProConfigProvider, { hashed: false },
111
+ }, []);
112
+ return React.createElement(React.Fragment, null,
113
113
  contextHolder,
114
114
  React.createElement(ProLayout, { className: css `
115
115
  .ant-pro-sider-logo {
@@ -259,7 +259,7 @@ const Component = (props) => {
259
259
  align-items: center;
260
260
 
261
261
  & > img {
262
- height: ${props?.logo?.height || 22}px;
262
+ height: ${props?.logo?.height || 28}px;
263
263
  display: block;
264
264
  margin: 0 6px;
265
265
  }
@@ -299,14 +299,13 @@ const Component = (props) => {
299
299
  {
300
300
  type: 'divider'
301
301
  },
302
- ...(props?.userMenus || []),
303
- {
304
- type: 'divider'
305
- },
302
+ ...((props?.userMenus || [])?.length > 0 ? [...(props?.userMenus || []), {
303
+ type: 'divider'
304
+ }] : []),
306
305
  {
307
306
  key: 'EXIT',
308
307
  danger: true,
309
- label: React.createElement("div", { onClick: onLogout }, "\u9000\u51FA\u767B\u5F55")
308
+ label: React.createElement("div", { style: { width: '100%' }, onClick: onLogout }, "\u9000\u51FA\u767B\u5F55")
310
309
  }
311
310
  ]
312
311
  } }, dom));
@@ -0,0 +1,7 @@
1
+ import React, { FC } from 'react';
2
+ export declare type BackPageContainerProps = {
3
+ title?: string | undefined;
4
+ children?: React.ReactNode | undefined;
5
+ };
6
+ export declare const Component: FC<BackPageContainerProps>;
7
+ export default Component;
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { css } from '@emotion/css';
3
+ import { PageContainer } from '@ant-design/pro-components';
4
+ import { useNavigate } from 'react-router-dom';
5
+ export const Component = (props) => {
6
+ const navigate = useNavigate();
7
+ return React.createElement(React.Fragment, null,
8
+ React.createElement(PageContainer, { onBack: () => {
9
+ navigate(-1);
10
+ }, className: css `
11
+ .ant-page-header-heading {
12
+ padding-block-start: 0 !important;
13
+ }
14
+
15
+ .ant-page-header-heading-title {
16
+ font-size: 15px;
17
+ line-height: 1.5;
18
+ color: #333;
19
+ }
20
+ `, header: {
21
+ style: {
22
+ background: '#fff',
23
+ padding: '10px 24px 10px 24px',
24
+ borderBottom: '1px solid rgba(0, 0, 0, 0.06)'
25
+ }
26
+ }, title: props.title, ghost: true, childrenContentStyle: {
27
+ padding: '0'
28
+ } },
29
+ React.createElement("div", { className: css `
30
+ padding: 12px 16px;
31
+ ` }, props.children)));
32
+ };
33
+ export default Component;
@@ -0,0 +1,6 @@
1
+ import React, { FC } from 'react';
2
+ export declare type InlineContainer = {
3
+ children?: React.ReactNode;
4
+ };
5
+ export declare const Component: FC<InlineContainer>;
6
+ export default Component;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { App, ConfigProvider } from 'antd';
3
+ export const Component = (props) => {
4
+ return React.createElement(App, null,
5
+ React.createElement(ConfigProvider, { theme: {
6
+ token: {
7
+ fontSize: 12,
8
+ controlHeight: 26,
9
+ fontWeightStrong: 500
10
+ },
11
+ components: {
12
+ Table: {
13
+ motion: false,
14
+ headerColor: '#333',
15
+ rowHoverBg: '#f5f6f7',
16
+ rowSelectedBg: '#f4f5f6',
17
+ rowSelectedHoverBg: '#e6e7e8',
18
+ headerBg: '#fafafa',
19
+ cellPaddingInlineSM: 6,
20
+ cellPaddingBlockSM: 7
21
+ },
22
+ Switch: {
23
+ fontSize: 10
24
+ }
25
+ }
26
+ } }, props?.children));
27
+ };
28
+ export default Component;
@@ -0,0 +1,32 @@
1
+ import { ReactNode } from 'react';
2
+ import { DirectorySelectProps } from 'beer-assembly/DirectorySelect';
3
+ export type Handler<T> = {
4
+ ok: (callback?: (params: T) => void) => void;
5
+ };
6
+ type DirectoryRequest = NonNullable<DirectorySelectProps['request']>;
7
+ export declare type MediaItem = {
8
+ id: string;
9
+ name: string;
10
+ type: 'DIRECTORY' | 'FILE';
11
+ url: string;
12
+ active: boolean;
13
+ };
14
+ export declare type RequestParams = {
15
+ /**
16
+ * 获取列表数据.
17
+ * @param parentId 父类ID.
18
+ */
19
+ requestList: (parentId: string) => Promise<MediaItem[]>;
20
+ rename: (id: string, name: string) => Promise<Boolean>;
21
+ copy: (id: string) => Promise<Boolean>;
22
+ move: (moveId: string, targetId: string) => Promise<Boolean>;
23
+ remove: (id: string) => Promise<Boolean>;
24
+ createDirectory: (parentId: string, name: string) => Promise<Boolean>;
25
+ putFile: (parentId: string, files: FileList) => Promise<Boolean>;
26
+ } & {
27
+ directory: DirectoryRequest;
28
+ };
29
+ export declare class MediaModals {
30
+ static useMedia(request?: RequestParams): [Handler<string[]>, ReactNode];
31
+ }
32
+ export {};
package/MediaModals.js ADDED
@@ -0,0 +1,372 @@
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, 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 [isOpenModal, setIsOpenModal] = useState(false);
15
+ const [isOpenMoveModal, setIsOpenMoveModal] = useState(false);
16
+ const [isOpenRenameModal, setIsOpenRenameModal] = useState(false);
17
+ const [isOpenConfirmModal, setIsOpenConfirmModal] = useState(false);
18
+ const [isLoading, setIsLoading] = useState(false);
19
+ const [path, setPath] = useState([]);
20
+ const [dataList, setDataList] = useState([]);
21
+ const [selectId, setSelectId] = useState('');
22
+ const [selectName, setSelectName] = useState('');
23
+ const callbackRef = useRef(undefined);
24
+ const refreshData = (force) => {
25
+ const item = path[path.length - 1];
26
+ const chunkArray = (array, size) => {
27
+ const result = [];
28
+ for (let i = 0; i < array.length; i += size) {
29
+ result.push(array.slice(i, i + size));
30
+ }
31
+ return result;
32
+ };
33
+ setIsLoading(true);
34
+ if (force === true) {
35
+ setDataList([]);
36
+ }
37
+ request?.requestList?.(item.id)
38
+ .then(result => {
39
+ setIsLoading(false);
40
+ setDataList(chunkArray(result || [], 5));
41
+ })
42
+ .catch(() => {
43
+ setIsLoading(false);
44
+ });
45
+ };
46
+ const onActiveItem = (id) => {
47
+ setDataList(dataList?.map(item => {
48
+ return item.map(it => {
49
+ return {
50
+ ...it,
51
+ active: it.id === id
52
+ };
53
+ });
54
+ }));
55
+ };
56
+ const onDownload = async (name, url) => {
57
+ if ((url || '').trim() === '') {
58
+ return;
59
+ }
60
+ ElementUtils.download(url || '', name);
61
+ };
62
+ const onPutFile = async () => {
63
+ const files = await ElementUtils.selectFile();
64
+ if (files === null) {
65
+ return;
66
+ }
67
+ for (let i = 0; i < files.length; i += 1) {
68
+ const file = files[i];
69
+ if (file.size > (1048576 * 15)) {
70
+ messageApi.error(`文件 ${file.name} 太大,不能超过 15MB`);
71
+ return;
72
+ }
73
+ if (!['image/jpeg', 'image/png', 'image/gif', 'image/webp'].includes(file.type)) {
74
+ messageApi.error(`文件 ${file.name} 不是有效的图片格式`);
75
+ return;
76
+ }
77
+ }
78
+ const parentId = path[path.length - 1]?.id;
79
+ setIsLoading(true);
80
+ const result = await request?.putFile(parentId, files);
81
+ setIsLoading(false);
82
+ if (result === true) {
83
+ refreshData();
84
+ }
85
+ };
86
+ const onCreateDirectory = async (name) => {
87
+ const parentId = path[path.length - 1]?.id;
88
+ setIsLoading(true);
89
+ const result = await request?.createDirectory(parentId, name);
90
+ setIsLoading(false);
91
+ if (result === true) {
92
+ refreshData();
93
+ }
94
+ setSelectName('');
95
+ return true;
96
+ };
97
+ const onOpenDirectory = async (id, name) => {
98
+ if (isLoading) {
99
+ return;
100
+ }
101
+ const paths = [...getPaths(), {
102
+ id,
103
+ name
104
+ }];
105
+ setPaths(paths);
106
+ };
107
+ const onBackDirectory = async (id) => {
108
+ if (isLoading) {
109
+ return;
110
+ }
111
+ const paths = getPaths();
112
+ const index = paths.findIndex(it => it.id === id);
113
+ if (index < 0) {
114
+ return;
115
+ }
116
+ paths.splice(index + 1);
117
+ setPaths(paths);
118
+ };
119
+ const onSelectItem = async (id, name, url) => {
120
+ const current = callbackRef?.current;
121
+ if (current === undefined) {
122
+ return;
123
+ }
124
+ current?.([url || '']);
125
+ setIsOpenModal(false);
126
+ };
127
+ const onRename = async (id, name) => {
128
+ setIsOpenRenameModal(true);
129
+ setSelectId(id);
130
+ setSelectName(name);
131
+ };
132
+ const onConfirmRename = async () => {
133
+ if (await request?.rename(selectId, selectName)) {
134
+ refreshData();
135
+ setSelectName('');
136
+ setIsOpenRenameModal(false);
137
+ }
138
+ };
139
+ const onCopy = async (id) => {
140
+ const result = await request?.copy(id);
141
+ if (result === true) {
142
+ refreshData();
143
+ }
144
+ return result;
145
+ };
146
+ const onMove = async (id) => {
147
+ setIsOpenMoveModal(true);
148
+ setSelectId(id);
149
+ };
150
+ const onConfirmMove = async (targetId) => {
151
+ const result = await request?.move(selectId, targetId);
152
+ if (result === true) {
153
+ setIsOpenMoveModal(false);
154
+ refreshData();
155
+ }
156
+ };
157
+ const onRemove = async (id) => {
158
+ setIsOpenConfirmModal(true);
159
+ setSelectId(id);
160
+ };
161
+ const onConfirmRemove = async () => {
162
+ const result = await request?.remove(selectId);
163
+ if (result === true) {
164
+ setIsOpenConfirmModal(false);
165
+ refreshData();
166
+ }
167
+ return result;
168
+ };
169
+ const setPaths = (items) => {
170
+ setPath(items);
171
+ sessionStorage.setItem('MEDIA_MODALS_PATHS', JSON.stringify(items));
172
+ };
173
+ const getPaths = () => {
174
+ const paths = JSON.parse(sessionStorage.getItem('MEDIA_MODALS_PATHS') || '[]');
175
+ if (paths.length <= 0) {
176
+ paths.push({
177
+ id: '0',
178
+ name: '根目录'
179
+ });
180
+ }
181
+ return paths;
182
+ };
183
+ const Item = (props) => {
184
+ const directoryMenusItem = props.type === 'DIRECTORY' ? [
185
+ {
186
+ label: React.createElement(Space, { style: { width: 100 }, size: 5, onClick: () => onOpenDirectory(props.id, props.name) },
187
+ React.createElement(RightCircleOutlined, null),
188
+ "\u6253\u5F00\u76EE\u5F55"),
189
+ key: '0'
190
+ },
191
+ {
192
+ type: 'divider'
193
+ }
194
+ ] : [
195
+ {
196
+ label: React.createElement(Space, { style: { width: 100 }, size: 5, onClick: () => onDownload(props.name, props.src) },
197
+ React.createElement(CloudDownloadOutlined, null),
198
+ "\u4E0B\u8F7D\u6587\u4EF6"),
199
+ key: '0'
200
+ },
201
+ {
202
+ type: 'divider'
203
+ }
204
+ ];
205
+ const menusItems = [
206
+ ...directoryMenusItem,
207
+ {
208
+ label: React.createElement(Space, { style: { width: 100 }, size: 5, onClick: () => onRename(props.id, props.name) },
209
+ React.createElement(HighlightOutlined, null),
210
+ "\u91CD\u547D\u540D"),
211
+ key: '1'
212
+ },
213
+ {
214
+ label: React.createElement(Space, { style: { width: 100 }, size: 5, onClick: () => onCopy(props.id) },
215
+ React.createElement(CopyOutlined, null),
216
+ props?.type === 'DIRECTORY' ? '复制目录' : '复制文件'),
217
+ key: '2'
218
+ },
219
+ {
220
+ label: React.createElement(Space, { style: { width: 100 }, size: 5, onClick: () => onMove(props.id) },
221
+ React.createElement(ScissorOutlined, null),
222
+ props?.type === 'DIRECTORY' ? '移动目录' : '移动文件'),
223
+ key: '3'
224
+ },
225
+ {
226
+ type: 'divider'
227
+ },
228
+ {
229
+ label: React.createElement(Space, { style: { width: 100 }, size: 5, onClick: () => onRemove(props.id) },
230
+ React.createElement(DeleteOutlined, null),
231
+ props?.type === 'DIRECTORY' ? '删除目录' : '删除文件'),
232
+ key: '4',
233
+ danger: true
234
+ }
235
+ ];
236
+ return React.createElement(Dropdown, { menu: {
237
+ items: menusItems
238
+ }, trigger: ['contextMenu'] },
239
+ React.createElement("div", { style: {
240
+ padding: '8px 12px',
241
+ backgroundColor: props?.active ? '#e6f1ff' : undefined,
242
+ display: 'block',
243
+ cursor: 'pointer',
244
+ userSelect: 'none',
245
+ position: 'relative',
246
+ ...props.style
247
+ }, className: css `
248
+ border: ${props?.active ? '1px solid #cddef5' : '1px solid #fff'};
249
+
250
+ &:hover {
251
+ background-color: #eef1f5;
252
+ border: 1px solid ${props.active ? '#cddef5' : '#e6e6e6'};
253
+ }
254
+ `, onClick: () => {
255
+ setTimeout(() => onActiveItem(props.id), 10);
256
+ }, onDoubleClick: () => {
257
+ if (props.type === 'DIRECTORY') {
258
+ onOpenDirectory(props.id, props.name)
259
+ .then();
260
+ return;
261
+ }
262
+ onSelectItem(props.id, props.name, props.src)
263
+ .then();
264
+ } },
265
+ React.createElement("img", { src: props?.type === 'DIRECTORY' ? IconDirectory : props?.src, alt: "", style: {
266
+ width: 56,
267
+ height: 56,
268
+ margin: 'auto',
269
+ display: 'block',
270
+ overflow: 'hidden',
271
+ objectFit: props?.type === 'DIRECTORY' ? undefined : 'cover'
272
+ } }),
273
+ React.createElement(Typography.Text, { style: {
274
+ width: 70,
275
+ fontSize: 11,
276
+ display: 'block',
277
+ textAlign: 'center',
278
+ color: '#323232',
279
+ marginTop: props?.type === 'DIRECTORY' ? undefined : 1
280
+ }, ellipsis: true }, props?.name)));
281
+ };
282
+ const handler = {
283
+ ok: (callback) => {
284
+ setPath(getPaths());
285
+ setIsOpenModal(true);
286
+ if (callbackRef !== undefined) {
287
+ callbackRef.current = callback;
288
+ }
289
+ }
290
+ };
291
+ useEffect(() => {
292
+ if ((path || []).length <= 0) {
293
+ return;
294
+ }
295
+ refreshData(true);
296
+ }, [path]);
297
+ return [handler, React.createElement(React.Fragment, null,
298
+ React.createElement(InlineContainer, null,
299
+ React.createElement(Modal, { width: 565, footer: null, styles: {
300
+ content: { padding: 0 }
301
+ }, open: isOpenModal, maskClosable: false, onCancel: () => {
302
+ if (isLoading) {
303
+ return;
304
+ }
305
+ setIsOpenModal(false);
306
+ }, title: React.createElement("div", { style: {
307
+ padding: '16px 0 0 0'
308
+ } },
309
+ React.createElement("img", { style: {
310
+ marginInlineStart: 20,
311
+ display: 'block',
312
+ height: '17px',
313
+ padding: '2px 0 0 0'
314
+ }, alt: "", src: IconMedia })) },
315
+ React.createElement(Flux, { style: {
316
+ marginBottom: 6,
317
+ padding: '0 20px 10px 20px',
318
+ borderBottom: '1px solid #f3f3f3',
319
+ justifyContent: 'space-between'
320
+ } },
321
+ React.createElement(Breadcrumb, { items: path?.map((it, index) => {
322
+ return {
323
+ title: (index + 1 === path.length
324
+ ? React.createElement(Typography.Text, { style: {
325
+ maxWidth: 70,
326
+ fontSize: 12
327
+ }, ellipsis: true }, it.name)
328
+ : React.createElement("a", { onClick: () => onBackDirectory(it.id) },
329
+ React.createElement(Typography.Text, { style: {
330
+ maxWidth: 70,
331
+ fontSize: 12,
332
+ color: 'rgba(0, 0, 0, 0.45)'
333
+ }, ellipsis: true }, it.name)))
334
+ };
335
+ }) }),
336
+ React.createElement(Space, null,
337
+ React.createElement(Button, { type: "primary", onClick: () => onPutFile(), size: "small", style: {
338
+ height: 24,
339
+ fontSize: 12
340
+ }, loading: isLoading }, "\u4E0A\u4F20\u6587\u4EF6"),
341
+ 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" },
342
+ React.createElement(Button, { size: "small", style: {
343
+ height: 24,
344
+ fontSize: 12
345
+ }, loading: isLoading }, "\u65B0\u5EFA\u76EE\u5F55")))),
346
+ React.createElement(Spin, { spinning: isLoading },
347
+ React.createElement("div", { style: {
348
+ padding: '6px 0 24px 0',
349
+ height: 333,
350
+ maxHeight: 333,
351
+ overflowY: 'auto',
352
+ overflowX: 'hidden'
353
+ } }, dataList?.map((group, index) => (React.createElement("div", { key: index, style: {
354
+ padding: '0 20px 10px 20px',
355
+ display: 'flex'
356
+ } }, 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 })))))))))),
357
+ React.createElement(Modal, { title: "\u91CD\u547D\u540D", width: 340, open: isOpenRenameModal, onOk: () => onConfirmRename(), onCancel: () => setIsOpenRenameModal(false), okText: "\u786E\u5B9A", cancelText: "\u53D6\u6D88" },
358
+ React.createElement(Input, { value: selectName, onChange: (e) => setSelectName(e.currentTarget.value) })),
359
+ React.createElement(Modal, { title: React.createElement(React.Fragment, null,
360
+ React.createElement(ExclamationCircleFilled, { style: {
361
+ marginRight: 6,
362
+ fontSize: 16,
363
+ color: '#faad14'
364
+ } }),
365
+ "\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"),
366
+ React.createElement(DirectorySelect, { open: isOpenMoveModal, onCancel: () => {
367
+ refreshData();
368
+ setIsOpenMoveModal(false);
369
+ }, request: request?.directory, onOk: (value) => onConfirmMove(value) }),
370
+ contextHolder)];
371
+ }
372
+ }
@@ -0,0 +1,16 @@
1
+ import React, { 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
+ children?: React.ReactNode | undefined;
10
+ tabList?: Tab[];
11
+ onTabChange?: (e: string) => void;
12
+ onRefresh?: () => void;
13
+ banner?: React.ReactNode;
14
+ };
15
+ export declare const Component: FC<MyPageContainerProps>;
16
+ export default Component;