parent
cc5ec68490
commit
b03c9339bd
|
|
@ -15,7 +15,6 @@ import cleanCacheRequest from "@/server/api/admin/netease/clean";
|
|||
// Interface
|
||||
import { MouseEvent, ChangeEvent } from "react";
|
||||
|
||||
|
||||
// Components
|
||||
function RemoveMusicCache() {
|
||||
const { loading, run } = useRequest(
|
||||
|
|
@ -23,10 +22,7 @@ function RemoveMusicCache() {
|
|||
query: params
|
||||
}),
|
||||
{
|
||||
manual: true,
|
||||
onSuccess: (data) => {
|
||||
console.log(data);
|
||||
}
|
||||
manual: true
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
import { Api, Get, Query, useContext, useInject } from "@midwayjs/hooks";
|
||||
import { RedisService } from "@midwayjs/redis";
|
||||
|
||||
import fetch from "isomorphic-unfetch";
|
||||
|
||||
export default Api(
|
||||
Get(),
|
||||
Query<{ ip?: string }>(),
|
||||
async () => {
|
||||
const ctx = useContext();
|
||||
const client = await useInject(RedisService);
|
||||
|
||||
// 增加使用数量
|
||||
await client.incr("api-next:stat:ip");
|
||||
|
||||
const ip = ctx.query.ip || ctx.ip.replace(/::\S+:/, "");
|
||||
|
||||
const response = await fetch(`http://ip-api.com/json/${ip}?lang=zh-CN`, {
|
||||
headers: {
|
||||
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36"
|
||||
}
|
||||
});
|
||||
const json = await response.json();
|
||||
|
||||
delete json.status;
|
||||
|
||||
return {
|
||||
code: 1,
|
||||
msg: "Success",
|
||||
data: json
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
@ -45,7 +45,7 @@ export const parseSongData = async (item: any) => {
|
|||
return {
|
||||
id: item.id,
|
||||
title: item.name,
|
||||
artist: item.artists ?. [0].name || "",
|
||||
artist: item.artists ? item.artists.map((artist: any) => artist.name).join(" / ") : "",
|
||||
alias: item.transName || (Array.isArray(item.alias) ? (item.alias[0] || "") : ""),
|
||||
album: item.album.name || "",
|
||||
cover: `${item.album.picUrl.replace("http://", "https://")}?param=250y250"`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue