@ruan-cat/utils 1.3.1 → 1.3.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ruan-cat/utils",
3
- "version": "1.3.1",
4
- "description": "阮喵喵工具集合。一个纯typescript库。",
3
+ "version": "1.3.3",
4
+ "description": "阮喵喵工具集合。一个纯typescript库,也提供纯js文件。",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
7
7
  "types": "./src/index.ts",
@@ -19,7 +19,8 @@
19
19
  "import": "./src/index.ts",
20
20
  "types": "./src/index.ts"
21
21
  },
22
- "./src/*": "./src/*"
22
+ "./src/*": "./src/*",
23
+ "./dist/*": "./dist/*"
23
24
  },
24
25
  "keywords": [],
25
26
  "author": {
@@ -35,14 +36,17 @@
35
36
  },
36
37
  "files": [
37
38
  "src",
39
+ "dist",
38
40
  "!src/tests",
39
41
  "tsconfig.json"
40
42
  ],
43
+ "dependencies": {
44
+ "@vueuse/integrations": "^12.3.0",
45
+ "axios": "^1.7.9"
46
+ },
41
47
  "devDependencies": {
42
48
  "@antfu/utils": "^0.7.10",
43
49
  "@types/qs": "^6.9.17",
44
- "@vueuse/integrations": "^12.1.0",
45
- "axios": "^1.7.9",
46
50
  "qs": "^6.13.1",
47
51
  "tsup": "^8.3.5",
48
52
  "type-plus": "^7.6.2",
@@ -50,11 +54,9 @@
50
54
  "typedoc-plugin-markdown": "^4.3.0",
51
55
  "typescript": "5.7.2",
52
56
  "unplugin-vue-router": "^0.10.8",
53
- "@ruan-cat/vuepress-preset-config": "^0.1.14"
57
+ "@ruan-cat/vuepress-preset-config": "^0.1.16"
54
58
  },
55
59
  "peerDependencies": {
56
- "@vueuse/integrations": "^12",
57
- "axios": "^1.7.x",
58
60
  "typescript": "5.7.2",
59
61
  "unplugin-vue-router": "^0.10.8"
60
62
  },
@@ -89,6 +91,7 @@
89
91
  "get-type": "pnpm clean:type && pnpm generate:type-3",
90
92
  "build:-try-1": "pnpm clean:type && vue-tsc -p tsconfig.build.json",
91
93
  "build:tsup": "tsup",
94
+ "build": "pnpm run build:tsup",
92
95
  "rm:node_modules": "rimraf node_modules"
93
96
  }
94
97
  }
@@ -1,6 +1,10 @@
1
1
  import type { RequiredPick } from "type-plus";
2
2
  import type { AxiosRequestConfig, AxiosResponse, AxiosInstance } from "axios";
3
3
  import type { UseAxiosOptions, UseAxiosReturn } from "@vueuse/integrations/useAxios";
4
+ import { useAxios } from "@vueuse/integrations/useAxios";
5
+
6
+ /** 在封装函数时 需要使用该类型 */
7
+ export { UseAxiosOptions };
4
8
 
5
9
  /** 拓展的类型参数 用于约束必填的字段 */
6
10
  export type KeyAxiosRequestConfig<D = any> = keyof AxiosRequestConfig<D>;
@@ -8,6 +12,8 @@ export type KeyAxiosRequestConfig<D = any> = keyof AxiosRequestConfig<D>;
8
12
  /** 填写key值的帮助类型 */
9
13
  export type KeyHelper<K extends KeyAxiosRequestConfig> = K;
10
14
 
15
+ export type RemoveUrl<T extends KeyAxiosRequestConfig> = Exclude<T, "url">;
16
+
11
17
  /**
12
18
  * 创建 AxiosRequestConfig 的各种变种类型
13
19
  * @description
@@ -43,23 +49,25 @@ export interface StrictUseAxiosReturn<
43
49
  ) => Promise<StrictUseAxiosReturn<T, K, R, D>>;
44
50
  }
45
51
 
46
- /**
47
- * 拓展类型参数后的 useAxios 函数
48
- * @description
49
- * 在我们的封装中 使用本类型
50
- */
51
- export declare function useAxios<
52
- T = any,
53
- /** 拓展的类型参数 用于约束必填的字段 */
54
- K extends KeyAxiosRequestConfig<D> = "url",
55
- R = AxiosResponse<T>,
56
- D = any,
57
- >(
58
- url: string,
59
- config: AxiosRequestConfig<D>,
60
- instance: AxiosInstance,
61
- options?: UseAxiosOptions,
62
- ): StrictUseAxiosReturn<T, K, R, D> & Promise<StrictUseAxiosReturn<T, K, R, D>>;
52
+ declare module "@vueuse/integrations/useAxios" {
53
+ /**
54
+ * 拓展类型参数后的 useAxios 函数
55
+ * @description
56
+ * 在我们的封装中 使用本类型
57
+ */
58
+ function useAxios<
59
+ T = any,
60
+ /** 拓展的类型参数 用于约束必填的字段 */
61
+ K extends KeyAxiosRequestConfig<D> = "url",
62
+ R = AxiosResponse<T>,
63
+ D = any,
64
+ >(
65
+ url: string,
66
+ config: AxiosRequestConfig<D>,
67
+ instance: AxiosInstance,
68
+ options?: UseAxiosOptions,
69
+ ): StrictUseAxiosReturn<T, K, R, D> & Promise<StrictUseAxiosReturn<T, K, R, D>>;
70
+ }
63
71
 
64
72
  /** 包装器的参数 */
65
73
  export interface UseAxiosWrapperParams<
@@ -122,5 +130,9 @@ export function useAxiosWrapper<T, K extends KeyAxiosRequestConfig, D = any>(par
122
130
  instance,
123
131
  options,
124
132
  } = params;
133
+ // 跳转到 vueuse 内的函数声明
134
+ // return useAxios<T, AxiosResponse<T>, D>(url, config, instance, options);
135
+
136
+ // 跳转到我们拓展的函数声明
125
137
  return useAxios<T, K, AxiosResponse<T>, D>(url, config, instance, options);
126
138
  }