build: v1.3.5-beta10

This commit is contained in:
手瓜一十雪 2024-05-14 16:40:23 +08:00
parent caa2fca4e8
commit c2278e3536
3 changed files with 17 additions and 9 deletions

View File

@ -30,15 +30,15 @@ export class RequestUtil {
}
// 请求和回复都是JSON data传原始内容 自动编码json
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: any, headers: Record<string, string> = {}): Promise<T> {
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: any, headers: Record<string, string> = {}, isJsonRet: boolean = true): Promise<T> {
let option = new URL(url);
const protocol = url.startsWith('https://') ? https : http;
const options = {
hostname: option.hostname,
port: option.port,
path: option.href,
method,
headers,
method: method,
headers: headers
};
return new Promise((resolve, reject) => {
const req = protocol.request(options, (res: any) => {
@ -50,8 +50,12 @@ export class RequestUtil {
res.on('end', () => {
try {
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
const responseJson = JSON.parse(responseBody);
resolve(responseJson as T);
if (isJsonRet) {
const responseJson = JSON.parse(responseBody);
resolve(responseJson as T);
} else {
resolve(responseBody as T);
}
} else {
reject(new Error(`Unexpected status code: ${res.statusCode}`));
}
@ -73,6 +77,7 @@ export class RequestUtil {
// 请求返回都是原始内容
static async HttpGetText(url: string, method: string = 'GET', data?: any, headers: Record<string, string> = {}) {
return this.HttpGetJson<string>(url, method, data, headers);
//console.log(url);
return this.HttpGetJson<string>(url, method, data, headers, false);
}
}

@ -1 +1 @@
Subproject commit c30a351bbb9046c31b471e9a818d7b28f971541a
Subproject commit b1351835673f86d445d244fd515560bfcd0b7adb

View File

@ -5,13 +5,16 @@ import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { NTQQUserApi, WebApi } from '@/core/apis';
interface Payload {
groud_id: string
group_id: number
}
export class GetGroupHonorInfo extends BaseAction<Payload, Array<any>> {
actionName = ActionName.GetGroupHonorInfo;
protected async _handle(payload: Payload) {
// console.log(await NTQQUserApi.getRobotUinRange());
return await WebApi.getGroupHonorInfo(payload.groud_id);
if(!payload.group_id){
throw '缺少参数group_id';
}
return await WebApi.getGroupHonorInfo(payload.group_id.toString());
}
}