feat: improve admin experience and ignore local data

This commit is contained in:
2026-04-14 19:12:20 +08:00
parent 6378ab4994
commit 2e3eb4b8f8
10 changed files with 1132 additions and 119 deletions
+20 -7
View File
@@ -28,22 +28,35 @@ export async function saveProxyGroupAction(formData: FormData) {
const settings = await getSubscriptionSettings();
const id = String(formData.get("id") ?? "").trim() || createStableId();
const name = String(formData.get("name") ?? "").trim();
const memberSlugs = formData
.getAll("member_slugs")
.map((value) => String(value))
.filter(Boolean);
const seen = new Set<string>();
const memberSlugs = formData.getAll("member_slugs").flatMap((value) => {
const slug = String(value).trim();
if (!slug || seen.has(slug)) {
return [];
}
seen.add(slug);
return [slug];
});
if (!name) {
return;
}
const proxyGroups = settings.proxyGroups.filter((group) => group.id !== id);
proxyGroups.push({
const nextGroup = {
id,
name,
type: "select",
memberSlugs,
});
} as const;
const existingIndex = settings.proxyGroups.findIndex((group) => group.id === id);
const proxyGroups = [...settings.proxyGroups];
if (existingIndex === -1) {
proxyGroups.push(nextGroup);
} else {
proxyGroups[existingIndex] = nextGroup;
}
await saveProxyGroups(proxyGroups);
revalidatePath("/admin/subscriptions");