style: исправлены стили и форматирование кода
Some checks failed
Build and Deploy Gateway / build-and-deploy (push) Failing after 0s

This commit is contained in:
2026-05-08 18:23:56 +03:00
parent 8789496ae6
commit 1ed79c3a1e
8 changed files with 320 additions and 211 deletions

View File

@@ -2,32 +2,43 @@ async function request(url, options = {}) {
const response = await fetch(url, {
...options,
headers: {
'content-type': 'application/json',
"content-type": "application/json",
...(options.headers || {}),
},
});
const data = await response.json().catch(() => ({}));
if (!response.ok || (data && data.success === false)) {
throw new Error(data?.error || `Запрос ${url} завершился ошибкой ${response.status}`);
throw new Error(
data?.error || `Запрос ${url} завершился ошибкой ${response.status}`,
);
}
return data;
}
export const api = {
state: () => request('/api/state'),
config: () => request('/api/config'),
state: () => request("/api/state"),
config: () => request("/api/config"),
rules: {
get: () => request('/api/rules'),
save: (rules) => request('/api/rules', { method: 'PUT', body: JSON.stringify({ rules }) }),
get: () => request("/api/rules"),
save: (rules) =>
request("/api/rules", { method: "PUT", body: JSON.stringify({ rules }) }),
},
subscription: {
fetch: (url) => request('/api/subscription/fetch', { method: 'POST', body: JSON.stringify({ url }) }),
forget: () => request('/api/subscription', { method: 'DELETE' }),
fetch: (url) =>
request("/api/subscription/fetch", {
method: "POST",
body: JSON.stringify({ url }),
}),
forget: () => request("/api/subscription", { method: "DELETE" }),
},
apply: (selectedTag) => request('/api/apply', { method: 'POST', body: JSON.stringify({ selectedTag }) }),
apply: (selectedTag) =>
request("/api/apply", {
method: "POST",
body: JSON.stringify({ selectedTag }),
}),
singbox: {
stop: () => request('/api/singbox/stop', { method: 'POST' }),
restart: () => request('/api/singbox/restart', { method: 'POST' }),
clear: () => request('/api/singbox/clear', { method: 'POST' }),
stop: () => request("/api/singbox/stop", { method: "POST" }),
restart: () => request("/api/singbox/restart", { method: "POST" }),
clear: () => request("/api/singbox/clear", { method: "POST" }),
},
};