feat: simplify SCUM activity management

This commit is contained in:
npc0-hue
2026-09-20 21:22:15 +08:00
parent 1488d5a43e
commit ab1cd01351
5 changed files with 217 additions and 157 deletions
@@ -92,12 +92,14 @@ type SCUMPlatformSurfaceKey = "players" | "vehicles" | "trajectories" | "vehicle
// Squads and members load once per refresh; hovering, selecting and playback issue 0 API calls.
// Call budget per gifts load/15s refresh: 5 bounded plugin collections + 1 typed SCUM surface.
// Searching, viewing a definition and opening the editor issue 0 additional API calls.
// Call budget per activity load/15s refresh: 5 bounded plugin collections and 0 platform SCUM calls.
// Expanding an activity, picking a map region, and editing its item list issue 0 additional API calls.
const pageCollections: Record<PageKey, PluginCollectionSurfaceKey[]> = {
players: ["members", "activityEvents", "giftClaims", "pendingGifts", "giftDeliveries"],
squads: ["squads", "members", "flags"],
"live-map": ["mapPoints", "mapRegions", "mapSettings", "flags", "squads", "members", "tradeGoods"],
gifts: ["gifts", "giftClaims", "pendingGifts", "giftDeliveries", "timedGiftEvents"],
workflows: ["events", "eventProduces", "eventRuns", "nativeEventRounds", "tasks", "activityEvents", "tradeGoods", "tradeEvents"]
workflows: ["events", "eventProduces", "eventRuns", "mapRegions", "mapSettings"]
};
const pageSCUMTables: Record<PageKey, SCUMPlatformSurfaceKey[]> = {
@@ -105,7 +107,7 @@ const pageSCUMTables: Record<PageKey, SCUMPlatformSurfaceKey[]> = {
squads: ["players"],
"live-map": ["players", "vehicles", "trajectories", "vehicleLocks"],
gifts: ["players"],
workflows: ["players", "vehicles", "trajectories", "vehicleLocks"]
workflows: []
};
export async function loadSCUMSurface(actions: SCUMWorkspaceActions, pageKey: string): Promise<SCUMSurfaceData> {
@@ -182,7 +184,9 @@ export async function queueGiftDelivery(actions: SCUMWorkspaceActions, gift: Rec
export async function saveEventDefinition(actions: SCUMWorkspaceActions, event: RecordMap): Promise<unknown> {
const key = requiredKey(event, "id", "活动编号");
return requirePluginData(actions).put(scumCollections.events, key, event);
const storedEvent = { ...event };
if (event.items !== undefined) storedEvent.items = parseGiftItems(event.items);
return requirePluginData(actions).put(scumCollections.events, key, storedEvent);
}
export async function deleteEventDefinition(actions: SCUMWorkspaceActions, key: string, produces: RecordMap[] = []): Promise<void> {