mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-18 06:07:48 +00:00
feat: refresh cookie every day to keep user logged in
This commit is contained in:
parent
780b429fa9
commit
7d456f7460
5 changed files with 26 additions and 3 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import { isAccountLoggedIn } from "./auth";
|
||||
import { refreshCookie } from "@/api/auth";
|
||||
import dayjs from "dayjs";
|
||||
import store from "@/store";
|
||||
|
||||
export function isTrackPlayable(track) {
|
||||
|
|
@ -61,7 +63,7 @@ export function shuffleAList(list) {
|
|||
|
||||
export function throttle(fn, time) {
|
||||
let isRun = false;
|
||||
return function () {
|
||||
return function() {
|
||||
if (isRun) return;
|
||||
isRun = true;
|
||||
fn.apply(this, arguments);
|
||||
|
|
@ -75,3 +77,17 @@ export function updateHttps(url) {
|
|||
if (!url) return "";
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue