@jiangood/open-admin 2.5.5 → 2.5.6

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 (108) hide show
  1. package/package.json +3 -2
  2. package/src/.umi-production/appData.json +75 -74
  3. package/src/.umi-production/core/route.tsx +6 -6
  4. package/src/framework/GlobalData.d.ts +8 -0
  5. package/src/framework/GlobalData.js +33 -0
  6. package/src/framework/{components/system → biz}/HasPerm.tsx +1 -1
  7. package/src/framework/{components/OrgTree/index.tsx → biz/OrgTree.tsx} +12 -2
  8. package/src/framework/{components/system/ButtonList.tsx → biz/PermActions.tsx} +6 -5
  9. package/src/framework/{components/RoleTree/index.tsx → biz/RoleTree.tsx} +13 -3
  10. package/src/framework/{components/system → biz}/index.tsx +4 -2
  11. package/src/framework/components/ContextMenu/index.tsx +1 -1
  12. package/src/framework/components/DownloadModal/index.tsx +332 -0
  13. package/src/framework/components/ErrorBoundary/index.tsx +18 -0
  14. package/src/framework/components/NamedIcon/{index.jsx → index.tsx} +8 -3
  15. package/src/framework/components/Page/index.tsx +2 -2
  16. package/src/framework/components/ProTable/index.tsx +3 -10
  17. package/src/framework/components/index.ts +2 -6
  18. package/src/framework/fields/BaseRemoteSelect/index.tsx +2 -3
  19. package/src/framework/fields/FieldEditor/index.tsx +35 -44
  20. package/src/framework/fields/FieldNumberRange/index.tsx +2 -2
  21. package/src/framework/fields/FieldRemoteTree/index.tsx +1 -1
  22. package/src/framework/fields/FieldTable/index.tsx +20 -22
  23. package/src/framework/fields/FieldUploadFile/index.tsx +3 -3
  24. package/src/framework/fields/index.ts +1 -3
  25. package/src/framework/index.ts +2 -0
  26. package/src/framework/utils/ArrayUtils.d.ts +6 -0
  27. package/src/framework/utils/ArrayUtils.js +30 -0
  28. package/src/framework/utils/DateUtils.d.ts +20 -0
  29. package/src/framework/utils/DateUtils.js +81 -0
  30. package/src/framework/utils/DeviceUtils.d.ts +3 -0
  31. package/src/framework/utils/DeviceUtils.js +10 -0
  32. package/src/framework/utils/EventBus.d.ts +6 -0
  33. package/src/framework/utils/EventBus.js +51 -0
  34. package/src/framework/utils/MessageUtils.d.ts +10 -0
  35. package/src/framework/utils/MessageUtils.js +43 -0
  36. package/src/framework/utils/ObjectUtils.d.ts +14 -0
  37. package/src/framework/utils/ObjectUtils.js +12 -0
  38. package/src/framework/utils/StorageUtils.d.ts +4 -0
  39. package/src/framework/utils/{StorageUtils.ts → StorageUtils.js} +7 -11
  40. package/src/framework/utils/StringUtils.d.ts +17 -0
  41. package/src/framework/utils/StringUtils.js +107 -0
  42. package/src/framework/utils/TreeUtils.d.ts +13 -0
  43. package/src/framework/utils/TreeUtils.js +63 -0
  44. package/src/framework/utils/UrlUtils.d.ts +6 -0
  45. package/src/framework/utils/UrlUtils.js +71 -0
  46. package/src/framework/utils/index.ts +1 -5
  47. package/src/framework/utils/system/DictUtils.d.ts +20 -0
  48. package/src/framework/utils/system/DictUtils.js +31 -0
  49. package/src/framework/utils/system/FormRegistry.d.ts +8 -0
  50. package/src/framework/utils/system/FormRegistry.js +31 -0
  51. package/src/framework/utils/system/HttpUtils.d.ts +14 -0
  52. package/src/framework/utils/system/HttpUtils.js +87 -0
  53. package/src/framework/utils/system/PageUtils.d.ts +14 -0
  54. package/src/framework/utils/system/PageUtils.js +59 -0
  55. package/src/framework/utils/system/PermUtils.d.ts +5 -0
  56. package/src/framework/utils/system/PermUtils.js +27 -0
  57. package/src/framework/utils/system/ThemeUtils.d.ts +6 -0
  58. package/src/framework/utils/system/{ThemeUtils.ts → ThemeUtils.js} +19 -19
  59. package/src/framework/utils/system/index.ts +1 -2
  60. package/src/framework/views/ViewFile/index.tsx +1 -2
  61. package/src/framework/views/ViewImage/index.tsx +3 -3
  62. package/src/framework/views/{ViewBooleanEnableDisable → ViewSwitch}/index.tsx +1 -1
  63. package/src/framework/views/index.ts +3 -4
  64. package/src/layouts/admin/HeaderRight.jsx +32 -44
  65. package/src/layouts/admin/index.jsx +5 -29
  66. package/src/layouts/index.jsx +26 -17
  67. package/src/pages/about.jsx +24 -4
  68. package/src/pages/{userCenter/ChangePassword.jsx → account/changePassword.jsx} +1 -2
  69. package/src/pages/{userCenter → account}/index.jsx +2 -6
  70. package/src/pages/forceUpdatePwd.jsx +89 -0
  71. package/src/pages/login.jsx +5 -5
  72. package/src/pages/system/dict/index.jsx +6 -6
  73. package/src/pages/system/file/index.jsx +4 -4
  74. package/src/pages/system/job/index.jsx +2 -2
  75. package/src/pages/system/org/index.jsx +2 -2
  76. package/src/pages/system/role/index.jsx +4 -4
  77. package/src/pages/system/role/{perm.jsx → rolePerm.jsx} +2 -2
  78. package/src/pages/system/user/index.jsx +4 -4
  79. package/src/framework/components/DownloadFileButton/index.tsx +0 -33
  80. package/src/framework/components/NamedIcon/index.d.ts +0 -7
  81. package/src/framework/components/ProTable/utils/index.ts +0 -62
  82. package/src/framework/fields/FieldRemoteSelectMultipleInline/index.tsx +0 -33
  83. package/src/framework/fields/FieldRemoteTreeSelectMultiple/index.tsx +0 -43
  84. package/src/framework/utils/ArrayUtils.ts +0 -186
  85. package/src/framework/utils/ColorsUtils.ts +0 -378
  86. package/src/framework/utils/DateUtils.ts +0 -187
  87. package/src/framework/utils/DeviceUtils.ts +0 -46
  88. package/src/framework/utils/DomUtils.ts +0 -50
  89. package/src/framework/utils/EventBusUtils.ts +0 -143
  90. package/src/framework/utils/Logger.ts +0 -40
  91. package/src/framework/utils/MessageUtils.tsx +0 -90
  92. package/src/framework/utils/ObjectUtils.ts +0 -118
  93. package/src/framework/utils/StringUtils.ts +0 -436
  94. package/src/framework/utils/TreeUtils.ts +0 -251
  95. package/src/framework/utils/UrlUtils.ts +0 -152
  96. package/src/framework/utils/UuidUtils.ts +0 -88
  97. package/src/framework/utils/ValidateUtils.ts +0 -28
  98. package/src/framework/utils/system/DictUtils.ts +0 -96
  99. package/src/framework/utils/system/FormRegistryUtils.ts +0 -76
  100. package/src/framework/utils/system/HttpUtils.ts +0 -251
  101. package/src/framework/utils/system/PageUtils.ts +0 -163
  102. package/src/framework/utils/system/PermUtils.ts +0 -79
  103. package/src/framework/utils/system/SysUtils.ts +0 -105
  104. package/src/framework/views/ViewProcessInstanceProgress/index.tsx +0 -98
  105. package/src/framework/views/ViewProcessInstanceProgressButton/index.tsx +0 -23
  106. package/src/pages/userCenter/message.jsx +0 -105
  107. /package/src/framework/{components → views}/ViewRange/index.tsx +0 -0
  108. /package/src/pages/system/user/{UserPerm.jsx → userPerm.jsx} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {PlusOutlined} from '@ant-design/icons'
