mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 21:27:47 +00:00
typo: 代码注释
This commit is contained in:
parent
51b3908afd
commit
4c90ca5354
12 changed files with 457 additions and 139 deletions
|
|
@ -1,10 +1,12 @@
|
|||
import { findLowestLatencyUrl } from '../utils/network.js';
|
||||
|
||||
// 保存上次找的节点
|
||||
let lastFindFastestUrl = {
|
||||
url: null,
|
||||
time: 0,
|
||||
};
|
||||
|
||||
// 节点列表
|
||||
const URL_LIB = {
|
||||
'[JPFRP]': 'http://jp-3.lcf.1l1.icu:17217',
|
||||
'[HKFRP]': 'http://hk-1.lcf.1l1.icu:10200',
|
||||
|
|
@ -15,35 +17,46 @@ const URL_LIB = {
|
|||
'[Singapore]': 'https://sg.qxqx.cf',
|
||||
};
|
||||
|
||||
// 文件类型路径
|
||||
const TYPE_PATH = {
|
||||
wiki: 'wiki',
|
||||
resource: 'resource',
|
||||
guide: 'guide',
|
||||
};
|
||||
|
||||
// 资源路径
|
||||
const RESOURCE_PATH = {
|
||||
role: 'role',
|
||||
role_circle: 'role_circle',
|
||||
weapon: 'weapon',
|
||||
};
|
||||
|
||||
// 图鉴路径
|
||||
const GUIDE_PATH = {
|
||||
flower: 'flower',
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取最快节点
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
export const getFatestUrl = async () => {
|
||||
if (
|
||||
lastFindFastestUrl.url &&
|
||||
Date.now() - lastFindFastestUrl.time < 1000 * 60 * 5
|
||||
) {
|
||||
// 如果上次找到的节点在 5 分钟内,直接返回
|
||||
return lastFindFastestUrl.url;
|
||||
}
|
||||
// 获取最快节点
|
||||
const urls = Object.values(URL_LIB);
|
||||
const url = findLowestLatencyUrl(urls);
|
||||
// 保存节点
|
||||
lastFindFastestUrl = {
|
||||
url,
|
||||
time: Date.now(),
|
||||
};
|
||||
// 返回节点
|
||||
return url;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue