Skip to content

Commit 6d5fff7

Browse files
committed
add disableVersionBadge api
1 parent edf7a42 commit 6d5fff7

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

docs/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ All you need to do is adding [color-thief](https://github.com/lokesh/color-thief
140140
Since `v1.3.0`, Vue-APlayer supports `*.m3u8` media as an optional functionality. Simply install [hls.js](https://github.com/video-dev/hls.js) into your project, and Vue-APlayer handles the rest.
141141

142142

143+
### `disableVersionBadge`
144+
145+
By default Vue-APlayer prints a version badge in console. If you want to silent it, you can set `disableVersionBadge` to `true` before you first create a Vue-APlayer instance.
146+
147+
```js
148+
import VueAPlayer from 'vue-aplayer'
149+
VueAPlayer.disableVersionBadge = true
150+
```
151+
143152

144153
### Slots
145154

docs/README.zh-CN.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ new Vue({
141141
`v1.3.0` 开始, Vue-APlayer 可选支持 `*.m3u8` 音频. 你需要做的就是在项目中安装 [hls.js](https://github.com/video-dev/hls.js) 包即可.
142142

143143

144+
### `disableVersionBadge`
145+
146+
Vue-APlayer 默认会在控制台打印出当前的版本标识,如果你想要禁用它,可以将 `disableVersionBadge` 设为 `true`
147+
148+
```js
149+
import VueAPlayer from 'vue-aplayer'
150+
VueAPlayer.disableVersionBadge = true
151+
```
152+
144153

145154
### Slots
146155

src/demo/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
* Created by Doma on 2016/11/22.
33
*/
44
import Vue from 'vue'
5+
import VueAPlayer from '../vue-aplayer.vue'
56
Vue.config.devtools = true
7+
// VueAPlayer.disableVersionBadge = true
68

79
import App from './App.vue'
810
new Vue({

src/vue-aplayer.vue

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<span class="aplayer-author">{{ currentMusic.artist || currentMusic.author || 'Unknown' }}</span>
2727
</div>
2828
<slot name="display" :current-music="currentMusic" :play-stat="playStat">
29-
<lyrics :current-music="currentMusic" :play-stat="playStat" v-if="shouldShowLrc"/>
29+
<lyrics :current-music="currentMusic" :play-stat="playStat" v-if="shouldShowLrc" />
3030
</slot>
3131
<controls
3232
:shuffle="shouldShuffle"
@@ -64,11 +64,9 @@
6464
import MusicList from './components/aplayer-list.vue'
6565
import Controls from './components/aplayer-controller.vue'
6666
import Lyrics from './components/aplayer-lrc.vue'
67-
import {deprecatedProp, versionCompare, warn} from './utils'
68-
69-
// version badge
70-
console.log(`\n\n %c Vue-APlayer ${VERSION} %c vue-aplayer.js.org \n`, 'color: #fff; background:#41b883; padding:5px 0;', 'color: #fff; background: #35495e; padding:5px 0;')
67+
import { deprecatedProp, versionCompare, warn } from './utils'
7168
69+
let versionBadgePrinted = false
7270
const canUseSync = versionCompare(Vue.version, '2.3.0') >= 0
7371
7472
/**
@@ -90,8 +88,9 @@
9088
REPEAT_ALL: 'repeat-all',
9189
};
9290
93-
export default {
91+
const VueAPlayer = {
9492
name: 'APlayer',
93+
disableVersionBadge: false,
9594
components: {
9695
Thumbnail,
9796
Controls,
@@ -474,7 +473,7 @@
474473
this.floatOriginX = this.floatOffsetLeft
475474
this.floatOriginY = this.floatOffsetTop
476475
},
477-
onDragAround ({offsetLeft, offsetTop}) {
476+
onDragAround ({ offsetLeft, offsetTop }) {
478477
this.floatOffsetLeft = this.floatOriginX + offsetLeft
479478
this.floatOffsetTop = this.floatOriginY + offsetTop
480479
},
@@ -846,6 +845,13 @@
846845
this.internalRepeat = val
847846
},
848847
},
848+
beforeCreate () {
849+
if (!VueAPlayer.disableVersionBadge && !versionBadgePrinted) {
850+
// version badge
851+
console.log(`\n\n %c Vue-APlayer ${VERSION} %c vue-aplayer.js.org \n`, 'color: #fff; background:#41b883; padding:5px 0;', 'color: #fff; background: #35495e; padding:5px 0;')
852+
versionBadgePrinted = true
853+
}
854+
},
849855
created () {
850856
this.shuffledList = this.getShuffledList()
851857
},
@@ -864,6 +870,7 @@
864870
},
865871
}
866872
873+
export default VueAPlayer
867874
868875
</script>
869876

0 commit comments

Comments
 (0)