From bf368bab34b3c67f8b14cb8628f3004c02e84672 Mon Sep 17 00:00:00 2001 From: Zachary Date: Sat, 13 Feb 2021 03:32:56 +0800 Subject: [PATCH] feat: add new api methods --- src/api/base.js | 3 ++- src/api/data.js | 7 +++++++ src/api/index.js | 23 +++++++++++++++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 src/api/data.js diff --git a/src/api/base.js b/src/api/base.js index b68c2fb..bfcdfb6 100644 --- a/src/api/base.js +++ b/src/api/base.js @@ -1,6 +1,7 @@ import axios from "axios"; -const BASIC_URL = "http://zacharyzlj.cn:3000/"; +//const BASIC_URL = "http://zacharyzlj.cn:3000/"; +const BASIC_URL = "http://localhost:3000/"; function createBaseInstance() { const instance = axios.create({ baseURL: BASIC_URL }); diff --git a/src/api/data.js b/src/api/data.js new file mode 100644 index 0000000..ce62c2e --- /dev/null +++ b/src/api/data.js @@ -0,0 +1,7 @@ +export const toplistTypes = { + NEW: 3779629, + SOAR: 19723756, + ORIGINAL: 2884035, + HOT: 3778678, + RB: 991319590 +}; diff --git a/src/api/index.js b/src/api/index.js index 916b3e0..632d30d 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -1,17 +1,36 @@ import { requset } from "./base"; +export * from "./data"; export const getBanner = () => requset.get("/banner?type=0"); export const getSongers = (initial, type, area, page) => { - let offset = parseInt(page) - 1; + let limit = 80; + let offset = (parseInt(page) - 1) * limit; let params = { initial: initial, type: type, area: area, - limit: 80, + limit: limit, offset: offset }; return requset.get("/artist/list", { params: params }); }; export const getUserDetail = id => requset.get(`/user/detail?uid=${id}`); + +export const getCatList = () => requset.get("(/playlist/catlist"); + +export const getPlayList = (limit, page, cat) => { + let order = "hot"; + let offset = (parseInt(page) - 1) * limit; + let params = { + limit: limit, + offset: offset, + cat: cat, + order: order + }; + return requset.get("/top/playlist", { params: params }); +}; + +export const getTopList = toplistType => + requset.get(`/top/list?id=${toplistType}`); -- GitLab