chore: format codes

This commit is contained in:
qier222 2021-04-26 16:26:49 +08:00
parent 6922c716e2
commit 9351f6bc89
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
73 changed files with 2321 additions and 2321 deletions

View file

@ -1,31 +1,30 @@
<template>
<div v-show="show">
<div
class="playlist-info"
v-if="specialPlaylistInfo === undefined && !isLikeSongsPage"
class="playlist-info"
>
<Cover
:imageUrl="playlist.coverImgUrl | resizeImage(1024)"
:showPlayButton="true"
:alwaysShowShadow="true"
:clickCoverToPlay="true"
:fixedSize="288"
type="playlist"
:id="playlist.id"
:coverHover="false"
:playButtonSize="18"
:image-url="playlist.coverImgUrl | resizeImage(1024)"
:show-play-button="true"
:always-show-shadow="true"
:click-cover-to-play="true"
:fixed-size="288"
type="playlist"
:cover-hover="false"
:play-button-size="18"
@click.right.native="openMenu"
/>
<div class="info">
<div class="title" @click.right="openMenu"
><span class="lock-icon" v-if="playlist.privacy === 10">
><span v-if="playlist.privacy === 10" class="lock-icon">
<svg-icon icon-class="lock" /></span
>{{ playlist.name }}</div
>
<div class="artist">
Playlist by
<span
style="font-weight: 600"
v-if="
[
5277771961,
@ -35,6 +34,7 @@
5278068783,
].includes(playlist.id)
"
style="font-weight: 600"
>Apple Music</span
>
<a
@ -45,48 +45,48 @@
>
</div>
<div class="date-and-count">
{{ $t("playlist.updatedAt") }}
{{ $t('playlist.updatedAt') }}
{{ playlist.updateTime | formatDate }} · {{ playlist.trackCount }}
{{ $t("common.songs") }}
{{ $t('common.songs') }}
</div>
<div class="description" @click="showFullDescription = true">
{{ playlist.description }}
</div>
<div class="buttons">
<ButtonTwoTone @click.native="playPlaylistByID()" :iconClass="`play`">
{{ $t("common.play") }}
<ButtonTwoTone icon-class="play" @click.native="playPlaylistByID()">
{{ $t('common.play') }}
</ButtonTwoTone>
<ButtonTwoTone
v-if="playlist.creator.userId !== data.user.userId"
:iconClass="playlist.subscribed ? 'heart-solid' : 'heart'"
:iconButton="true"
:horizontalPadding="0"
:icon-class="playlist.subscribed ? 'heart-solid' : 'heart'"
:icon-button="true"
:horizontal-padding="0"
:color="playlist.subscribed ? 'blue' : 'grey'"
:textColor="playlist.subscribed ? '#335eea' : ''"
:backgroundColor="
:text-color="playlist.subscribed ? '#335eea' : ''"
:background-color="
playlist.subscribed ? 'var(--color-secondary-bg)' : ''
"
@click.native="likePlaylist"
>
</ButtonTwoTone>
<ButtonTwoTone
iconClass="more"
:iconButton="true"
:horizontalPadding="0"
icon-class="more"
:icon-button="true"
:horizontal-padding="0"
color="grey"
@click.native="openMenu"
>
</ButtonTwoTone>
</div>
</div>
<div class="search-box" v-if="displaySearchInPlaylist">
<div v-if="displaySearchInPlaylist" class="search-box">
<div class="container" :class="{ active: inputFocus }">
<svg-icon icon-class="search" />
<div class="input">
<input
:placeholder="inputFocus ? '' : $t('playlist.search')"
v-model.trim="inputSearchKeyWords"
v-focus="displaySearchInPlaylist"
:placeholder="inputFocus ? '' : $t('playlist.search')"
@input="inputDebounce()"
@focus="inputFocus = true"
@blur="inputFocus = false"
@ -95,7 +95,7 @@
</div>
</div>
</div>
<div class="special-playlist" v-if="specialPlaylistInfo !== undefined">
<div v-if="specialPlaylistInfo !== undefined" class="special-playlist">
<div
class="title"
:class="specialPlaylistInfo.gradient"
@ -111,29 +111,29 @@
<div class="buttons">
<ButtonTwoTone
class="play-button"
@click.native="playPlaylistByID()"
iconClass="play"
icon-class="play"
color="grey"
@click.native="playPlaylistByID()"
>
{{ $t("common.play") }}
{{ $t('common.play') }}
</ButtonTwoTone>
<ButtonTwoTone
v-if="playlist.creator.userId !== data.user.userId"
:iconClass="playlist.subscribed ? 'heart-solid' : 'heart'"
:iconButton="true"
:horizontalPadding="0"
:icon-class="playlist.subscribed ? 'heart-solid' : 'heart'"
:icon-button="true"
:horizontal-padding="0"
:color="playlist.subscribed ? 'blue' : 'grey'"
:textColor="playlist.subscribed ? '#335eea' : ''"
:backgroundColor="
:text-color="playlist.subscribed ? '#335eea' : ''"
:background-color="
playlist.subscribed ? 'var(--color-secondary-bg)' : ''
"
@click.native="likePlaylist"
>
</ButtonTwoTone>
<ButtonTwoTone
iconClass="more"
:iconButton="true"
:horizontalPadding="0"
icon-class="more"
:icon-button="true"
:horizontal-padding="0"
color="grey"
@click.native="openMenu"
>
@ -141,19 +141,19 @@
</div>
</div>
<div class="user-info" v-if="isLikeSongsPage">
<div v-if="isLikeSongsPage" class="user-info">
<h1>
<img class="avatar" :src="data.user.avatarUrl | resizeImage" />{{
data.user.nickname
}}{{ $t("library.sLikedSongs") }}
}}{{ $t('library.sLikedSongs') }}
</h1>
</div>
<TrackList
:tracks="filteredTracks"
:type="'playlist'"
:id="playlist.id"
:extraContextMenuItem="
:tracks="filteredTracks"
type="playlist"
:extra-context-menu-item="
isUserOwnPlaylist ? ['removeTrackFromPlaylist'] : []
"
/>
@ -161,27 +161,27 @@
<Modal
:show="showFullDescription"
:close="() => (showFullDescription = false)"
:showFooter="false"
:clickOutsideHide="true"
:show-footer="false"
:click-outside-hide="true"
title="歌单介绍"
>{{ playlist.description }}</Modal
>
<ContextMenu ref="playlistMenu">
<div class="item">{{ $t("contextMenu.playNext") }}</div>
<div class="item">{{ $t('contextMenu.playNext') }}</div>
<div class="item" @click="likePlaylist(true)">{{
playlist.subscribed ? "从音乐库删除" : "保存到音乐库"
playlist.subscribed ? '从音乐库删除' : '保存到音乐库'
}}</div>
<div class="item" @click="searchInPlaylist()">歌单内搜索</div>
<div
class="item"
v-if="playlist.creator.userId === data.user.userId"
class="item"
@click="editPlaylist"
>编辑歌单信息</div
>
<div
class="item"
v-if="playlist.creator.userId === data.user.userId"
class="item"
@click="deletePlaylist"
>删除歌单</div
>
@ -190,112 +190,112 @@
</template>
<script>
import { mapMutations, mapActions, mapState } from "vuex";
import NProgress from "nprogress";
import { mapMutations, mapActions, mapState } from 'vuex';
import NProgress from 'nprogress';
import {
getPlaylistDetail,
subscribePlaylist,
deletePlaylist,
} from "@/api/playlist";
import { getTrackDetail } from "@/api/track";
import { isAccountLoggedIn } from "@/utils/auth";
import nativeAlert from "@/utils/nativeAlert";
} from '@/api/playlist';
import { getTrackDetail } from '@/api/track';
import { isAccountLoggedIn } from '@/utils/auth';
import nativeAlert from '@/utils/nativeAlert';
import ButtonTwoTone from "@/components/ButtonTwoTone.vue";
import ContextMenu from "@/components/ContextMenu.vue";
import TrackList from "@/components/TrackList.vue";
import Cover from "@/components/Cover.vue";
import Modal from "@/components/Modal.vue";
import ButtonTwoTone from '@/components/ButtonTwoTone.vue';
import ContextMenu from '@/components/ContextMenu.vue';
import TrackList from '@/components/TrackList.vue';
import Cover from '@/components/Cover.vue';
import Modal from '@/components/Modal.vue';
const specialPlaylist = {
2829816518: {
name: "欧美私人订制",
gradient: "gradient-pink-purple-blue",
name: '欧美私人订制',
gradient: 'gradient-pink-purple-blue',
},
2890490211: {
name: "助眠鸟鸣声",
gradient: "gradient-green",
name: '助眠鸟鸣声',
gradient: 'gradient-green',
},
5089855855: {
name: "夜的胡思乱想",
gradient: "gradient-moonstone-blue",
name: '夜的胡思乱想',
gradient: 'gradient-moonstone-blue',
},
2888212971: {
name: "全球百大DJ",
gradient: "gradient-orange-red",
name: '全球百大DJ',
gradient: 'gradient-orange-red',
},
2829733864: {
name: "睡眠伴侣",
gradient: "gradient-midnight-blue",
name: '睡眠伴侣',
gradient: 'gradient-midnight-blue',
},
2829844572: {
name: "洗澡时听的歌",
gradient: "gradient-yellow",
name: '洗澡时听的歌',
gradient: 'gradient-yellow',
},
2920647537: {
name: "还是会想你",
gradient: "gradient-dark-blue-midnight-blue",
name: '还是会想你',
gradient: 'gradient-dark-blue-midnight-blue',
},
2890501416: {
name: "助眠白噪声",
gradient: "gradient-sky-blue",
name: '助眠白噪声',
gradient: 'gradient-sky-blue',
},
5217150082: {
name: "摇滚唱片行",
gradient: "gradient-yellow-red",
name: '摇滚唱片行',
gradient: 'gradient-yellow-red',
},
2829961453: {
name: "古风音乐大赏",
gradient: "gradient-fog",
name: '古风音乐大赏',
gradient: 'gradient-fog',
},
4923261701: {
name: "Trance",
gradient: "gradient-light-red-light-blue ",
name: 'Trance',
gradient: 'gradient-light-red-light-blue ',
},
5212729721: {
name: "欧美点唱机",
gradient: "gradient-indigo-pink-yellow",
name: '欧美点唱机',
gradient: 'gradient-indigo-pink-yellow',
},
3103434282: {
name: "甜蜜少女心",
gradient: "gradient-pink",
name: '甜蜜少女心',
gradient: 'gradient-pink',
},
2829896389: {
name: "日系私人订制",
gradient: "gradient-yellow-pink",
name: '日系私人订制',
gradient: 'gradient-yellow-pink',
},
2829779628: {
name: "运动随身听",
gradient: "gradient-orange-red",
name: '运动随身听',
gradient: 'gradient-orange-red',
},
2860654884: {
name: "独立女声精选",
gradient: "gradient-sharp-blue",
name: '独立女声精选',
gradient: 'gradient-sharp-blue',
},
898150: {
name: "浪漫婚礼专用",
gradient: "gradient-pink",
name: '浪漫婚礼专用',
gradient: 'gradient-pink',
},
2638104052: {
name: "牛奶泡泡浴",
gradient: "gradient-fog",
name: '牛奶泡泡浴',
gradient: 'gradient-fog',
},
5317236517: {
name: "后朋克精选",
gradient: "gradient-pink-purple-blue",
name: '后朋克精选',
gradient: 'gradient-pink-purple-blue',
},
2821115454: {
name: "一周原创发现",
gradient: "gradient-blue-purple",
name: '一周原创发现',
gradient: 'gradient-blue-purple',
},
3136952023: {
name: "私人雷达",
gradient: "gradient-radar",
name: '私人雷达',
gradient: 'gradient-radar',
},
};
export default {
name: "Playlist",
name: 'Playlist',
components: {
Cover,
ButtonTwoTone,
@ -303,14 +303,21 @@ export default {
Modal,
ContextMenu,
},
directives: {
focus: {
inserted: function (el) {
el.focus();
},
},
},
data() {
return {
show: false,
playlist: {
id: 0,
coverImgUrl: "",
coverImgUrl: '',
creator: {
userId: "",
userId: '',
},
trackIds: [],
},
@ -319,26 +326,16 @@ export default {
loadingMore: false,
lastLoadedTrackIndex: 9,
displaySearchInPlaylist: false,
searchKeyWords: "", // 使
inputSearchKeyWords: "", //
searchKeyWords: '', // 使
inputSearchKeyWords: '', //
inputFocus: false,
debounceTimeout: null,
};
},
created() {
if (this.$route.name === "likedSongs") {
this.loadData(this.data.likedSongPlaylistID);
} else {
this.loadData(this.$route.params.id);
}
},
destroyed() {
window.removeEventListener("scroll", this.handleScroll, true);
},
computed: {
...mapState(["player", "data"]),
...mapState(['player', 'data']),
isLikeSongsPage() {
return this.$route.name === "likedSongs";
return this.$route.name === 'likedSongs';
},
specialPlaylistInfo() {
return specialPlaylist[this.playlist.id];
@ -351,7 +348,7 @@ export default {
},
filteredTracks() {
return this.tracks.filter(
(track) =>
track =>
(track.name &&
track.name
.toLowerCase()
@ -361,7 +358,7 @@ export default {
.toLowerCase()
.includes(this.searchKeyWords.toLowerCase())) ||
track.ar.find(
(artist) =>
artist =>
artist.name &&
artist.name
.toLowerCase()
@ -370,35 +367,45 @@ export default {
);
},
},
created() {
if (this.$route.name === 'likedSongs') {
this.loadData(this.data.likedSongPlaylistID);
} else {
this.loadData(this.$route.params.id);
}
},
destroyed() {
window.removeEventListener('scroll', this.handleScroll, true);
},
methods: {
...mapMutations(["appendTrackToPlayerList"]),
...mapActions(["playFirstTrackOnList", "playTrackOnListByID", "showToast"]),
playPlaylistByID(trackID = "first") {
let trackIDs = this.playlist.trackIds.map((t) => t.id);
...mapMutations(['appendTrackToPlayerList']),
...mapActions(['playFirstTrackOnList', 'playTrackOnListByID', 'showToast']),
playPlaylistByID(trackID = 'first') {
let trackIDs = this.playlist.trackIds.map(t => t.id);
this.$store.state.player.replacePlaylist(
trackIDs,
this.playlist.id,
"playlist",
'playlist',
trackID
);
},
likePlaylist(toast = false) {
if (!isAccountLoggedIn()) {
this.showToast("此操作需要登录网易云账号");
this.showToast('此操作需要登录网易云账号');
return;
}
subscribePlaylist({
id: this.playlist.id,
t: this.playlist.subscribed ? 2 : 1,
}).then((data) => {
}).then(data => {
if (data.code === 200) {
this.playlist.subscribed = !this.playlist.subscribed;
if (toast === true)
this.showToast(
this.playlist.subscribed ? "已保存到音乐库" : "已从音乐库删除"
this.playlist.subscribed ? '已保存到音乐库' : '已从音乐库删除'
);
}
getPlaylistDetail(this.id, true).then((data) => {
getPlaylistDetail(this.id, true).then(data => {
this.playlist = data.playlist;
});
});
@ -406,7 +413,7 @@ export default {
loadData(id, next = undefined) {
this.id = id;
getPlaylistDetail(this.id, true)
.then((data) => {
.then(data => {
this.playlist = data.playlist;
this.tracks = data.playlist.tracks;
NProgress.done();
@ -414,7 +421,7 @@ export default {
this.show = true;
this.lastLoadedTrackIndex = data.playlist.tracks.length - 1;
if (this.playlist.trackCount > this.tracks.length) {
window.addEventListener("scroll", this.handleScroll, true);
window.addEventListener('scroll', this.handleScroll, true);
}
return data;
})
@ -433,15 +440,15 @@ export default {
)
return t;
});
trackIDs = trackIDs.map((t) => t.id);
getTrackDetail(trackIDs.join(",")).then((data) => {
trackIDs = trackIDs.map(t => t.id);
getTrackDetail(trackIDs.join(',')).then(data => {
this.tracks.push(...data.songs);
this.lastLoadedTrackIndex += trackIDs.length;
this.loadingMore = false;
});
},
handleScroll(e) {
let dom = document.querySelector("html");
let dom = document.querySelector('html');
let scrollHeight = Math.max(dom.scrollHeight, dom.scrollHeight);
let scrollTop = e.target.scrollingElement.scrollTop;
let clientHeight =
@ -461,39 +468,39 @@ export default {
},
deletePlaylist() {
if (!isAccountLoggedIn()) {
this.showToast("此操作需要登录网易云账号");
this.showToast('此操作需要登录网易云账号');
return;
}
let confirmation = confirm(`确定要删除歌单 ${this.playlist.name}`);
if (confirmation === true) {
deletePlaylist(this.playlist.id).then((data) => {
deletePlaylist(this.playlist.id).then(data => {
if (data.code === 200) {
nativeAlert(`已删除歌单 ${this.playlist.name}`);
this.$router.go(-1);
} else {
nativeAlert("发生错误");
nativeAlert('发生错误');
}
});
}
},
editPlaylist() {
nativeAlert("此功能开发中");
nativeAlert('此功能开发中');
},
searchInPlaylist() {
this.displaySearchInPlaylist = !this.displaySearchInPlaylist;
if (this.displaySearchInPlaylist == false) {
this.searchKeyWords = "";
this.inputSearchKeyWords = "";
this.searchKeyWords = '';
this.inputSearchKeyWords = '';
} else {
this.loadMore(500);
}
},
removeTrack(trackID) {
if (!isAccountLoggedIn()) {
this.showToast("此操作需要登录网易云账号");
this.showToast('此操作需要登录网易云账号');
return;
}
this.tracks = this.tracks.filter((t) => t.id !== trackID);
this.tracks = this.tracks.filter(t => t.id !== trackID);
},
inputDebounce() {
if (this.debounceTimeout) clearTimeout(this.debounceTimeout);
@ -502,13 +509,6 @@ export default {
}, 600);
},
},
directives: {
focus: {
inserted: function (el) {
el.focus();
},
},
},
};
</script>
@ -647,7 +647,7 @@ export default {
background-image: linear-gradient(to left, #92fe9d 0%, #00c9ff 100%);
}
[data-theme="dark"] {
[data-theme='dark'] {
.gradient-radar {
background-image: linear-gradient(to left, #92fe9d 0%, #00c9ff 100%);
}
@ -824,7 +824,7 @@ export default {
}
}
[data-theme="dark"] {
[data-theme='dark'] {
.search-box {
.active {
input,