支持指定路径保存关卡数据包并移除旧中台导出

This commit is contained in:
2026-11-27 10:59:34 +08:00
parent 2362c6d4df
commit c01a0ff7ac
3 changed files with 41 additions and 25 deletions
+1 -10
View File
@@ -7,7 +7,7 @@
return Array.from(new Uint8Array(digest), value => value.toString(16).padStart(2, '0')).join('');
}
async function create(prepared, mode = 'changes') {
if (!['changes', 'all', 'staging'].includes(mode)) throw new Error('导出范围无效');
if (!['changes', 'all'].includes(mode)) throw new Error('导出范围无效');
const { data, files, package: bundle } = prepared, hashes = new Map(), uuids = new Map();
const uuid = name => {
if (!uuids.has(name)) {
@@ -27,15 +27,6 @@
if (name.endsWith('.json') && !writes[name]) writes[name] = { before: text, text };
}
}
if (mode === 'staging') {
const revision = 'test-' + uuid('中台批次');
const archive = Object.fromEntries(Object.entries(writes)
.filter(([name]) => name.startsWith(ProjectFiles.directory))
.map(([name, value]) => [revision + '/' + name.slice(ProjectFiles.directory.length), encode(value.text)]));
archive['release.json'] = encode(JSON.stringify({ schemaVersion: 1, revision }) + '\n');
await new Promise(resolve => setTimeout(resolve, 0));
return { bytes: fflate.zipSync(archive, { level: 6 }), revision };
}
if (!Object.keys(writes).length) throw new Error('没有变更的 JSON,请选择“导出全部 JSON”');
const manifest = { formatVersion: 1, createdAt: new Date().toISOString(), dataVersion: data.dataVersion,
rulesVersion: data.rulesVersion, levelCount: bundle.order.length, exportMode: mode, changedCount,