diff --git a/.env b/.env
index c747522..a1241ca 100644
--- a/.env
+++ b/.env
@@ -31,8 +31,9 @@ VITE_WEATHER_KEY = "57eaea5833ff1616cfd1ff2c4cf9b58a"
VITE_SITE_START = "2020-10-24"
# 歌曲 API 地址
-## 请参照 https://github.com/imsyy/Meting-API#cloudflare-workers 进行 API 服务部署
+## 请参照 https://github.com/xizeyoupan/Meting-API#deno-deploy 进行 API 服务部署
## 此处提供的服务可能会超量从而无法访问,请自行部署
+## 若使用QQ音乐歌单,歌曲数量最好不要超出50首
## 备用:https://api.wuenci.com/meting/api/
VITE_SONG_API = "https://api-meting.imsyy.top/api"
# 歌曲服务器 ( netease-网易云, tencent-qq音乐 )
diff --git a/package.json b/package.json
index 0b4d42e..97ee2f8 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
"aplayer": "^1.10.1",
"axios": "^1.1.3",
"element-plus": "^2.2.18",
+ "fetch-jsonp": "^1.2.3",
"pinia": "^2.0.23",
"pinia-plugin-persistedstate": "^3.0.0",
"terser": "^5.16.1",
diff --git a/src/api/index.js b/src/api/index.js
index 3bfb168..fa9adc0 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -1,4 +1,5 @@
// import axios from "axios";
+import fetchJsonp from "fetch-jsonp";
/**
* 音乐播放器
@@ -6,9 +7,38 @@
// 获取音乐播放列表
export const getPlayerList = async (server, type, id) => {
- const res = await fetch(`${import.meta.env.VITE_SONG_API}?server=${server}&type=${type}&id=${id}`);
- return await res.json();
-}
+ const res = await fetch(
+ `${import.meta.env.VITE_SONG_API}?server=${server}&type=${type}&id=${id}`
+ );
+ const data = await res.json();
+
+ if (data[0].url.startsWith("@")) {
+ const [handle, jsonpCallback, jsonpCallbackFunction, url] = data[0].url
+ .split("@")
+ .slice(1);
+ const jsonpData = await fetchJsonp(url).then((res) => res.json());
+ const domain = (
+ jsonpData.req_0.data.sip.find((i) => !i.startsWith("http://ws")) ||
+ jsonpData.req_0.data.sip[0]
+ ).replace("http://", "https://");
+
+ return data.map((v, i) => ({
+ title: v.name || v.title,
+ artist: v.artist || v.author,
+ src: domain + jsonpData.req_0.data.midurlinfo[i].purl,
+ pic: v.pic,
+ lrc: v.lrc,
+ }));
+ } else {
+ return data.map((v) => ({
+ title: v.name || v.title,
+ artist: v.artist || v.author,
+ src: v.url,
+ pic: v.pic,
+ lrc: v.lrc,
+ }));
+ }
+};
/**
* 一言
@@ -16,26 +46,27 @@ export const getPlayerList = async (server, type, id) => {
// 获取一言数据
export const getHitokoto = async () => {
- const res = await fetch("https://v1.hitokoto.cn");
- return await res.json();
-}
+ const res = await fetch("https://v1.hitokoto.cn");
+ return await res.json();
+};
/**
* 天气
*/
-
// 获取高德地理位置信息
export const getAdcode = async (key) => {
- const res = await fetch(`https://restapi.amap.com/v3/ip?key=${key}`);
- return await res.json();
-}
+ const res = await fetch(`https://restapi.amap.com/v3/ip?key=${key}`);
+ return await res.json();
+};
// 获取高德地理天气信息
export const getWeather = async (key, city) => {
- const res = await fetch(`https://restapi.amap.com/v3/weather/weatherInfo?key=${key}&city=${city}`);
- return await res.json();
-}
+ const res = await fetch(
+ `https://restapi.amap.com/v3/weather/weatherInfo?key=${key}&city=${city}`
+ );
+ return await res.json();
+};
/**
* 获取配置
@@ -43,6 +74,6 @@ export const getWeather = async (key, city) => {
// 获取社交链接
export const getSocialLinks = async () => {
- const res = await fetch("/socialLinks.json");
- return await res.json();
-}
\ No newline at end of file
+ const res = await fetch("/socialLinks.json");
+ return await res.json();
+};
diff --git a/src/components/Music/test.vue b/src/components/Music/test.vue
deleted file mode 100644
index cd61f3b..0000000
--- a/src/components/Music/test.vue
+++ /dev/null
@@ -1,375 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/components/Player/index.vue b/src/components/Player/index.vue
index 2df519e..6ccb90c 100644
--- a/src/components/Player/index.vue
+++ b/src/components/Player/index.vue
@@ -20,17 +20,10 @@
-
-
\ No newline at end of file
diff --git a/yarn.lock b/yarn.lock
index 1fcc6a9..e72b382 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2024,6 +2024,11 @@ fastq@^1.6.0:
dependencies:
reusify "^1.0.4"
+fetch-jsonp@^1.2.3:
+ version "1.2.3"
+ resolved "https://registry.yarnpkg.com/fetch-jsonp/-/fetch-jsonp-1.2.3.tgz#ae99a867095cb1ce5c39fac601d70d1084db122f"
+ integrity sha512-C13k1o7R9JTN1wmhKkrW5bU/00LwixXnkufQUR6Rbf4KCS0i8mycQaovt4WVbHnA2NKgi7Ryp9Whpy/CGcij6Q==
+
filelist@^1.0.1:
version "1.0.4"
resolved "https://registry.npmmirror.com/filelist/-/filelist-1.0.4.tgz"