@cqsjjb/jjb-react-admin-component 3.0.25 → 3.0.26

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.
@@ -1,7 +1,7 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
  import React from 'react';
3
3
  import { tools } from '@cqsjjb/jjb-common-lib';
4
- import { FilePdfOutlined, LinkOutlined } from '@ant-design/icons';
4
+ import { FilePdfOutlined, LinkOutlined, PlayCircleOutlined } from '@ant-design/icons';
5
5
  import { Modal, Descriptions, Empty, Image, Tooltip, Tag, Spin, Table } from 'antd';
6
6
  const formilyItemMargin = new Map([['small', 8], ['middle', 12], ['default', 16]]);
7
7
  export default function FormilyDescriptions(props) {
@@ -57,6 +57,7 @@ export default function FormilyDescriptions(props) {
57
57
  }));
58
58
  }
59
59
  function ItemRender(props) {
60
+ const [type, setType] = React.useState(undefined);
60
61
  const [open, setOpen] = React.useState(false);
61
62
  const [previewUrl, setPreviewUrl] = React.useState('');
62
63
  const {
@@ -100,10 +101,23 @@ function ItemRender(props) {
100
101
  alignItems: 'center'
101
102
  },
102
103
  onClick: () => {
104
+ setType('pdf');
103
105
  setOpen(true);
104
106
  setPreviewUrl(next.url);
105
107
  }
106
- }, /*#__PURE__*/React.createElement(FilePdfOutlined, null), "\u70B9\u51FB\u67E5\u770B") : /*#__PURE__*/React.createElement("a", {
108
+ }, /*#__PURE__*/React.createElement(FilePdfOutlined, null), "\u70B9\u51FB\u67E5\u770B") : /\.(mp4|ogg|mkv|webm)$/.test(next.url) ? /*#__PURE__*/React.createElement("a", {
109
+ key: nextIndex,
110
+ style: {
111
+ gap: 4,
112
+ display: 'flex',
113
+ alignItems: 'center'
114
+ },
115
+ onClick: () => {
116
+ setType('video');
117
+ setOpen(true);
118
+ setPreviewUrl(next.url);
119
+ }
120
+ }, /*#__PURE__*/React.createElement(PlayCircleOutlined, null), "\u70B9\u51FB\u67E5\u770B") : /*#__PURE__*/React.createElement("a", {
107
121
  key: nextIndex,
108
122
  href: next.url,
109
123
  style: {
@@ -123,15 +137,20 @@ function ItemRender(props) {
123
137
  renderItemText: props.renderItemText
124
138
  }), /*#__PURE__*/React.createElement(Modal, {
125
139
  destroyOnClose: true,
126
- title: "\u67E5\u770BPDF",
140
+ title: "\u67E5\u770B\u6587\u4EF6",
127
141
  open: open,
128
142
  width: 1100,
129
143
  footer: false,
130
144
  onCancel: () => setOpen(false)
131
- }, /*#__PURE__*/React.createElement("embed", {
145
+ }, type === 'pdf' && /*#__PURE__*/React.createElement("embed", {
132
146
  src: previewUrl,
133
147
  width: "100%",
134
148
  height: 600
149
+ }), type === 'video' && /*#__PURE__*/React.createElement("video", {
150
+ controls: true,
151
+ src: previewUrl,
152
+ width: "100%",
153
+ height: "350"
135
154
  })));
136
155
  }
137
156
  function generateValue(data, prefix = []) {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
3
  import { tools } from '@cqsjjb/jjb-common-lib';
4
- import { FilePdfOutlined, LinkOutlined } from '@ant-design/icons';
4
+ import { FilePdfOutlined, LinkOutlined, PlayCircleOutlined } from '@ant-design/icons';
5
5
  import { Modal, Descriptions, Empty, Image, Tooltip, Tag, Spin, Table } from 'antd';
6
6
 
7
7
  const formilyItemMargin = new Map([
@@ -74,6 +74,7 @@ export default function FormilyDescriptions(props) {
74
74
  }
75
75
 
76
76
  function ItemRender(props) {
77
+ const [ type, setType ] = React.useState(undefined);
77
78
  const [ open, setOpen ] = React.useState(false);
78
79
  const [ previewUrl, setPreviewUrl ] = React.useState('');
79
80
 
@@ -135,6 +136,7 @@ function ItemRender(props) {
135
136
  alignItems: 'center'
136
137
  }}
137
138
  onClick={() => {
139
+ setType('pdf');
138
140
  setOpen(true);
139
141
  setPreviewUrl(next.url);
140
142
  }}
@@ -143,21 +145,40 @@ function ItemRender(props) {
143
145
  点击查看
144
146
  </a>
145
147
  )
146
- : (
147
- <a
148
- key={nextIndex}
149
- href={next.url}
150
- style={{
151
- gap: 4,
152
- display: 'flex',
153
- alignItems: 'center'
154
- }}
155
- target="_blank"
156
- >
157
- <LinkOutlined />
158
- 点击下载
159
- </a>
160
- )}
148
+ : /\.(mp4|ogg|mkv|webm)$/.test(next.url)
149
+ ? (
150
+ <a
151
+ key={nextIndex}
152
+ style={{
153
+ gap: 4,
154
+ display: 'flex',
155
+ alignItems: 'center'
156
+ }}
157
+ onClick={() => {
158
+ setType('video');
159
+ setOpen(true);
160
+ setPreviewUrl(next.url);
161
+ }}
162
+ >
163
+ <PlayCircleOutlined />
164
+ 点击查看
165
+ </a>
166
+ )
167
+ : (
168
+ <a
169
+ key={nextIndex}
170
+ href={next.url}
171
+ style={{
172
+ gap: 4,
173
+ display: 'flex',
174
+ alignItems: 'center'
175
+ }}
176
+ target="_blank"
177
+ >
178
+ <LinkOutlined />
179
+ 点击下载
180
+ </a>
181
+ )}
161
182
  </Tooltip>
162
183
  );
163
184
  }
@@ -177,17 +198,27 @@ function ItemRender(props) {
177
198
  )}
178
199
  <Modal
179
200
  destroyOnClose
180
- title="查看PDF"
201
+ title="查看文件"
181
202
  open={open}
182
203
  width={1100}
183
204
  footer={false}
184
205
  onCancel={() => setOpen(false)}
185
206
  >
186
- <embed
187
- src={previewUrl}
188
- width="100%"
189
- height={600}
190
- />
207
+ {type === 'pdf' && (
208
+ <embed
209
+ src={previewUrl}
210
+ width="100%"
211
+ height={600}
212
+ />
213
+ )}
214
+ {type === 'video' && (
215
+ <video
216
+ controls
217
+ src={previewUrl}
218
+ width="100%"
219
+ height="350"
220
+ />
221
+ )}
191
222
  </Modal>
192
223
  </React.Fragment>
193
224
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cqsjjb/jjb-react-admin-component",
3
- "version": "3.0.25",
3
+ "version": "3.0.26",
4
4
  "description": "jjb-react-admin-组件库@new",
5
5
  "main": "index.js",
6
6
  "author": "jjb-front-team",