2
2
  import {Button, Form, Input, InputNumber, Modal, Popconfirm, Select, Transfer, Tree} from 'antd'
3
3
  import React from 'react'
4
- import {ButtonList, FieldBoolean, HttpUtils, Page, PageUtils, ProTable, ViewText} from "../../../framework";
4
+ import {PermActions, FieldBoolean, HttpUtils, Page, PageUtils, ProTable, ViewText} from "../../../framework";
5
5
 
6
6
 
7
7
  export default class extends React.Component {
@@ -131,12 +131,12 @@ export default class extends React.Component {
131
131
  render: (_, record) => {
132
132
 
133
133
  return (
134
- <ButtonList>
134
+ <PermActions>
135
135
  <Button size='small' perm='sys-role:grant-permission'
136
136
  onClick={() => this.handleEditUser(record)}>用户设置</Button>
137
137
 
138
138
  <Button size='small' perm='sys-role:grant-permission' disabled={record.builtin}
139
- onClick={() => PageUtils.open('/system/role/perm?id=' + record.id, '角色权限设置')}>权限设置</Button>
139
+ onClick={() => PageUtils.open('/system/role/rolePerm?id=' + record.id, '角色权限设置')}>权限设置</Button>
140
140
 
141
141
  <Button size='small' perm='sys-role:update' disabled={record.builtin}
142
142
  onClick={() => this.handleEdit(record)}>编辑</Button>
@@ -144,7 +144,7 @@ export default class extends React.Component {
144
144
  onConfirm={() => this.handleDelete(record)}>
145
145
  <Button size='small' disabled={record.builtin}>删除</Button>
146
146
  </Popconfirm>
147
- </ButtonList>
147
+ </PermActions>
148
148
  );
149
149
  },
150
150
  },
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import {Button, Card, Checkbox, Table, Typography} from "antd";
3
3
  import {SaveOutlined} from "@ant-design/icons";
4
- import {ArrayUtils, HttpUtils, Page, PageUtils} from "../../../framework";
4
+ import {HttpUtils, Page, PageUtils} from "../../../framework";
5
5
  export default class extends React.Component {
6
6
 
7
7
 
@@ -80,7 +80,7 @@ export default class extends React.Component {
80
80
  continue;
81
81
  }
82
82
  menus.push(menuId)
83
- ArrayUtils.addAll(perms, ks)
83
+ perms.push(...ks)
84
84
  }
85
85
  HttpUtils.post('admin/sysRole/save-perms', {id: this.roleId, perms, menus}).then(rs => {
86
86
  // Page.open(PageUtils.currentPathname(), PageUtils.currentLabel())
@@ -2,7 +2,7 @@ import {PlusOutlined} from '@ant-design/icons';
2
2
  import {Button, Card, Form, Input, Modal, Popconfirm, Select, Splitter} from 'antd';
3
3
  import React from 'react';
4
4
  import {
5
- ButtonList,
5
+ PermActions,
6
6
  DictUtils,
7
7
  FieldBoolean,
8
8
  FieldRemoteSelect,
@@ -12,7 +12,7 @@ import {
12
12
  Page,
13
13
  ProTable,
14
14
  } from "../../../framework";
15
- import UserPerm from "./UserPerm";
15
+ import UserPerm from "./userPerm";
16
16
 
17
17
  export default class extends React.Component {
18
18
 
@@ -119,7 +119,7 @@ export default class extends React.Component {
119
119
  dataIndex: 'option',
120
120
  fixed: 'right',
121
121
  render: (_, record) => {
122
- return <ButtonList>
122
+ return <PermActions>
123
123
  <Button size='small' perm='sys-user:update' onClick={() => this.handleEdit(record)}> 编辑 </Button>
124
124
 
125
125
  <Button size='small' perm='sys-user:grant-permission'
@@ -133,7 +133,7 @@ export default class extends React.Component {
133
133
  onConfirm={() => this.handleDelete(record)}>
134
134
  <Button size='small'>删除</Button>
135
135
  </Popconfirm>
136
- </ButtonList>;
136
+ </PermActions>;
137
137
  },
138
138
  },
139
139
  ];
@@ -1,33 +0,0 @@
1
- import React from "react";
2
- import {Button, Modal, Spin} from "antd";
3
- import {HttpUtils} from "../../utils";
4
-
5
-
6
- export class DownloadFileButton extends React.Component {
7
-
8
- state = {
9
- open:false
10
- }
11
-
12
- onClick(){
13
- const {url, params, children, ...rest} = this.props;
14
- this.setState({open:true})
15
- HttpUtils.downloadFile(url,params).then(rs=>{
16
-
17
- }).finally(()=>{
18
- this.setState({open:false})
19
- })
20
- }
21
-
22
- render() {
23
- const {url, params, children, ...rest} = this.props;
24
-
25
-
26
- return <> <Button {...rest}>{children}</Button>
27
-
28
- <Modal title='提示' footer={null} mask={{closable: false}} onCancel={()=>{this.setState({open:false})}}>
29
- <Spin /> 下载文件中,请勿关闭浏览器
30
- </Modal>
31
- </>
32
- }
33
- }
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
-
3
- type NamedIconProps = {
4
- name: string;
5
- } & React.ComponentProps<typeof import('@ant-design/icons').WarningOutlined>;
6
-
7
- export function NamedIcon(props: NamedIconProps): React.ReactElement;
@@ -1,62 +0,0 @@
1
- import type { MutableRefObject } from 'react';
2
-
3
- interface PageInfo {
4
- current: number;
5
- pageSize: number;
6
- total: number;
7
- }
8
-
9
- interface ActionType {
10
- pageInfo: PageInfo;
11
- reload: () => void;
12
- reset: () => void;
13
- setPageInfo: (info: Partial<PageInfo>) => void;
14
- }
15
-
16
- interface ActionProps {
17
- onCleanSelected: () => void;
18
- resetAll: () => void;
19
- }
20
-
21
- interface UserAction {
22
- pageInfo: PageInfo;
23
- reload: (resetPageIndex?: boolean) => Promise<void>;
24
- reloadAndRest: () => Promise<void>;
25
- reset: () => Promise<void>;
26
- clearSelected: () => void;
27
- setPageInfo: (rest: Partial<PageInfo>) => void;
28
- }
29
-
30
- /**
31
- * 获取用户的 action 信息
32
- */
33
- export function useActionType(
34
- ref: MutableRefObject<UserAction | undefined>,
35
- action: ActionType,
36
- props: ActionProps,
37
- ): void {
38
- /** 这里生成action的映射,保证 action 总是使用的最新 只需要渲染一次即可 */
39
- const userAction: UserAction = {
40
- pageInfo: action.pageInfo,
41
- reload: async (resetPageIndex) => {
42
- if (resetPageIndex) {
43
- await action.setPageInfo({ current: 1 });
44
- }
45
- action?.reload();
46
- },
47
- reloadAndRest: async () => {
48
- props.onCleanSelected();
49
- await action.setPageInfo({ current: 1 });
50
- await action?.reload();
51
- },
52
- reset: async () => {
53
- await props.resetAll();
54
- await action?.reset?.();
55
- await action?.reload();
56
- },
57
- clearSelected: () => props.onCleanSelected(),
58
- setPageInfo: (rest) => action.setPageInfo(rest),
59
- };
60
- // eslint-disable-next-line no-param-reassign
61
- ref.current = userAction;
62
- }
@@ -1,33 +0,0 @@
1
- import React from 'react';
2
- import { Select } from 'antd';
3
- import { StringUtils } from '../../utils';
4
- import { BaseRemoteSelect } from '../BaseRemoteSelect';
5
-
6
- /**
7
- * 多选,但是值是字符串,逗号拼接的
8
- */
9
- export class FieldRemoteSelectMultipleInline extends BaseRemoteSelect {
10
- static defaultProps = {
11
- placeholder: '请搜索选择',
12
- };
13
-
14
- render() {
15
- const { value, onChange, url, ...selectProps } = this.props;
16
- const { data, loading } = this.state;
17
-
18
- return (
19
- <Select
20
- showSearch={this.getShowSearch()}
21
- value={StringUtils.split(value, ',')}
22
- onChange={(arr) => onChange && onChange(StringUtils.join(arr, ','))}
23
- options={data}
24
- notFoundContent={this.getNotFoundContent()}
25
- style={{ width: '100%', minWidth: 200 }}
26
- allowClear
27
- mode="multiple"
28
- loading={loading}
29
- {...selectProps}
30
- />
31
- );
32
- }
33
- }
@@ -1,43 +0,0 @@
1
- import { Spin, TreeSelect } from 'antd';
2
- import React from 'react';
3
- import { StringUtils } from '../../utils';
4
- import { BaseRemoteSelect } from '../BaseRemoteSelect';
5
-
6
- export class FieldRemoteTreeSelectMultiple extends BaseRemoteSelect {
7
- static defaultProps = {
8
- treeDefaultExpandAll: true,
9
- style: {
10
- width: '100%',
11
- minWidth: 200,
12
- },
13
- };
14
-
15
- getLoadParams() {
16
- return undefined;
17
- }
18
-
19
- render() {
20
- const { value, onChange, style, treeDefaultExpandAll } = this.props;
21
- const { data, loading } = this.state;
22
-
23
- if (loading) return <Spin />;
24
-
25
- return (
26
- <TreeSelect
27
- style={style}
28
- allowClear
29
- styles={{ popup: { root: { maxHeight: 400, overflow: 'auto' } } }}
30
- treeData={data}
31
- showCheckedStrategy={TreeSelect.SHOW_ALL}
32
- value={value || undefined}
33
- onChange={onChange}
34
- multiple
35
- showSearch={{ filterTreeNode: (inputValue, treeNode) =>
36
- StringUtils.contains(treeNode.title, inputValue)
37
- }}
38
- treeLine={{ showLeafIcon: true }}
39
- treeDefaultExpandAll={treeDefaultExpandAll}
40
- />
41
- );
42
- }
43
- }
@@ -1,186 +0,0 @@
1
- /**
2
- * 数组工具类
3
- * 提供了一系列对数组进行操作的静态方法。
4
- */
5
- export class ArrayUtils {
6
-
7
- /**
8
- * 检查数组是否包含某个元素。
9
- * @param arr 目标数组。
10
- * @param item 要检查的元素。
11
- * @returns 如果包含则返回 true,否则返回 false。
12
- */
13
- static contains<T>(arr: T[], item: T): boolean {
14
- return arr.indexOf(item) !== -1;
15
- }
16
-
17
- /**
18
- * 检查数组是否包含至少一个指定的元素。
19
- *
20
- * @param arr 目标数组。
21
- * @param items 要检查的一个或多个元素。
22
- * @returns 如果包含任意一个元素则返回 true,否则返回 false。
23
- */
24
- static containsAny<T>(arr: T[], ...items: T[]): boolean {
25
- for (const item of items) {
26
- if (ArrayUtils.contains(arr, item)) {
27
- return true;
28
- }
29
- }
30
- return false;
31
- }
32
-
33
- /**
34
- * 在数组末尾添加一个元素。
35
- * @param arr 目标数组。
36
- * @param item 要添加的元素。
37
- */
38
- static add<T>(arr: T[], item: T): void {
39
- arr.push(item);
40
- }
41
-
42
- /**
43
- * 在数组的指定索引处添加一个元素。
44
- * @param arr 目标数组。
45
- * @param index 插入位置的索引。
46
- * @param item 要添加的元素。
47
- */
48
- static addAt<T>(arr: T[], index: number, item: T): void {
49
- arr.splice(index, 0, item);
50
- }
51
-
52
- /**
53
- * 将另一个数组的所有元素追加到目标数组的尾部。
54
- * @param arr 目标数组。
55
- * @param items 要追加的元素数组。
56
- */
57
- static addAll<T>(arr: T[], items: T[]): void {
58
- arr.push(...items);
59
- }
60
-
61
- /**
62
- * 移除数组指定索引处的元素。
63
- * @param arr 目标数组。
64
- * @param index 要移除元素的索引。
65
- */
66
- static removeAt<T>(arr: T[], index: number): void {
67
- if (index >= 0 && index < arr.length) {
68
- arr.splice(index, 1);
69
- }
70
- }
71
-
72
- /**
73
- * 移除数组中第一个匹配的元素。
74
- * @param arr 目标数组。
75
- * @param item 要移除的元素。
76
- */
77
- static remove<T>(arr: T[], item: T): void {
78
- const index = arr.indexOf(item);
79
- if (index !== -1) {
80
- ArrayUtils.removeAt(arr, index);
81
- }
82
- }
83
-
84
- /**
85
- * 清空数组。
86
- * @param arr 目标数组。
87
- */
88
- static clear<T>(arr: T[]): void {
89
- arr.length = 0;
90
- }
91
-
92
- /**
93
- * 截取数组的一个子集。
94
- * @param arr 目标数组。
95
- * @param fromIndex 开始索引(包含)。
96
- * @param toIndex 结束索引(不包含)。
97
- * @returns 截取后的新数组。
98
- */
99
- static sub<T>(arr: T[], fromIndex?: number, toIndex?: number): T[] {
100
- return arr.slice(fromIndex, toIndex);
101
- }
102
-
103
- /**
104
- * 交换数组中两个元素的位置。
105
- * @param arr 目标数组。
106
- * @param item1 元素1。
107
- * @param item2 元素2。
108
- */
109
- static swap<T>(arr: T[], item1: T, item2: T): void {
110
- const index1 = arr.indexOf(item1);
111
- const index2 = arr.indexOf(item2);
112
-
113
- if (index1 !== -1 && index2 !== -1) {
114
- [arr[index1], arr[index2]] = [arr[index2], arr[index1]];
115
- }
116
- }
117
-
118
- /**
119
- * 在数组的指定索引处插入一个元素(与 addAt 相同,保留以兼容原 API)。
120
- * @param arr 目标数组。
121
- * @param index 插入位置的索引。
122
- * @param item 要插入的元素。
123
- */
124
- static insert<T>(arr: T[], index: number, item: T): void {
125
- ArrayUtils.addAt(arr, index, item);
126
- }
127
-
128
- /**
129
- * 如果元素不存在于数组中,则将其添加到数组末尾。
130
- * @param arr 目标数组。
131
- * @param item 要添加的元素。
132
- */
133
- static pushIfNotExist<T>(arr: T[], item: T): void {
134
- if (!ArrayUtils.contains(arr, item)) {
135
- arr.push(item);
136
- }
137
- }
138
-
139
- /**
140
- * 将新数组中的所有元素添加到目标数组的末尾。
141
- * @param arr 目标数组。
142
- * @param newArr 要添加的元素数组。
143
- */
144
- static pushAll<T>(arr: T[], newArr: T[]): void {
145
- ArrayUtils.addAll(arr, newArr);
146
- }
147
-
148
- /**
149
- * 获取对象数组中某一属性值最大的对象。
150
- *
151
- * @param arr 对象数组。
152
- * @param key 用于比较的属性名。
153
- * @returns 属性值最大的对象,如果数组为空则返回 undefined。
154
- */
155
- static maxBy<T extends Record<K, any>, K extends keyof T>(
156
- arr: T[],
157
- key: K
158
- ): T | undefined {
159
- if (arr == null || arr.length === 0) {
160
- return undefined;
161
- }
162
-
163
- let maxElement: T | undefined = undefined;
164
- let maxValue: number = -Infinity;
165
-
166
- for (const element of arr) {
167
- const value = element[key];
168
-
169
- if (typeof value === 'number' && value > maxValue) {
170
- maxValue = value;
171
- maxElement = element;
172
- }
173
- }
174
-
175
- return maxElement;
176
- }
177
-
178
- /**
179
- * 对数组进行去重。
180
- * @param arr 目标数组。
181
- * @returns 去重后的新数组。
182
- */
183
- static unique<T>(arr: T[]): T[] {
184
- return [...new Set(arr)];
185
- }
186
- }