mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2025-03-03 04:26:23 +08:00
feat: refresh cookie every day to keep user logged in
This commit is contained in:
parent
780b429fa9
commit
7d456f7460
src
@ -27,7 +27,7 @@ export function loginWithEmail(params) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loginRefresh() {
|
export function refreshCookie() {
|
||||||
return request({
|
return request({
|
||||||
url: "/login/refresh",
|
url: "/login/refresh",
|
||||||
method: "post",
|
method: "post",
|
||||||
|
@ -8,6 +8,7 @@ import "@/assets/icons";
|
|||||||
import "@/utils/filters";
|
import "@/utils/filters";
|
||||||
import { initMediaSession } from "@/utils/mediaSession";
|
import { initMediaSession } from "@/utils/mediaSession";
|
||||||
import "./registerServiceWorker";
|
import "./registerServiceWorker";
|
||||||
|
import { dailyTask } from "@/utils/common";
|
||||||
|
|
||||||
import * as Sentry from "@sentry/browser";
|
import * as Sentry from "@sentry/browser";
|
||||||
import { Vue as VueIntegration } from "@sentry/integrations";
|
import { Vue as VueIntegration } from "@sentry/integrations";
|
||||||
@ -41,6 +42,8 @@ if (process.env.VUE_APP_ENABLE_SENTRY === "true") {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dailyTask();
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
i18n,
|
i18n,
|
||||||
store,
|
store,
|
||||||
|
@ -86,6 +86,9 @@ const initState = {
|
|||||||
},
|
},
|
||||||
lang: null,
|
lang: null,
|
||||||
musicQuality: 320000,
|
musicQuality: 320000,
|
||||||
|
showGithubIcon: true,
|
||||||
|
showPlaylistsByAppleMusic: true,
|
||||||
|
lastRefreshCookieDate: 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { isAccountLoggedIn } from "./auth";
|
import { isAccountLoggedIn } from "./auth";
|
||||||
|
import { refreshCookie } from "@/api/auth";
|
||||||
|
import dayjs from "dayjs";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
|
|
||||||
export function isTrackPlayable(track) {
|
export function isTrackPlayable(track) {
|
||||||
@ -75,3 +77,17 @@ export function updateHttps(url) {
|
|||||||
if (!url) return "";
|
if (!url) return "";
|
||||||
return url.replace(/^http:/, "https:");
|
return url.replace(/^http:/, "https:");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function dailyTask() {
|
||||||
|
if (
|
||||||
|
store.state.settings.lastRefreshCookieDate === undefined ||
|
||||||
|
store.state.settings.lastRefreshCookieDate !== dayjs().date()
|
||||||
|
) {
|
||||||
|
console.log("execute dailyTask");
|
||||||
|
store.commit("updateSettings", {
|
||||||
|
key: "lastRefreshCookieDate",
|
||||||
|
value: dayjs().date(),
|
||||||
|
});
|
||||||
|
refreshCookie();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
import { mapState } from "vuex";
|
import { mapState } from "vuex";
|
||||||
import { getTrackDetail, getLyric } from "@/api/track";
|
import { getTrackDetail, getLyric } from "@/api/track";
|
||||||
import { userDetail, userPlaylist } from "@/api/user";
|
import { userDetail, userPlaylist } from "@/api/user";
|
||||||
import { randomNum } from "@/utils/common";
|
import { randomNum, dailyTask } from "@/utils/common";
|
||||||
import { getPlaylistDetail } from "@/api/playlist";
|
import { getPlaylistDetail } from "@/api/playlist";
|
||||||
import { playPlaylistByID } from "@/utils/play";
|
import { playPlaylistByID } from "@/utils/play";
|
||||||
import NProgress from "nprogress";
|
import NProgress from "nprogress";
|
||||||
@ -98,6 +98,7 @@ export default {
|
|||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
this.loadData();
|
this.loadData();
|
||||||
|
dailyTask();
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["settings"]),
|
...mapState(["settings"]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user