Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1) Add dplayer support; 2) Format config.js; 3) Update post 1-4-deploy-hexo. #58
- Loading branch information
1 parent
37e5c98
commit d3b5f8b
Showing
5 changed files
with
218 additions
and
201 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
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,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> |
Oops, something went wrong.