fix: conflict

master
kunkka 4 years ago
commit fa1b397571

@ -1 +1,2 @@
VUE_APP_NETEASE_API_URL=http://localhost:3000 VUE_APP_NETEASE_API_URL=http://localhost:3000
VUE_APP_ENABLE_SENTRY=false

@ -81,10 +81,14 @@ export default {
}); });
}, },
changeLang() { changeLang() {
let lang = "";
if (this.$i18n.locale === "zh-CN") { 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);
}, },
}, },
}; };

@ -7,16 +7,29 @@
@mouseover="focus = true" @mouseover="focus = true"
@mouseleave="focus = false" @mouseleave="focus = false"
> >
<img :src="imgUrl | resizeImage(224)" v-if="!isAlbum" @click="goToAlbum" /> <img
:src="imgUrl | resizeImage(224)"
v-if="!isAlbum"
@click="goToAlbum"
:class="{ hover: focus }"
/>
<div class="no" v-if="isAlbum"> <div class="no" v-if="isAlbum">
<button <button
class="play-button" class="play-button"
v-show="focus && track.playable" v-show="focus && track.playable && !isPlaying"
@click="playTrack" @click="playTrack"
> >
<svg-icon icon-class="play"></svg-icon> <svg-icon icon-class="play"></svg-icon>
</button> </button>
<span v-show="!focus || !track.playable">{{ track.no }}</span> <span v-show="(!focus || !track.playable) && !isPlaying">{{
track.no
}}</span>
<button v-show="isPlaying">
<svg-icon
icon-class="volume"
style="height: 16px; width: 16px"
></svg-icon>
</button>
</div> </div>
<div class="title-and-artist"> <div class="title-and-artist">
<div class="container"> <div class="container">
@ -156,15 +169,6 @@ button {
} }
} }
button.play-button {
opacity: 1;
.svg-icon {
height: 14px;
width: 14px;
color: #335eea;
}
}
.track { .track {
display: flex; display: flex;
align-items: center; align-items: center;
@ -205,6 +209,11 @@ button.play-button {
border: 1px solid rgba(0, 0, 0, 0.04); border: 1px solid rgba(0, 0, 0, 0.04);
cursor: pointer; cursor: pointer;
} }
img.hover {
filter: drop-shadow(100 200 0 black);
}
.title-and-artist { .title-and-artist {
flex: 1; flex: 1;
display: flex; display: flex;
@ -282,6 +291,7 @@ button.play-button {
.artist, .artist,
.album, .album,
.time, .time,
.no,
.featured { .featured {
color: rgba(0, 0, 0, 0.28) !important; color: rgba(0, 0, 0, 0.28) !important;
} }

@ -1,5 +1,6 @@
import Vue from "vue"; import Vue from "vue";
import VueI18n from "vue-i18n"; import VueI18n from "vue-i18n";
import store from "@/store";
import en from "./lang/en.js"; import en from "./lang/en.js";
import zhCN from "./lang/zh-CN.js"; import zhCN from "./lang/zh-CN.js";
@ -7,7 +8,7 @@ import zhCN from "./lang/zh-CN.js";
Vue.use(VueI18n); Vue.use(VueI18n);
const i18n = new VueI18n({ const i18n = new VueI18n({
locale: "en", locale: store.state.settings.lang,
messages: { messages: {
en, en,
"zh-CN": zhCN, "zh-CN": zhCN,

@ -32,6 +32,9 @@ export default {
showLess: "SHOW LESS", showLess: "SHOW LESS",
EPsSingles: "EPs & Singles", EPsSingles: "EPs & Singles",
albums: "Albums", albums: "Albums",
withAlbums: "Albums",
artist: "Artist",
videos: "Music Videos",
}, },
album: { album: {
released: "Released", released: "Released",
@ -89,5 +92,9 @@ export default {
mv: "MVs", mv: "MVs",
playlist: "Playlists", playlist: "Playlists",
noResult: "No Results", noResult: "No Results",
searchFor: "Search for",
},
common: {
songs: "Songs",
}, },
}; };

@ -32,6 +32,9 @@ export default {
showLess: "收起", showLess: "收起",
EPsSingles: "EP和单曲", EPsSingles: "EP和单曲",
albums: "专辑", albums: "专辑",
withAlbums: "张专辑",
artist: "歌手",
videos: "个视频"
}, },
album: { album: {
released: "发行于", released: "发行于",
@ -94,5 +97,9 @@ export default {
mv: "视频", mv: "视频",
playlist: "歌单", playlist: "歌单",
noResult: "暂无结果", noResult: "暂无结果",
searchFor: "搜索"
}, },
common: {
songs: "首歌",
}
}; };

@ -13,7 +13,6 @@ if (localStorage.getItem("appVersion") === null) {
window.location.reload(); window.location.reload();
} }
Vue.use(Vuex);
const saveToLocalStorage = (store) => { const saveToLocalStorage = (store) => {
store.subscribe((mutation, state) => { store.subscribe((mutation, state) => {
// console.log(mutation); // console.log(mutation);
@ -22,6 +21,7 @@ const saveToLocalStorage = (store) => {
}); });
}; };
Vue.use(Vuex);
const store = new Vuex.Store({ const store = new Vuex.Store({
state: state, state: state,
mutations, mutations,
@ -38,4 +38,11 @@ store.state.howler = new Howl({
}); });
Howler.volume(store.state.player.volume); 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; export default store;

@ -84,6 +84,7 @@ const initState = {
user: { user: {
id: 0, id: 0,
}, },
lang: null,
}, },
}; };

@ -100,4 +100,7 @@ export default {
return t; return t;
}); });
}, },
changeLang(state, lang) {
state.settings.lang = lang;
},
}; };

