Dashboard UI overhaul: modern design with system stats, SVG icons, Inter font, theme toggle, loading states, and log modal
This commit is contained in:
@@ -1,13 +1,33 @@
|
||||
const BASE = "/api";
|
||||
export async function get(path) {
|
||||
const r = await fetch(BASE + path);
|
||||
return r.json();
|
||||
|
||||
async function request(path, opts = {}) {
|
||||
try {
|
||||
const r = await fetch(BASE + path, opts);
|
||||
if (!r.ok) throw new Error(`HTTP ${r.status}`);
|
||||
return r.json();
|
||||
} catch (e) {
|
||||
console.error(`API ${opts.method || "GET"} ${path}:`, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export async function post(path) {
|
||||
const r = await fetch(BASE + path, { method: "POST" });
|
||||
return r.json();
|
||||
|
||||
export function get(path) {
|
||||
return request(path);
|
||||
}
|
||||
export async function del(path) {
|
||||
const r = await fetch(BASE + path, { method: "DELETE" });
|
||||
return r.json();
|
||||
|
||||
export function post(path) {
|
||||
return request(path, { method: "POST" });
|
||||
}
|
||||
|
||||
export function del(path) {
|
||||
return request(path, { method: "DELETE" });
|
||||
}
|
||||
|
||||
export async function upload(path, file) {
|
||||
const form = new FormData();
|
||||
form.append("file", file);
|
||||
return request(`/files/upload?path=${encodeURIComponent(path)}`, {
|
||||
method: "POST",
|
||||
body: form,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user