🌈 style: 代码格式化

This commit is contained in:
zhiyu1998 2023-03-15 23:46:57 +08:00
parent 8426215d5f
commit 648ed593c7
2 changed files with 29 additions and 41 deletions

View File

@ -27,11 +27,7 @@ async function store2ha1(passstore) {
const parts = passstore.split("."); const parts = passstore.split(".");
if (parts.length === 2) { if (parts.length === 2) {
// 新的加密方式 with IV: IV.E // 新的加密方式 with IV: IV.E
const c = crypto.createDecipheriv( const c = crypto.createDecipheriv("aes-256-cbc", key, Buffer.from(parts[0], "hex"));
"aes-256-cbc",
key,
Buffer.from(parts[0], "hex")
);
let d = c.update(parts[1], "hex", "binary"); let d = c.update(parts[1], "hex", "binary");
d += c.final("binary"); d += c.final("binary");
return d; return d;
@ -45,12 +41,9 @@ async function store2ha1(passstore) {
} catch (e) { } catch (e) {
console.error( console.error(
"在[default]部分设置的passwordSecret无法解密信息。请确保所有节点的passwordSecret相同。如果您更改了密码保密信息可能需要重新添加用户。", "在[default]部分设置的passwordSecret无法解密信息。请确保所有节点的passwordSecret相同。如果您更改了密码保密信息可能需要重新添加用户。",
e e,
); );
} }
} }
export { export { ha12store, store2ha1 };
ha12store,
store2ha1
}

View File

@ -2,7 +2,7 @@
import fetch from "node-fetch"; import fetch from "node-fetch";
import axios from "axios"; import axios from "axios";
const BASE_URL = "http://cloud-music.pl-fe.cn" const BASE_URL = "http://cloud-music.pl-fe.cn";
/** /**
* 获取cookie * 获取cookie
@ -11,7 +11,7 @@ const BASE_URL = "http://cloud-music.pl-fe.cn"
*/ */
async function getCookies(key) { async function getCookies(key) {
const cookieUrl = `${BASE_URL}/login/qr/check?key=${key}&timestamp=${Date.now()}`; const cookieUrl = `${BASE_URL}/login/qr/check?key=${key}&timestamp=${Date.now()}`;
return fetch(cookieUrl).then(async (resp) => { return fetch(cookieUrl).then(async resp => {
return await resp.json(); return await resp.json();
}); });
} }
@ -24,14 +24,13 @@ async function getCookies(key) {
async function getLoginStatus(cookie) { async function getLoginStatus(cookie) {
return axios({ return axios({
url: `${BASE_URL}/login/status?timestamp=${Date.now()}`, url: `${BASE_URL}/login/status?timestamp=${Date.now()}`,
method: 'post', method: "post",
data: { data: {
cookie, cookie,
}, },
}) }).then(resp => {
.then(resp => { return resp.data.data;
return resp.data.data });
});
} }
/** /**
@ -42,14 +41,13 @@ async function getLoginStatus(cookie) {
async function getDailyRecommend(cookie) { async function getDailyRecommend(cookie) {
return axios({ return axios({
url: `${BASE_URL}/recommend/songs?timestamp=${Date.now()}`, url: `${BASE_URL}/recommend/songs?timestamp=${Date.now()}`,
method: 'get', method: "get",
data: { data: {
cookie, cookie,
}, },
}) }).then(resp => {
.then(resp => { return resp.data.data;
return resp.data.data });
});
} }
/** /**
@ -58,7 +56,7 @@ async function getDailyRecommend(cookie) {
*/ */
async function getKey() { async function getKey() {
const keyUrl = `${BASE_URL}/login/qr/key?timestamp=${Date.now()}`; const keyUrl = `${BASE_URL}/login/qr/key?timestamp=${Date.now()}`;
return await fetch(keyUrl).then(async (resp) => { return await fetch(keyUrl).then(async resp => {
const respJson = await resp.json(); const respJson = await resp.json();
return respJson.data.unikey; return respJson.data.unikey;
}); });
@ -71,7 +69,7 @@ async function getKey() {
*/ */
async function getQrCode(key) { async function getQrCode(key) {
const qrPicUrl = `${BASE_URL}/login/qr/create?key=${key}&qrimg=true&timestamp=${Date.now()}`; const qrPicUrl = `${BASE_URL}/login/qr/create?key=${key}&qrimg=true&timestamp=${Date.now()}`;
return await fetch(qrPicUrl).then(async (resp) => { return await fetch(qrPicUrl).then(async resp => {
const respJson = await resp.json(); const respJson = await resp.json();
return respJson.data.qrimg; return respJson.data.qrimg;
}); });
@ -85,11 +83,10 @@ async function getQrCode(key) {
async function getUserRecord(uid) { async function getUserRecord(uid) {
return axios({ return axios({
url: `${BASE_URL}/user/record?uid=${uid}&type=1&timestamp=${Date.now()}`, url: `${BASE_URL}/user/record?uid=${uid}&type=1&timestamp=${Date.now()}`,
method: 'get', method: "get",
}) }).then(resp => {
.then(resp => { return resp.data;
return resp.data });
});
} }
/** /**
@ -100,24 +97,22 @@ async function getUserRecord(uid) {
async function checkMusic(id) { async function checkMusic(id) {
return axios({ return axios({
url: `${BASE_URL}/check/music?id=${id}&timestamp=${Date.now()}`, url: `${BASE_URL}/check/music?id=${id}&timestamp=${Date.now()}`,
method: 'get', method: "get",
}) }).then(resp => {
.then(resp => { return resp.data;
return resp.data });
});
} }
async function getSong(id, cookie) { async function getSong(id, cookie) {
return axios({ return axios({
url: `${BASE_URL}/song/url/v1?id=${id}&level=standard&timestamp=${Date.now()}`, url: `${BASE_URL}/song/url/v1?id=${id}&level=standard&timestamp=${Date.now()}`,
method: 'post', method: "post",
data: { data: {
cookie, cookie,
}, },
}) }).then(resp => {
.then(resp => { return resp.data.data;
return resp.data.data });
});
} }
export { export {
@ -128,5 +123,5 @@ export {
getQrCode, getQrCode,
getUserRecord, getUserRecord,
checkMusic, checkMusic,
getSong getSong,
} };