three-trees-ui 1.1.0 → 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/LICENSE +21 -21
- package/lib/three-trees-ui.common.js +297 -178
- package/lib/three-trees-ui.css +1 -1
- package/lib/three-trees-ui.umd.js +297 -178
- package/lib/three-trees-ui.umd.min.js +1 -1
- package/package.json +3 -2
- package/packages/File/src/main.vue +120 -12
- package/packages/Preview/src/FrameViewer.vue +5 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-trees-ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"publicPath": "/ui",
|
|
5
5
|
"author": "hotent",
|
|
6
6
|
"private": false,
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"element-resize-detector": "^1.2.3",
|
|
36
|
+
"v-viewer": "1.6.4",
|
|
36
37
|
"vee-validate": "2.1.7"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
@@ -62,9 +63,9 @@
|
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@babel/core": "^7.19.0",
|
|
65
|
-
"@babel/runtime-corejs3": "^7.19.0",
|
|
66
66
|
"@babel/plugin-transform-runtime": "^7.18.10",
|
|
67
67
|
"@babel/preset-env": "^7.19.0",
|
|
68
|
+
"@babel/runtime-corejs3": "^7.19.0",
|
|
68
69
|
"@vue/cli-plugin-babel": "^3.8.0",
|
|
69
70
|
"@vue/cli-plugin-eslint": "^3.8.0",
|
|
70
71
|
"@vue/cli-plugin-unit-jest": "^4.0.5",
|
|
@@ -96,9 +96,29 @@
|
|
|
96
96
|
@remove="removeFile"
|
|
97
97
|
@sort="handleSort"
|
|
98
98
|
/>
|
|
99
|
+
<!-- 图片预览组件 -->
|
|
100
|
+
<el-image
|
|
101
|
+
v-if="!isMobile"
|
|
102
|
+
v-show="false"
|
|
103
|
+
ref="previewImage"
|
|
104
|
+
:preview-src-list="[imgPreviewUrl]"
|
|
105
|
+
></el-image>
|
|
106
|
+
<!-- 移动端图片 -->
|
|
107
|
+
<viewer
|
|
108
|
+
v-if="isMobile"
|
|
109
|
+
ref="viewerRef"
|
|
110
|
+
class="images"
|
|
111
|
+
:options="viewerOptions"
|
|
112
|
+
:images="imgList"
|
|
113
|
+
@inited="inited"
|
|
114
|
+
>
|
|
115
|
+
<img v-for="src in imgList" v-show="false" :key="src" :src="src" />
|
|
116
|
+
</viewer>
|
|
99
117
|
</div>
|
|
100
118
|
</template>
|
|
101
119
|
<script>
|
|
120
|
+
import { component as viewer } from 'v-viewer'
|
|
121
|
+
import 'viewerjs/dist/viewer.css'
|
|
102
122
|
import utils from '@/utils.js'
|
|
103
123
|
import permission from '@/mixins/permission.js'
|
|
104
124
|
import inputName from '@/mixins/inputName.js'
|
|
@@ -115,13 +135,20 @@
|
|
|
115
135
|
|
|
116
136
|
export default {
|
|
117
137
|
name: 'HtFile',
|
|
118
|
-
components: {
|
|
138
|
+
components: {
|
|
139
|
+
HtFieldTail,
|
|
140
|
+
FileUpload,
|
|
141
|
+
FileTable,
|
|
142
|
+
FileList,
|
|
143
|
+
FileCard,
|
|
144
|
+
viewer,
|
|
145
|
+
},
|
|
119
146
|
mixins: [Locale, permission, inputName, form, mobileMode],
|
|
120
147
|
props: {
|
|
121
148
|
type: {
|
|
122
149
|
type: String,
|
|
123
150
|
default: 'table',
|
|
124
|
-
validator: function
|
|
151
|
+
validator: function(value) {
|
|
125
152
|
return ['table', 'list', 'card'].indexOf(value) !== -1
|
|
126
153
|
},
|
|
127
154
|
},
|
|
@@ -223,6 +250,27 @@
|
|
|
223
250
|
},
|
|
224
251
|
data() {
|
|
225
252
|
return {
|
|
253
|
+
$viewer: null, // viewer组件实例对象
|
|
254
|
+
viewerOptions: {
|
|
255
|
+
backdrop: true, // 是否启用播放模态背景[布尔值/字符串:默认true](不启用时,点击空白处不会退出播放,仅点击右上角关闭按钮才会退出播放)
|
|
256
|
+
inline: false, // 启用inline模式[布尔值:默认false]
|
|
257
|
+
button: true, // 显示右上角关闭按钮[布尔值:默认true]
|
|
258
|
+
navbar: false, // 显示缩略图导航[布尔值/数字:默认true]
|
|
259
|
+
title: false, // 显示当前图片的标题(显示alt属性或从URL解析出的图片名称)[布尔值/数字/方法/数组:默认true]
|
|
260
|
+
toolbar: true, // 显示工具栏、自定义工具栏[布尔值/数字/对象:默认true]
|
|
261
|
+
tooltip: true, // 显示缩放百分比[布尔值:默认true]
|
|
262
|
+
movable: true, // 图片是否可移动[布尔值:默认true]
|
|
263
|
+
zoomable: true, // 图片是否可缩放[布尔值:默认true]
|
|
264
|
+
rotatable: true, // 图片是否可旋转[布尔值:默认true]
|
|
265
|
+
scalable: true, // 图片是否可翻转[布尔值:默认true]
|
|
266
|
+
transition: true, // 使用CSS3过渡[布尔值:默认true]
|
|
267
|
+
fullscreen: true, // 播放时是否全屏[布尔值/全屏配置:默认true]
|
|
268
|
+
keyboard: true, // 是否支持键盘[布尔值:默认true]
|
|
269
|
+
url: 'src', // 播放时图片地址 URL 来源。[字符串/方法:默认src](如果是字符串,则应该是每个图像元素的属性之一。 如果是方法,则应该返回一个有效的图像URL)
|
|
270
|
+
},
|
|
271
|
+
index: null,
|
|
272
|
+
imgList: [],
|
|
273
|
+
imgPreviewUrl: '',
|
|
226
274
|
writeable: true,
|
|
227
275
|
temp: null,
|
|
228
276
|
refreshFileUploadDebounce: _.debounce(this.refreshFileUpload, 200),
|
|
@@ -230,7 +278,7 @@
|
|
|
230
278
|
}
|
|
231
279
|
},
|
|
232
280
|
computed: {
|
|
233
|
-
typeVal: function
|
|
281
|
+
typeVal: function() {
|
|
234
282
|
return this.isSimple || this.simplicity ? 'list' : this.type
|
|
235
283
|
},
|
|
236
284
|
inputsContainerWidth() {
|
|
@@ -238,7 +286,7 @@
|
|
|
238
286
|
? { width: 'auto' }
|
|
239
287
|
: {}
|
|
240
288
|
},
|
|
241
|
-
actionUrlVal: function
|
|
289
|
+
actionUrlVal: function() {
|
|
242
290
|
return this.actionUrl
|
|
243
291
|
? this.actionUrl
|
|
244
292
|
: this.$requestConfig.uploadUrl
|
|
@@ -262,14 +310,14 @@
|
|
|
262
310
|
}
|
|
263
311
|
return baseUrl
|
|
264
312
|
},
|
|
265
|
-
headerVal: function
|
|
313
|
+
headerVal: function() {
|
|
266
314
|
return this.header
|
|
267
315
|
? this.header
|
|
268
316
|
: this.$requestConfig.header
|
|
269
317
|
? this.$requestConfig.header()
|
|
270
318
|
: null
|
|
271
319
|
},
|
|
272
|
-
acceptType: function
|
|
320
|
+
acceptType: function() {
|
|
273
321
|
if (this.accept) {
|
|
274
322
|
const ary = []
|
|
275
323
|
this.accept.split(',').forEach((m) => {
|
|
@@ -283,10 +331,10 @@
|
|
|
283
331
|
}
|
|
284
332
|
return null
|
|
285
333
|
},
|
|
286
|
-
previewableVal: function
|
|
334
|
+
previewableVal: function() {
|
|
287
335
|
return (this.inputWriteable && this.previewable) || this.allowPreview
|
|
288
336
|
},
|
|
289
|
-
downloadableVal: function
|
|
337
|
+
downloadableVal: function() {
|
|
290
338
|
return (this.inputWriteable && this.downloadable) || this.allowDownload
|
|
291
339
|
},
|
|
292
340
|
},
|
|
@@ -311,7 +359,14 @@
|
|
|
311
359
|
this.inputVal = JSON.parse(this.value)
|
|
312
360
|
}
|
|
313
361
|
},
|
|
362
|
+
mounted() {},
|
|
314
363
|
methods: {
|
|
364
|
+
/**
|
|
365
|
+
* 组件初始化完成,获取组件实例对象
|
|
366
|
+
*/
|
|
367
|
+
inited(viewer) {
|
|
368
|
+
this.$viewer = viewer
|
|
369
|
+
},
|
|
315
370
|
// 上传前做校验
|
|
316
371
|
beforeUploadMethod(file) {
|
|
317
372
|
if (
|
|
@@ -466,6 +521,49 @@
|
|
|
466
521
|
})
|
|
467
522
|
}
|
|
468
523
|
},
|
|
524
|
+
customPreviewImg(fileId) {
|
|
525
|
+
this.$requestConfig
|
|
526
|
+
.request({
|
|
527
|
+
url: `${window.context.portal}/system/file/v1/preview?fileId=${fileId}`,
|
|
528
|
+
method: 'get',
|
|
529
|
+
responseType: 'blob',
|
|
530
|
+
})
|
|
531
|
+
.then((response) => {
|
|
532
|
+
if (response.size > 0) {
|
|
533
|
+
var blob = response
|
|
534
|
+
var reader = new FileReader()
|
|
535
|
+
let that = this
|
|
536
|
+
reader.readAsDataURL(blob)
|
|
537
|
+
reader.onload = function(e) {
|
|
538
|
+
that.imgPreviewUrl = e.target.result
|
|
539
|
+
if (that.isMobile) {
|
|
540
|
+
that.imgList = [that.imgPreviewUrl]
|
|
541
|
+
// 2、通过ref获取到对应节点,再通过$viewer属性获取对应的元素信息对象,继而调用方法显示
|
|
542
|
+
that.$refs.viewerRef.$viewer.show()
|
|
543
|
+
return
|
|
544
|
+
}
|
|
545
|
+
that.$refs.previewImage.clickHandler()
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
})
|
|
549
|
+
},
|
|
550
|
+
isImgFile(fileName) {
|
|
551
|
+
let fileType = fileName.split('.')[fileName.split('.').length - 1]
|
|
552
|
+
return [
|
|
553
|
+
'gif',
|
|
554
|
+
'jpg',
|
|
555
|
+
'jpeg',
|
|
556
|
+
'png',
|
|
557
|
+
'webp',
|
|
558
|
+
'svg',
|
|
559
|
+
'GIF',
|
|
560
|
+
'JPG',
|
|
561
|
+
'JPEG',
|
|
562
|
+
'PNG',
|
|
563
|
+
'WEBP',
|
|
564
|
+
'SVG',
|
|
565
|
+
].includes(fileType)
|
|
566
|
+
},
|
|
469
567
|
preview(file) {
|
|
470
568
|
if (file.status !== 'success') {
|
|
471
569
|
this.$message.warning(this.t('ht.file.forbiddenPreview'))
|
|
@@ -475,11 +573,21 @@
|
|
|
475
573
|
// 当前组件未添加preview事件监听 并且 设置了全局预览方法
|
|
476
574
|
if (!this._events.preview && this.$preview) {
|
|
477
575
|
if (this.isMobile) {
|
|
478
|
-
this
|
|
576
|
+
if (this.isImgFile(file.response.fileName)) {
|
|
577
|
+
this.customPreviewImg(file.response.fileId)
|
|
578
|
+
} else {
|
|
579
|
+
this.$preview(file)
|
|
580
|
+
}
|
|
479
581
|
} else {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
582
|
+
if (this.isImgFile(file.response.fileName)) {
|
|
583
|
+
this.customPreviewImg(file.response.fileId)
|
|
584
|
+
} else {
|
|
585
|
+
let token = this.$requestConfig
|
|
586
|
+
.getToken()
|
|
587
|
+
.replace('Bearer ', '')
|
|
588
|
+
let url = `${window.context.front}/previewFile/${file.response.fileId}/${file.response.fileName}?token=${token}`
|
|
589
|
+
window.open(url, '_blank')
|
|
590
|
+
}
|
|
483
591
|
}
|
|
484
592
|
} else {
|
|
485
593
|
this.$emit('preview', file, this.inputVal)
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
v-else-if="contentType.indexOf('image') > -1"
|
|
7
7
|
class="frame-viewer__img"
|
|
8
8
|
>
|
|
9
|
-
<
|
|
10
|
-
style="width: 100px; height: 100px"
|
|
9
|
+
<img
|
|
11
10
|
:src="dataSrc"
|
|
12
|
-
:
|
|
13
|
-
|
|
11
|
+
:style="{ height: utils.isMobile() ? 'auto' : '100%' }"
|
|
12
|
+
/>
|
|
14
13
|
</div>
|
|
15
14
|
<iframe
|
|
16
15
|
v-else
|
|
@@ -125,12 +124,12 @@
|
|
|
125
124
|
return
|
|
126
125
|
}
|
|
127
126
|
if (iframe.attachEvent) {
|
|
128
|
-
iframe.attachEvent('onload', function
|
|
127
|
+
iframe.attachEvent('onload', function() {
|
|
129
128
|
that.setFrameBody(this.contentWindow.document)
|
|
130
129
|
that.watermarkRender()
|
|
131
130
|
})
|
|
132
131
|
} else {
|
|
133
|
-
iframe.onload = function
|
|
132
|
+
iframe.onload = function() {
|
|
134
133
|
that.setFrameBody(this.contentWindow.document)
|
|
135
134
|
that.watermarkRender()
|
|
136
135
|
}
|