-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
236 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<template> | ||
<div v-if="isActive"> | ||
<!--<x-button @click.native="changeSrc(f)" v-for="f in files" :key="f.Definition">{{f.name}}</x-button>--> | ||
</div> | ||
</template> | ||
<script> | ||
import {XButton} from 'vux' | ||
import {get} from 'lodash' | ||
import Cache from 'vue-django/src/utils/cache' | ||
export default{ | ||
props: { | ||
options: Object | ||
}, | ||
data () { | ||
return { | ||
breakPoint: 0, | ||
currentTime: 0, | ||
cache: Cache(`qcloud.vod.${this.fileId}.currentTime`) | ||
} | ||
}, | ||
components: {XButton}, | ||
mounted () { | ||
if (this.isActive) { | ||
this.init() | ||
} | ||
}, | ||
methods: { | ||
changeSrc (f) { | ||
let el = this.getEl() | ||
let ct = el.currentTime | ||
el.src = f.url | ||
el.play() | ||
this.setCurrentTime(ct) | ||
}, | ||
init () { | ||
let ct = this.cache.read() || 0 | ||
this.breakPoint = ct | ||
// this.setCurrentTime(ct) | ||
this.getEl().addEventListener('timeupdate', this.onTimeUpdate) | ||
}, | ||
getEl () { | ||
return document.querySelector('video') | ||
}, | ||
onTimeUpdate () { | ||
let ct = this.getEl().currentTime | ||
if (this.breakPoint > 0 && ct > 0) { | ||
ct = this.breakPoint | ||
this.breakPoint = 0 | ||
this.getEl().currentTime = ct | ||
} | ||
this.cache.save(ct) | ||
}, | ||
setCurrentTime (ct) { | ||
setTimeout(() => { | ||
this.getEl().currentTime = ct | ||
}, 800) | ||
} | ||
}, | ||
computed: { | ||
isWechat () { | ||
return (/MicroMessenger/i).test(window.navigator.userAgent) | ||
}, | ||
isIPhone () { | ||
return (/iphone/i).test(window.navigator.userAgent) | ||
}, | ||
fileId () { | ||
return this.options.FileId || this.options.FileId | ||
}, | ||
files () { | ||
let dm = { | ||
10: '流畅', | ||
20: '标清', | ||
30: '高清', | ||
1100: '纯音频' | ||
} | ||
return get(this.options, 'TranscodeInfo.TranscodeSet', []) | ||
.filter(a => [10, 20, 30, 1100].includes(a.Definition)) | ||
.map(a => { | ||
return {definition: a.Definition, name: dm[a.Definition], url: a.Url} | ||
}) | ||
}, | ||
isActive () { | ||
return this.isWechat && !this.isIPhone | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Created by denishuang on 2020/2/11. | ||
*/ | ||
|
||
export default function (cache) { | ||
return { | ||
cache, | ||
isWechat () { | ||
return window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) === 'micromessenger' | ||
}, | ||
cacheCurrentTime () { | ||
this.cache.save() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<list v-bind="[$attrs,$props]" v-model="data"></list> | ||
</template> | ||
<script> | ||
import List from './List.vue' | ||
import {Register} from '../../utils/app_model' | ||
export default{ | ||
props: { | ||
appModel: String, | ||
queries: {type: Object, default: {}}, | ||
}, | ||
data () { | ||
return { | ||
data: [], | ||
model: Register.get(this.appModel) | ||
} | ||
}, | ||
components: {List}, | ||
created () { | ||
this.load() | ||
}, | ||
methods: { | ||
load () { | ||
return this.model.query(this.queries).then(data => { | ||
this.data = data.results | ||
}) | ||
} | ||
}, | ||
computed: {}, | ||
watch: { | ||
queries (v) { | ||
this.load() | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<template> | ||
<popup-radio v-bind="[$attrs]" :title="title" :options="options" v-model="value_"></popup-radio> | ||
</template> | ||
<script> | ||
import {Register} from '../../utils/app_model' | ||
import {PopupRadio} from 'vux' | ||
export default{ | ||
props: { | ||
appModel: String, | ||
queries: {type: Object, default: {}}, | ||
value: [String, Number] | ||
}, | ||
data () { | ||
return { | ||
model: Register.get(this.appModel), | ||
options: [], | ||
value_: undefined | ||
} | ||
}, | ||
components: {PopupRadio}, | ||
created () { | ||
this.value_ = this.value | ||
this.load() | ||
}, | ||
methods: { | ||
load () { | ||
return this.model.query(this.queries).then(data => { | ||
this.options = data.results.map(a => { | ||
return {key: a.id, value: a[this.labelField]} | ||
}) | ||
}) | ||
} | ||
}, | ||
computed: { | ||
title () { | ||
return this.$attrs.title || this.model.verboseName | ||
}, | ||
labelField () { | ||
return this.$attrs.labelField || this.model.title_field | ||
} | ||
}, | ||
watch: { | ||
value (v) { | ||
this.value_ = v | ||
}, | ||
value_ (v) { | ||
this.$emit('input', v) | ||
}, | ||
queries (v) { | ||
this.load() | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Created by denishuang on 2020/2/11. | ||
*/ | ||
import {throttle} from 'lodash' | ||
export default function (key, interval) { | ||
function saveAtOnce (v) { | ||
localStorage.setItem(key, v) | ||
} | ||
|
||
let save = throttle(saveAtOnce, interval || 1000) | ||
|
||
function destroy () { | ||
localStorage.removeItem(key) | ||
} | ||
|
||
function read () { | ||
return localStorage.getItem(key) | ||
} | ||
|
||
return { | ||
save, | ||
read, | ||
saveAtOnce, | ||
destroy | ||
} | ||
} |