2020-10-10 19:54:44 +08:00
|
|
|
<template>
|
|
|
|
<div id="app">
|
2020-11-03 23:34:43 +08:00
|
|
|
<Navbar ref="navbar"/>
|
2020-10-10 19:54:44 +08:00
|
|
|
<main>
|
|
|
|
<keep-alive>
|
|
|
|
<router-view v-if="$route.meta.keepAlive"></router-view>
|
|
|
|
</keep-alive>
|
|
|
|
<router-view v-if="!$route.meta.keepAlive"></router-view>
|
|
|
|
</main>
|
|
|
|
<transition name="slide-up">
|
2020-10-14 21:10:45 +08:00
|
|
|
<Player
|
2020-10-14 15:39:41 +08:00
|
|
|
v-if="this.$store.state.player.enable"
|
|
|
|
ref="player"
|
2020-10-17 00:18:24 +08:00
|
|
|
v-show="
|
|
|
|
['mv', 'loginUsername', 'login', 'loginAccount'].includes(
|
|
|
|
this.$route.name
|
|
|
|
) === false
|
|
|
|
"
|
2020-10-10 19:54:44 +08:00
|
|
|
/></transition>
|
2020-10-14 21:10:45 +08:00
|
|
|
<GlobalEvents :filter="globalEventFilter" @keydown.space="play" />
|
2020-10-10 19:54:44 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Navbar from "./components/Navbar.vue";
|
2020-10-14 21:10:45 +08:00
|
|
|
import Player from "./components/Player.vue";
|
2020-10-10 19:54:44 +08:00
|
|
|
import GlobalEvents from "vue-global-events";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "App",
|
|
|
|
components: {
|
|
|
|
Navbar,
|
2020-10-14 21:10:45 +08:00
|
|
|
Player,
|
2020-10-22 21:44:34 +08:00
|
|
|
GlobalEvents,
|
2020-10-10 19:54:44 +08:00
|
|
|
},
|
2020-10-31 14:03:23 +08:00
|
|
|
data() {
|
|
|
|
return {
|
2020-10-31 14:03:41 +08:00
|
|
|
isElectron: process.env.IS_ELECTRON, // "true" || undefined
|
|
|
|
};
|
2020-10-31 14:03:23 +08:00
|
|
|
},
|
2020-10-30 10:59:26 +08:00
|
|
|
created() {
|
2020-10-31 14:03:23 +08:00
|
|
|
if (this.isElectron) {
|
2020-11-03 23:34:43 +08:00
|
|
|
const self = this
|
2020-10-31 14:03:23 +08:00
|
|
|
// 添加专有的类名
|
2020-10-31 14:03:41 +08:00
|
|
|
document.body.classList.add("is-electron");
|
2020-10-31 14:03:23 +08:00
|
|
|
// ipc message channel
|
|
|
|
const electron = window.require("electron");
|
|
|
|
const ipcRenderer = electron.ipcRenderer;
|
|
|
|
// listens to the main process 'changeRouteTo' event and changes the route from
|
|
|
|
// inside this Vue instance, according to what path the main process requires.
|
|
|
|
// responds to Menu click() events at the main process and changes the route accordingly.
|
|
|
|
ipcRenderer.on("changeRouteTo", (event, path) => {
|
2020-11-03 23:34:43 +08:00
|
|
|
self.$router.push(path);
|
2020-10-31 14:03:23 +08:00
|
|
|
});
|
2020-11-03 23:34:43 +08:00
|
|
|
ipcRenderer.on("search", () => {
|
|
|
|
// 触发数据响应
|
|
|
|
self.$refs.navbar.$refs.searchInput.focus()
|
|
|
|
self.$refs.navbar.inputFocus = true
|
|
|
|
})
|
2020-10-31 14:03:23 +08:00
|
|
|
ipcRenderer.on("play", () => {
|
2020-11-03 23:34:43 +08:00
|
|
|
self.$refs.player.play();
|
2020-10-31 14:03:23 +08:00
|
|
|
});
|
|
|
|
ipcRenderer.on("next", () => {
|
2020-11-03 23:34:43 +08:00
|
|
|
self.$refs.player.next();
|
2020-10-31 14:03:23 +08:00
|
|
|
});
|
|
|
|
ipcRenderer.on("previous", () => {
|
2020-11-03 23:34:43 +08:00
|
|
|
self.$refs.player.previous();
|
2020-10-31 14:03:23 +08:00
|
|
|
});
|
|
|
|
ipcRenderer.on("increaseVolume", () => {
|
2020-11-03 23:34:43 +08:00
|
|
|
if (self.$refs.player.volume + 0.1 >= 1) {
|
|
|
|
return (self.$refs.player.volume = 1);
|
2020-10-31 14:03:23 +08:00
|
|
|
}
|
2020-11-03 23:34:43 +08:00
|
|
|
self.$refs.player.volume += 0.1;
|
2020-10-31 14:03:23 +08:00
|
|
|
});
|
|
|
|
ipcRenderer.on("decreaseVolume", () => {
|
2020-11-03 23:34:43 +08:00
|
|
|
if (self.$refs.player.volume - 0.1 <= 0) {
|
|
|
|
return (self.$refs.player.volume = 0);
|
2020-10-31 14:03:23 +08:00
|
|
|
}
|
2020-11-03 23:34:43 +08:00
|
|
|
self.$refs.player.volume -= 0.1;
|
2020-10-31 14:03:23 +08:00
|
|
|
});
|
|
|
|
ipcRenderer.on("like", () => {
|
2020-11-03 23:34:43 +08:00
|
|
|
self.$refs.player.likeCurrentSong();
|
2020-10-31 14:03:23 +08:00
|
|
|
});
|
|
|
|
ipcRenderer.on("repeat", () => {
|
2020-11-03 23:34:43 +08:00
|
|
|
self.$refs.player.repeat();
|
2020-10-31 14:03:23 +08:00
|
|
|
});
|
|
|
|
ipcRenderer.on("shuffle", () => {
|
2020-11-03 23:34:43 +08:00
|
|
|
self.$refs.player.shuffle();
|
2020-10-31 14:03:23 +08:00
|
|
|
});
|
|
|
|
}
|
2020-10-29 18:46:54 +08:00
|
|
|
},
|
2020-10-10 19:54:44 +08:00
|
|
|
methods: {
|
|
|
|
play(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
this.$refs.player.play();
|
|
|
|
},
|
2020-10-14 21:10:45 +08:00
|
|
|
globalEventFilter(event) {
|
|
|
|
if (event.target.tagName === "INPUT") return false;
|
|
|
|
if (this.$route.name === "mv") return false;
|
|
|
|
return true;
|
2020-10-22 21:44:34 +08:00
|
|
|
},
|
|
|
|
},
|
2020-10-10 19:54:44 +08:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import url("https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,500;0,600;0,700;0,800;0,900;1,500;1,600;1,700;1,800;1,900&display=swap");
|
|
|
|
|
2020-10-25 21:04:33 +08:00
|
|
|
:root {
|
|
|
|
--color-body-bg: #ffffff;
|
|
|
|
--color-text: #000;
|
|
|
|
--color-primary: #335eea;
|
|
|
|
--color-primary-bg: #eaeffd;
|
|
|
|
--color-secondary: #7a7a7b;
|
|
|
|
--color-secondary-bg: #f5f5f7;
|
|
|
|
--color-navbar-bg: rgba(255, 255, 255, 0.86);
|
|
|
|
}
|
|
|
|
|
|
|
|
[data-theme="dark"] {
|
|
|
|
--color-body-bg: #222222;
|
|
|
|
--color-text: #ffffff;
|
|
|
|
--color-primary: #335eea;
|
|
|
|
--color-primary-bg: #bbcdff;
|
|
|
|
--color-secondary: #7a7a7b;
|
|
|
|
--color-secondary-bg: #323232;
|
|
|
|
--color-navbar-bg: #335eea;
|
|
|
|
--color-navbar-bg: rgba(34, 34, 34, 0.86);
|
|
|
|
}
|
|
|
|
|
2020-10-10 19:54:44 +08:00
|
|
|
#app {
|
|
|
|
font-family: "Barlow", -apple-system, BlinkMacSystemFont, Helvetica Neue,
|
|
|
|
PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans CJK SC,
|
|
|
|
WenQuanYi Micro Hei, sans-serif;
|
|
|
|
width: 100%;
|
2020-10-25 21:04:33 +08:00
|
|
|
transition: all 0.4s;
|
|
|
|
}
|
|
|
|
body {
|
|
|
|
background-color: var(--color-body-bg);
|
2020-10-10 19:54:44 +08:00
|
|
|
}
|
2020-10-17 00:18:24 +08:00
|
|
|
|
2020-10-10 19:54:44 +08:00
|
|
|
html {
|
|
|
|
overflow-y: overlay;
|
|
|
|
min-width: 1000px;
|
|
|
|
}
|
|
|
|
|
|
|
|
main {
|
|
|
|
margin-top: 96px;
|
|
|
|
margin-bottom: 96px;
|
|
|
|
padding: {
|
|
|
|
right: 10vw;
|
|
|
|
left: 10vw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-23 00:00:17 +08:00
|
|
|
select,
|
2020-10-10 19:54:44 +08:00
|
|
|
button {
|
2020-10-20 21:40:01 +08:00
|
|
|
font-family: inherit;
|
2020-10-23 00:00:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
button {
|
2020-10-10 19:54:44 +08:00
|
|
|
background: none;
|
|
|
|
border: none;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
input,
|
|
|
|
button {
|
|
|
|
&:focus {
|
|
|
|
outline: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
a {
|
|
|
|
color: inherit;
|
|
|
|
text-decoration: none;
|
2020-10-31 12:05:28 +08:00
|
|
|
cursor: pointer;
|
2020-10-10 19:54:44 +08:00
|
|
|
&:hover {
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-31 14:03:23 +08:00
|
|
|
// for electron
|
|
|
|
body.is-electron::-webkit-scrollbar {
|
|
|
|
width: 0;
|
|
|
|
}
|
|
|
|
|
2020-10-10 19:54:44 +08:00
|
|
|
/* Let's get this party started */
|
|
|
|
::-webkit-scrollbar {
|
|
|
|
width: 8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
::-webkit-scrollbar-track {
|
|
|
|
background: transparent;
|
2020-10-25 21:04:33 +08:00
|
|
|
border-left: 1px solid rgba(128, 128, 128, 0.18);
|
2020-10-10 19:54:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
|
|
-webkit-border-radius: 10px;
|
|
|
|
border-radius: 10px;
|
2020-10-25 21:04:33 +08:00
|
|
|
background: var(--color-secondary-bg);
|
2020-10-10 19:54:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.slide-up-enter-active,
|
|
|
|
.slide-up-leave-active {
|
|
|
|
transition: all 0.4s;
|
|
|
|
}
|
|
|
|
.slide-up-enter, .slide-up-leave-to /* .fade-leave-active below version 2.1.8 */ {
|
|
|
|
transform: translateY(100%);
|
|
|
|
}
|
|
|
|
</style>
|