mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 21:27:47 +00:00
feat: base panel
This commit is contained in:
parent
cbef7478c2
commit
ac0c3d0d6c
12 changed files with 361 additions and 149 deletions
|
|
@ -59,6 +59,24 @@ export default class MysZZZApi extends MysApi {
|
|||
dsSalt = '',
|
||||
} = urlMap[type];
|
||||
if (query) url += `?${query}`;
|
||||
if (data.query) {
|
||||
let str = '';
|
||||
for (let key in data.query) {
|
||||
if (data.query[key] === undefined) continue;
|
||||
else if (data.query[key] === null) str += `${key}&`;
|
||||
else if (Array.isArray(data.query[key])) {
|
||||
data.query[key].forEach(item => {
|
||||
str += `${key}[]=${item}&`;
|
||||
});
|
||||
} else str += `${key}=${data.query[key]}&`;
|
||||
}
|
||||
str = str.slice(0, -1);
|
||||
if (url.includes('?')) {
|
||||
url += `&${str}`;
|
||||
} else {
|
||||
url += `?${str}`;
|
||||
}
|
||||
}
|
||||
if (body) body = JSON.stringify(body);
|
||||
|
||||
let headers = this.getHeaders(query, body);
|
||||
|
|
@ -96,6 +114,7 @@ export default class MysZZZApi extends MysApi {
|
|||
body = JSON.stringify(body);
|
||||
}
|
||||
}
|
||||
logger.debug(`[mysapi]请求url:${url}`);
|
||||
return { url, headers, body };
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +187,7 @@ export default class MysZZZApi extends MysApi {
|
|||
*/
|
||||
async checkCode(e, res, type, data = {}) {
|
||||
if (!res || !e) {
|
||||
this.e.reply('米游社接口请求失败,暂时无法查询');
|
||||
e.reply('米游社接口请求失败,暂时无法查询');
|
||||
return false;
|
||||
}
|
||||
this.e = e;
|
||||
|
|
@ -221,6 +240,20 @@ export default class MysZZZApi extends MysApi {
|
|||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取米游社数据
|
||||
* @param {*} e 消息e
|
||||
* @param {keyof ZZZApiTool['zzzUrlMap']} type 请求类型
|
||||
* @param {{deviceFp: string; query: Record<string, any>; headers: object;}} data
|
||||
* @param {boolean} cached
|
||||
*/
|
||||
async getFinalData(e, type, data = {}, cached = false) {
|
||||
const result = await this.getData(type, data, cached);
|
||||
const _data = await this.checkCode(e, result, type, {});
|
||||
if (!_data || _data.retcode !== 0) return false;
|
||||
return _data.data;
|
||||
}
|
||||
}
|
||||
|
||||
export function randomString(length) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue