feat(saves): localize battle and preset names, merge overview form and guard cache writes

This commit is contained in:
N0VAN0M4LY committed 2026-11-30 19:26:13 +08:00
1 parent e6e75d92c6
commit 7cb1011f0d
11 files changed
+276 -59

No files matched your search

+7 -3
View File
@@ -4,10 +4,11 @@ import { CopyIdSchema } from './install.ts';
export const LocalUserIdSchema = z.string().regex(/^\d+$/);
export const SaveKeysSchema = z.object({ copyId: CopyIdSchema, userId: LocalUserIdSchema });
export const LocalizedNameSchema = z.object({ en: z.string(), zh: z.string() });
export const SaveAvatarIdSchema = z.string().regex(/^cardicon_[a-z0-9_]+$/);
export const SaveAvatarChoicesSchema = z.array(z.object({
id: SaveAvatarIdSchema,
name: z.object({ en: z.string(), zh: z.string() }),
name: LocalizedNameSchema,
}));
export type SaveAvatarChoices = z.output<typeof SaveAvatarChoicesSchema>;
@@ -48,8 +49,10 @@ export const SaveDetailsSchema = z.object({
save: SaveSummarySchema,
maxLevel: z.number().int().positive().nullable(),
battles: z.array(z.object({
id: z.string(), time: z.number(), won: z.boolean().nullable(), mission: z.string(), mode: z.string(),
vehicles: z.array(z.string()), silverLions: z.number(), researchPoints: z.number(),
id: z.string(), time: z.number(), won: z.boolean().nullable(), mission: z.string(),
missionName: LocalizedNameSchema, mode: z.string(),
vehicles: z.array(z.string()), vehicleNames: z.array(LocalizedNameSchema),
silverLions: z.number(), researchPoints: z.number(),
})),
owned: z.array(z.string()),
research: z.array(z.object({ name: z.string(), points: z.number() })),
@@ -87,6 +90,7 @@ export const OfficialPreviewSchema = z.object({
files: z.array(z.object({ name: z.string(), version: z.number().int() })),
presets: z.array(z.object({ country: z.string(), title: z.string(), vehicles: z.array(z.string()) })),
vehicles: z.array(z.string()),
vehicleNames: z.record(z.string(), LocalizedNameSchema),
omitted: z.array(z.string()),
});
export const ResearchBranchSchema = z.object({ country: z.string().min(1), type: z.string().min(1) });