@ -58,3 +58,15 @@ export function shuffleAList(list) {
}); });
return newSorts; 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);
};
}

@ -19,7 +19,11 @@ Vue.filter("formatTime", (Milliseconds, format = "HH:MM:SS") => {
? `${hours}:${mins.padStart(2, "0")}:${seconds}` ? `${hours}:${mins.padStart(2, "0")}:${seconds}`
: `${mins}:${seconds}`; : `${mins}:${seconds}`;
} else if (format === "Human") { } 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}`;
} }
}); });

@ -27,7 +27,8 @@
<span :title="album.publishTime | formatDate">{{ <span :title="album.publishTime | formatDate">{{
new Date(album.publishTime).getFullYear() new Date(album.publishTime).getFullYear()
}}</span> }}</span>
<span> · {{ album.size }} songs</span>, <span> · {{ album.size }} {{ $t("common.songs") }}</span
>,
{{ albumTime | formatTime("Human") }} {{ albumTime | formatTime("Human") }}
</div> </div>
<div class="description" @click="showFullDescription = true"> <div class="description" @click="showFullDescription = true">

@ -6,10 +6,11 @@
</div> </div>
<div> <div>
<div class="name">{{ artist.name }}</div> <div class="name">{{ artist.name }}</div>
<div class="artist">Artist</div> <div class="artist">{{ $t("artist.artist") }}</div>
<div class="statistics"> <div class="statistics">
{{ artist.musicSize }} Songs · {{ artist.albumSize }} Albums · {{ artist.musicSize }} {{ $t("common.songs") }} ·
{{ artist.mvSize }} Music Videos {{ artist.albumSize }} {{ $t("artist.withAlbums") }} ·
{{ artist.mvSize }} {{ $t("artist.videos") }}
</div> </div>
<div class="buttons"> <div class="buttons">
<ButtonTwoTone @click.native="playPopularSongs()" :iconClass="`play`"> <ButtonTwoTone @click.native="playPopularSongs()" :iconClass="`play`">
@ -45,7 +46,7 @@
</div> </div>
<div class="type"> <div class="type">
{{ latestRelease.type | formatAlbumType(latestRelease) }} · {{ latestRelease.type | formatAlbumType(latestRelease) }} ·
{{ latestRelease.size }} Songs {{ latestRelease.size }} {{ $t("common.songs") }}
</div> </div>
</div> </div>
</div> </div>

@ -21,7 +21,7 @@
<div class="titles"> <div class="titles">
<div class="title">{{ $t("library.likedSongs") }}</div> <div class="title">{{ $t("library.likedSongs") }}</div>
<div class="sub-title"> <div class="sub-title">
{{ likedSongsPlaylist.trackCount }} songs {{ likedSongsPlaylist.trackCount }} {{ $t("common.songs") }}
</div> </div>
</div> </div>
<button @click.stop="playLikedSongs"> <button @click.stop="playLikedSongs">

@ -10,7 +10,7 @@
<input <input
:placeholder="$t('login.searchHolder')" :placeholder="$t('login.searchHolder')"
v-model="keyword" v-model="keyword"
@keydown.enter="search" @keydown.enter="throttleSearch"
/> />
</div> </div>
</div> </div>
@ -53,6 +53,7 @@ import NProgress from "nprogress";
import { search } from "@/api/others"; import { search } from "@/api/others";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { userPlaylist } from "@/api/user"; import { userPlaylist } from "@/api/user";
import { throttle } from "@/utils/common";
import ButtonTwoTone from "@/components/ButtonTwoTone.vue"; import ButtonTwoTone from "@/components/ButtonTwoTone.vue";
@ -74,6 +75,7 @@ export default {
methods: { methods: {
...mapMutations(["updateUser", "updateUserInfo"]), ...mapMutations(["updateUser", "updateUserInfo"]),
search() { search() {
if (!this.keyword) return;
search({ keywords: this.keyword, limit: 9, type: 1002 }).then((data) => { search({ keywords: this.keyword, limit: 9, type: 1002 }).then((data) => {
this.result = data.result.userprofiles; this.result = data.result.userprofiles;
this.activeUser = this.result[0]; this.activeUser = this.result[0];
@ -93,6 +95,9 @@ export default {
this.$router.push({ path: "/library" }); this.$router.push({ path: "/library" });
}); });
}, },
throttleSearch: throttle(function () {
this.search();
}, 500),
}, },
}; };
</script> </script>

@ -34,8 +34,8 @@
</div> </div>
<div class="date-and-count"> <div class="date-and-count">
{{ $t("playlist.updatedAt") }} {{ $t("playlist.updatedAt") }}
{{ playlist.updateTime | formatDate }} · {{ playlist.updateTime | formatDate }} · {{ playlist.trackCount }}
{{ playlist.trackCount }} Songs {{ $t("common.songs") }}
</div> </div>
<div class="description" @click="showFullDescription = true"> <div class="description" @click="showFullDescription = true">
{{ playlist.description }} {{ playlist.description }}

@ -1,6 +1,8 @@
<template> <template>
<div class="search" v-show="show"> <div class="search" v-show="show">
<h1><span>Search for</span> "{{ keywords }}"</h1> <h1>
<span>{{ $t("search.searchFor") }}</span> "{{ keywords }}"
</h1>
<div class="result" v-if="isExistResult"> <div class="result" v-if="isExistResult">
<div class="row"> <div class="row">
<div class="artists" v-if="result.hasOwnProperty('artist')"> <div class="artists" v-if="result.hasOwnProperty('artist')">

Loading…
Cancel
Save