chore: remove dead code and unused dependencies

Cleans up stale implementation artifacts:
- Delete legacy `src/webhook.ts` (dead code per AGENTS.md)
- Delete admin composables `useMe.ts` and `useRoutes.ts`
- Remove unused dependencies `jose` and `yaml`
- Remove stale `Me` interface, `FILTER_LABELS`, `invalidateConfigCache`, and formatter re-exports
This commit is contained in:
RhenCloud 2026-08-11 16:31:13 +08:00
parent 76ba2c0a89
commit e1b1daac98
14 changed files with 7 additions and 320 deletions

View file

@ -1,30 +0,0 @@
import type { Me } from "~/types";
export function useMeApi() {
const me = ref<Me | null>(null);
const loading = ref(false);
const needLogin = ref(false);
async function load(): Promise<void> {
loading.value = true;
needLogin.value = false;
try {
const res = await fetch("/admin/api/me", {
headers: { accept: "application/json" },
credentials: "same-origin",
});
if (res.status === 401) {
needLogin.value = true;
return;
}
if (!res.ok) throw new Error(`HTTP ${res.status}`);
me.value = (await res.json()) as Me;
} catch {
me.value = null;
} finally {
loading.value = false;
}
}
return { me, loading, needLogin, load };
}

View file

@ -1,51 +0,0 @@
import type { Route } from "~/types";
export function useRoutesApi() {
const routes = ref<Route[]>([]);
const loading = ref(false);
const needLogin = ref(false);
const error = ref("");
async function load(): Promise<void> {
loading.value = true;
error.value = "";
needLogin.value = false;
try {
const res = await fetch("/admin/api/routes", {
headers: { accept: "application/json" },
credentials: "same-origin",
});
if (res.status === 401) {
needLogin.value = true;
return;
}
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = (await res.json()) as { routes?: Route[] };
routes.value = data.routes ?? [];
} catch (err) {
error.value = err instanceof Error ? err.message : String(err);
} finally {
loading.value = false;
}
}
async function save(next: Route[]): Promise<void> {
const res = await fetch("/admin/api/routes", {
method: "PUT",
headers: { "content-type": "application/json" },
credentials: "same-origin",
body: JSON.stringify({ routes: next }),
});
if (res.status === 401) {
needLogin.value = true;
throw new Error("unauthorized");
}
if (!res.ok) {
const data = (await res.json().catch(() => ({}))) as { error?: string };
throw new Error(data.error ?? `HTTP ${res.status}`);
}
routes.value = next;
}
return { routes, loading, needLogin, error, load, save };
}

View file

@ -33,13 +33,6 @@ export interface Group {
emoji?: boolean;
}
export interface Me {
login: string;
userId: string;
isSuper: boolean;
groups: Group[];
}
export interface RouteTemplate {
id: string;
nameKey: string;
@ -125,15 +118,6 @@ export const ROUTE_TEMPLATES: RouteTemplate[] = [
export const FILTER_TYPES = ["event", "repo", "actor", "action", "branch", "keyword"] as const;
export const FILTER_LABELS: Record<string, string> = {
event: "Event",
repo: "Repo",
actor: "Actor",
action: "Action",
branch: "Branch",
keyword: "Keyword",
};
export function fmtMatch(match: string | string[]): string {
if (Array.isArray(match)) return match.join(", ");
return String(match ?? "");