@fe-free/core 1.0.3 → 1.1.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 1.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: curd 调整
8
+ - @fe-free/tool@1.1.2
9
+
10
+ ## 1.1.1
11
+
12
+ ### Patch Changes
13
+
14
+ - fix: 调整 crud props
15
+ - @fe-free/tool@1.1.1
16
+
17
+ ## 1.1.0
18
+
19
+ ### Minor Changes
20
+
21
+ - feat: 优化 date
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies
26
+ - @fe-free/tool@1.1.0
27
+
3
28
  ## 1.0.3
4
29
 
5
30
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "1.0.3",
3
+ "version": "1.1.2",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -29,7 +29,7 @@
29
29
  "react-syntax-highlighter": "^15.5.0",
30
30
  "vanilla-jsoneditor": "^0.23.1",
31
31
  "zustand": "^4.5.4",
32
- "@fe-free/tool": "1.0.3"
32
+ "@fe-free/tool": "1.1.2"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@ant-design/pro-components": "^2.7.15",
package/src/crud/crud.tsx CHANGED
@@ -39,7 +39,7 @@ interface CRUDProps {
39
39
  };
40
40
 
41
41
  /** 删除接口 */
42
- deleteByRecord?: (record) => Promise<any>;
42
+ requestDeleteByRecord?: (record) => Promise<any>;
43
43
  /** 删除相关 */
