@jiangood/open-admin 3.0.12 → 3.0.13
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/package.json +1 -1
- package/src/framework/components/ProTable/index.tsx +3 -1
- package/src/framework/fields/FieldEditor/index.tsx +56 -10
- package/src/framework/fields/FieldUploadFile/index.tsx +6 -6
- package/src/framework/fields/FieldUploadImage/index.tsx +494 -233
- package/src/framework/views/ViewImage/index.tsx +56 -50
- package/src/layouts/admin/index.less +1 -1
- package/src/pages/article/$code.jsx +20 -6
- package/src/pages/article/article.less +124 -0
- package/src/pages/system/article/index.jsx +12 -22
- package/src/pages/system/file/index.jsx +77 -93
- package/src/pages/system/job/index.jsx +1 -1
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import './index.less'
|
|
|
9
9
|
/** 通过 actionRef 暴露的表格操作 */
|
|
10
10
|
export interface ProTableActionRef {
|
|
11
11
|
reload: () => void;
|
|
12
|
+
clearSelection: () => void;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
/** request 返回结构(Spring Data Page 序列化 + 扩展数据) */
|
|
@@ -122,7 +123,8 @@ export class ProTable<T = any> extends React.Component<ProTableProps<T>, ProTabl
|
|
|
122
123
|
this.loadData()
|
|
123
124
|
if (this.props.actionRef) {
|
|
124
125
|
this.props.actionRef.current = {
|
|
125
|
-
reload: () => this.loadData()
|
|
126
|
+
reload: () => this.loadData(),
|
|
127
|
+
clearSelection: () => this.setState({selectedRowKeys: [], selectedRows: []})
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {Spin} from 'antd';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import {Editor as TinyMceEditor} from '@tinymce/tinymce-react';
|
|
3
4
|
import {UrlUtils} from '../../utils';
|
|
@@ -6,8 +7,8 @@ import type {FieldProps} from '../types';
|
|
|
6
7
|
export interface FieldEditorProps extends FieldProps<string> {
|
|
7
8
|
/** 编辑器高度,默认 300 */
|
|
8
9
|
height?: number;
|
|
9
|
-
/**
|
|
10
|
-
|
|
10
|
+
/** 是否公开免登录访问,默认 true(富文本图片需公开访问) */
|
|
11
|
+
isPublic?: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -15,18 +16,42 @@ export interface FieldEditorProps extends FieldProps<string> {
|
|
|
15
16
|
*
|
|
16
17
|
* 图片上传相关配置 https://www.tiny.cloud/docs/tinymce/7/image/
|
|
17
18
|
*/
|
|
18
|
-
export class FieldEditor extends React.Component<FieldEditorProps> {
|
|
19
|
+
export class FieldEditor extends React.Component<FieldEditorProps, {loading: boolean}> {
|
|
20
|
+
state = {loading: false};
|
|
21
|
+
private timer: number | undefined;
|
|
22
|
+
|
|
23
|
+
componentDidMount() {
|
|
24
|
+
this.timer = window.setTimeout(() => {
|
|
25
|
+
this.setState({loading: true});
|
|
26
|
+
}, 200);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
componentWillUnmount() {
|
|
30
|
+
if (this.timer != null) {
|
|
31
|
+
window.clearTimeout(this.timer);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
19
35
|
render() {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
36
|
+
const {loading} = this.state;
|
|
37
|
+
const isPublic = this.props.isPublic ?? true;
|
|
38
|
+
const uploadUrl = UrlUtils.contextPath('/admin/sysFile/upload') + '?isPublic=' + isPublic;
|
|
22
39
|
const jsUrl = UrlUtils.contextPath('/admin/tinymce/tinymce.min.js');
|
|
23
40
|
const {value, onChange, height} = this.props;
|
|
41
|
+
const editorHeight = height || 300;
|
|
24
42
|
|
|
25
43
|
return (
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
<div style={{position: 'relative', minHeight: loading ? editorHeight + 44 : undefined}}>
|
|
45
|
+
<TinyMceEditor
|
|
46
|
+
value={value}
|
|
47
|
+
tinymceScriptSrc={jsUrl}
|
|
48
|
+
onInit={() => {
|
|
49
|
+
if (this.timer != null) {
|
|
50
|
+
window.clearTimeout(this.timer);
|
|
51
|
+
}
|
|
52
|
+
this.setState({loading: false});
|
|
53
|
+
}}
|
|
54
|
+
init={{
|
|
30
55
|
min_height: 300,
|
|
31
56
|
language: 'zh_CN',
|
|
32
57
|
height: height,
|
|
@@ -54,7 +79,28 @@ export class FieldEditor extends React.Component<FieldEditorProps> {
|
|
|
54
79
|
onChange(content);
|
|
55
80
|
}
|
|
56
81
|
}}
|
|
57
|
-
|
|
82
|
+
/>
|
|
83
|
+
{loading && (
|
|
84
|
+
<div style={{
|
|
85
|
+
position: 'absolute',
|
|
86
|
+
top: 0,
|
|
87
|
+
left: 0,
|
|
88
|
+
right: 0,
|
|
89
|
+
bottom: 0,
|
|
90
|
+
minHeight: editorHeight + 44,
|
|
91
|
+
display: 'flex',
|
|
92
|
+
flexDirection: 'column',
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
justifyContent: 'center',
|
|
95
|
+
gap: 8,
|
|
96
|
+
background: '#fff',
|
|
97
|
+
zIndex: 1,
|
|
98
|
+
}}>
|
|
99
|
+
<Spin/>
|
|
100
|
+
<span style={{color: '#999'}}>编辑器加载中...</span>
|
|
101
|
+
</div>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
58
104
|
);
|
|
59
105
|
}
|
|
60
106
|
}
|
|
@@ -16,8 +16,8 @@ export interface FieldUploadFileProps extends FieldProps<string> {
|
|
|
16
16
|
listType?: UploadProps['listType'];
|
|
17
17
|
/** 接受的文件类型,如 image/* */
|
|
18
18
|
accept?: string;
|
|
19
|
-
/**
|
|
20
|
-
|
|
19
|
+
/** 是否公开免登录访问,默认 true(private 需登录) */
|
|
20
|
+
isPublic?: boolean;
|
|
21
21
|
/** 文件列表变化回调(新增文件上传成功后才触发) */
|
|
22
22
|
onFileChange?: (fileList: SysUploadFile[]) => void;
|
|
23
23
|
}
|
|
@@ -28,7 +28,7 @@ interface FieldUploadFileState {
|
|
|
28
28
|
/** 逗号分隔的文件 objectName */
|
|
29
29
|
value: string | null;
|
|
30
30
|
accept?: string;
|
|
31
|
-
|
|
31
|
+
isPublic?: boolean;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -39,7 +39,7 @@ export class FieldUploadFile extends React.Component<FieldUploadFileProps, Field
|
|
|
39
39
|
state: FieldUploadFileState & { errorTitle?: string; errorContent?: string; previewObjectName?: string } = {
|
|
40
40
|
// 传入的参数
|
|
41
41
|
maxCount: 1,
|
|
42
|
-
|
|
42
|
+
isPublic: true,
|
|
43
43
|
|
|
44
44
|
// 内部参数
|
|
45
45
|
fileList: [],
|
|
@@ -55,7 +55,7 @@ export class FieldUploadFile extends React.Component<FieldUploadFileProps, Field
|
|
|
55
55
|
componentDidUpdate(prevProps: FieldUploadFileProps) {
|
|
56
56
|
const next: Partial<FieldUploadFileState> = {};
|
|
57
57
|
if (this.props.maxCount !== prevProps.maxCount) next.maxCount = this.props.maxCount;
|
|
58
|
-
if (this.props.
|
|
58
|
+
if (this.props.isPublic !== prevProps.isPublic) next.isPublic = this.props.isPublic;
|
|
59
59
|
|
|
60
60
|
const prevValue = prevProps.value ?? null;
|
|
61
61
|
const curValue = this.props.value ?? null;
|
|
@@ -150,7 +150,7 @@ export class FieldUploadFile extends React.Component<FieldUploadFileProps, Field
|
|
|
150
150
|
|
|
151
151
|
return <Upload
|
|
152
152
|
action={UrlUtils.contextPath('/admin/sysFile/upload')}
|
|
153
|
-
data={{
|
|
153
|
+
data={{isPublic: this.state.isPublic}}
|
|
154
154
|
listType={this.props.listType || 'picture-card'}
|
|
155
155
|
fileList={fileList}
|
|
156
156
|
onChange={this.handleChange}
|