Add files via upload

This commit is contained in:
公明
2026-07-28 10:37:49 +08:00
committed by GitHub
parent ba1796d7ce
commit c616822cd6
3 changed files with 19 additions and 2 deletions
+1
View File
@@ -1106,6 +1106,7 @@
"importValidRows": "Import valid rows",
"importValidRowsCount": "Import {{count}} valid rows",
"importPreviewSummary": "{{total}} rows: {{valid}} valid, {{invalid}} need attention",
"importBackendRowError": "Excel row {{row}} (submitted valid asset #{{index}}): {{message}}",
"previewLimited": "Showing the first 100 rows; all {{count}} rows will be processed",
"fileTypeInvalid": "Only .xlsx and .csv files are supported",
"fileTooLarge": "The file must not exceed 100 MB",
+1
View File
@@ -1094,6 +1094,7 @@
"importValidRows": "导入有效数据",
"importValidRowsCount": "导入 {{count}} 条有效数据",
"importPreviewSummary": "共 {{total}} 行,{{valid}} 行有效,{{invalid}} 行需修正",
"importBackendRowError": "Excel 第 {{row}} 行(提交有效数据第 {{index}} 条):{{message}}",
"previewLimited": "仅展示前 100 行;提交时将处理全部 {{count}} 行",
"fileTypeInvalid": "仅支持 .xlsx 和 .csv 文件",
"fileTooLarge": "文件不能超过 100 MB",
+17 -2
View File
@@ -358,7 +358,8 @@ function renderAssetImportPreview() {
async function submitAssetImport() {
if (assetPageState.importBusy) return;
const assets = assetPageState.importRows.filter(row => !row.error).map(row => row.asset);
const validRows = assetPageState.importRows.filter(row => !row.error);
const assets = validRows.map(row => row.asset);
if (!assets.length) return;
setAssetImportError('');
setAssetImportBusy(true);
@@ -367,7 +368,7 @@ async function submitAssetImport() {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ assets, source: 'manual-import', source_query: assetPageState.importFileName })
});
if (!response.ok) throw new Error(await assetEditorResponseError(response));
if (!response.ok) throw new Error(formatAssetImportSubmitError(await assetEditorResponseError(response), validRows));
const result = await response.json();
const invalid = assetPageState.importRows.length - assets.length;
closeAssetImport(true);
@@ -384,6 +385,20 @@ async function submitAssetImport() {
}
}
function formatAssetImportSubmitError(message, validRows) {
const text = String(message || '').trim();
const match = text.match(/^第\s*(\d+)\s*个资产无效[:]\s*(.+)$/);
if (!match) return text;
const assetNumber = Number(match[1]);
const row = Array.isArray(validRows) ? validRows[assetNumber - 1] : null;
if (!row || !row.rowNumber) return text;
return assetT('assets.importBackendRowError', `Excel 第 ${row.rowNumber} 行(提交有效数据第 ${assetNumber} 条): ${match[2]}`, {
row: row.rowNumber,
index: assetNumber,
message: match[2]
});
}
async function loadAssetOverview() {
try {
const response = await apiFetch('/api/assets/stats?days=' + assetOverviewDays);