Skip to content

Commit

Permalink
✨ Add dplayer support
Browse files Browse the repository at this point in the history
1) Add dplayer support;
2) Format config.js;
3) Update post 1-4-deploy-hexo.

 #58
  • Loading branch information
Mitscherlich committed Dec 9, 2018
1 parent 37e5c98 commit d3b5f8b
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 201 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Expand Up @@ -8,6 +8,10 @@ indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
insert_final_newline = false

[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
81 changes: 81 additions & 0 deletions docs/.vuepress/components/dplayer.vue
@@ -0,0 +1,81 @@
<template>
<div class="dplayer">
<button
class="btn-show-player"
v-show="!shouldShowPlayer"
@click="shouldShowPlayer = true">
点击加载播放器
</button>
<div v-show="shouldShowPlayer" ref="container"></div>
</div>
</template>

<script>
export default {
props: {
src: null,
screenshot: false,
subtitle: null,
autoplay: false,
theme: '#b7daff',
loop: false,
hotkey: true,
preload: 'auto',
logo: '',
mutex: true,
},
data () {
return {
shouldShowPlayer: false,
}
},
mounted () {
if (!window) {
// ssr 时忽略这个组件
return
}
const DPlayer = window.DPlayer || null
if (!DPlayer) {
// 加载失败时忽略这个组件
return
}
// const url = import(this.src)
// console.log(url)
this.$nextTick(() => {
new DPlayer({
container: this.$refs.container,
autoplay: this.autoplay,
theme: this.theme,
loop: this.loop,
screenshot: this.screenshot,
hotkey: this.hotkey,
preload: this.preload,
logo: this.logo,
video: {
url: this.src,
},
subtitle: {
url: this.subtitle,
},
mutex: this.mutex,
})
})
}
}
</script>

<style scoped>
button.btn-show-player {
margin-top: .75rem;
border: 2px solid #4dba87;
background-color: #fff;
cursor: pointer;
outline: none;
border-radius: 33px;
padding: 5px 16px;
font-size: 13px;
font-weight: 700;
transition: background-color .3s ease;
color: #4dba87;
}
</style>

0 comments on commit d3b5f8b

Please sign in to comment.