mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-17 13:47:44 +00:00
部分enka面板更新能力
This commit is contained in:
parent
d6a299c275
commit
28432cd0a5
6 changed files with 1359 additions and 46 deletions
39
lib/ekapi/query.js
Normal file
39
lib/ekapi/query.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import settings from '../settings.js'
|
||||
import { ENKA_API } from './api.js'
|
||||
import _ from 'request'
|
||||
|
||||
const useEnka = _.get(settings.getConfig('config'), 'useEnka', true);
|
||||
export async function getZzzEnkaData(uid) {
|
||||
if (useEnka) {
|
||||
try {
|
||||
const response = await fetch(ENKA_API.replace('{uid}', uid), {
|
||||
headers: {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
||||
'Referer': 'https://enka.network/',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.error(`HTTP 错误! 状态码: ${response.status}`);
|
||||
return response.status;
|
||||
}
|
||||
|
||||
const data = await response.json(); // 解析 JSON 响应
|
||||
if (typeof data === 'number') {
|
||||
return data;
|
||||
}
|
||||
return data;
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error fetching ZZZ Enka data:", error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// 如果 useEnka 为 false,你可能需要返回一个默认值或者执行其他逻辑
|
||||
return null; // 或者其他你希望返回的值
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue