Files
frpc-console/static/modules/proxies.js
T

47 lines
1.1 KiB
JavaScript

// 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)
);
}