feat: 修改 400问题

This commit is contained in:
2026-09-28 22:39:54 +08:00
parent 7f1503294f
commit 0fa7b6bb8f
4 changed files with 57 additions and 3 deletions
@@ -803,6 +803,12 @@ export default function TrialSuitePanel({ product, assets, onRefreshAssets }: Pr
});
const name = cleanFilename(img.name || img.key) || '生图结果';
const suffix = (() => {
const mimeExt: Record<string, string> = {
'image/jpeg': '.jpg', 'image/png': '.png', 'image/webp': '.webp',
'image/gif': '.gif', 'image/bmp': '.bmp',
};
const fromMime = mimeExt[blob.type.split(';')[0].toLowerCase()];
if (fromMime) return fromMime;
try {
return new URL(img.url, window.location.origin).pathname.match(/\.(jpe?g|png|webp|gif|bmp)$/i)?.[0] ?? '.jpg';
} catch {
+11 -1
View File
@@ -11,7 +11,17 @@ const apiClient: AxiosInstance = axios.create({
apiClient.interceptors.response.use(
(response) => response,
(error) => {
async (error) => {
// responseType: 'blob' 也会把 JSON 错误体包装成 Blob,先还原 detail。
const data = error.response?.data;
const contentType = error.response?.headers?.['content-type'] || data?.type || '';
if (data instanceof Blob && contentType.includes('json')) {
try {
error.response.data = JSON.parse(await data.text());
} catch {
// 保留原始响应,由调用方按普通请求错误处理。
}
}
if (envConfig.debug) {
console.error('请求失败:', error.response?.data || error.message);
}