0.2.5-dev: a restore-defaults loadout sync is never overwritten by an older in-flight sync (PR #540 by @Xinglan233, ported); importing a loadout with ops is refused before writing when the DIY data is missing (PR #538 by @Xinglan233, ported); the player package's package.json keeps only scripts whose files ship (#531) and its docs link unshipped files to the release tag on GitHub (#530); golden: unchanged

This commit is contained in:
sganggs committed 2026-10-12 14:45:01 +08:00
1 parent 7fd0478dc0
commit 52b70434d0
13 files changed
+610 -5

No files matched your search

+18
View File
@@ -451,6 +451,20 @@ export function importRefusal(kind, ready, status = data.status) {
return null;
}
/**
* A loadout payload that carries `ops` (including empty `ops`) replaces 潜能 / 练度. 自选 operators are in that list
* and only backups.json names them, so the refusal is the 自选编队 one: chess.json and backups.json both loaded.
* Null when the payload has no `ops` (an older file leaves the current 练度 alone) or that data is ready (GitHub #538).
* @param {Record<string, any> | null | undefined} ops
* @param {boolean} ready
* @param {(name: string) => string} [status]
* @returns {{ text: string, tone: 'warn'|'error' } | null}
*/
export function loadoutOpsImportRefusal(ops, ready, status = data.status) {
if (ops == null) return null;
return importRefusal('diy', ready, status);
}
/** In place of a tab whose game data did not load (missingGameData): which files, and what to try (GitHub #173). */
export function DataMissing({ files }) {
const urls = files.map((name) => `/data/${DATA_FILES[name] || `${name}.json`}`);
@@ -586,6 +600,10 @@ function LoadoutScreen({ st }) {
}
const res = parseImport(ioText);
if (!res.ok) { toast(t('导入失败:{error}', { error: res.error }), 'error'); return; }
// ops replaces 潜能 / 练度, including 自选 operators that only backups.json names. Missing data used to drop
// them and still save, clearing a 练度 the file did not mean to erase (GitHub #538).
const opsRefused = loadoutOpsImportRefusal(res.ops, ready);
if (opsRefused) { toast(opsRefused.text, opsRefused.tone); return; }
// 0.2.2: a payload with `ops` replaces the 潜能 / 练度 too (an older export leaves them alone)
const opIds = res.ops ? cultivationCharIds(data.get('chess'), data.get('backups')) : null;
const r = applyLoadoutEntries(res.entries, getChess, res.ops ? { ops: res.ops, isOperator: (id) => opIds.has(id) } : {});