@fe-free/core 2.2.13 → 2.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 2.2.15
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: interceptor
8
+ - @fe-free/tool@2.2.15
9
+
10
+ ## 2.2.14
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+ - @fe-free/tool@2.2.14
16
+
3
17
  ## 2.2.13
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "2.2.13",
3
+ "version": "2.2.15",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -41,7 +41,7 @@
41
41
  "remark-gfm": "^4.0.1",
42
42
  "vanilla-jsoneditor": "^0.23.1",
43
43
  "zustand": "^4.5.4",
44
- "@fe-free/tool": "2.2.13"
44
+ "@fe-free/tool": "2.2.15"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@ant-design/pro-components": "2.8.9",
@@ -6,8 +6,11 @@ function downloadInterceptor(instance: AxiosInstance) {
6
6
  const contentDisposition = response.headers['content-disposition'];
7
7
 
8
8
  if (contentDisposition) {
9
- let filename;
9
+ if (response.config.responseType !== 'blob') {
10
+ console.warn('responseType is not blob。', response.config.responseType);
11
+ }
10
12
 
13
+ let filename;
11
14
  // 更加健壮且简洁的写法,优先处理 filename*=,否则处理 filename=
12
15
  if (contentDisposition.includes('filename*=')) {
13
16
  // RFC 5987 格式:filename*=utf-8''xxx
@@ -18,13 +21,10 @@ function downloadInterceptor(instance: AxiosInstance) {
18
21
  const match = contentDisposition.match(/filename\s*=\s*("?)([^";]+)\1/i);
19
22
  filename = match ? decodeURIComponent(match[2]) : undefined;
20
23
  }
21
-
22
24
  filename = filename || 'download';
23
25
 
24
26
  // 处理文件下载 - 确保正确处理二进制数据
25
- const blob = response.data;
26
-
27
- saveAs(blob, filename);
27
+ saveAs(response.data, filename);
28
28
  }
29
29
 
30
30
  return response;