Compare commits

...

4 Commits

Author SHA1 Message Date
手瓜一十雪
1b874a0264 fix: defaultHttpUrl 2025-01-25 20:00:24 +08:00
Mlikiowa
26525a0ff9 release: v4.4.9 2025-01-25 10:59:08 +00:00
手瓜一十雪
49234ea5c7 fix: music proxy 2025-01-25 18:34:11 +08:00
Mlikiowa
c474158a09 release: v4.4.8 2025-01-25 05:40:09 +00:00
8 changed files with 37 additions and 11 deletions

View File

@@ -4,7 +4,7 @@
"name": "NapCatQQ",
"slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现",
"version": "4.4.7",
"version": "4.4.9",
"icon": "./logo.png",
"authors": [
{

View File

@@ -28,7 +28,10 @@ export interface OneBotApiDebugProps {
const OneBotApiDebug: React.FC<OneBotApiDebugProps> = (props) => {
const { path, data } = props
const url = new URL(window.location.origin).href
const defaultHttpUrl = url.replace(':6099', ':3000')
let defaultHttpUrl = url.replace(':6099', ':3000')
if (defaultHttpUrl.endsWith('/')) {
defaultHttpUrl = defaultHttpUrl.slice(0, -1)
}
const [httpConfig, setHttpConfig] = useState({
url: defaultHttpUrl,
token: ''

View File

@@ -24,6 +24,14 @@ export default class WebUIManager {
return data.data.Credential
}
public static async proxy<T>(url = '') {
const data = await serverRequest.get<ServerResponse<string>>(
'/base/proxy?url=' + encodeURIComponent(url)
)
data.data.data = JSON.parse(data.data.data)
return data.data as ServerResponse<T>
}
public static async getPackageInfo() {
const { data } =
await serverRequest.get<ServerResponse<PackageInfo>>('/base/PackageInfo')

View File

@@ -6,17 +6,17 @@ import type {
Music163URLResponse
} from '@/types/music'
import { request } from './request'
import WebUIManager from '@/controllers/webui_manager'
/**
* 获取网易云音乐歌单
* @param id 歌单id
* @returns 歌单信息
*/
export const get163MusicList = async (id: string) => {
const res = await request.get<Music163ListResponse>(
`https://wavesgame.top/playlist/track/all?id=${id}`
)
let res = await WebUIManager.proxy<Music163ListResponse>('https://wavesgame.top/playlist/track/all?id=' + id);
// const res = await request.get<Music163ListResponse>(
// `https://wavesgame.top/playlist/track/all?id=${id}`
// )
if (res?.data?.code !== 200) {
throw new Error('获取歌曲列表失败')
}
@@ -39,7 +39,7 @@ export const getSongsURL = async (ids: number[]) => {
}, [] as number[][])
const res = await Promise.all(
_ids.map(async (id) => {
const res = await request.get<Music163URLResponse>(
const res = await WebUIManager.proxy<Music163URLResponse>(
`https://wavesgame.top/song/url?id=${id.join(',')}`
)
if (res?.data?.code !== 200) {

View File

@@ -2,7 +2,7 @@
"name": "napcat",
"private": true,
"type": "module",
"version": "4.4.7",
"version": "4.4.9",
"scripts": {
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",

View File

@@ -1 +1 @@
export const napCatVersion = '4.4.7';
export const napCatVersion = '4.4.9';

View File

@@ -0,0 +1,14 @@
import { RequestHandler } from "express";
import { RequestUtil } from "@/common/request";
import { sendError, sendSuccess } from "../utils/response";
export const GetProxyHandler: RequestHandler = async (req, res) => {
let { url } = req.query;
if (url && typeof url === "string") {
url = decodeURIComponent(url);
const responseText = await RequestUtil.HttpGetText(url);
res.send(sendSuccess(res, responseText));
} else {
res.send(sendError(res, 'url参数不合法'));
}
};

View File

@@ -1,11 +1,12 @@
import { Router } from 'express';
import { PackageInfoHandler, QQVersionHandler } from '../api/BaseInfo';
import { StatusRealTimeHandler } from "@webapi/api/Status";
import { GetProxyHandler } from '../api/Proxy';
const router = Router();
// router: 获取nc的package.json信息
router.get('/QQVersion', QQVersionHandler);
router.get('/PackageInfo', PackageInfoHandler);
router.get('/GetSysStatusRealTime', StatusRealTimeHandler);
router.get('/proxy', GetProxyHandler);
export { router as BaseRouter };