From 17ffe87f8158aa0ac11f43cc56e5d4efa00592e3 Mon Sep 17 00:00:00 2001
From: guqing <1484563614@qq.com>
Date: Wed, 26 Jun 2019 19:58:08 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=99=84=E5=8A=A0=E8=A7=86?=
=?UTF-8?q?=E9=A2=91=E9=A2=84=E8=A7=88=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=B9=B6?=
=?UTF-8?q?=E5=AF=B9=E4=B8=8D=E6=94=AF=E6=8C=81=E9=A2=84=E8=A7=88=E7=9A=84?=
=?UTF-8?q?=E7=BC=A9=E7=95=A5=E5=9B=BE=E5=81=9A=E4=B8=8D=E6=94=AF=E6=8C=81?=
=?UTF-8?q?=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 5 +-
src/views/attachment/AttachmentList.vue | 29 ++++++++-
.../components/AttachmentDetailDrawer.vue | 60 ++++++++++++++++---
3 files changed, 82 insertions(+), 12 deletions(-)
diff --git a/package.json b/package.json
index 1689866e7..18eb587f6 100644
--- a/package.json
+++ b/package.json
@@ -21,12 +21,13 @@
"vue": "^2.6.10",
"vue-clipboard2": "^0.3.0",
"vue-codemirror-lite": "^1.0.4",
+ "vue-count-to": "^1.0.13",
"vue-cropper": "0.4.9",
"vue-ls": "^3.2.1",
"vue-router": "^3.0.6",
+ "vue-video-player": "^5.0.2",
"vuejs-logger": "^1.5.3",
- "vuex": "^3.1.1",
- "vue-count-to": "^1.0.13"
+ "vuex": "^3.1.1"
},
"devDependencies": {
"@babel/polyfill": "^7.4.4",
diff --git a/src/views/attachment/AttachmentList.vue b/src/views/attachment/AttachmentList.vue
index 689c85acf..85aa9c2e8 100644
--- a/src/views/attachment/AttachmentList.vue
+++ b/src/views/attachment/AttachmentList.vue
@@ -99,7 +99,8 @@
@click="handleShowDetailDrawer(item)"
>
-
![]()
+
当前格式不支持预览
+
此文件不支持预览
-
![]()
+
![]()
+
+
@@ -149,18 +154,41 @@
import { mixin, mixinDevice } from '@/utils/mixin.js'
import attachmentApi from '@/api/attachment'
import photoApi from '@/api/photo'
+import 'video.js/dist/video-js.css'
+import { videoPlayer } from 'vue-video-player'
export default {
name: 'AttachmentDetailDrawer',
mixins: [mixin, mixinDevice],
+ components: {
+ videoPlayer
+ },
data() {
return {
detailLoading: true,
editable: false,
photo: {},
photoPreviewVisible: false,
- vedioPreviewVisible: false,
- nonsupportPreviewVisible: false
+ videoPreviewVisible: false,
+ nonsupportPreviewVisible: false,
+ playerOptions: {
+ // videojs options
+ muted: true,
+ language: 'zh-CN',
+ aspectRatio: '16:9',
+ fluid: true,
+ controls: true,
+ loop: false,
+ muted: false,
+ playbackRates: [0.7, 1.0, 1.5, 2.0],
+ sources: [{
+ type: "video/mp4",
+ src: "https://cdn.theguardian.tv/webM/2015/07/20/150716YesMen_synd_768k_vp8.webm"
+ }],
+ poster: "/static/images/author.jpg",
+ width: document.documentElement.clientWidth,
+ notSupportedMessage: '此视频暂无法播放,请稍后再试'
+ }
}
},
model: {
@@ -186,6 +214,11 @@ export default {
created() {
this.loadSkeleton()
},
+ computed: {
+ player() {
+ return this.$refs.videoPlayer.player
+ }
+ },
watch: {
visiable: function(newValue, oldValue) {
this.$log.debug('old value', oldValue)
@@ -197,8 +230,7 @@ export default {
attachment: function(newValue, oldValue) {
if (newValue) {
var attachment = newValue
- var mediaType = attachment.mediaType
- this.handleJudgeMediaType(mediaType)
+ this.handleJudgeMediaType(attachment)
}
}
},
@@ -262,20 +294,29 @@ export default {
onClose() {
this.$emit('close', false)
},
- handleJudgeMediaType(mediaType) {
+ handleJudgeMediaType(attachment) {
+ var mediaType = attachment.mediaType
// 判断文件类型
if(mediaType) {
var prefix = mediaType.split('/')[0]
if(prefix === 'video' || prefix==='flv') {
- this.vedioPreviewVisible = true
+ this.videoPreviewVisible = true
+ this.photoPreviewVisible = false
this.nonsupportPreviewVisible = false
+ // 设置视频地址
+ this.$set(this.playerOptions.sources, 0, {
+ type: mediaType,
+ src: attachment.path
+ })
+ console.log(this.playerOptions.sources)
} else if(prefix === 'image') {
this.photoPreviewVisible = true
+ this.videoPreviewVisible = false
this.nonsupportPreviewVisible = false
} else {
this.nonsupportPreviewVisible = true
- this.vedioPreviewVisible = false
+ this.videoPreviewVisible = false
this.photoPreviewVisible = false
}
}
@@ -288,4 +329,7 @@ export default {
.attach-detail-img img {
width: 100%;
}
+.video-player-box {
+ width: 100%;
+}