Skip to content

Commit

Permalink
dailylog
Browse files Browse the repository at this point in the history
  • Loading branch information
szuprefix committed Feb 10, 2020
1 parent d6e9e32 commit e78fd04
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 3 deletions.
56 changes: 53 additions & 3 deletions src/components/media/qcloud/Video.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<video class="vod-player player-size" :style="{width, height}" preload="auto" playsinline webkit-playsinline>
<video class="vod-player player-size" :style="{width, height}"
preload="auto" playsinline webkit-playsinline>
</video>
</template>
<script>
Expand All @@ -9,7 +10,8 @@
fileID: String,
appID: String,
width: String,
height: String
height: String,
fullScreen: false
},
data () {
return {
Expand All @@ -32,6 +34,20 @@
},
createPlayer () {
this.player = window.TCPlayer(this.$el, this.playerOptions)
let es = ['ended', 'pause', 'timeupdate']
es.forEach(e => {
this.player.on(e, (a) => {
try {
this.$emit(e, a)
} catch (err) {
}
})
})
// if (this.fullScreen) {
// this.$nextTick(() => {
// this.player.requestFullscreen()
// })
// }
},
init () {
if (!window.TCPlayer) {
Expand All @@ -53,13 +69,21 @@
ContinuePlay: { // 开启续播功能
auto: true
}
}
},
...this.$attrs
}
}
},
watch: {
fileID (v) {
this.player.loadVideoByID(this.playerOptions)
},
fullScreen (v) {
if (v) {
this.player.requestFullscreen()
} else {
this.player.exitFullscreen()
}
}
}
}
Expand Down Expand Up @@ -88,4 +112,30 @@
width: 50%;
}
}
video{
width: 100%;
}
video::-webkit-media-controls-fullscreen-button {
display: none;
}
video::-webkit-media-controls-play-button {
background: red;
}
video::-webkit-media-controls-play-button {display: none}
video::-webkit-media-controls-timeline {display: none}
video::-webkit-media-controls-current-time-display{}
video::-webkit-media-controls-time-remaining-display {}
video::-webkit-media-controls-time-remaining-display {}
video::-webkit-media-controls-mute-button {}
video::-webkit-media-controls-toggle-closed-captions-button {}
video::-webkit-media-controls-volume-slider {}
video::-internal-media-controls-download-button {
display:none;
}
video::-webkit-media-controls-enclosure {
overflow:hidden;
}
video::-webkit-media-controls-panel {
width: calc(100% + 30px);
}
</style>
2 changes: 2 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import Vue from 'vue'
import Vuex from 'vuex'
import apps from '@/configs/apps'
import {logout} from '../utils/auth'
import dailyLog from 'vue-django/src/utils/dailylog'
Vue.use(Vuex)
const state = {
bus: new Vue(),
user: {},
dailyLog,
apps,
system_name: '',
logo: require('../assets/logo.png')
Expand Down
36 changes: 36 additions & 0 deletions src/utils/dailylog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Created by denishuang on 2020/2/8.
*/
import Vue from 'vue'
import {throttle} from 'lodash'

let INTERVAL = 5
export default new Vue({
data: {
m: {},
saveTime: undefined,
delayMethods: {}
},
methods: {
log (app, model, id, metics, subMetics, v, interval) {
let k = `${app}.${model}.${id}.${metics}.${subMetics}`
let d = new Date()
let dk = d.toISOString().substr(0, 10)
let dm = this.m[dk] || {}
let it = interval || INTERVAL
dm[k] = v
this.m[dk] = dm
this.delayMethods[`save${it}s`]()
},
save () {
return this.$http.post('/dailylog/dailylog/write/', this.m)
}
},
created () {
for (var i = 1; i <= 3; i++) {
let p = Math.pow(2, i - 1) * INTERVAL
this.delayMethods[`save${p}s`] = throttle(this.save, p * 1000)
}
// console.log(this.delayMethods)
}
})
27 changes: 27 additions & 0 deletions src/utils/duration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Created by denishuang on 2020/2/8.
*/

export default function () {
return {
lastTime: undefined,
ms: 0,
run () {
if (this.lastTime === undefined) {
this.lastTime = new Date()
}
let dt = new Date()
this.ms += dt - this.lastTime
this.lastTime = dt
},
pause () {
this.lastTime = undefined
},
clear () {
this.ms = 0
},
getSeconds () {
return Math.floor(this.ms / 1000)
}
}
}

0 comments on commit e78fd04

Please sign in to comment.