diff --git a/.env.example b/.env.example index ab14a6b..eec8514 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,2 @@ -VUE_APP_NETEASE_API_URL=http://localhost:3000 \ No newline at end of file +VUE_APP_NETEASE_API_URL=http://localhost:3000 +VUE_APP_ENABLE_SENTRY=false \ No newline at end of file diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue index 56a08c0..322fbda 100644 --- a/src/components/Navbar.vue +++ b/src/components/Navbar.vue @@ -81,10 +81,14 @@ export default { }); }, changeLang() { + let lang = ""; if (this.$i18n.locale === "zh-CN") { - return (this.$i18n.locale = "en"); + lang = "en"; + } else { + lang = "zh-CN"; } - this.$i18n.locale = "zh-CN"; + this.$i18n.locale = lang; + this.$store.commit("changeLang", lang); }, }, }; diff --git a/src/components/TrackListItem.vue b/src/components/TrackListItem.vue index f7cefcf..d95c813 100644 --- a/src/components/TrackListItem.vue +++ b/src/components/TrackListItem.vue @@ -7,16 +7,29 @@ @mouseover="focus = true" @mouseleave="focus = false" > - +
- {{ track.no }} + {{ + track.no + }} +
@@ -156,15 +169,6 @@ button { } } -button.play-button { - opacity: 1; - .svg-icon { - height: 14px; - width: 14px; - color: #335eea; - } -} - .track { display: flex; align-items: center; @@ -205,6 +209,11 @@ button.play-button { border: 1px solid rgba(0, 0, 0, 0.04); cursor: pointer; } + + img.hover { + filter: drop-shadow(100 200 0 black); + } + .title-and-artist { flex: 1; display: flex; @@ -282,6 +291,7 @@ button.play-button { .artist, .album, .time, + .no, .featured { color: rgba(0, 0, 0, 0.28) !important; } diff --git a/src/locale/index.js b/src/locale/index.js index 06eb4d7..2d41179 100644 --- a/src/locale/index.js +++ b/src/locale/index.js @@ -1,5 +1,6 @@ import Vue from "vue"; import VueI18n from "vue-i18n"; +import store from "@/store"; import en from "./lang/en.js"; import zhCN from "./lang/zh-CN.js"; @@ -7,7 +8,7 @@ import zhCN from "./lang/zh-CN.js"; Vue.use(VueI18n); const i18n = new VueI18n({ - locale: "en", + locale: store.state.settings.lang, messages: { en, "zh-CN": zhCN, diff --git a/src/locale/lang/en.js b/src/locale/lang/en.js index b1bebba..cea3a0c 100644 --- a/src/locale/lang/en.js +++ b/src/locale/lang/en.js @@ -32,6 +32,9 @@ export default { showLess: "SHOW LESS", EPsSingles: "EPs & Singles", albums: "Albums", + withAlbums: "Albums", + artist: "Artist", + videos: "Music Videos", }, album: { released: "Released", @@ -89,5 +92,9 @@ export default { mv: "MVs", playlist: "Playlists", noResult: "No Results", + searchFor: "Search for", + }, + common: { + songs: "Songs", }, }; diff --git a/src/locale/lang/zh-CN.js b/src/locale/lang/zh-CN.js index bdfcdb2..aa04950 100644 --- a/src/locale/lang/zh-CN.js +++ b/src/locale/lang/zh-CN.js @@ -32,6 +32,9 @@ export default { showLess: "收起", EPsSingles: "EP和单曲", albums: "专辑", + withAlbums: "张专辑", + artist: "歌手", + videos: "个视频" }, album: { released: "发行于", @@ -94,5 +97,9 @@ export default { mv: "视频", playlist: "歌单", noResult: "暂无结果", + searchFor: "搜索" }, + common: { + songs: "首歌", + } }; diff --git a/src/store/index.js b/src/store/index.js index 836ebcb..f69ef0a 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -13,7 +13,6 @@ if (localStorage.getItem("appVersion") === null) { window.location.reload(); } -Vue.use(Vuex); const saveToLocalStorage = (store) => { store.subscribe((mutation, state) => { // console.log(mutation); @@ -22,6 +21,7 @@ const saveToLocalStorage = (store) => { }); }; +Vue.use(Vuex); const store = new Vuex.Store({ state: state, mutations, @@ -38,4 +38,11 @@ store.state.howler = new Howl({ }); Howler.volume(store.state.player.volume); +if ([undefined, null].includes(store.state.settings.lang)) { + let lang = "en"; + if (navigator.language.slice(0, 2) === "zh") lang = "zh-CN"; + store.state.settings.lang = lang; + localStorage.setItem("settings", JSON.stringify(store.state.settings)); +} + export default store; diff --git a/src/store/initState.js b/src/store/initState.js index bdec04f..6442ecc 100644 --- a/src/store/initState.js +++ b/src/store/initState.js @@ -84,6 +84,7 @@ const initState = { user: { id: 0, }, + lang: null, }, }; diff --git a/src/store/mutations.js b/src/store/mutations.js index a682155..428701a 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -100,4 +100,7 @@ export default { return t; }); }, + changeLang(state, lang) { + state.settings.lang = lang; + }, }; diff --git a/src/utils/common.js b/src/utils/common.js index 6845ba9..d061bf9 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -58,3 +58,15 @@ export function shuffleAList(list) { }); return newSorts; } + +export function throttle(fn, time) { + let isRun = false; + return function () { + if (isRun) return; + isRun = true; + fn.apply(this, arguments); + setTimeout(() => { + isRun = false; + }, time); + }; +} diff --git a/src/utils/filters.js b/src/utils/filters.js index 60082b5..521bf14 100644 --- a/src/utils/filters.js +++ b/src/utils/filters.js @@ -19,7 +19,11 @@ Vue.filter("formatTime", (Milliseconds, format = "HH:MM:SS") => { ? `${hours}:${mins.padStart(2, "0")}:${seconds}` : `${mins}:${seconds}`; } else if (format === "Human") { - return hours !== "0" ? `${hours} hr ${mins} min` : `${mins} min`; + const hoursUnit = locale.locale === "zh-CN" ? "小时" : "hr"; + const minitesUnit = locale.locale === "zh-CN" ? "分钟" : "min"; + return hours !== "0" + ? `${hours} ${hoursUnit} ${mins} ${minitesUnit}` + : `${mins} ${minitesUnit}`; } }); diff --git a/src/views/album.vue b/src/views/album.vue index 30516c3..ad3c552 100644 --- a/src/views/album.vue +++ b/src/views/album.vue @@ -27,7 +27,8 @@ {{ new Date(album.publishTime).getFullYear() }} - · {{ album.size }} songs, + · {{ album.size }} {{ $t("common.songs") }}, {{ albumTime | formatTime("Human") }}
diff --git a/src/views/artist.vue b/src/views/artist.vue index 3614dae..71e0cdc 100644 --- a/src/views/artist.vue +++ b/src/views/artist.vue @@ -6,10 +6,11 @@
{{ artist.name }}
-
Artist
+
{{ $t("artist.artist") }}
- {{ artist.musicSize }} Songs · {{ artist.albumSize }} Albums · - {{ artist.mvSize }} Music Videos + {{ artist.musicSize }} {{ $t("common.songs") }} · + {{ artist.albumSize }} {{ $t("artist.withAlbums") }} · + {{ artist.mvSize }} {{ $t("artist.videos") }}
@@ -45,7 +46,7 @@
{{ latestRelease.type | formatAlbumType(latestRelease) }} · - {{ latestRelease.size }} Songs + {{ latestRelease.size }} {{ $t("common.songs") }}
diff --git a/src/views/library.vue b/src/views/library.vue index 556636a..efa986e 100644 --- a/src/views/library.vue +++ b/src/views/library.vue @@ -21,7 +21,7 @@
{{ $t("library.likedSongs") }}
- {{ likedSongsPlaylist.trackCount }} songs + {{ likedSongsPlaylist.trackCount }} {{ $t("common.songs") }}