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

View File

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