From acf3d768f8c57b318868ce0464d2188ef5e4b27e Mon Sep 17 00:00:00 2001 From: qier222 Date: Sat, 2 Jan 2021 20:55:43 +0800 Subject: [PATCH] refactor: enhance UI compatibility --- src/App.vue | 10 +- src/background.js | 2 + src/components/Cover.vue | 240 +++++++++++++------------------ src/components/CoverRow.vue | 95 +++++------- src/components/MvRow.vue | 70 +++++---- src/components/Navbar.vue | 14 +- src/components/Player.vue | 6 + src/components/TrackList.vue | 35 +++-- src/components/TrackListItem.vue | 5 - src/views/album.vue | 13 +- src/views/artist.vue | 13 +- src/views/library.vue | 9 +- src/views/playlist.vue | 11 +- src/views/search.vue | 51 ++----- 14 files changed, 254 insertions(+), 320 deletions(-) diff --git a/src/App.vue b/src/App.vue index 755b000..08e2e96 100644 --- a/src/App.vue +++ b/src/App.vue @@ -108,11 +108,11 @@ body { html { overflow-y: overlay; - min-width: 1000px; + min-width: 768px; } main { - margin-top: 96px; + margin-top: 84px; margin-bottom: 96px; padding: { right: 10vw; @@ -120,6 +120,12 @@ main { } } +@media (max-width: 1336px) { + main { + padding: 0 5vw; + } +} + select, button { font-family: inherit; diff --git a/src/background.js b/src/background.js index f041fc2..664010f 100644 --- a/src/background.js +++ b/src/background.js @@ -89,6 +89,8 @@ class Background { this.window = new BrowserWindow({ width: this.store.get("window.width") | 1440, height: this.store.get("window.height") | 840, + minWidth: 768, + minHeight: 608, titleBarStyle: "hiddenInset", webPreferences: { webSecurity: false, diff --git a/src/components/Cover.vue b/src/components/Cover.vue index 0bd18fc..93ea0c3 100644 --- a/src/components/Cover.vue +++ b/src/components/Cover.vue @@ -1,35 +1,30 @@ @@ -37,83 +32,54 @@ import { playAlbumByID, playPlaylistByID, playArtistByID } from "@/utils/play"; export default { - name: "Cover", props: { - id: Number, - type: String, - url: String, - hoverEffect: Boolean, - showPlayButton: Boolean, - alwaysShowShadow: Boolean, - showBlackShadow: Boolean, - clickToPlay: Boolean, - size: { - type: Number, - default: 208, - }, - shadowMargin: { - type: Number, - default: 12, - }, - radius: { - type: Number, - default: 12, - }, - playButtonSize: { - type: Number, - default: 48, - }, + id: { type: Number, required: true }, + type: { type: String, required: true }, + imageUrl: { type: String, required: true }, + fixedSize: { type: Number, default: 0 }, + playButtonSize: { type: Number, default: 22 }, + coverHover: { type: Boolean, default: true }, + alwaysShowPlayButton: { type: Boolean, default: true }, + alwaysShowShadow: { type: Boolean, default: false }, + clickCoverToPlay: { type: Boolean, default: false }, + shadowMargin: { type: Number, default: 12 }, + radius: { type: Number, default: 12 }, }, data() { return { focus: false, - shadowStyle: {}, - playButtonStyle: {}, - }; - }, - created() { - this.shadowStyle = { - height: `${this.size}px`, - width: `${~~(this.size * 0.96)}px`, - top: `${this.shadowMargin}px`, - right: `${~~(this.size * 0.02)}px`, - borderRadius: `${this.radius}px`, - }; - this.playButtonStyle = { - height: `${this.playButtonSize}px`, - width: `${this.playButtonSize}px`, }; }, computed: { - coverStyle() { - return { - backgroundImage: `url('${this.url}')`, - boxShadow: this.showBlackShadow - ? "0 12px 16px -8px rgba(0, 0, 0, 0.2)" - : "", - height: `${this.size}px`, - width: `${this.size}px`, - borderRadius: `${this.radius}px`, - cursor: this.clickToPlay ? "default" : "pointer", - }; + imageStyles() { + let styles = {}; + if (this.fixedSize !== 0) { + styles.width = this.fixedSize + "px"; + } + if (this.type === "artist") styles.borderRadius = "50%"; + return styles; + }, + playButtonStyles() { + let styles = {}; + styles.width = this.playButtonSize + "%"; + styles.height = this.playButtonSize + "%"; + return styles; + }, + shadowStyles() { + let styles = {}; + styles.backgroundImage = `url(${this.imageUrl})`; + if (this.type === "artist") styles.borderRadius = "50%"; + return styles; }, }, methods: { play() { - if (this.type === "album") { - playAlbumByID(this.id); - } else if (this.type === "playlist") { - playPlaylistByID(this.id); - } - }, - playButtonClicked() { - if (this.type === "album") { - playAlbumByID(this.id); - } else if (this.type === "playlist") { - playPlaylistByID(this.id); - } else if (this.type === "artist") { - playArtistByID(this.id); - } + const playActions = { + album: playAlbumByID, + playlist: playPlaylistByID, + artist: playArtistByID, + }; + playActions[this.type](this.id); }, goTo() { this.$router.push({ name: this.type, params: { id: this.id } }); @@ -125,72 +91,70 @@ export default { diff --git a/src/views/artist.vue b/src/views/artist.vue index 73878d4..2bd6a3e 100644 --- a/src/views/artist.vue +++ b/src/views/artist.vue @@ -36,16 +36,11 @@
diff --git a/src/views/library.vue b/src/views/library.vue index 3e3df56..b9debbc 100644 --- a/src/views/library.vue +++ b/src/views/library.vue @@ -33,9 +33,9 @@
@@ -245,7 +245,7 @@ export default { getLikedSongs(getLyric = true) { getPlaylistDetail(this.data.likedSongPlaylistID, true).then((data) => { this.likedSongsPlaylist = data.playlist; - let TrackIDs = data.playlist.trackIds.slice(0, 20).map((t) => t.id); + let TrackIDs = data.playlist.trackIds.slice(0, 12).map((t) => t.id); this.likedSongIDs = TrackIDs; getTrackDetail(this.likedSongIDs.join(",")).then((data) => { this.likedSongs = data.songs; @@ -323,7 +323,6 @@ h1 { flex: 7; margin-top: 8px; margin-left: 36px; - height: 216px; overflow: hidden; } } @@ -332,8 +331,6 @@ h1 { flex: 3; margin-top: 8px; cursor: pointer; - height: 216px; - width: 300px; border-radius: 16px; padding: 18px 24px; display: flex; @@ -442,7 +439,7 @@ h1 { button.add-playlist { color: var(--color-text); border-radius: 8px; - padding: 0 12px; + padding: 0 14px; display: flex; justify-content: center; align-items: center; diff --git a/src/views/playlist.vue b/src/views/playlist.vue index 957cc57..a511475 100644 --- a/src/views/playlist.vue +++ b/src/views/playlist.vue @@ -5,11 +5,15 @@ v-if="specialPlaylistInfo === undefined && !isLikeSongsPage" >
@@ -288,6 +292,7 @@ export default { return { show: false, playlist: { + id: 0, coverImgUrl: "", creator: { userId: "", diff --git a/src/views/search.vue b/src/views/search.vue index ece7683..3e18bca 100644 --- a/src/views/search.vue +++ b/src/views/search.vue @@ -14,16 +14,11 @@ :key="artist.id" >
{{ @@ -43,16 +38,11 @@ >
@@ -72,12 +62,12 @@
{{ $t("search.song") }}
- +
{{ $t("search.mv") }}
- +
@@ -90,16 +80,11 @@ >
@@ -209,6 +194,7 @@ h1 { .row { display: flex; + flex-wrap: wrap; } .artists, @@ -271,11 +257,4 @@ h1 { margin-top: 24px; font-size: 24px; } - -.mvs { - .mv-row { - margin-top: -12px; - margin-bottom: -24px; - } -}