@fe-free/core 3.0.38 → 3.0.40

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,21 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 3.0.40
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: some
8
+ - @fe-free/icons@3.0.40
9
+ - @fe-free/tool@3.0.40
10
+
11
+ ## 3.0.39
12
+
13
+ ### Patch Changes
14
+
15
+ - feat: crud
16
+ - @fe-free/icons@3.0.39
17
+ - @fe-free/tool@3.0.39
18
+
3
19
  ## 3.0.38
4
20
 
5
21
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "3.0.38",
3
+ "version": "3.0.40",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -46,8 +46,8 @@
46
46
  "antd": "^5.27.1",
47
47
  "dayjs": "~1.11.10",
48
48
  "react": "^19.2.0",
49
- "@fe-free/tool": "3.0.38",
50
- "@fe-free/icons": "3.0.38"
49
+ "@fe-free/icons": "3.0.40",
50
+ "@fe-free/tool": "3.0.40"
51
51
  },
52
52
  "scripts": {
53
53
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,6 +1,7 @@
1
1
  import { DeleteOutlined } from '@fe-free/icons';
2
- import { App, Tooltip } from 'antd';
2
+ import { App } from 'antd';
3
3
  import { useCallback } from 'react';
4
+ import { OperateBtn } from './helper';
4
5
 
5
6
  interface Params {
6
7
  name: string;
@@ -40,22 +41,14 @@ function OperateDelete(props: Params) {
40
41
  const { name, desc, onDelete, operateText, disabled } = props;
41
42
  const { doDelete } = useDelete({ name, desc, onDelete, operateText });
42
43
 
43
- if (disabled) {
44
- return (
45
- <Tooltip title="删除">
46
- <span className="cursor-not-allowed text-lg text-03">
47
- {operateText || <DeleteOutlined />}
48
- </span>
49
- </Tooltip>
50
- );
51
- }
52
-
53
44
  return (
54
- <Tooltip title="删除">
55
- <a className="text-lg" onClick={doDelete}>
56
- {operateText || <DeleteOutlined />}
57
- </a>
58
- </Tooltip>
45
+ <OperateBtn
46
+ title="删除"
47
+ icon={<DeleteOutlined />}
48
+ operateText={operateText}
49
+ disabled={disabled}
50
+ onClick={doDelete}
51
+ />
59
52
  );
60
53
  }
61
54
 
@@ -0,0 +1,45 @@
1
+ import { Tooltip } from 'antd';
2
+
3
+ function OperateBtn({
4
+ title,
5
+ icon,
6
+ operateText,
7
+ disabled,
8
+ onClick,
9
+ }: {
10
+ title: string;
11
+ icon: React.ReactNode;
12
+ operateText?: string;
13
+ disabled?: boolean;
14
+ onClick?: () => void;
15
+ }) {
16
+ if (disabled) {
17
+ if (operateText) {
18
+ return <span className="cursor-not-allowed text-lg text-03">{operateText || icon}</span>;
19
+ } else {
20
+ return (
21
+ <Tooltip title={title}>
22
+ <span className="cursor-not-allowed text-lg text-03">{icon}</span>
23
+ </Tooltip>
24
+ );
25
+ }
26
+ }
27
+
28
+ if (operateText) {
29
+ return (
30
+ <span className="cursor-pointer text-lg text-primary" onClick={onClick}>
31
+ {operateText}
32
+ </span>
33
+ );
34
+ }
35
+
36
+ return (
37
+ <Tooltip title={title}>
38
+ <span className="cursor-pointer text-lg text-primary" onClick={onClick}>
39
+ {operateText || icon}
40
+ </span>
41
+ </Tooltip>
42
+ );
43
+ }
44
+
45
+ export { OperateBtn };
@@ -1,10 +1,11 @@
1
1
  import { EditOutlined, EyeOutlined } from '@fe-free/icons';
2
- import { message, Tooltip } from 'antd';
2
+ import { App } from 'antd';
3
3
  import { isString } from 'lodash-es';
4
4
  import { useCallback, useMemo } from 'react';
5
- import { Link } from 'react-router-dom';
5
+ import { routeTool } from '../route';
6
6
  import { OperateDelete } from './crud_delete';
7
7
  import { CRUDDetail } from './crud_detail';
8
+ import { OperateBtn } from './helper';
8
9
  import type { TableProps } from './table';
9
10
 
10
11
  function useOperate(props, detailProps, actionRef) {
@@ -18,6 +19,7 @@ function useOperate(props, detailProps, actionRef) {
18
19
  detailIdIndex,
19
20
  requestDeleteByRecord,
20
21
  } = props;
22
+ const { message } = App.useApp();
21
23
 
22
24
  const idField = tableProps.rowKey || 'id';
23
25
 
@@ -56,13 +58,15 @@ function useOperate(props, detailProps, actionRef) {
56
58
 
57
59
  if (!hidden) {
58
60
  const disabled = readProps?.operateIsDisabled?.(record) || false;
61
+
59
62
  if (disabled) {
60
63
  return (
61
- <Tooltip title={readProps?.operateText || '查看'}>
62
- <span key="read" className="cursor-not-allowed text-lg text-03">
63
- {readProps?.operateText || <EyeOutlined />}
64
- </span>
65
- </Tooltip>
64
+ <OperateBtn
65
+ title="查看"
66
+ icon={<EyeOutlined />}
67
+ operateText={readProps?.operateText}
68
+ disabled
69
+ />
66
70
  );
67
71
  } else {
68
72
  return (
@@ -72,9 +76,11 @@ function useOperate(props, detailProps, actionRef) {
72
76
  record={record}
73
77
  onSuccess={handleReload}
74
78
  trigger={
75
- <Tooltip title={readProps?.operateText || '查看'}>
76
- <a className="text-lg">{readProps?.operateText || <EyeOutlined />}</a>
77
- </Tooltip>
79
+ <OperateBtn
80
+ title="查看"
81
+ icon={<EyeOutlined />}
82
+ operateText={readProps?.operateText}
83
+ />
78
84
  }
79
85
  action="read"
80
86
  {...detailProps}
@@ -94,24 +100,31 @@ function useOperate(props, detailProps, actionRef) {
94
100
  const disabled = readProps?.operateIsDisabled?.(record) || false;
95
101
  if (disabled) {
96
102
  return (
97
- <Tooltip title={readProps?.operateText || '查看'}>
98
- <span key="read" className="cursor-not-allowed text-lg text-03">
99
- {readProps?.operateText || <EyeOutlined />}
100
- </span>
101
- </Tooltip>
103
+ <OperateBtn
104
+ title="查看"
105
+ icon={<EyeOutlined />}
106
+ operateText={readProps?.operateText}
107
+ disabled
108
+ />
102
109
  );
103
110
  } else {
104
111
  return (
105
- <Tooltip title={readProps?.operateText || '查看'}>
106
- <Link
107
- key="read_detail"
108
- to={`./detail/${record[detailIdIndex || 'id']}`}
109
- target={readProps?.target}
110
- className="text-lg"
111
- >
112
- {readProps?.operateText || <EyeOutlined />}
113
- </Link>
114
- </Tooltip>
112
+ <OperateBtn
113
+ title="查看"
114
+ icon={<EyeOutlined />}
115
+ operateText={readProps?.operateText}
116
+ onClick={() => {
117
+ if (readProps?.target === '_blank') {
118
+ const url = `${window.location.pathname}/detail/${record[detailIdIndex || 'id']}`;
119
+ window.open(url, readProps?.target);
120
+ } else {
121
+ routeTool.navigateTo({
122
+ path: './detail/:id',
123
+ params: { id: record[detailIdIndex || 'id'] },
124
+ });
125
+ }
126
+ }}
127
+ />
115
128
  );
116
129
  }
117
130
  }
@@ -128,11 +141,12 @@ function useOperate(props, detailProps, actionRef) {
128
141
 
129
142
  if (disabled) {
130
143
  return (
131
- <Tooltip title={updateProps?.operateText || '编辑'}>
132
- <span key="update" className="cursor-not-allowed text-lg text-03">
133
- {updateProps?.operateText || <EditOutlined />}
134
- </span>
135
- </Tooltip>
144
+ <OperateBtn
145
+ title="编辑"
146
+ icon={<EditOutlined />}
147
+ operateText={updateProps?.operateText}
148
+ disabled
149
+ />
136
150
  );
137
151
  } else {
138
152
  return (
@@ -142,9 +156,11 @@ function useOperate(props, detailProps, actionRef) {
142
156
  record={record}
143
157
  onSuccess={handleReload}
144
158
  trigger={
145
- <Tooltip title={updateProps?.operateText || '编辑'}>
146
- <a className="text-lg">{updateProps?.operateText || <EditOutlined />}</a>
147
- </Tooltip>
159
+ <OperateBtn
160
+ title="编辑"
161
+ icon={<EditOutlined />}
162
+ operateText={updateProps?.operateText}
163
+ />
148
164
  }
149
165
  action="update"
150
166
  {...detailProps}
package/src/style.scss CHANGED
@@ -14,6 +14,19 @@
14
14
  /* stylelint-disable-next-line at-rule-no-unknown */
15
15
  @tailwind utilities;
16
16
 
17
+ ::-webkit-scrollbar {
18
+ width: 8px;
19
+ }
20
+
21
+ ::-webkit-scrollbar-thumb {
22
+ background: #ccc;
23
+ border-radius: 2px;
24
+ }
25
+
26
+ ::-webkit-scrollbar-track {
27
+ background: transparent;
28
+ }
29
+
17
30
  .fec-app-hidden-form-item-label-colon {
18
31
  // 隐藏 label 的冒号
19
32
  .ant-form-item .ant-form-item-label > label::after {