44
44
  deleteProps?: {
45
45
  /** 显示名称索引 */
@@ -89,7 +89,7 @@ const CRUD = forwardRef<CRUDMethods, CRUDProps>(function CRUD(props, ref) {
89
89
  createButton,
90
90
  operateColumnProps,
91
91
  readProps,
92
- deleteByRecord,
92
+ requestDeleteByRecord,
93
93
  deleteProps,
94
94
  detailIdIndex,
95
95
  detailForm,
@@ -138,16 +138,16 @@ const CRUD = forwardRef<CRUDMethods, CRUDProps>(function CRUD(props, ref) {
138
138
  const getHandleDelete = useCallback(
139
139
  (record) => {
140
140
  return () => {
141
- if (deleteByRecord) {
142
- return deleteByRecord(record).then(() => {
141
+ if (requestDeleteByRecord) {
142
+ return requestDeleteByRecord(record).then(() => {
143
143
  actionRef.current?.reload();
144
144
  });
145
145
  }
146
146
 
147
- throw new Error('没有传 deleteByRecord');
147
+ throw new Error('没有传 requestDeleteByRecord');
148
148
  };
149
149
  },
150
- [deleteByRecord]
150
+ [requestDeleteByRecord]
151
151
  );
152
152
 
153
153
  const handleReload = useCallback(() => {
@@ -218,17 +218,18 @@ const CRUD = forwardRef<CRUDMethods, CRUDProps>(function CRUD(props, ref) {
218
218
 
219
219
  return tableProps.columns as TableProps['columns'];
220
220
  }, [
221
+ operateColumnProps,
221
222
  actions,
223
+ tableProps.columns,
224
+ handleReload,
222
225
  readProps?.operateText,
223
- deleteProps,
224
- detailIdIndex,
226
+ readProps?.target,
225
227
  detailProps,
226
- getHandleDelete,
227
- handleReload,
228
- tableProps.columns,
229
228
  location.pathname,
230
- operateColumnProps,
229
+ detailIdIndex,
231
230
  updateProps?.operateText,
231
+ deleteProps,
232
+ getHandleDelete,
232
233
  ]);
233
234
 
234
235
  const toolBarRender = useCallback(
@@ -123,12 +123,9 @@ function CRUDDetail(props: CRUDDetailProps) {
123
123
  if (id) {
124
124
  setLoading(true);
125
125
 
126
- let res;
127
- if (requestGetByRecord) {
128
- res = await requestGetByRecord(record);
129
- }
126
+ const d = await requestGetByRecord?.(record);
130
127
 
131
- form?.setFieldsValue(res.data.data);
128
+ form?.setFieldsValue(d);
132
129
 
133
130
  setLoading(false);
134
131
  }
@@ -82,11 +82,7 @@ async function fakeGetByRecord(record) {
82
82
 
83
83
  return new Promise((resolve) => {
84
84
  setTimeout(() => {
85
- resolve({
86
- data: {
87
- data: fakeData.find((item) => item.id === record.id),
88
- },
89
- });
85
+ resolve(fakeData.find((item) => item.id === record.id));
90
86
  }, 1000);
91
87
  });
92
88
  }
@@ -45,7 +45,7 @@ const Normal = () => {
45
45
  columns,
46
46
  request: fakeRequest,
47
47
  }}
48
- deleteByRecord={fakeDeleteByRecord}
48
+ requestDeleteByRecord={fakeDeleteByRecord}
49
49
  deleteProps={{
50
50
  nameIndex: 'name',
51
51
  }}
@@ -309,7 +309,7 @@ const CustomText = () => {
309
309
  readProps={{
310
310
  operateText: '查看啦',
311
311
  }}
312
- deleteByRecord={fakeDeleteByRecord}
312
+ requestDeleteByRecord={fakeDeleteByRecord}
313
313
  deleteProps={{
314
314
  nameIndex: 'name',
315
315
  operateText: '删除啦',
package/src/crud/index.md CHANGED
@@ -95,26 +95,25 @@ type CrudAction = 'create' | 'read' | 'read_detail' | 'update' | 'delete';
95
95
  interface CRUDProps {
96
96
  actions: CrudAction[];
97
97
 
98
- /** 表格相关 */
99
- tableProps: TableProps;
100
-
101
98
  /** 新建按钮,默认新建 */
102
99
  createButton?: ReactNode;
103
100
 
101
+ /** 表格相关 */
102
+ tableProps: TableProps;
104
103
  operateColumnProps?: {
105
104
  width?: number;
106
105
  /** 扩展操作区域 */
107
106
  moreOperator?: (record) => ReactNode;
108
107
  };
109
-
110
108
  readProps?: {
111
109
  /** 文本 */
112
110
  operateText?: string;
111
+ /** 打开方式, action 为 read_detail 有效 */
112
+ target?: '_blank';
113
113
  };
114
114
 
115
115
  /** 删除接口 */
116
- deleteById?: ({ id, ids }) => Promise<any>;
117
- deleteByRecord?: (record) => Promise<any>;
116
+ requestDeleteByRecord?: (record) => Promise<any>;
118
117
  /** 删除相关 */
119
118
  deleteProps?: {
120
119
  /** 显示名称索引 */
@@ -131,9 +130,8 @@ interface CRUDProps {
131
130
  detailFormInstance?: ProFormInstance;
132
131
 
133
132
  /** 新增接口 */
134
- requestAdd?: (values) => Promise<any>;
135
-
136
- addProps?: {
133
+ requestCreate?: (values) => Promise<any>;
134
+ createProps?: {
137
135
  /** 成功文案 */
138
136
  successText?: string | (() => string);
139
137
  };
@@ -148,12 +146,9 @@ interface CRUDProps {
148
146
  };
149
147
 
150
148
  /** 获取详情接口 */
151
- requestGetById?: ({ id }) => Promise<any>;
152
-
153
- /** 获取详情接口,非 id 的时候 */
154
149
  requestGetByRecord?: (record) => Promise<any>;
155
150
 
156
- /** 跳转到详情的 id 所以,默认 id */
151
+ /** 跳转到详情的索引 ,默认 id */
157
152
  detailIdIndex?: string;
158
153
  }
159
154
 
@@ -1,15 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ProFormDateRangePicker } from '@ant-design/pro-components';
3
3
  import dayjs from 'dayjs';
4
- import { isString } from 'lodash-es';
5
-
6
- function getDayjs(text: string | number) {
7
- if (isString(text) && /^\d+$/.test(text as string)) {
8
- return dayjs(parseInt(text as string));
9
- }
10
- // 其他都可以 dayjs
11
- return dayjs(text);
12
- }
4
+ import { getDayjs } from '@fe-free/tool';
13
5
 
14
6
  const renderMap = {
15
7
  dateTime: (text) => {
@@ -9,6 +9,8 @@ toc: content
9
9
 
10
10
  ## customValueTypeMap
11
11
 
12
+ 配置 customValueTypeMap
13
+
12
14
  ```tsx | pure
13
15
  import { customValueTypeMap } from '@fe-free/core';
14
16
  import { ProConfigProvider } from '@ant-design/pro-components';
@@ -24,6 +26,8 @@ export default Demo;
24
26
 
25
27
  ## CustomValueTypeEnum
26
28
 
29
+ 使用
30
+
27
31
  ```tsx | pure
28
32
  enum CustomValueTypeEnum {
29
33
  /** 渲染时间 + 搜索日期范围 */
@@ -48,6 +52,7 @@ async function fakeRequest() {
48
52
  timeNumber: +dayjs('2024-10-01 10:00:00'),
49
53
  dateStr: `2024-10-01`,
50
54
  dateNumber: +dayjs('2024-10-01'),
55
+ seconds: Math.abs(+dayjs('2024-10-01') / 1000),
51
56
  jsonText: JSON.stringify({ name: 'hello world hello world hello world' }),
52
57
  }));
53
58
 
@@ -88,6 +93,12 @@ const Table = () => {
88
93
  valueType: CustomValueTypeEnum.CustomDateAndDateRange,
89
94
  search: true,
90
95
  },
96
+ {
97
+ title: '秒数',
98
+ dataIndex: 'seconds',
99
+ valueType: CustomValueTypeEnum.CustomDateAndDateRange,
100
+ search: true,
101
+ },
91
102
  {
92
103
  title: 'json',
93
104
  dataIndex: 'jsonText',