From 06d40f965aefc854b85a2ee2d7d79db59ca7e8dc Mon Sep 17 00:00:00 2001 From: kunkka Date: Sun, 18 Oct 2020 19:28:33 +0800 Subject: [PATCH 01/37] feat: add config to resolve path alias. --- jsconfig.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 jsconfig.json diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..0d612a8 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,14 @@ +{ + // 支持 @ 的别名解析 + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": ["src/*"] + }, + "target": "ES6", + "module": "commonjs", + "allowSyntheticDefaultImports": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules"] +} From 6aab864a89e7c172ddee041ce5480265c7a42c2c Mon Sep 17 00:00:00 2001 From: kunkka Date: Mon, 19 Oct 2020 00:39:47 +0800 Subject: [PATCH 02/37] feat: use vue-i18n for language switch --- package.json | 1 + src/assets/icons/translation.svg | 3 +++ src/components/Navbar.vue | 31 +++++++++++++++++++++++++++---- src/locale/index.js | 12 ++++++++++++ src/locale/messages.js | 18 ++++++++++++++++++ src/main.js | 2 ++ yarn.lock | 5 +++++ 7 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 src/assets/icons/translation.svg create mode 100644 src/locale/index.js create mode 100644 src/locale/messages.js diff --git a/package.json b/package.json index 95f6177..ddb5346 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "vue": "^2.6.11", "vue-analytics": "^5.22.1", "vue-global-events": "^1.2.1", + "vue-i18n": "^8.22.0", "vue-router": "^3.4.3", "vue-slider-component": "^3.2.5", "vuex": "^3.4.0" diff --git a/src/assets/icons/translation.svg b/src/assets/icons/translation.svg new file mode 100644 index 0000000..9cbd770 --- /dev/null +++ b/src/assets/icons/translation.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue index 7c32e19..c14eb35 100644 --- a/src/components/Navbar.vue +++ b/src/components/Navbar.vue @@ -10,17 +10,17 @@
@@ -32,7 +32,7 @@
+
+ +
@@ -57,6 +61,7 @@ export default { return { inputFocus: false, keywords: "", + langs: ['zh-CN', 'en'] }; }, methods: { @@ -70,6 +75,12 @@ export default { query: { keywords: this.keywords }, }); }, + changeLang() { + if (this.$i18n.locale === "zh-CN") { + return this.$i18n.locale = "en"; + } + this.$i18n.locale = "zh-CN"; + } }, }; @@ -133,6 +144,7 @@ nav { color: #335eea; } } + .search { .svg-icon { height: 18px; @@ -193,4 +205,15 @@ nav { width: 24px; } } + +.locale-changer { + position: relative; + .translation { + margin-left: 16px; + height: 48px; + width: 48px; + } +} + + diff --git a/src/locale/index.js b/src/locale/index.js new file mode 100644 index 0000000..5005c24 --- /dev/null +++ b/src/locale/index.js @@ -0,0 +1,12 @@ +import Vue from 'vue'; +import VueI18n from 'vue-i18n' +import messages from './messages'; + +Vue.use(VueI18n) + +const i18n = new VueI18n({ + locale: 'zh-CN', + messages +}); + +export default i18n; \ No newline at end of file diff --git a/src/locale/messages.js b/src/locale/messages.js new file mode 100644 index 0000000..43fb8cb --- /dev/null +++ b/src/locale/messages.js @@ -0,0 +1,18 @@ +export default { + en: { + message: { + home: 'Home', + explore: 'Explore', + library: 'Library', + search: 'Search' + } + }, + 'zh-CN': { + message: { + home: '首页', + explore: '发现', + library: '歌单', + search: '搜索' + } + } +}; diff --git a/src/main.js b/src/main.js index 11017bf..dd8958d 100644 --- a/src/main.js +++ b/src/main.js @@ -3,6 +3,7 @@ import VueAnalytics from "vue-analytics"; import App from "./App.vue"; import router from "./router"; import store from "./store"; +import i18n from '@/locale'; import "@/assets/icons"; import "@/utils/filters"; import { initMediaSession } from "@/utils/mediaSession"; @@ -18,6 +19,7 @@ Vue.config.productionTip = false; initMediaSession(); new Vue({ + i18n, store, router, render: (h) => h(App), diff --git a/yarn.lock b/yarn.lock index 3836b5b..efd1ac5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8535,6 +8535,11 @@ vue-hot-reload-api@^2.3.0: resolved "https://registry.npm.taobao.org/vue-hot-reload-api/download/vue-hot-reload-api-2.3.4.tgz?cache=0&sync_timestamp=1589682714858&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-hot-reload-api%2Fdownload%2Fvue-hot-reload-api-2.3.4.tgz#532955cc1eb208a3d990b3a9f9a70574657e08f2" integrity sha1-UylVzB6yCKPZkLOp+acFdGV+CPI= +vue-i18n@^8.22.0: + version "8.22.0" + resolved "https://registry.npm.taobao.org/vue-i18n/download/vue-i18n-8.22.0.tgz?cache=0&sync_timestamp=1602001179053&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-i18n%2Fdownload%2Fvue-i18n-8.22.0.tgz#6403381a6eab1d229e515a62addb29b2ff3abfed" + integrity sha1-ZAM4Gm6rHSKeUVpirdspsv86v+0= + "vue-loader-v16@npm:vue-loader@^16.0.0-beta.7": version "16.0.0-beta.7" resolved "https://registry.npm.taobao.org/vue-loader/download/vue-loader-16.0.0-beta.7.tgz?cache=0&sync_timestamp=1599639283575&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-loader%2Fdownload%2Fvue-loader-16.0.0-beta.7.tgz#6f2726fa0e2b1fbae67895c47593bbf69f2b9ab8" From 3d33d2ba8c64d464c22f9b723ff8a3756adc729b Mon Sep 17 00:00:00 2001 From: kunkka Date: Mon, 19 Oct 2020 00:41:03 +0800 Subject: [PATCH 03/37] feat: add .editorconfig for ide --- .editorconfig | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..db87e1f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = false +insert_final_newline = false \ No newline at end of file From 915fa386a7ffbcb526e367703b34e22368fd22e1 Mon Sep 17 00:00:00 2001 From: kunkka Date: Mon, 19 Oct 2020 11:11:33 +0800 Subject: [PATCH 04/37] fix: add no-referrer to avoid CROB --- public/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/public/index.html b/public/index.html index 025b89a..91e96b7 100644 --- a/public/index.html +++ b/public/index.html @@ -4,6 +4,7 @@ + <%= htmlWebpackPlugin.options.title %> From 19a5269d5c6c0486fa1cb25cab9e4b16291347f4 Mon Sep 17 00:00:00 2001 From: kunkka Date: Mon, 19 Oct 2020 11:52:10 +0800 Subject: [PATCH 05/37] fix: setCookie and fix typo --- src/views/loginAccount.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/views/loginAccount.vue b/src/views/loginAccount.vue index c335d67..8edfd64 100644 --- a/src/views/loginAccount.vue +++ b/src/views/loginAccount.vue @@ -112,6 +112,7 @@ export default { methods: { ...mapMutations(["updateUser", "updateUserInfo"]), afterLogin() { + Cookies.set("MUSIC_U", true, { expires: 3650 }); Cookies.set("loginMode", "account", { expires: 3650 }); userPlaylist({ uid: this.$store.state.settings.user.userId, @@ -128,7 +129,7 @@ export default { this.processing = true; if (this.mode === "phone") { if ( - this.countrycode === "" || + this.countryCode === "" || this.phone === "" || this.password === "" ) { From ebbf78fddbe7f6caa95f9ac7bcc67b315a97b614 Mon Sep 17 00:00:00 2001 From: kunkka Date: Mon, 19 Oct 2020 22:34:34 +0800 Subject: [PATCH 06/37] feat: integrate vue-i18n --- src/components/Footer.vue | 2 +- src/components/Navbar.vue | 9 +-- src/locale/messages.js | 154 ++++++++++++++++++++++++++++++++---- src/views/album.vue | 7 +- src/views/artist.vue | 14 ++-- src/views/explore.vue | 4 +- src/views/home.vue | 25 +++--- src/views/library.vue | 6 +- src/views/login.vue | 10 ++- src/views/loginAccount.vue | 18 ++--- src/views/loginUsername.vue | 10 +-- src/views/mv.vue | 2 +- src/views/newAlbum.vue | 2 +- src/views/next.vue | 4 +- src/views/playlist.vue | 6 +- src/views/search.vue | 2 +- 16 files changed, 196 insertions(+), 79 deletions(-) diff --git a/src/components/Footer.vue b/src/components/Footer.vue index 8df7833..b639e81 100644 --- a/src/components/Footer.vue +++ b/src/components/Footer.vue @@ -1,7 +1,7 @@ diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue index c14eb35..4c176b5 100644 --- a/src/components/Navbar.vue +++ b/src/components/Navbar.vue @@ -10,17 +10,17 @@
@@ -32,7 +32,7 @@
YesPlayMusic's GitHub repository to build and use the self-hosted NetEase Cloud API.` + }, + mv: { + moreVideo: 'More Videos' + }, + next: { + nowPlaying: 'Now Playing', + nextUp: 'Next Up' + }, + playlist: "Playlists", + play: "PLAY", + likedSong: "Liked Songs", + shortIs: "'s", + is: "'s", + updatedAt: "Updated at", }, - 'zh-CN': { - message: { - home: '首页', - explore: '发现', - library: '歌单', - search: '搜索' - } + "zh-CN": { + nav: { + home: "首页", + explore: "发现", + library: "歌单", + search: "搜索" + }, + footer: { + settings: '设置', + }, + home: { + recommendPlaylist: "推荐歌单", + recommendArtist: "推荐歌手", + newAlbum: "新专速递", + leaderboard: "排行榜", + seeMore: "更多", + }, + library: "歌单", + explore: { + explore: "发现", + loadMore: "加载更多", + }, + artist: { + latestRelease: "最新发布", + popularSongs: "热门歌曲", + showMore: "显示更多", + showLess: "收起", + EPSingle: "专辑及单曲", + albums: "专辑" + }, + album: { + released: "发布于", + }, + login: { + accessToAll: "可访问全部数据", + loginText: "登录网易云账号", + search: "搜索网易云账号", + readonly: "只能读取账号公开数据", + usernameLogin: '用户名登录', + searchHolder: "请输入你的网易云用户名", + enterTip: "按 Enter 搜索", + choose: "在列表中选中你的账号", + confirm: "确认", + countrycode: '国际区号', + phone: '手机号', + email: '邮箱', + password: '密码', + login: '登录', + usingEmail: '使用邮箱登录', + usingPhone: '使用手机号登录', + // TODO + agreement: `YesPlayMusic 承诺不会保存你的任何账号信息到云端。
+ 你的密码会在本地进行 MD5 加密后再传输到网易云 API。
+ YesPlayMusic 并非网易云官方网站,输入账号信息前请慎重考虑。 你也可以前往 + YesPlayMusic 的 GitHub 源代码仓库 + 自行构建并使用自托管的网易云 API。` + }, + mv: { + moreVideo: '更多视频' + }, + next: { + nowPlaying: '正在播放', + nextUp: '即将播放' + }, + playlist: "播放列表", + play: "播放", + likedSong: "我喜欢的音乐", + shortIs: "", + is: "的", + updatedAt: "更新于" } -}; +}; \ No newline at end of file diff --git a/src/views/album.vue b/src/views/album.vue index d24563b..a0d21dd 100644 --- a/src/views/album.vue +++ b/src/views/album.vue @@ -38,24 +38,21 @@ @click.native="playAlbumByID(album.id)" :iconClass="`play`" > - PLAY + {{ $t('play') }}
- -
- Released {{ album.publishTime | formatDate("MMMM D, YYYY") }} + {{ $t("album.released") }} {{ album.publishTime | formatDate("MMMM D, YYYY") }}
-
- PLAY + {{ $t('play') }}
-
Latest Release
+
{{ $t('artist.latestRelease') }}
-
Albums
+
{{ $t('artist.album') }}
-
EPs & Singles
+
{{ $t('artist.EPSingle') }}
-

Explore

+

{{ $t('explore.explore') }}

Load More{{ $t('explore.loadMore') }}
diff --git a/src/views/home.vue b/src/views/home.vue index 78fe867..71d3695 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -11,11 +11,10 @@ :imageSize="1024" />
-
- {{ recommendPlaylist.name }} - SEE MORE + {{ $t("home.recommendPlaylist") }} + {{ $t("home.seeMore") }}
-
-
{{ recommendArtists.name }}
+
{{ $t("home.recommendArtist") }}
-
- {{ newReleasesAlbum.name }} - SEE MORE + {{ $t("home.newAlbum") }} + {{ $t("home.seeMore") }}
-
- {{ topList.name }} - SEE MORE + {{ $t("home.leaderboard") }} + {{ $t("home.seeMore") }}
{{ user.profile.nickname - }}'s Library + }}{{ $t("is") }} {{ $t("library") }}
@@ -19,7 +19,7 @@
-
Liked Songs
+
{{ $t("likedSong") }}
{{ likedSongsPlaylist.trackCount }} songs
@@ -41,7 +41,7 @@
-
Playlists
+
{{ $t("playlist") }}
-
登录网易云账号
-
可访问全部数据
+
{{ $t('login.loginText') }}
+
{{ $t('login.accessToAll') }}
@@ -28,8 +28,8 @@ >
-
搜索网易云账号
-
只能读取账号公开数据
+
{{ $t('login.search') }}
+
{{ $t('login.readonly') }}
@@ -105,6 +105,8 @@ export default { height: 128px; width: 300px; transition: all 0.3s; + padding-left: 22px; + box-sizing: border-box; .active { .title-info { diff --git a/src/views/loginAccount.vue b/src/views/loginAccount.vue index 8edfd64..b6cc11a 100644 --- a/src/views/loginAccount.vue +++ b/src/views/loginAccount.vue @@ -3,7 +3,7 @@
-
登录网易云账号
+
{{ $t("login.loginText") }}
@@ -11,14 +11,14 @@
- +
YesPlayMusic 承诺不会保存你的任何账号信息到云端。
@@ -112,7 +112,7 @@ export default { methods: { ...mapMutations(["updateUser", "updateUserInfo"]), afterLogin() { - Cookies.set("MUSIC_U", true, { expires: 3650 }); + // Cookies.set("MUSIC_U", true, { expires: 3650 }); Cookies.set("loginMode", "account", { expires: 3650 }); userPlaylist({ uid: this.$store.state.settings.user.userId, diff --git a/src/views/loginUsername.vue b/src/views/loginUsername.vue index 4683b77..3b4f809 100644 --- a/src/views/loginUsername.vue +++ b/src/views/loginUsername.vue @@ -1,14 +1,14 @@