feat: add music language preference

This commit is contained in:
qier222 2021-06-08 17:17:34 +08:00
parent f89fc84f95
commit 78d90f15f5
No known key found for this signature in database
GPG Key ID: 9C85007ED905F14D
5 changed files with 46 additions and 14 deletions

View File

@ -50,12 +50,14 @@ export function getArtistAlbum(params) {
* @param {number=} type * @param {number=} type
*/ */
export function toplistOfArtists(type = null) { export function toplistOfArtists(type = null) {
let params = {};
if (type) {
params.type = type;
}
return request({ return request({
url: '/toplist/artist', url: '/toplist/artist',
method: 'get', method: 'get',
params: { params,
type,
},
}); });
} }
/** /**

View File

@ -9,6 +9,7 @@ let localStorage = {
player: {}, player: {},
settings: { settings: {
lang: null, lang: null,
musicLanguage: 'all',
appearance: 'auto', appearance: 'auto',
musicQuality: 320000, musicQuality: 320000,
lyricFontSize: 28, lyricFontSize: 28,

View File

@ -121,12 +121,22 @@ export default {
this.show = true; this.show = true;
}); });
newAlbums({ newAlbums({
area: 'EA', area: this.settings.musicLanguage ?? 'ALL',
limit: 10, limit: 10,
}).then(data => { }).then(data => {
this.newReleasesAlbum.items = data.albums; this.newReleasesAlbum.items = data.albums;
}); });
toplistOfArtists(2).then(data => {
const toplistOfArtistsAreaTable = {
all: null,
zh: 1,
ea: 2,
jp: 4,
kr: 3,
};
toplistOfArtists(
toplistOfArtistsAreaTable[this.settings.musicLanguage ?? 'all']
).then(data => {
let indexs = []; let indexs = [];
while (indexs.length < 6) { while (indexs.length < 6) {
let tmp = ~~(Math.random() * 100); let tmp = ~~(Math.random() * 100);

View File

@ -378,15 +378,9 @@ export default {
Vibrant.from(cover, { colorCount: 1 }) Vibrant.from(cover, { colorCount: 1 })
.getPalette() .getPalette()
.then(palette => { .then(palette => {
const color = Color.rgb(palette.DarkMuted._rgb) const orignColor = Color.rgb(palette.DarkMuted._rgb);
.darken(0.1) const color = orignColor.darken(0.1).rgb().string();
.rgb() const color2 = orignColor.lighten(0.28).rotate(-30).rgb().string();
.string();
const color2 = Color.rgb(palette.DarkMuted._rgb)
.lighten(0.28)
.rotate(-30)
.rgb()
.string();
this.background = `linear-gradient(to top left, ${color}, ${color2})`; this.background = `linear-gradient(to top left, ${color}, ${color2})`;
}); });
}, },

View File

@ -54,6 +54,20 @@
</select> </select>
</div> </div>
</div> </div>
<div class="item">
<div class="left">
<div class="title"> 音乐语种偏好 </div>
</div>
<div class="right">
<select v-model="musicLanguage">
<option value="all">无偏好</option>
<option value="zh">华语</option>
<option value="ea">欧美</option>
<option value="jp">日语</option>
<option value="kr">韩语</option>
</select>
</div>
</div>
<h3>音质</h3> <h3>音质</h3>
<div class="item"> <div class="item">
@ -454,6 +468,17 @@ export default {
this.$store.commit('changeLang', lang); this.$store.commit('changeLang', lang);
}, },
}, },
musicLanguage: {
get() {
return this.settings.musicLanguage ?? 'all';
},
set(value) {
this.$store.commit('updateSettings', {
key: 'musicLanguage',
value,
});
},
},
appearance: { appearance: {
get() { get() {
if (this.settings.appearance === undefined) return 'auto'; if (this.settings.appearance === undefined) return 'auto';