diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..fcadb2cf97 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text eol=lf diff --git a/package.json b/package.json index 28f6120e4a..bf8dd9567e 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,8 @@ "electron-log": "^4.3.0", "electron-store": "^6.0.1", "electron-updater": "^4.3.5", + "eslint-config-prettier": "^8.1.0", + "eslint-plugin-prettier": "^3.3.1", "express": "^4.17.1", "express-fileupload": "^1.2.0", "express-http-proxy": "^1.6.2", @@ -92,7 +94,8 @@ }, "extends": [ "plugin:vue/essential", - "eslint:recommended" + "eslint:recommended", + "plugin:prettier/recommended" ], "parserOptions": { "parser": "babel-eslint" diff --git a/src/background.js b/src/background.js index 5d2a7c0e8c..a3ce22668c 100644 --- a/src/background.js +++ b/src/background.js @@ -12,7 +12,6 @@ import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer"; import express from "express"; import expressProxy from "express-http-proxy"; import Store from "electron-store"; -import path from "path"; class Background { constructor() { diff --git a/src/electron/touchBar.js b/src/electron/touchBar.js index 7976dabda9..f4fc825a6b 100644 --- a/src/electron/touchBar.js +++ b/src/electron/touchBar.js @@ -10,6 +10,7 @@ export function createTouchBar(window) { // Icon Resource: https://devimages-cdn.apple.com/design/resources/ function getNativeIcon(name) { return nativeImage.createFromPath( + // eslint-disable-next-line no-undef path.join(__static, "img/touchbar/", name) ); } diff --git a/src/locale/lang/en.js b/src/locale/lang/en.js index 9337d7550a..c702e98661 100644 --- a/src/locale/lang/en.js +++ b/src/locale/lang/en.js @@ -27,6 +27,11 @@ export default { albums: "Albums", artists: "Artists", mvs: "MVs", + newPlayList: "New Playlist", + userProfileMenu: { + settings: "Settings", + logout: "Logout", + }, }, explore: { explore: "Explore", @@ -129,6 +134,8 @@ export default { automaticallyCacheSongs: "Automatically cache songs", clearSongsCache: "Clear Songs Cache", cacheCount: "Cached {song} songs ({size})", + showLyricsTranslation: "Show lyrics translation", + minimizeToTray: "Minimize to tray", showGitHubIcon: "Show GitHub icon", showUnavailableSongInGreyStyle: "Show unavailable song in grey style", showPlaylistsByAppleMusic: "Show playlists by Apple Music", diff --git a/src/locale/lang/zh-CN.js b/src/locale/lang/zh-CN.js index 3b7e0a17a6..1fcf9063b4 100644 --- a/src/locale/lang/zh-CN.js +++ b/src/locale/lang/zh-CN.js @@ -24,6 +24,11 @@ export default { albums: "专辑", artists: "艺人", mvs: "MV", + newPlayList: "新建歌单", + userProfileMenu: { + settings: "设置", + logout: "退出登录", + }, }, explore: { explore: "发现", @@ -130,6 +135,8 @@ export default { automaticallyCacheSongs: "自动缓存歌曲", clearSongsCache: "清除歌曲缓存", cacheCount: "已缓存 {song} 首 ({size})", + showLyricsTranslation: "显示歌词翻译", + minimizeToTray: "最小化到托盘", showGitHubIcon: "显示 GitHub 图标", showUnavailableSongInGreyStyle: "显示不可播放的歌曲为灰色", showPlaylistsByAppleMusic: "首页显示来自 Apple Music 的歌单", diff --git a/src/store/index.js b/src/store/index.js index 4562017156..53da26cd4b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -26,9 +26,10 @@ const options = { const store = new Vuex.Store(options); 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; + const defaultLang = "en"; + // when more languages are available, use Map instead of prefer logic + const preferChinese = navigator.language.slice(0, 2) === "zh"; + store.state.settings.lang = preferChinese ? "zh-CN" : defaultLang; localStorage.setItem("settings", JSON.stringify(store.state.settings)); } diff --git a/src/views/library.vue b/src/views/library.vue index ebfeeccb25..6349515fc2 100644 --- a/src/views/library.vue +++ b/src/views/library.vue @@ -80,7 +80,7 @@ icon="plus" v-show="currentTab === 'playlists'" @click="openAddPlaylistModal" - >新建歌单{{ $t("library.newPlayList") }} @@ -114,12 +114,14 @@ -
设置
-
退出登录
+
+ + {{ $t("library.userProfileMenu.settings") }} +
+
+ + {{ $t("library.userProfileMenu.logout") }} +
diff --git a/src/views/settings.vue b/src/views/settings.vue index 7a51c6c874..85d917209b 100644 --- a/src/views/settings.vue +++ b/src/views/settings.vue @@ -128,7 +128,7 @@
-
显示歌词翻译
+
{{ $t("settings.showLyricsTranslation") }}
@@ -144,7 +144,7 @@
-
最小化到托盘
+
{{ $t("settings.minimizeToTray") }}
diff --git a/yarn.lock b/yarn.lock index 9aa1641646..8bdd9011cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4813,6 +4813,11 @@ escodegen@^1.8.1: optionalDependencies: source-map "~0.6.1" +eslint-config-prettier@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.1.0.tgz#4ef1eaf97afe5176e6a75ddfb57c335121abc5a6" + integrity sha512-oKMhGv3ihGbCIimCAjqkdzx2Q+jthoqnXSP+d86M9tptwugycmTFdVR4IpLgq2c4SHifbwO90z2fQ8/Aio73yw== + eslint-loader@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/eslint-loader/-/eslint-loader-2.2.1.tgz#28b9c12da54057af0845e2a6112701a2f6bf8337" @@ -4824,6 +4829,13 @@ eslint-loader@^2.2.1: object-hash "^1.1.4" rimraf "^2.6.1" +eslint-plugin-prettier@^3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz#7079cfa2497078905011e6f82e8dd8453d1371b7" + integrity sha512-Rq3jkcFY8RYeQLgk2cCwuc0P7SEFwDravPhsJZOQ5N4YI4DSg50NyqJ/9gdZHzQlHf8MvafSesbNJCcP/FF6pQ== + dependencies: + prettier-linter-helpers "^1.0.0" + eslint-plugin-vue@^6.2.2: version "6.2.2" resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-6.2.2.tgz#27fecd9a3a24789b0f111ecdd540a9e56198e0fe" @@ -5203,6 +5215,11 @@ fast-deep-equal@^3.1.1: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== +fast-diff@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" + integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== + fast-glob@^2.2.6: version "2.2.7" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d" @@ -9166,6 +9183,13 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + prettier@2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5"