mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-18 14:18:03 +00:00
chore: format codes
This commit is contained in:
parent
6922c716e2
commit
9351f6bc89
73 changed files with 2321 additions and 2321 deletions
|
|
@ -1,35 +1,35 @@
|
|||
import Cookies from "js-cookie";
|
||||
import { logout } from "@/api/auth";
|
||||
import store from "@/store";
|
||||
import Cookies from 'js-cookie';
|
||||
import { logout } from '@/api/auth';
|
||||
import store from '@/store';
|
||||
|
||||
export function doLogout() {
|
||||
logout();
|
||||
// 网易云的接口会自动移除该 cookies
|
||||
// Cookies.remove("MUSIC_U");
|
||||
// 更新状态仓库中的用户信息
|
||||
store.commit("updateData", { key: "user", value: {} });
|
||||
store.commit('updateData', { key: 'user', value: {} });
|
||||
// 更新状态仓库中的登录状态
|
||||
store.commit("updateData", { key: "loginMode", value: null });
|
||||
store.commit('updateData', { key: 'loginMode', value: null });
|
||||
// 更新状态仓库中的喜欢列表
|
||||
store.commit("updateData", { key: "likedSongPlaylistID", value: undefined });
|
||||
store.commit('updateData', { key: 'likedSongPlaylistID', value: undefined });
|
||||
}
|
||||
|
||||
// MUSIC_U 只有在账户登录的情况下才有
|
||||
export function isLoggedIn() {
|
||||
return Cookies.get("MUSIC_U") !== undefined ? true : false;
|
||||
return Cookies.get('MUSIC_U') !== undefined ? true : false;
|
||||
}
|
||||
|
||||
// 账号登录
|
||||
export function isAccountLoggedIn() {
|
||||
return (
|
||||
Cookies.get("MUSIC_U") !== undefined &&
|
||||
store.state.data.loginMode === "account"
|
||||
Cookies.get('MUSIC_U') !== undefined &&
|
||||
store.state.data.loginMode === 'account'
|
||||
);
|
||||
}
|
||||
|
||||
// 用户名搜索(用户数据为只读)
|
||||
export function isUsernameLoggedIn() {
|
||||
return store.state.data.loginMode === "username";
|
||||
return store.state.data.loginMode === 'username';
|
||||
}
|
||||
|
||||
// 账户登录或者用户名搜索都判断为登录,宽松检查
|
||||
|
|
@ -38,15 +38,15 @@ export function isLooseLoggedIn() {
|
|||
}
|
||||
|
||||
export function getMusicU(string) {
|
||||
const temp = string.split(";");
|
||||
const temp = string.split(';');
|
||||
if (!temp.length) {
|
||||
return undefined;
|
||||
}
|
||||
const MUSIC_U = temp.find((item) => item.includes("MUSIC_U"));
|
||||
const MUSIC_U = temp.find(item => item.includes('MUSIC_U'));
|
||||
if (MUSIC_U) {
|
||||
return MUSIC_U.split("=")[1];
|
||||
return MUSIC_U.split('=')[1];
|
||||
}
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
export function setMusicU(key, value) {
|
||||
|
|
@ -54,8 +54,8 @@ export function setMusicU(key, value) {
|
|||
}
|
||||
|
||||
export function setCookies(string) {
|
||||
const cookies = string.split(";;");
|
||||
cookies.map((cookie) => {
|
||||
const cookies = string.split(';;');
|
||||
cookies.map(cookie => {
|
||||
document.cookie = cookie;
|
||||
console.log(cookie);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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}`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,25 @@
|
|||
import axios from "axios";
|
||||
import Dexie from "dexie";
|
||||
import store from "@/store";
|
||||
import axios from 'axios';
|
||||
import Dexie from 'dexie';
|
||||
import store from '@/store';
|
||||
// import pkg from "../../package.json";
|
||||
|
||||
const db = new Dexie("yesplaymusic");
|
||||
const db = new Dexie('yesplaymusic');
|
||||
|
||||
db.version(2)
|
||||
.stores({
|
||||
trackSources: "&id",
|
||||
trackSources: '&id',
|
||||
})
|
||||
.upgrade((tx) =>
|
||||
.upgrade(tx =>
|
||||
tx
|
||||
.table("trackSources")
|
||||
.table('trackSources')
|
||||
.toCollection()
|
||||
.modify(
|
||||
(track) =>
|
||||
!track.createTime && (track.createTime = new Date().getTime())
|
||||
track => !track.createTime && (track.createTime = new Date().getTime())
|
||||
)
|
||||
);
|
||||
|
||||
db.version(1).stores({
|
||||
trackSources: "&id",
|
||||
trackSources: '&id',
|
||||
});
|
||||
|
||||
let tracksCacheBytes = 0;
|
||||
|
|
@ -33,7 +32,7 @@ async function deleteExcessCache() {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
const delCache = await db.trackSources.orderBy("createTime").first();
|
||||
const delCache = await db.trackSources.orderBy('createTime').first();
|
||||
await db.trackSources.delete(delCache.id);
|
||||
tracksCacheBytes -= delCache.source.byteLength;
|
||||
console.debug(
|
||||
|
|
@ -41,18 +40,18 @@ async function deleteExcessCache() {
|
|||
);
|
||||
deleteExcessCache();
|
||||
} catch (error) {
|
||||
console.debug("[debug][db.js] deleteExcessCacheFailed", error);
|
||||
console.debug('[debug][db.js] deleteExcessCacheFailed', error);
|
||||
}
|
||||
}
|
||||
|
||||
export function cacheTrackSource(trackInfo, url, bitRate, from = "netease") {
|
||||
export function cacheTrackSource(trackInfo, url, bitRate, from = 'netease') {
|
||||
const name = trackInfo.name;
|
||||
const artist = trackInfo.ar[0]?.name || trackInfo.artists[0]?.name;
|
||||
return axios
|
||||
.get(url, {
|
||||
responseType: "arraybuffer",
|
||||
responseType: 'arraybuffer',
|
||||
})
|
||||
.then((response) => {
|
||||
.then(response => {
|
||||
db.trackSources.put({
|
||||
id: trackInfo.id,
|
||||
source: response.data,
|
||||
|
|
@ -70,7 +69,7 @@ export function cacheTrackSource(trackInfo, url, bitRate, from = "netease") {
|
|||
}
|
||||
|
||||
export function getTrackSource(id) {
|
||||
return db.trackSources.get(Number(id)).then((track) => {
|
||||
return db.trackSources.get(Number(id)).then(track => {
|
||||
if (!track) return null;
|
||||
console.debug(
|
||||
`[debug][db.js] get track from cache 👉 ${track.name} by ${track.artist}`
|
||||
|
|
@ -82,7 +81,7 @@ export function getTrackSource(id) {
|
|||
export function countDBSize() {
|
||||
const trackSizes = [];
|
||||
return db.trackSources
|
||||
.each((track) => {
|
||||
.each(track => {
|
||||
trackSizes.push(track.source.byteLength);
|
||||
})
|
||||
.then(() => {
|
||||
|
|
@ -99,7 +98,7 @@ export function countDBSize() {
|
|||
}
|
||||
|
||||
export function clearDB() {
|
||||
return new Promise((resolve) => {
|
||||
return new Promise(resolve => {
|
||||
db.tables.forEach(function (table) {
|
||||
table.clear();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,63 +1,63 @@
|
|||
import Vue from "vue";
|
||||
import dayjs from "dayjs";
|
||||
import duration from "dayjs/plugin/duration";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
import locale from "@/locale";
|
||||
import Vue from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import duration from 'dayjs/plugin/duration';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import locale from '@/locale';
|
||||
|
||||
Vue.filter("formatTime", (Milliseconds, format = "HH:MM:SS") => {
|
||||
if (!Milliseconds) return "";
|
||||
Vue.filter('formatTime', (Milliseconds, format = 'HH:MM:SS') => {
|
||||
if (!Milliseconds) return '';
|
||||
dayjs.extend(duration);
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
let time = dayjs.duration(Milliseconds);
|
||||
let hours = time.hours().toString();
|
||||
let mins = time.minutes().toString();
|
||||
let seconds = time.seconds().toString().padStart(2, "0");
|
||||
let seconds = time.seconds().toString().padStart(2, '0');
|
||||
|
||||
if (format === "HH:MM:SS") {
|
||||
return hours !== "0"
|
||||
? `${hours}:${mins.padStart(2, "0")}:${seconds}`
|
||||
if (format === 'HH:MM:SS') {
|
||||
return hours !== '0'
|
||||
? `${hours}:${mins.padStart(2, '0')}:${seconds}`
|
||||
: `${mins}:${seconds}`;
|
||||
} else if (format === "Human") {
|
||||
const hoursUnit = locale.locale === "zh-CN" ? "小时" : "hr";
|
||||
const minitesUnit = locale.locale === "zh-CN" ? "分钟" : "min";
|
||||
return hours !== "0"
|
||||
} else if (format === 'Human') {
|
||||
const hoursUnit = locale.locale === 'zh-CN' ? '小时' : 'hr';
|
||||
const minitesUnit = locale.locale === 'zh-CN' ? '分钟' : 'min';
|
||||
return hours !== '0'
|
||||
? `${hours} ${hoursUnit} ${mins} ${minitesUnit}`
|
||||
: `${mins} ${minitesUnit}`;
|
||||
}
|
||||
});
|
||||
|
||||
Vue.filter("formatDate", (timestamp, format = "MMM D, YYYY") => {
|
||||
if (!timestamp) return "";
|
||||
if (locale.locale === "zh-CN") format = "YYYY年MM月DD日";
|
||||
Vue.filter('formatDate', (timestamp, format = 'MMM D, YYYY') => {
|
||||
if (!timestamp) return '';
|
||||
if (locale.locale === 'zh-CN') format = 'YYYY年MM月DD日';
|
||||
return dayjs(timestamp).format(format);
|
||||
});
|
||||
|
||||
Vue.filter("formatAlbumType", (type, album) => {
|
||||
if (!type) return "";
|
||||
if (type === "EP/Single") {
|
||||
return album.size === 1 ? "Single" : "EP";
|
||||
} else if (type === "Single") {
|
||||
return "Single";
|
||||
} else if (type === "专辑") {
|
||||
return "Album";
|
||||
Vue.filter('formatAlbumType', (type, album) => {
|
||||
if (!type) return '';
|
||||
if (type === 'EP/Single') {
|
||||
return album.size === 1 ? 'Single' : 'EP';
|
||||
} else if (type === 'Single') {
|
||||
return 'Single';
|
||||
} else if (type === '专辑') {
|
||||
return 'Album';
|
||||
} else {
|
||||
return type;
|
||||
}
|
||||
});
|
||||
|
||||
Vue.filter("resizeImage", (imgUrl, size = 512) => {
|
||||
if (!imgUrl) return "";
|
||||
Vue.filter('resizeImage', (imgUrl, size = 512) => {
|
||||
if (!imgUrl) return '';
|
||||
let httpsImgUrl = imgUrl;
|
||||
if (imgUrl.slice(0, 5) !== "https") {
|
||||
httpsImgUrl = "https" + imgUrl.slice(4);
|
||||
if (imgUrl.slice(0, 5) !== 'https') {
|
||||
httpsImgUrl = 'https' + imgUrl.slice(4);
|
||||
}
|
||||
return `${httpsImgUrl}?param=${size}y${size}`;
|
||||
});
|
||||
|
||||
Vue.filter("formatPlayCount", (count) => {
|
||||
if (!count) return "";
|
||||
if (locale.locale === "zh-CN") {
|
||||
Vue.filter('formatPlayCount', count => {
|
||||
if (!count) return '';
|
||||
if (locale.locale === 'zh-CN') {
|
||||
if (count > 100000000) {
|
||||
return `${Math.floor((count / 100000000) * 100) / 100}亿`; // 2.32 亿
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ Vue.filter("formatPlayCount", (count) => {
|
|||
}
|
||||
});
|
||||
|
||||
Vue.filter("toHttps", (url) => {
|
||||
if (!url) return "";
|
||||
return url.replace(/^http:/, "https:");
|
||||
Vue.filter('toHttps', url => {
|
||||
if (!url) return '';
|
||||
return url.replace(/^http:/, 'https:');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,29 +2,29 @@
|
|||
|
||||
export function lyricParser(lrc) {
|
||||
return {
|
||||
lyric: parseLyric(lrc?.lrc?.lyric || ""),
|
||||
tlyric: parseLyric(lrc?.tlyric?.lyric || ""),
|
||||
lyric: parseLyric(lrc?.lrc?.lyric || ''),
|
||||
tlyric: parseLyric(lrc?.tlyric?.lyric || ''),
|
||||
lyricuser: lrc.lyricUser,
|
||||
transuser: lrc.transUser,
|
||||
};
|
||||
}
|
||||
|
||||
export function parseLyric(lrc) {
|
||||
const lyrics = lrc.split("\n");
|
||||
const lyrics = lrc.split('\n');
|
||||
const lrcObj = [];
|
||||
for (let i = 0; i < lyrics.length; i++) {
|
||||
const lyric = decodeURIComponent(lyrics[i]);
|
||||
const timeReg = /\[\d*:\d*((\.|:)\d*)*\]/g;
|
||||
const timeRegExpArr = lyric.match(timeReg);
|
||||
if (!timeRegExpArr) continue;
|
||||
const content = lyric.replace(timeReg, "");
|
||||
const content = lyric.replace(timeReg, '');
|
||||
for (let k = 0, h = timeRegExpArr.length; k < h; k++) {
|
||||
const t = timeRegExpArr[k];
|
||||
const min = Number(String(t.match(/\[\d*/i)).slice(1));
|
||||
const sec = Number(String(t.match(/:\d*/i)).slice(1));
|
||||
const ms = Number(t.match(/\d*\]/i)[0].slice(0, 2)) / 100;
|
||||
const time = min * 60 + sec + ms;
|
||||
if (content !== "") {
|
||||
if (content !== '') {
|
||||
lrcObj.push({ time: time, rawTime: timeRegExpArr[0], content });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ const nativeAlert = (() => {
|
|||
if (process.env.IS_ELECTRON === true) {
|
||||
const {
|
||||
remote: { dialog },
|
||||
} = require("electron");
|
||||
} = require('electron');
|
||||
if (dialog) {
|
||||
return (message) => {
|
||||
return message => {
|
||||
var options = {
|
||||
type: "warning",
|
||||
type: 'warning',
|
||||
detail: message,
|
||||
};
|
||||
dialog.showMessageBoxSync(null, options);
|
||||
|
|
|
|||
|
|
@ -1,41 +1,41 @@
|
|||
export const byAppleMusic = [
|
||||
{
|
||||
coverImgUrl:
|
||||
"https://p2.music.126.net/GvYQoflE99eoeGi9jG4Bsw==/109951165375336156.jpg",
|
||||
name: "Happy Hits",
|
||||
'https://p2.music.126.net/GvYQoflE99eoeGi9jG4Bsw==/109951165375336156.jpg',
|
||||
name: 'Happy Hits',
|
||||
id: 5278068783,
|
||||
},
|
||||
{
|
||||
coverImgUrl:
|
||||
"https://p2.music.126.net/5CJeYN35LnzRDsv5Lcs0-Q==/109951165374966765.jpg",
|
||||
name: "\u4e2d\u563b\u5408\u74a7",
|
||||
'https://p2.music.126.net/5CJeYN35LnzRDsv5Lcs0-Q==/109951165374966765.jpg',
|
||||
name: '\u4e2d\u563b\u5408\u74a7',
|
||||
id: 5277771961,
|
||||
},
|
||||
{
|
||||
coverImgUrl:
|
||||
"https://p1.music.126.net/cPaBXr1wZSg86ddl47AK7Q==/109951165375130918.jpg",
|
||||
name: "Heartbreak Pop",
|
||||
'https://p1.music.126.net/cPaBXr1wZSg86ddl47AK7Q==/109951165375130918.jpg',
|
||||
name: 'Heartbreak Pop',
|
||||
id: 5277965913,
|
||||
},
|
||||
{
|
||||
coverImgUrl:
|
||||
"https://p2.music.126.net/FDtX55P2NjccDna-LBj9PA==/109951165375065973.jpg",
|
||||
name: "Festival Bangers",
|
||||
'https://p2.music.126.net/FDtX55P2NjccDna-LBj9PA==/109951165375065973.jpg',
|
||||
name: 'Festival Bangers',
|
||||
id: 5277969451,
|
||||
},
|
||||
{
|
||||
coverImgUrl:
|
||||
"https://p2.music.126.net/hC0q2dGbOWHVfg4nkhIXPg==/109951165374881177.jpg",
|
||||
name: "Bedtime Beats",
|
||||
'https://p2.music.126.net/hC0q2dGbOWHVfg4nkhIXPg==/109951165374881177.jpg',
|
||||
name: 'Bedtime Beats',
|
||||
id: 5277778542,
|
||||
},
|
||||
];
|
||||
|
||||
export const playlistCategories = [
|
||||
{
|
||||
name: "全部",
|
||||
name: '全部',
|
||||
enable: true,
|
||||
bigCat: "static",
|
||||
bigCat: 'static',
|
||||
},
|
||||
// {
|
||||
// name: "For You",
|
||||
|
|
@ -43,9 +43,9 @@ export const playlistCategories = [
|
|||
// bigCat: "static",
|
||||
// },
|
||||
{
|
||||
name: "推荐歌单",
|
||||
name: '推荐歌单',
|
||||
enable: true,
|
||||
bigCat: "static",
|
||||
bigCat: 'static',
|
||||
},
|
||||
// {
|
||||
// name: "最新专辑",
|
||||
|
|
@ -53,368 +53,368 @@ export const playlistCategories = [
|
|||
// bigCat: "static",
|
||||
// },
|
||||
{
|
||||
name: "精品歌单",
|
||||
name: '精品歌单',
|
||||
enable: true,
|
||||
bigCat: "static",
|
||||
bigCat: 'static',
|
||||
},
|
||||
{
|
||||
name: "官方",
|
||||
name: '官方',
|
||||
enable: true,
|
||||
bigCat: "static",
|
||||
bigCat: 'static',
|
||||
},
|
||||
{
|
||||
name: "排行榜",
|
||||
name: '排行榜',
|
||||
enable: true,
|
||||
bigCat: "static",
|
||||
bigCat: 'static',
|
||||
},
|
||||
{
|
||||
name: "华语",
|
||||
name: '华语',
|
||||
enable: false,
|
||||
bigCat: "语种",
|
||||
bigCat: '语种',
|
||||
},
|
||||
{
|
||||
name: "欧美",
|
||||
name: '欧美',
|
||||
enable: true,
|
||||
bigCat: "语种",
|
||||
bigCat: '语种',
|
||||
},
|
||||
{
|
||||
name: "日语",
|
||||
name: '日语',
|
||||
enable: false,
|
||||
bigCat: "语种",
|
||||
bigCat: '语种',
|
||||
},
|
||||
{
|
||||
name: "韩语",
|
||||
name: '韩语',
|
||||
enable: false,
|
||||
bigCat: "语种",
|
||||
bigCat: '语种',
|
||||
},
|
||||
{
|
||||
name: "粤语",
|
||||
name: '粤语',
|
||||
enable: false,
|
||||
bigCat: "语种",
|
||||
bigCat: '语种',
|
||||
},
|
||||
{
|
||||
name: "流行",
|
||||
name: '流行',
|
||||
enable: true,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "摇滚",
|
||||
name: '摇滚',
|
||||
enable: true,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "民谣",
|
||||
name: '民谣',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "电子",
|
||||
name: '电子',
|
||||
enable: true,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "舞曲",
|
||||
name: '舞曲',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "说唱",
|
||||
name: '说唱',
|
||||
enable: true,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "轻音乐",
|
||||
name: '轻音乐',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "爵士",
|
||||
name: '爵士',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "乡村",
|
||||
name: '乡村',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "R&B/Soul",
|
||||
name: 'R&B/Soul',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "古典",
|
||||
name: '古典',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "民族",
|
||||
name: '民族',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "英伦",
|
||||
name: '英伦',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "金属",
|
||||
name: '金属',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "朋克",
|
||||
name: '朋克',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "蓝调",
|
||||
name: '蓝调',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "雷鬼",
|
||||
name: '雷鬼',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "世界音乐",
|
||||
name: '世界音乐',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "拉丁",
|
||||
name: '拉丁',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "New Age",
|
||||
name: 'New Age',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "古风",
|
||||
name: '古风',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "后摇",
|
||||
name: '后摇',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "Bossa Nova",
|
||||
name: 'Bossa Nova',
|
||||
enable: false,
|
||||
bigCat: "风格",
|
||||
bigCat: '风格',
|
||||
},
|
||||
{
|
||||
name: "清晨",
|
||||
name: '清晨',
|
||||
enable: false,
|
||||
bigCat: "场景",
|
||||
bigCat: '场景',
|
||||
},
|
||||
{
|
||||
name: "夜晚",
|
||||
name: '夜晚',
|
||||
enable: false,
|
||||
bigCat: "场景",
|
||||
bigCat: '场景',
|
||||
},
|
||||
{
|
||||
name: "学习",
|
||||
name: '学习',
|
||||
enable: false,
|
||||
bigCat: "场景",
|
||||
bigCat: '场景',
|
||||
},
|
||||
{
|
||||
name: "工作",
|
||||
name: '工作',
|
||||
enable: false,
|
||||
bigCat: "场景",
|
||||
bigCat: '场景',
|
||||
},
|
||||
{
|
||||
name: "午休",
|
||||
name: '午休',
|
||||
enable: false,
|
||||
bigCat: "场景",
|
||||
bigCat: '场景',
|
||||
},
|
||||
{
|
||||
name: "下午茶",
|
||||
name: '下午茶',
|
||||
enable: false,
|
||||
bigCat: "场景",
|
||||
bigCat: '场景',
|
||||
},
|
||||
{
|
||||
name: "地铁",
|
||||
name: '地铁',
|
||||
enable: false,
|
||||
bigCat: "场景",
|
||||
bigCat: '场景',
|
||||
},
|
||||
{
|
||||
name: "驾车",
|
||||
name: '驾车',
|
||||
enable: false,
|
||||
bigCat: "场景",
|
||||
bigCat: '场景',
|
||||
},
|
||||
{
|
||||
name: "运动",
|
||||
name: '运动',
|
||||
enable: false,
|
||||
bigCat: "场景",
|
||||
bigCat: '场景',
|
||||
},
|
||||
{
|
||||
name: "旅行",
|
||||
name: '旅行',
|
||||
enable: false,
|
||||
bigCat: "场景",
|
||||
bigCat: '场景',
|
||||
},
|
||||
{
|
||||
name: "散步",
|
||||
name: '散步',
|
||||
enable: false,
|
||||
bigCat: "场景",
|
||||
bigCat: '场景',
|
||||
},
|
||||
{
|
||||
name: "酒吧",
|
||||
name: '酒吧',
|
||||
enable: false,
|
||||
bigCat: "场景",
|
||||
bigCat: '场景',
|
||||
},
|
||||
{
|
||||
name: "怀旧",
|
||||
name: '怀旧',
|
||||
enable: false,
|
||||
bigCat: "情感",
|
||||
bigCat: '情感',
|
||||
},
|
||||
{
|
||||
name: "清新",
|
||||
name: '清新',
|
||||
enable: false,
|
||||
bigCat: "情感",
|
||||
bigCat: '情感',
|
||||
},
|
||||
{
|
||||
name: "浪漫",
|
||||
name: '浪漫',
|
||||
enable: false,
|
||||
bigCat: "情感",
|
||||
bigCat: '情感',
|
||||
},
|
||||
{
|
||||
name: "伤感",
|
||||
name: '伤感',
|
||||
enable: false,
|
||||
bigCat: "情感",
|
||||
bigCat: '情感',
|
||||
},
|
||||
{
|
||||
name: "治愈",
|
||||
name: '治愈',
|
||||
enable: false,
|
||||
bigCat: "情感",
|
||||
bigCat: '情感',
|
||||
},
|
||||
{
|
||||
name: "放松",
|
||||
name: '放松',
|
||||
enable: false,
|
||||
bigCat: "情感",
|
||||
bigCat: '情感',
|
||||
},
|
||||
{
|
||||
name: "孤独",
|
||||
name: '孤独',
|
||||
enable: false,
|
||||
bigCat: "情感",
|
||||
bigCat: '情感',
|
||||
},
|
||||
{
|
||||
name: "感动",
|
||||
name: '感动',
|
||||
enable: false,
|
||||
bigCat: "情感",
|
||||
bigCat: '情感',
|
||||
},
|
||||
{
|
||||
name: "兴奋",
|
||||
name: '兴奋',
|
||||
enable: false,
|
||||
bigCat: "情感",
|
||||
bigCat: '情感',
|
||||
},
|
||||
{
|
||||
name: "快乐",
|
||||
name: '快乐',
|
||||
enable: false,
|
||||
bigCat: "情感",
|
||||
bigCat: '情感',
|
||||
},
|
||||
{
|
||||
name: "安静",
|
||||
name: '安静',
|
||||
enable: false,
|
||||
bigCat: "情感",
|
||||
bigCat: '情感',
|
||||
},
|
||||
{
|
||||
name: "思念",
|
||||
name: '思念',
|
||||
enable: false,
|
||||
bigCat: "情感",
|
||||
bigCat: '情感',
|
||||
},
|
||||
{
|
||||
name: "综艺",
|
||||
name: '综艺',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "影视原声",
|
||||
name: '影视原声',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "ACG",
|
||||
name: 'ACG',
|
||||
enable: true,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "儿童",
|
||||
name: '儿童',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "校园",
|
||||
name: '校园',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "游戏",
|
||||
name: '游戏',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "70后",
|
||||
name: '70后',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "80后",
|
||||
name: '80后',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "90后",
|
||||
name: '90后',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "网络歌曲",
|
||||
name: '网络歌曲',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "KTV",
|
||||
name: 'KTV',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "经典",
|
||||
name: '经典',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "翻唱",
|
||||
name: '翻唱',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "吉他",
|
||||
name: '吉他',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "钢琴",
|
||||
name: '钢琴',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "器乐",
|
||||
name: '器乐',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "榜单",
|
||||
name: '榜单',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
{
|
||||
name: "00后",
|
||||
name: '00后',
|
||||
enable: false,
|
||||
bigCat: "主题",
|
||||
bigCat: '主题',
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,30 +1,30 @@
|
|||
import initLocalStorage from "@/store/initLocalStorage.js";
|
||||
import pkg from "../../package.json";
|
||||
import initLocalStorage from '@/store/initLocalStorage.js';
|
||||
import pkg from '../../package.json';
|
||||
|
||||
const updateSetting = () => {
|
||||
const parsedSettings = JSON.parse(localStorage.getItem("settings"));
|
||||
const parsedSettings = JSON.parse(localStorage.getItem('settings'));
|
||||
const settings = {
|
||||
...initLocalStorage.settings,
|
||||
...parsedSettings,
|
||||
};
|
||||
|
||||
localStorage.setItem("settings", JSON.stringify(settings));
|
||||
localStorage.setItem('settings', JSON.stringify(settings));
|
||||
};
|
||||
|
||||
const updateData = () => {
|
||||
const parsedData = JSON.parse(localStorage.getItem("data"));
|
||||
const parsedData = JSON.parse(localStorage.getItem('data'));
|
||||
const data = {
|
||||
...parsedData,
|
||||
};
|
||||
localStorage.setItem("data", JSON.stringify(data));
|
||||
localStorage.setItem('data', JSON.stringify(data));
|
||||
};
|
||||
|
||||
const updatePlayer = () => {
|
||||
let parsedData = JSON.parse(localStorage.getItem("player"));
|
||||
let appVersion = localStorage.getItem("appVersion");
|
||||
let parsedData = JSON.parse(localStorage.getItem('player'));
|
||||
let appVersion = localStorage.getItem('appVersion');
|
||||
if (appVersion === `"0.2.5"`) parsedData = {}; // 0.2.6版本重构了player
|
||||
const data = {
|
||||
_repeatMode: "off",
|
||||
_repeatMode: 'off',
|
||||
_shuffle: false,
|
||||
_list: [],
|
||||
_current: 0,
|
||||
|
|
@ -38,12 +38,12 @@ const updatePlayer = () => {
|
|||
_shuffledCurrent: 0,
|
||||
...parsedData,
|
||||
};
|
||||
localStorage.setItem("player", JSON.stringify(data));
|
||||
localStorage.setItem('player', JSON.stringify(data));
|
||||
};
|
||||
|
||||
const removeOldStuff = () => {
|
||||
// remove old indexedDB databases created by localforage
|
||||
indexedDB.deleteDatabase("tracks");
|
||||
indexedDB.deleteDatabase('tracks');
|
||||
};
|
||||
|
||||
export default function () {
|
||||
|
|
@ -51,5 +51,5 @@ export default function () {
|
|||
updateData();
|
||||
updatePlayer();
|
||||
removeOldStuff();
|
||||
localStorage.setItem("appVersion", JSON.stringify(pkg.version));
|
||||
localStorage.setItem('appVersion', JSON.stringify(pkg.version));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue