fix(ssa): harden spreadsheet upload recognition and guidance
Fix SSA data-context generation for Excel uploads by parsing xlsx/xls via extension-aware paths instead of UTF-8 fallback. Add on-demand overview rebuild in Agent flow, align xls friendly prompts on frontend/backend, and surface backend upload errors to users. Made-with: Cursor
This commit is contained in:
@@ -137,6 +137,22 @@ export const SSAChatPane: React.FC = () => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
const ext = file.name.split('.').pop()?.toLowerCase() || '';
|
||||
if (ext === 'xls') {
|
||||
const msg = '系统为了保证表格解析的稳定性,当前仅支持 .xlsx / .csv 格式。请您在本地 Excel/WPS 中打开该文件,选择“另存为 -> Excel 工作簿 (.xlsx)”后再次上传。';
|
||||
setUploadStatus('error');
|
||||
setError(msg);
|
||||
addToast(msg, 'error');
|
||||
return;
|
||||
}
|
||||
if (!['csv', 'xlsx'].includes(ext)) {
|
||||
const msg = `不支持的文件类型: .${ext || 'unknown'}。当前支持:.csv、.xlsx`;
|
||||
setUploadStatus('error');
|
||||
setError(msg);
|
||||
addToast(msg, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
setUploadStatus('uploading');
|
||||
setError(null);
|
||||
|
||||
|
||||
@@ -91,7 +91,16 @@ export function useAnalysis(): UseAnalysisReturn {
|
||||
body: formData,
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error('上传失败');
|
||||
if (!response.ok) {
|
||||
let errMsg = '上传失败';
|
||||
try {
|
||||
const errData = await response.json();
|
||||
errMsg = errData?.error || errData?.message || errMsg;
|
||||
} catch {
|
||||
// ignore parse error
|
||||
}
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
const result = await response.json();
|
||||
setUploadProgress(100);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user