mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 05:38:04 +00:00
chore: format codes
This commit is contained in:
parent
6922c716e2
commit
9351f6bc89
73 changed files with 2321 additions and 2321 deletions
|
|
@ -1,13 +1,13 @@
|
|||
import { isAccountLoggedIn } from "./auth";
|
||||
import { refreshCookie } from "@/api/auth";
|
||||
import { dailySignin } from "@/api/user";
|
||||
import dayjs from "dayjs";
|
||||
import store from "@/store";
|
||||
import { isAccountLoggedIn } from './auth';
|
||||
import { refreshCookie } from '@/api/auth';
|
||||
import { dailySignin } from '@/api/user';
|
||||
import dayjs from 'dayjs';
|
||||
import store from '@/store';
|
||||
|
||||
export function isTrackPlayable(track) {
|
||||
let result = {
|
||||
playable: true,
|
||||
reason: "",
|
||||
reason: '',
|
||||
};
|
||||
// cloud storage judgement logic
|
||||
if (isAccountLoggedIn() && track?.privilege?.cs) {
|
||||
|
|
@ -18,27 +18,27 @@ export function isTrackPlayable(track) {
|
|||
result.playable = true;
|
||||
} else {
|
||||
result.playable = false;
|
||||
result.reason = "VIP Only";
|
||||
result.reason = 'VIP Only';
|
||||
}
|
||||
} else if (track.fee === 4 || track.privilege?.fee === 4) {
|
||||
result.playable = false;
|
||||
result.reason = "付费专辑";
|
||||
result.reason = '付费专辑';
|
||||
} else if (
|
||||
track.noCopyrightRcmd !== null &&
|
||||
track.noCopyrightRcmd !== undefined
|
||||
) {
|
||||
result.playable = false;
|
||||
result.reason = "无版权";
|
||||
result.reason = '无版权';
|
||||
} else if (track.privilege?.st < 0 && isAccountLoggedIn()) {
|
||||
result.playable = false;
|
||||
result.reason = "已下架";
|
||||
result.reason = '已下架';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function mapTrackPlayableStatus(tracks, privileges = []) {
|
||||
return tracks.map((t) => {
|
||||
const privilege = privileges.find((item) => item.id === t.id) || {};
|
||||
return tracks.map(t => {
|
||||
const privilege = privileges.find(item => item.id === t.id) || {};
|
||||
if (t.privilege) {
|
||||
Object.assign(t.privilege, privilege);
|
||||
} else {
|
||||
|
|
@ -63,13 +63,13 @@ export function randomNum(minNum, maxNum) {
|
|||
}
|
||||
|
||||
export function shuffleAList(list) {
|
||||
let sortsList = list.map((t) => t.sort);
|
||||
let sortsList = list.map(t => t.sort);
|
||||
for (let i = 1; i < sortsList.length; i++) {
|
||||
const random = Math.floor(Math.random() * (i + 1));
|
||||
[sortsList[i], sortsList[random]] = [sortsList[random], sortsList[i]];
|
||||
}
|
||||
let newSorts = {};
|
||||
list.map((track) => {
|
||||
list.map(track => {
|
||||
newSorts[track.id] = sortsList.pop();
|
||||
});
|
||||
return newSorts;
|
||||
|
|
@ -88,8 +88,8 @@ export function throttle(fn, time) {
|
|||
}
|
||||
|
||||
export function updateHttps(url) {
|
||||
if (!url) return "";
|
||||
return url.replace(/^http:/, "https:");
|
||||
if (!url) return '';
|
||||
return url.replace(/^http:/, 'https:');
|
||||
}
|
||||
|
||||
export function dailyTask() {
|
||||
|
|
@ -98,9 +98,9 @@ export function dailyTask() {
|
|||
isAccountLoggedIn() &&
|
||||
(lastDate === undefined || lastDate !== dayjs().date())
|
||||
) {
|
||||
console.log("execute dailyTask");
|
||||
store.commit("updateData", {
|
||||
key: "lastRefreshCookieDate",
|
||||
console.log('execute dailyTask');
|
||||
store.commit('updateData', {
|
||||
key: 'lastRefreshCookieDate',
|
||||
value: dayjs().date(),
|
||||
});
|
||||
refreshCookie();
|
||||
|
|
@ -110,85 +110,85 @@ export function dailyTask() {
|
|||
}
|
||||
|
||||
export function changeAppearance(appearance) {
|
||||
if (appearance === "auto" || appearance === undefined) {
|
||||
appearance = window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
? "dark"
|
||||
: "light";
|
||||
if (appearance === 'auto' || appearance === undefined) {
|
||||
appearance = window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
? 'dark'
|
||||
: 'light';
|
||||
}
|
||||
document.body.setAttribute("data-theme", appearance);
|
||||
document.body.setAttribute('data-theme', appearance);
|
||||
document
|
||||
.querySelector('meta[name="theme-color"]')
|
||||
.setAttribute("content", appearance === "dark" ? "#222" : "#fff");
|
||||
.setAttribute('content', appearance === 'dark' ? '#222' : '#fff');
|
||||
}
|
||||
|
||||
export function splitSoundtrackAlbumTitle(title) {
|
||||
let keywords = [
|
||||
"Music from the Original Motion Picture Score",
|
||||
"The Original Motion Picture Soundtrack",
|
||||
"Original MGM Motion Picture Soundtrack",
|
||||
"Complete Original Motion Picture Score",
|
||||
"Original Music From The Motion Picture",
|
||||
"Music From The Disney+ Original Movie",
|
||||
"Original Music From The Netflix Film",
|
||||
"Original Score to the Motion Picture",
|
||||
"Original Motion Picture Soundtrack",
|
||||
"Soundtrack from the Motion Picture",
|
||||
"Original Television Soundtrack",
|
||||
"Original Motion Picture Score",
|
||||
"Music From the Motion Picture",
|
||||
"Music From The Motion Picture",
|
||||
"Complete Motion Picture Score",
|
||||
"Music from the Motion Picture",
|
||||
"Original Videogame Soundtrack",
|
||||
"La Bande Originale du Film",
|
||||
"Music from the Miniseries",
|
||||
"Bande Originale du Film",
|
||||
"Die Original Filmmusik",
|
||||
"Original Soundtrack",
|
||||
"Complete Score",
|
||||
"Original Score",
|
||||
'Music from the Original Motion Picture Score',
|
||||
'The Original Motion Picture Soundtrack',
|
||||
'Original MGM Motion Picture Soundtrack',
|
||||
'Complete Original Motion Picture Score',
|
||||
'Original Music From The Motion Picture',
|
||||
'Music From The Disney+ Original Movie',
|
||||
'Original Music From The Netflix Film',
|
||||
'Original Score to the Motion Picture',
|
||||
'Original Motion Picture Soundtrack',
|
||||
'Soundtrack from the Motion Picture',
|
||||
'Original Television Soundtrack',
|
||||
'Original Motion Picture Score',
|
||||
'Music From the Motion Picture',
|
||||
'Music From The Motion Picture',
|
||||
'Complete Motion Picture Score',
|
||||
'Music from the Motion Picture',
|
||||
'Original Videogame Soundtrack',
|
||||
'La Bande Originale du Film',
|
||||
'Music from the Miniseries',
|
||||
'Bande Originale du Film',
|
||||
'Die Original Filmmusik',
|
||||
'Original Soundtrack',
|
||||
'Complete Score',
|
||||
'Original Score',
|
||||
];
|
||||
for (let keyword of keywords) {
|
||||
if (title.includes(keyword) === false) continue;
|
||||
return {
|
||||
title: title
|
||||
.replace(`(${keyword})`, "")
|
||||
.replace(`: ${keyword}`, "")
|
||||
.replace(`[${keyword}]`, "")
|
||||
.replace(`- ${keyword}`, "")
|
||||
.replace(`${keyword}`, ""),
|
||||
.replace(`(${keyword})`, '')
|
||||
.replace(`: ${keyword}`, '')
|
||||
.replace(`[${keyword}]`, '')
|
||||
.replace(`- ${keyword}`, '')
|
||||
.replace(`${keyword}`, ''),
|
||||
subtitle: keyword,
|
||||
};
|
||||
}
|
||||
return {
|
||||
title: title,
|
||||
subtitle: "",
|
||||
subtitle: '',
|
||||
};
|
||||
}
|
||||
|
||||
export function splitAlbumTitle(title) {
|
||||
let keywords = [
|
||||
"Bonus Tracks Edition",
|
||||
"Complete Edition",
|
||||
"Deluxe Edition",
|
||||
"Deluxe Version",
|
||||
"Tour Edition",
|
||||
'Bonus Tracks Edition',
|
||||
'Complete Edition',
|
||||
'Deluxe Edition',
|
||||
'Deluxe Version',
|
||||
'Tour Edition',
|
||||
];
|
||||
for (let keyword of keywords) {
|
||||
if (title.includes(keyword) === false) continue;
|
||||
return {
|
||||
title: title
|
||||
.replace(`(${keyword})`, "")
|
||||
.replace(`: ${keyword}`, "")
|
||||
.replace(`[${keyword}]`, "")
|
||||
.replace(`- ${keyword}`, "")
|
||||
.replace(`${keyword}`, ""),
|
||||
.replace(`(${keyword})`, '')
|
||||
.replace(`: ${keyword}`, '')
|
||||
.replace(`[${keyword}]`, '')
|
||||
.replace(`- ${keyword}`, '')
|
||||
.replace(`${keyword}`, ''),
|
||||
subtitle: keyword,
|
||||
};
|
||||
}
|
||||
return {
|
||||
title: title,
|
||||
subtitle: "",
|
||||
subtitle: '',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -201,17 +201,17 @@ export function bytesToSize(bytes) {
|
|||
|
||||
let lang = store.state.settings.lang;
|
||||
|
||||
if (bytes < kiloBytes) return bytes + (lang === "en" ? " Bytes" : "字节");
|
||||
if (bytes < kiloBytes) return bytes + (lang === 'en' ? ' Bytes' : '字节');
|
||||
else if (bytes < megaBytes)
|
||||
return (bytes / kiloBytes).toFixed(decimal) + " KB";
|
||||
return (bytes / kiloBytes).toFixed(decimal) + ' KB';
|
||||
else if (bytes < gigaBytes)
|
||||
return (bytes / megaBytes).toFixed(decimal) + " MB";
|
||||
else return (bytes / gigaBytes).toFixed(decimal) + " GB";
|
||||
return (bytes / megaBytes).toFixed(decimal) + ' MB';
|
||||
else return (bytes / gigaBytes).toFixed(decimal) + ' GB';
|
||||
}
|
||||
|
||||
export function formatTrackTime(value) {
|
||||
if (!value) return "";
|
||||
if (!value) return '';
|
||||
let min = ~~((value / 60) % 60);
|
||||
let sec = (~~(value % 60)).toString().padStart(2, "0");
|
||||
let sec = (~~(value % 60)).toString().padStart(2, '0');
|
||||
return `${min}:${sec}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue