Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add time to lyric page #1676

Merged
merged 4 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/locale/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export default {
subTitleDefault: 'Show Alias for Subtitle by default',
enableReversedMode: 'Enable Reversed Mode (Experimental)',
enableCustomTitlebar: 'Enable custom title bar (Need restart)',
showLyricsTime: 'Display current time',
lyricsBackground: {
text: 'Show Lyrics Background',
off: 'Off',
Expand Down
1 change: 1 addition & 0 deletions src/locale/lang/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export default {
on: '打开',
dynamic: '动态(GPU 占用较高)',
},
showLyricsTime: '显示当前时间',
closeAppOption: {
text: '关闭主面板时...',
ask: '询问',
Expand Down
1 change: 1 addition & 0 deletions src/locale/lang/zh-TW.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export default {
subTitleDefault: '副標題使用別名',
enableReversedMode: '啟用倒序播放功能 (實驗性功能)',
enableCustomTitlebar: '啟用自訂標題列(重新啟動後生效)',
showLyricsTime: '顯示當前時間',
8790 marked this conversation as resolved.
Show resolved Hide resolved
lyricsBackground: {
text: '顯示歌詞背景',
off: '關閉',
Expand Down
42 changes: 42 additions & 0 deletions src/views/lyrics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@

<div class="left-side">
<div>
<div v-if="settings.showLyricsTime" class="date">
{{ date }}
</div>
<div class="cover">
<div class="cover-container">
<img :src="imageUrl" loading="lazy" />
Expand Down Expand Up @@ -245,6 +248,7 @@ export default {
highlightLyricIndex: -1,
minimize: true,
background: '',
date: this.formatTime(new Date()),
};
},
computed: {
Expand Down Expand Up @@ -327,13 +331,37 @@ export default {
created() {
this.getLyric();
this.getCoverColor();
this.initDate();
},
beforeDestroy: function () {
if (this.timer) {
clearInterval(this.timer);
}
},
destroyed() {
clearInterval(this.lyricsInterval);
},
methods: {
...mapMutations(['toggleLyrics']),
...mapActions(['likeATrack']),
initDate() {
var _this = this;
this.timer = setInterval(function () {
_this.date = _this.formatTime(new Date());
}, 1000);
8790 marked this conversation as resolved.
Show resolved Hide resolved
},
formatTime(value) {
let hour = value.getHours();
let minute = value.getMinutes();
let second = value.getSeconds();
return (
(hour >= 10 ? hour : '0' + hour) +
':' +
(minute >= 10 ? minute : '0' + minute) +
':' +
(second >= 10 ? second : '0' + second)
8790 marked this conversation as resolved.
Show resolved Hide resolved
);
},
playPrevTrack() {
this.player.playPrevTrack();
},
Expand Down Expand Up @@ -536,6 +564,20 @@ export default {

z-index: 1;

.date {
max-width: 54vh;
margin: 24px 0;
color: var(--color-text);
text-align: center;
font-size: 4rem;
font-weight: 600;
opacity: 0.88;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
}

.controls {
max-width: 54vh;
margin-top: 24px;
Expand Down
27 changes: 27 additions & 0 deletions src/views/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,22 @@
</select>
</div>
</div>
<div class="item">
<div class="left">
<div class="title"> {{ $t('settings.showLyricsTime') }} </div>
</div>
<div class="right">
<div class="toggle">
<input
id="show-lyrics-time"
v-model="showLyricsTime"
type="checkbox"
name="show-lyrics-time"
/>
<label for="show-lyrics-time"></label>
</div>
</div>
</div>
<div class="item">
<div class="left">
<div class="title"> {{ $t('settings.lyricFontSize.text') }} </div>
Expand Down Expand Up @@ -936,6 +952,17 @@ export default {
});
},
},
showLyricsTime: {
get() {
return this.settings.showLyricsTime;
},
set(value) {
this.$store.commit('updateSettings', {
key: 'showLyricsTime',
value,
});
},
},
closeAppOption: {
get() {
return this.settings.closeAppOption;
Expand Down