部分重型模块的原子化拆解

This commit is contained in:
2026-07-23 20:46:16 +08:00
parent 2afff129b9
commit 5fa1b99c5d
12 changed files with 1688 additions and 875 deletions
+47
View File
@@ -0,0 +1,47 @@
// modules/proxies.js
import { apiFetch } from './api.js';
export async function loadProxies() {
try {
const data = await apiFetch('/proxies');
if (data.code === 0) {
return data.data || [];
}
} catch (e) {
console.warn('加载隧道失败', e);
}
return [];
}
export async function createProxy(proxy) {
const data = await apiFetch('/proxy', {
method: 'POST',
body: JSON.stringify(proxy),
});
return data;
}
export async function updateProxy(proxy) {
const data = await apiFetch('/proxy/' + proxy.id, {
method: 'PUT',
body: JSON.stringify(proxy),
});
return data;
}
export async function deleteProxy(id) {
const data = await apiFetch('/proxy/' + id, {
method: 'DELETE',
});
return data;
}
export function filterProxies(list, keyword) {
if (!keyword) return list;
const kw = keyword.toLowerCase();
return list.filter(p =>
p.name.toLowerCase().includes(kw) ||
p.localIP.includes(kw) ||
String(p.remotePort).includes(kw)
);
}