feat(saves): edit local save nicknames and premium days

Let the launcher update a save's account nickname and replace or clear its remaining premium time. Reuse registration validation and preserve the existing login and password hash.
This commit is contained in:
N0VAN0M4LY committed 2026-11-29 17:41:46 +08:00
1 parent 1d3af395c2
commit d20b7f4249
13 files changed
+127 -19

No files matched your search

+5 -1
View File
@@ -16,7 +16,7 @@ import {
import { LabInfoSchema, LaunchStateSchema } from '../schemas/launch.ts';
import { MaintenanceInfoSchema, MaintenanceProgressSchema, MaintenanceRequestSchema } from '../schemas/maintenance.ts';
import { ActivePatchSetSchema, PackApplyResultSchema, PackCheckSchema } from '../schemas/patch-pack.ts';
import { ResearchBranchSchema, ResearchOperationSchema, SaveResearchSchema, OfficialImportOptionsSchema, OfficialPreviewSchema, SaveOfficialRequestSchema, CurrencyEditsSchema, SaveBackupNameSchema, SaveBackupSchema, SaveDetailsSchema, SaveKeysSchema, SaveListSchema, SaveRegistrationSchema, SaveTransferSchema } from '../schemas/saves.ts';
import { AccountEditsSchema, ResearchBranchSchema, ResearchOperationSchema, SaveResearchSchema, OfficialImportOptionsSchema, OfficialPreviewSchema, SaveOfficialRequestSchema, CurrencyEditsSchema, SaveBackupNameSchema, SaveBackupSchema, SaveDetailsSchema, SaveKeysSchema, SaveListSchema, SaveRegistrationSchema, SaveTransferSchema } from '../schemas/saves.ts';
import { TuningPatchSchema, TuningViewSchema } from '../schemas/tuning.ts';
import { SettingsPatchSchema, SettingsSchema } from '../schemas/settings.ts';
@@ -146,6 +146,10 @@ export const ipcContract = {
input: SaveRegistrationSchema,
output: SaveListSchema,
},
'saves:editAccount': {
input: SaveKeysSchema.extend({ edits: AccountEditsSchema }),
output: SaveDetailsSchema,
},
'saves:editCurrencies': {
input: SaveKeysSchema.extend({ values: CurrencyEditsSchema }),
output: SaveDetailsSchema,
@@ -4,6 +4,9 @@ import { CopyIdSchema } from './install.ts';
export const LocalUserIdSchema = z.string().regex(/^\d+$/);
export const SaveKeysSchema = z.object({ copyId: CopyIdSchema, userId: LocalUserIdSchema });
export const AccountEditsSchema = z.object({ nick: z.string().optional(), premiumDays: z.number().int().nonnegative().optional() });
export type AccountEdits = z.output<typeof AccountEditsSchema>;
export const CurrencyEditsSchema = z.object({
silverLions: z.number().int().nonnegative().optional(),
goldenEagles: z.number().int().min(0).max(0x7fffffff).optional(),