feat(ui): update ui style

This commit is contained in:
RhenCloud 2026-08-16 21:25:57 +08:00
parent ca6dfd3f64
commit 47d7c9105b
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
35 changed files with 1577 additions and 591 deletions

View file

@ -1018,7 +1018,12 @@ export async function adminAudit(event: H3Event): Promise<Record<string, unknown
export async function adminApiMetrics(event: H3Event): Promise<Record<string, unknown>> {
const auth = await requireAnyAccess(event);
const env = cfEnv(event);
const metrics = await getDeliveryMetrics(env.DB);
const query = getQuery(event);
const groupId = String(query["groupId"] ?? "") || undefined;
if (groupId && !auth.scope.isSuper && !auth.scope.groupIds.has(groupId)) {
return respondError(event, 403, "Forbidden");
}
const metrics = await getDeliveryMetrics(env.DB, groupId);
if (auth.scope.isSuper) return { metrics };
return {
metrics: {

View file

@ -4,6 +4,8 @@ import { log } from "../lib/log";
import { migrateGroups, validateGroups } from "../config/schema";
const GROUPS_KEY = "config:groups";
const GROUPS_CACHE_TTL = 300_000;
let groupsCache: { groups: Group[]; expiresAt: number } | null = null;
/**
* Normalizes a group's member list. Groups stored with the legacy `adminIds`
@ -38,9 +40,14 @@ export function normalizeGroupMembers(group: Group): GroupMember[] {
}
export async function loadGroups(kv: KVNamespace): Promise<Group[]> {
if (groupsCache && Date.now() < groupsCache.expiresAt) {
return groupsCache.groups;
}
try {
const stored = await kv.get<Group[]>(GROUPS_KEY, "json");
if (Array.isArray(stored)) return validateGroups(migrateGroups(stored));
const groups = Array.isArray(stored) ? validateGroups(migrateGroups(stored)) : [];
groupsCache = { groups, expiresAt: Date.now() + GROUPS_CACHE_TTL };
return groups;
} catch (err) {
log.warn({ err }, "Failed to load groups from KV");
}
@ -49,6 +56,11 @@ export async function loadGroups(kv: KVNamespace): Promise<Group[]> {
export async function saveGroups(kv: KVNamespace, groups: Group[]): Promise<void> {
await kv.put(GROUPS_KEY, JSON.stringify(groups));
groupsCache = null;
}
export function invalidateGroupsCache(): void {
groupsCache = null;
}
/** Case-insensitive match of a GitHub userId or login against a list of ids/logins. */

View file

@ -10,7 +10,7 @@ export interface Invite {
note?: string;
}
const INVITE_TTL = 7 * 24 * 3600;
const INVITE_TTL = 24 * 3600;
function generateInviteToken(): string {
const bytes = new Uint8Array(32);

View file

@ -1,7 +1,7 @@
import type { Env } from "../types";
const SESSION_COOKIE = "wh_admin_session";
const SESSION_TTL = 7 * 24 * 3600;
const SESSION_TTL = 24 * 3600;
export interface AdminSession {
userId: string;