Skip to content

Commit 591b6b5

Browse files
committed
optimize first poster display
1 parent 5e610b1 commit 591b6b5

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/js/player.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class APlayer {
6262
this.template = new Template({
6363
container: this.container,
6464
options: this.options,
65+
randomOrder: this.randomOrder,
6566
});
6667

6768
if (this.template.info.offsetWidth < 200) {

src/js/template.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,23 @@ class Template {
55
constructor (options) {
66
this.container = options.container;
77
this.options = options.options;
8+
this.randomOrder = this.randomOrder;
89
this.init();
910
}
1011

1112
init () {
13+
let pic;
14+
if (this.options.order === 'random') {
15+
pic = this.options.music[this.randomOrder[0]].pic;
16+
}
17+
else {
18+
pic = this.options.music[0].pic;
19+
}
20+
1221
this.container.innerHTML = tplPlayer({
1322
options: this.options,
1423
icons: Icons,
24+
pic: pic,
1525
});
1626

1727
this.lrc = this.container.querySelector('.aplayer-lrc-contents');

src/template/player.art

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="aplayer-pic">
1+
<div class="aplayer-pic"{{ if pic }} style="background-image: url("{{ pic }}");"{{ /if }}>
22
<div class="aplayer-button aplayer-play">{{@ icons.play }}</div>
33
</div>
44
<div class="aplayer-info">

0 commit comments

Comments
 (0)