refactor: 重构lib代码(无实质性功能更新,可不更新)

This commit is contained in:
bietiaop 2024-08-22 13:34:08 +08:00
parent a7f06d404b
commit aa3b7928ec
26 changed files with 547 additions and 483 deletions

View file

@ -1,41 +1,16 @@
import { findLowestLatencyUrl } from '../utils/network.js';
import {
URL_LIB,
TYPE_PATH,
RESOURCE_PATH,
GUIDE_PATH,
} from './assets/const.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',
'[USFRP]': 'http://us-6.lcf.1l1.icu:28596',
'[XiaoWu]': 'http://frp.xiaowuap.com:63481',
'[Chuncheon]': 'https://kr.qxqx.cf',
'[Seoul]': 'https://kr-s.qxqx.cf',
'[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>}
@ -61,10 +36,10 @@ export const getFatestUrl = async () => {
};
/**
* Get resource remote path
* @param {keyof TYPE_PATH} type
* @param {keyof RESOURCE_PATH | keyof GUIDE_PATH} label
* @param {string} name
* 获取远程路径
* @param {keyof TYPE_PATH} type 资源类型
* @param {keyof RESOURCE_PATH | keyof GUIDE_PATH} label 资源标签
* @param {string} name 资源名称
* @returns
*/
export const getRemotePath = async (type, label, name) => {
@ -72,7 +47,12 @@ export const getRemotePath = async (type, label, name) => {
return `${url}/ZZZeroUID/${type}/${label}/${name}`;
};
// 获取资源远程路径
/**
* 获取资源远程路径
* @param {keyof RESOURCE_PATH} label 资源标签
* @param {string} name 资源名称
* @returns {Promise<string>}
*/
export const getResourceRemotePath = async (label, name) => {
return getRemotePath(TYPE_PATH.resource, label, name);
};