新增中台关卡测试包导出
This commit is contained in:
+5
-4
@@ -16,7 +16,7 @@
|
||||
helpButton.onclick = () => { const help = $('help-dialog'); if (!help.open) help.showModal(); };
|
||||
const exportDialog = document.createElement('dialog'); exportDialog.id = 'project-export-dialog'; exportDialog.setAttribute('aria-labelledby', 'project-export-title');
|
||||
exportDialog.innerHTML = '<form method="dialog"><div class="mainline-heading"><h2 id="project-export-title">导出项目 JSON</h2><button value="cancel" title="关闭" aria-label="关闭"><i data-lucide="x"></i></button></div>' +
|
||||
'<div class="mainline-row"><button id="project-export-changes" value="changes"><i data-lucide="file-diff"></i>导出变更 JSON</button><button id="project-export-all" class="primary" value="all"><i data-lucide="files"></i>导出全部 JSON</button></div></form>';
|
||||
'<div class="mainline-row"><button id="project-export-changes" value="changes"><i data-lucide="file-diff"></i>导出变更 JSON</button><button id="project-export-all" class="primary" value="all"><i data-lucide="files"></i>导出全部 JSON</button><button id="project-export-staging" value="staging"><i data-lucide="folder-down"></i>导出中台测试包</button></div></form>';
|
||||
document.body.append(exportDialog);
|
||||
const input = document.createElement('input'); input.type = 'file'; input.accept = '.json'; input.hidden = true; document.body.append(input);
|
||||
const dialog = document.createElement('dialog'); dialog.id = 'mainline-dialog'; dialog.setAttribute('aria-labelledby', 'mainline-title');
|
||||
@@ -194,7 +194,7 @@
|
||||
projectExport.onclick = () => { if (!state.busy && state.level) { exportDialog.returnValue = 'cancel'; exportDialog.showModal(); } };
|
||||
exportDialog.addEventListener('close', guarded(async () => {
|
||||
const mode = exportDialog.returnValue;
|
||||
if (!['changes', 'all'].includes(mode)) return;
|
||||
if (!['changes', 'all', 'staging'].includes(mode)) return;
|
||||
if (state.busy || !state.level) return;
|
||||
setBusy(true); projectExport.disabled = true;
|
||||
try {
|
||||
@@ -204,9 +204,10 @@
|
||||
const result = await ProjectExport.create(prepared, mode);
|
||||
const url = URL.createObjectURL(new Blob([result.bytes], { type: 'application/zip' }));
|
||||
const link = document.createElement('a'); link.href = url;
|
||||
link.download = '关卡项目文件包-' + (mode === 'all' ? '全部-' : '变更-') + new Date().toISOString().replace(/[:.]/g, '-') + '.zip'; link.click();
|
||||
link.download = mode === 'staging' ? '中台关卡测试包-' + result.revision + '.zip'
|
||||
: '关卡项目文件包-' + (mode === 'all' ? '全部-' : '变更-') + new Date().toISOString().replace(/[:.]/g, '-') + '.zip'; link.click();
|
||||
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
||||
message('已下载' + (mode === 'all' ? '全部' : '变更') + '项目 JSON 包,共 ' + result.manifest.files.length + ' 个文件;请在浏览器下载记录中查看,覆盖前先备份');
|
||||
message(mode === 'staging' ? '已下载中台关卡测试包' : '已下载' + (mode === 'all' ? '全部' : '变更') + '项目 JSON 包,共 ' + result.manifest.files.length + ' 个文件;请在浏览器下载记录中查看,覆盖前先备份');
|
||||
} finally { projectExport.disabled = false; setBusy(false); }
|
||||
}));
|
||||
importButton.onclick = () => { if (!state.busy) input.click(); };
|
||||
|
||||
Reference in New Issue
Block a user