mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 21:58:03 +00:00
fix: bugs
This commit is contained in:
parent
11eb29b3b8
commit
ee77b34ee9
13 changed files with 606 additions and 153 deletions
|
|
@ -16,6 +16,20 @@ export function userDetail(uid) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号详情
|
||||
* 说明 : 登录后调用此接口 ,可获取用户账号信息
|
||||
*/
|
||||
export function userAccount() {
|
||||
return request({
|
||||
url: "/user/account",
|
||||
method: "get",
|
||||
params: {
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户歌单
|
||||
* 说明 : 登录后调用此接口 , 传入用户 id, 可以获取用户歌单
|
||||
|
|
|
|||
|
|
@ -94,8 +94,8 @@ class Background {
|
|||
this.window = new BrowserWindow({
|
||||
width: this.store.get("window.width") | 1440,
|
||||
height: this.store.get("window.height") | 840,
|
||||
minWidth: 360,
|
||||
minHeight: 240,
|
||||
minWidth: 1080,
|
||||
minHeight: 720,
|
||||
titleBarStyle: "hiddenInset",
|
||||
frame: !withoutFrame,
|
||||
webPreferences: {
|
||||
|
|
@ -140,11 +140,9 @@ class Background {
|
|||
});
|
||||
};
|
||||
|
||||
if (process.platform === "darwin") {
|
||||
autoUpdater.on("update-available", (info) => {
|
||||
showNewVersionMessage(info);
|
||||
});
|
||||
}
|
||||
autoUpdater.on("update-available", (info) => {
|
||||
showNewVersionMessage(info);
|
||||
});
|
||||
}
|
||||
|
||||
handleWindowEvents() {
|
||||
|
|
@ -176,7 +174,6 @@ class Background {
|
|||
["win32", "linux"].includes(process.platform) &&
|
||||
this.store.get("settings.minimizeToTray")
|
||||
) {
|
||||
this.tray = createTray(this.window);
|
||||
this.window.hide();
|
||||
}
|
||||
});
|
||||
|
|
@ -209,6 +206,11 @@ class Background {
|
|||
// create menu
|
||||
createMenu(this.window);
|
||||
|
||||
// create tray
|
||||
if (["win32", "linux"].includes(process.platform)) {
|
||||
this.tray = createTray(this.window);
|
||||
}
|
||||
|
||||
// create dock menu for macOS
|
||||
app.dock.setMenu(createDockMenu(this.window));
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ export function createTray(win) {
|
|||
|
||||
tray.on("click", () => {
|
||||
win.show();
|
||||
tray.destroy();
|
||||
});
|
||||
|
||||
tray.on("right-click", () => {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ export default class {
|
|||
this._playing = false;
|
||||
this._isPersonalFM = false;
|
||||
this._personalFMTrack = { id: 0 };
|
||||
this._personalFMNextTrack = { id: 0 };
|
||||
|
||||
this._howler = null;
|
||||
Object.defineProperty(this, "_howler", {
|
||||
|
|
@ -112,19 +113,27 @@ export default class {
|
|||
_init() {
|
||||
Howler.autoUnlock = false;
|
||||
Howler.usingWebAudio = true;
|
||||
Howler.masterGain = true;
|
||||
this._loadSelfFromLocalStorage();
|
||||
this._replaceCurrentTrack(this._currentTrack.id, false).then(() => {
|
||||
this._howler.seek(localStorage.getItem("playerCurrentTrackTime") ?? 0);
|
||||
setInterval(
|
||||
() =>
|
||||
localStorage.setItem("playerCurrentTrackTime", this._howler.seek()),
|
||||
1000
|
||||
);
|
||||
}); // update audio source and init howler
|
||||
this._initMediaSession();
|
||||
if (this._enabled) {
|
||||
this._replaceCurrentTrack(this._currentTrack.id, false).then(() => {
|
||||
this._howler.seek(localStorage.getItem("playerCurrentTrackTime") ?? 0);
|
||||
setInterval(
|
||||
() =>
|
||||
localStorage.setItem("playerCurrentTrackTime", this._howler.seek()),
|
||||
1000
|
||||
);
|
||||
}); // update audio source and init howler
|
||||
this._initMediaSession();
|
||||
}
|
||||
Howler.volume(this.volume);
|
||||
this._loadPersonalFMTrack();
|
||||
if (this._personalFMTrack.id === 0 || this._personalFMNextTrack.id === 0) {
|
||||
// init fm
|
||||
personalFM().then((result) => {
|
||||
this._personalFMTrack = result.data[0];
|
||||
this._personalFMNextTrack = result.data[1];
|
||||
return this._personalFMTrack;
|
||||
});
|
||||
}
|
||||
}
|
||||
_getNextTrack() {
|
||||
// 返回 [trackID, index]
|
||||
|
|
@ -298,10 +307,10 @@ export default class {
|
|||
this.playNextTrack();
|
||||
}
|
||||
}
|
||||
_loadPersonalFMTrack() {
|
||||
_loadPersonalFMNextTrack() {
|
||||
return personalFM().then((result) => {
|
||||
this._personalFMTrack = result.data[0];
|
||||
return this._personalFMTrack;
|
||||
this._personalFMNextTrack = result.data[0];
|
||||
return this._personalFMNextTrack;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -315,9 +324,9 @@ export default class {
|
|||
playNextTrack(isFM = false) {
|
||||
if (this._isPersonalFM || isFM) {
|
||||
this._isPersonalFM = true;
|
||||
this._loadPersonalFMTrack().then(() => {
|
||||
this._replaceCurrentTrack(this._personalFMTrack.id);
|
||||
});
|
||||
this._personalFMTrack = this._personalFMNextTrack;
|
||||
this._replaceCurrentTrack(this._personalFMTrack.id);
|
||||
this._loadPersonalFMNextTrack();
|
||||
return true;
|
||||
}
|
||||
// TODO: 切换歌曲时增加加载中的状态
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ const service = axios.create({
|
|||
});
|
||||
|
||||
service.interceptors.request.use(function (config) {
|
||||
if (!config.params) config.params = {};
|
||||
config.params.cookie = `MUSIC_U=${Cookies.get("MUSIC_U")};`;
|
||||
return config;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ import { mapActions, mapMutations, mapState } from "vuex";
|
|||
import { getTrackDetail, getLyric } from "@/api/track";
|
||||
import {
|
||||
userDetail,
|
||||
userAccount,
|
||||
userPlaylist,
|
||||
likedAlbums,
|
||||
likedArtists,
|
||||
|
|
@ -169,9 +170,21 @@ export default {
|
|||
},
|
||||
created() {
|
||||
NProgress.start();
|
||||
userDetail(this.data.user.userId).then((data) => {
|
||||
this.$store.commit("updateData", { key: "user", value: data.profile });
|
||||
});
|
||||
if (isAccountLoggedIn()) {
|
||||
userAccount().then((result) => {
|
||||
this.$store.commit("updateData", {
|
||||
key: "user",
|
||||
value: result.profile,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
userDetail(this.data.user.userId).then((result) => {
|
||||
this.$store.commit("updateData", {
|
||||
key: "user",
|
||||
value: result.profile,
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
if (!this.data.likedSongPlaylistID) {
|
||||
|
|
|
|||
|
|
@ -128,12 +128,7 @@
|
|||
</div>
|
||||
<div class="right-side">
|
||||
<transition name="slide-fade">
|
||||
<div
|
||||
class="lyrics-container"
|
||||
ref="lyricsContainer"
|
||||
v-show="!noLyric"
|
||||
@scroll="blurEffect($event)"
|
||||
>
|
||||
<div class="lyrics-container" ref="lyricsContainer" v-show="!noLyric">
|
||||
<div class="line" id="line-1"></div>
|
||||
<div
|
||||
class="line"
|
||||
|
|
@ -290,25 +285,6 @@ export default {
|
|||
this.seek(value);
|
||||
}
|
||||
},
|
||||
blurEffect(ev) {
|
||||
for (let i = 0; i < ev.target.children.length; i++) {
|
||||
const el = ev.target.children[i];
|
||||
|
||||
const distanceToCenterPercentage =
|
||||
Math.abs(
|
||||
el.getBoundingClientRect().y +
|
||||
el.clientHeight / 2 -
|
||||
window.innerHeight / 2
|
||||
) /
|
||||
(window.innerHeight / 2);
|
||||
const functionedEffectValue =
|
||||
1 - Math.sqrt(1 - Math.pow(distanceToCenterPercentage, 2));
|
||||
el.style.setProperty(
|
||||
"--func-val",
|
||||
isNaN(functionedEffectValue) ? "" : functionedEffectValue.toFixed(2)
|
||||
);
|
||||
}
|
||||
},
|
||||
setLyricsInterval() {
|
||||
this.lyricsInterval = setInterval(() => {
|
||||
const progress = this.player.seek() ?? 0;
|
||||
|
|
@ -321,36 +297,11 @@ export default {
|
|||
});
|
||||
if (oldHighlightLyricIndex !== this.highlightLyricIndex) {
|
||||
const el = document.getElementById(`line${this.highlightLyricIndex}`);
|
||||
if (el) {
|
||||
const duration = 500;
|
||||
var start;
|
||||
var animationProgress;
|
||||
const oldY = el.parentNode.scrollTop;
|
||||
const newY =
|
||||
el.offsetTop - window.innerHeight / 2 + el.clientHeight / 2;
|
||||
const distance = oldY - newY;
|
||||
var animation = (timeStamp) => {
|
||||
if (!start) {
|
||||
start = timeStamp;
|
||||
}
|
||||
animationProgress = (timeStamp - start) / duration;
|
||||
if (animationProgress < 1) {
|
||||
el.parentNode.scrollTo(
|
||||
0,
|
||||
oldY -
|
||||
Math.sqrt(
|
||||
2 * animationProgress - Math.pow(animationProgress, 2)
|
||||
) *
|
||||
distance
|
||||
);
|
||||
window.requestAnimationFrame(animation);
|
||||
} else {
|
||||
window.cancelAnimationFrame(animation);
|
||||
}
|
||||
};
|
||||
|
||||
window.requestAnimationFrame(animation);
|
||||
}
|
||||
if (el)
|
||||
el.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "center",
|
||||
});
|
||||
}
|
||||
}, 50);
|
||||
},
|
||||
|
|
@ -383,8 +334,6 @@ export default {
|
|||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$layoutBreakpoint: 1000px;
|
||||
|
||||
.lyrics-page {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
|
|
@ -493,28 +442,9 @@ $layoutBreakpoint: 1000px;
|
|||
height: 22px;
|
||||
width: 22px;
|
||||
}
|
||||
@media (max-width: $layoutBreakpoint) {
|
||||
button:nth-child(2) .svg-icon {
|
||||
height: 48px;
|
||||
width: 48px;
|
||||
}
|
||||
.svg-icon {
|
||||
height: 36px;
|
||||
width: 36px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: $layoutBreakpoint) {
|
||||
.controls {
|
||||
max-width: 100vw;
|
||||
width: calc(100vw - 2 * var(--main-content-padding-x));
|
||||
padding: var(--main-content-padding);
|
||||
margin-top: 48px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cover {
|
||||
|
|
@ -523,31 +453,18 @@ $layoutBreakpoint: 1000px;
|
|||
.cover-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@media (max-width: $layoutBreakpoint) {
|
||||
.cover-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
border-radius: 0.75em;
|
||||
width: 86vw;
|
||||
height: 86vw;
|
||||
max-width: 54vh;
|
||||
max-height: 54vh;
|
||||
width: 54vh;
|
||||
height: 54vh;
|
||||
user-select: none;
|
||||
object-fit: cover;
|
||||
}
|
||||
.shadow {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
width: 86vw;
|
||||
height: 86vw;
|
||||
max-width: 54vh;
|
||||
max-height: 54vh;
|
||||
height: 54vh;
|
||||
width: 54vh;
|
||||
filter: blur(16px) opacity(0.6);
|
||||
transform: scale(0.92, 0.96);
|
||||
z-index: -1;
|
||||
|
|
@ -570,29 +487,20 @@ $layoutBreakpoint: 1000px;
|
|||
overflow-y: auto;
|
||||
transition: 0.5s;
|
||||
.line {
|
||||
--func-val: 1;
|
||||
// margin-top: 38px;
|
||||
padding: 18px;
|
||||
transition: background 0.2s, transform 0.5s cubic-bezier(0.2, 0, 0, 1);
|
||||
transition: 0.2s;
|
||||
border-radius: 12px;
|
||||
filter: blur(12px);
|
||||
filter: blur(calc(var(--func-val) * 12px));
|
||||
opacity: calc(1 - var(--func-val));
|
||||
transform: scale(0.9) translate(-5%, 0);
|
||||
&:hover {
|
||||
background: var(--color-secondary-bg);
|
||||
}
|
||||
&#line-1 {
|
||||
pointer-events: none;
|
||||
}
|
||||
&.highlight {
|
||||
transform: scale(1) translate(0, 0);
|
||||
}
|
||||
span {
|
||||
opacity: 0.28;
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
.line#line-1:hover {
|
||||
background: unset;
|
||||
}
|
||||
.highlight span {
|
||||
opacity: 0.98;
|
||||
transition: 0.5s;
|
||||
|
|
@ -609,12 +517,6 @@ $layoutBreakpoint: 1000px;
|
|||
}
|
||||
}
|
||||
|
||||
@media (max-width: $layoutBreakpoint) {
|
||||
.right-side {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.close-button {
|
||||
position: fixed;
|
||||
top: 24px;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue