mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 05:38:04 +00:00
feat: add show lyrics translation to settings
This commit is contained in:
parent
d4be289946
commit
0dd30e251f
6 changed files with 53 additions and 9 deletions
|
|
@ -4,13 +4,10 @@ import state from "./state";
|
||||||
import mutations from "./mutations";
|
import mutations from "./mutations";
|
||||||
import actions from "./actions";
|
import actions from "./actions";
|
||||||
import { changeAppearance } from "@/utils/common";
|
import { changeAppearance } from "@/utils/common";
|
||||||
import updateApp from "@/utils/updateApp";
|
|
||||||
import Player from "@/utils/Player";
|
import Player from "@/utils/Player";
|
||||||
// vuex 自定义插件
|
// vuex 自定义插件
|
||||||
import saveToLocalStorage from "./plugins/localStorage";
|
import saveToLocalStorage from "./plugins/localStorage";
|
||||||
|
|
||||||
updateApp();
|
|
||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
||||||
let plugins = [saveToLocalStorage];
|
let plugins = [saveToLocalStorage];
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ let localStorage = {
|
||||||
showUnavailableSongInGreyStyle: true,
|
showUnavailableSongInGreyStyle: true,
|
||||||
automaticallyCacheSongs: false,
|
automaticallyCacheSongs: false,
|
||||||
nyancatStyle: false,
|
nyancatStyle: false,
|
||||||
|
showLyricsTranslation: true,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
user: {},
|
user: {},
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import initLocalStorage from "./initLocalStorage";
|
import initLocalStorage from "./initLocalStorage";
|
||||||
import pkg from "../../package.json";
|
import pkg from "../../package.json";
|
||||||
|
import updateApp from "@/utils/updateApp";
|
||||||
|
|
||||||
if (localStorage.getItem("appVersion") === null) {
|
if (localStorage.getItem("appVersion") === null) {
|
||||||
localStorage.setItem("settings", JSON.stringify(initLocalStorage.settings));
|
localStorage.setItem("settings", JSON.stringify(initLocalStorage.settings));
|
||||||
|
|
@ -7,6 +8,8 @@ if (localStorage.getItem("appVersion") === null) {
|
||||||
localStorage.setItem("appVersion", pkg.version);
|
localStorage.setItem("appVersion", pkg.version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateApp();
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
showLyrics: false,
|
showLyrics: false,
|
||||||
liked: {
|
liked: {
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,19 @@ import pkg from "../../package.json";
|
||||||
|
|
||||||
const updateSetting = () => {
|
const updateSetting = () => {
|
||||||
const parsedSettings = JSON.parse(localStorage.getItem("settings"));
|
const parsedSettings = JSON.parse(localStorage.getItem("settings"));
|
||||||
|
const {
|
||||||
|
playlistCategories,
|
||||||
|
showUnavailableSongInGreyStyle,
|
||||||
|
automaticallyCacheSongs,
|
||||||
|
nyancatStyle,
|
||||||
|
showLyricsTranslation,
|
||||||
|
} = initLocalStorage.settings;
|
||||||
const settings = {
|
const settings = {
|
||||||
playlistCategories: initLocalStorage?.settings?.playlistCategories,
|
playlistCategories,
|
||||||
showUnavailableSongInGreyStyle:
|
showUnavailableSongInGreyStyle,
|
||||||
initLocalStorage?.settings?.showUnavailableSongInGreyStyle,
|
automaticallyCacheSongs,
|
||||||
automaticallyCacheSongs:
|
nyancatStyle,
|
||||||
initLocalStorage?.settings?.automaticallyCacheSongs,
|
showLyricsTranslation,
|
||||||
nyancatStyle: initLocalStorage?.settings?.nyancatStyle,
|
|
||||||
...parsedSettings,
|
...parsedSettings,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@
|
||||||
"
|
"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
v-html="formatLine(line)"
|
||||||
</div>
|
</div>
|
||||||
<div class="close-button" @click="toggleLyrics">
|
<div class="close-button" @click="toggleLyrics">
|
||||||
<button><svg-icon icon-class="arrow-down" /></button>
|
<button><svg-icon icon-class="arrow-down" /></button>
|
||||||
|
|
@ -274,6 +275,15 @@ export default {
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
},
|
},
|
||||||
|
formatLine(line) {
|
||||||
|
const showLyricsTranslation = this.$store.state.settings
|
||||||
|
.showLyricsTranslation;
|
||||||
|
if (showLyricsTranslation && line.contents[1]) {
|
||||||
|
return line.contents[0] + "<br/>" + line.contents[1];
|
||||||
|
} else {
|
||||||
|
return line.contents[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
currentTrack() {
|
currentTrack() {
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,22 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="item">
|
||||||
|
<div class="left">
|
||||||
|
<div class="title">显示歌词翻译</div>
|
||||||
|
</div>
|
||||||
|
<div class="right">
|
||||||
|
<div class="toggle">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="show-lyrics-translation"
|
||||||
|
id="show-lyrics-translation"
|
||||||
|
v-model="showLyricsTranslation"
|
||||||
|
/>
|
||||||
|
<label for="show-lyrics-translation"></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<div class="title"> {{ $t("settings.showGitHubIcon") }} </div>
|
<div class="title"> {{ $t("settings.showGitHubIcon") }} </div>
|
||||||
|
|
@ -294,6 +310,17 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
showLyricsTranslation: {
|
||||||
|
get() {
|
||||||
|
return this.settings.showLyricsTranslation;
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
this.$store.commit("updateSettings", {
|
||||||
|
key: "showLyricsTranslation",
|
||||||
|
value,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
logout() {
|
logout() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue