mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 13:17:46 +00:00
refactor: explore category
This commit is contained in:
parent
2f0e8e1e24
commit
f16d08ab6d
5 changed files with 44 additions and 32 deletions
|
|
@ -1,9 +1,13 @@
|
||||||
import { playlistCategories } from "@/utils/staticData";
|
import { playlistCategories } from "@/utils/staticData";
|
||||||
|
|
||||||
|
console.log("[debug][initLocalStorage.js]");
|
||||||
|
const enabledPlaylistCategories = playlistCategories
|
||||||
|
.filter((c) => c.enable)
|
||||||
|
.map((c) => c.name);
|
||||||
|
|
||||||
let localStorage = {
|
let localStorage = {
|
||||||
player: {},
|
player: {},
|
||||||
settings: {
|
settings: {
|
||||||
playlistCategories,
|
|
||||||
lang: null,
|
lang: null,
|
||||||
appearance: "auto",
|
appearance: "auto",
|
||||||
musicQuality: 320000,
|
musicQuality: 320000,
|
||||||
|
|
@ -20,6 +24,7 @@ let localStorage = {
|
||||||
enableDiscordRichPresence: false,
|
enableDiscordRichPresence: false,
|
||||||
enableGlobalShortcut: true,
|
enableGlobalShortcut: true,
|
||||||
showLibraryDefault: false,
|
showLibraryDefault: false,
|
||||||
|
enabledPlaylistCategories,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
user: {},
|
user: {},
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,16 @@ export default {
|
||||||
state.data[key] = value;
|
state.data[key] = value;
|
||||||
},
|
},
|
||||||
togglePlaylistCategory(state, name) {
|
togglePlaylistCategory(state, name) {
|
||||||
let cat = state.settings.playlistCategories.find((c) => c.name === name);
|
const index = state.settings.enabledPlaylistCategories.findIndex(
|
||||||
cat.enable = !cat.enable;
|
(c) => c.name === name
|
||||||
state.settings.playlistCategories = state.settings.playlistCategories.map(
|
|
||||||
(c) => {
|
|
||||||
if (c.name === name) {
|
|
||||||
return cat;
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
if (index !== -1) {
|
||||||
|
state.settings.enabledPlaylistCategories = state.settings.enabledPlaylistCategories.filter(
|
||||||
|
(c) => c.name !== name
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
state.settings.enabledPlaylistCategories.push(name);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
updateToast(state, toast) {
|
updateToast(state, toast) {
|
||||||
state.toast = toast;
|
state.toast = toast;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ export const byAppleMusic = [
|
||||||
name: "\u4e2d\u563b\u5408\u74a7",
|
name: "\u4e2d\u563b\u5408\u74a7",
|
||||||
id: 5277771961,
|
id: 5277771961,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
coverImgUrl:
|
coverImgUrl:
|
||||||
"https://p1.music.126.net/cPaBXr1wZSg86ddl47AK7Q==/109951165375130918.jpg",
|
"https://p1.music.126.net/cPaBXr1wZSg86ddl47AK7Q==/109951165375130918.jpg",
|
||||||
|
|
@ -38,6 +37,11 @@ export const playlistCategories = [
|
||||||
enable: true,
|
enable: true,
|
||||||
bigCat: "static",
|
bigCat: "static",
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// name: "For You",
|
||||||
|
// enable: true,
|
||||||
|
// bigCat: "static",
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
name: "推荐歌单",
|
name: "推荐歌单",
|
||||||
enable: true,
|
enable: true,
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,20 @@ import pkg from "../../package.json";
|
||||||
const updateSetting = () => {
|
const updateSetting = () => {
|
||||||
const parsedSettings = JSON.parse(localStorage.getItem("settings"));
|
const parsedSettings = JSON.parse(localStorage.getItem("settings"));
|
||||||
const {
|
const {
|
||||||
playlistCategories,
|
|
||||||
showUnavailableSongInGreyStyle,
|
showUnavailableSongInGreyStyle,
|
||||||
automaticallyCacheSongs,
|
automaticallyCacheSongs,
|
||||||
nyancatStyle,
|
nyancatStyle,
|
||||||
showLyricsTranslation,
|
showLyricsTranslation,
|
||||||
minimizeToTray,
|
minimizeToTray,
|
||||||
|
enabledPlaylistCategories,
|
||||||
} = initLocalStorage.settings;
|
} = initLocalStorage.settings;
|
||||||
const settings = {
|
const settings = {
|
||||||
playlistCategories,
|
|
||||||
showUnavailableSongInGreyStyle,
|
showUnavailableSongInGreyStyle,
|
||||||
automaticallyCacheSongs,
|
automaticallyCacheSongs,
|
||||||
nyancatStyle,
|
nyancatStyle,
|
||||||
showLyricsTranslation,
|
showLyricsTranslation,
|
||||||
minimizeToTray,
|
minimizeToTray,
|
||||||
|
enabledPlaylistCategories,
|
||||||
...parsedSettings,
|
...parsedSettings,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
<h1>{{ $t("explore.explore") }}</h1>
|
<h1>{{ $t("explore.explore") }}</h1>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<div
|
<div
|
||||||
|
v-for="category in settings.enabledPlaylistCategories"
|
||||||
|
:key="category"
|
||||||
class="button"
|
class="button"
|
||||||
v-for="cat in settings.playlistCategories.filter((p) => p.enable)"
|
:class="{ active: category === activeCategory && !showCatOptions }"
|
||||||
:key="cat.name"
|
@click="goToCategory(category)"
|
||||||
:class="{ active: cat.name === activeCategory && !showCatOptions }"
|
|
||||||
@click="goToCategory(cat.name)"
|
|
||||||
>
|
>
|
||||||
{{ cat.name }}
|
{{ category }}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="button more"
|
class="button more"
|
||||||
|
|
@ -20,15 +20,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel" v-show="showCatOptions">
|
<div v-show="showCatOptions" class="panel">
|
||||||
<div class="big-cat" v-for="bigCat in allBigCats" :key="bigCat">
|
<div v-for="bigCat in allBigCats" :key="bigCat" class="big-cat">
|
||||||
<div class="name">{{ bigCat }}</div>
|
<div class="name">{{ bigCat }}</div>
|
||||||
<div class="cats">
|
<div class="cats">
|
||||||
<div
|
<div
|
||||||
class="cat"
|
|
||||||
:class="{ active: cat.enable }"
|
|
||||||
v-for="cat in getCatsByBigCat(bigCat)"
|
v-for="cat in getCatsByBigCat(bigCat)"
|
||||||
:key="cat.name"
|
:key="cat.name"
|
||||||
|
class="cat"
|
||||||
|
:class="{
|
||||||
|
active: settings.enabledPlaylistCategories.includes(cat.name),
|
||||||
|
}"
|
||||||
@click="toggleCat(cat.name)"
|
@click="toggleCat(cat.name)"
|
||||||
><span>{{ cat.name }}</span></div
|
><span>{{ cat.name }}</span></div
|
||||||
>
|
>
|
||||||
|
|
@ -40,21 +42,21 @@
|
||||||
<CoverRow
|
<CoverRow
|
||||||
type="playlist"
|
type="playlist"
|
||||||
:items="playlists"
|
:items="playlists"
|
||||||
:subText="subText"
|
:sub-text="subText"
|
||||||
:showPlayButton="true"
|
:show-play-button="true"
|
||||||
:showPlayCount="activeCategory !== '排行榜' ? true : false"
|
:show-play-count="activeCategory !== '排行榜' ? true : false"
|
||||||
:imageSize="activeCategory !== '排行榜' ? 512 : 1024"
|
:image-size="activeCategory !== '排行榜' ? 512 : 1024"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="load-more"
|
|
||||||
v-show="['推荐歌单', '排行榜'].includes(activeCategory) === false"
|
v-show="['推荐歌单', '排行榜'].includes(activeCategory) === false"
|
||||||
|
class="load-more"
|
||||||
>
|
>
|
||||||
<ButtonTwoTone
|
<ButtonTwoTone
|
||||||
v-show="showLoadMoreButton && hasMore"
|
v-show="showLoadMoreButton && hasMore"
|
||||||
@click.native="getPlaylist"
|
|
||||||
color="grey"
|
color="grey"
|
||||||
:loading="loadingMore"
|
:loading="loadingMore"
|
||||||
|
@click.native="getPlaylist"
|
||||||
>{{ $t("explore.loadMore") }}</ButtonTwoTone
|
>{{ $t("explore.loadMore") }}</ButtonTwoTone
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -70,6 +72,7 @@ import {
|
||||||
recommendPlaylist,
|
recommendPlaylist,
|
||||||
toplists,
|
toplists,
|
||||||
} from "@/api/playlist";
|
} from "@/api/playlist";
|
||||||
|
import { playlistCategories } from "@/utils/staticData";
|
||||||
|
|
||||||
import ButtonTwoTone from "@/components/ButtonTwoTone.vue";
|
import ButtonTwoTone from "@/components/ButtonTwoTone.vue";
|
||||||
import CoverRow from "@/components/CoverRow.vue";
|
import CoverRow from "@/components/CoverRow.vue";
|
||||||
|
|
@ -102,6 +105,9 @@ export default {
|
||||||
return "none";
|
return "none";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
activated() {
|
||||||
|
this.loadData();
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(["togglePlaylistCategory"]),
|
...mapMutations(["togglePlaylistCategory"]),
|
||||||
loadData() {
|
loadData() {
|
||||||
|
|
@ -167,15 +173,12 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getCatsByBigCat(name) {
|
getCatsByBigCat(name) {
|
||||||
return this.settings.playlistCategories.filter((c) => c.bigCat === name);
|
return playlistCategories.filter((c) => c.bigCat === name);
|
||||||
},
|
},
|
||||||
toggleCat(name) {
|
toggleCat(name) {
|
||||||
this.togglePlaylistCategory(name);
|
this.togglePlaylistCategory(name);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
activated() {
|
|
||||||
this.loadData();
|
|
||||||
},
|
|
||||||
beforeRouteUpdate(to, from, next) {
|
beforeRouteUpdate(to, from, next) {
|
||||||
NProgress.start();
|
NProgress.start();
|
||||||
this.showLoadMoreButton = false;
|
this.showLoadMoreButton = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue