@hzab/utils 1.0.1-beta1 → 1.0.1

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,9 +1,11 @@
1
- # @hzab/utils@1.0.1
2
-
3
- feat: OssUploadUtil
4
-
5
- # @hzab/utils@1.0.0
6
- 优化文件上传逻辑
7
-
8
- # @hzab/utils@0.0.1
1
+ # @hzab/utils@1.0.1
2
+
3
+ feat: OssUploadUtil
4
+ feat: 新增二维码,创建、获取,区分测试、正式环境
5
+
6
+
7
+ # @hzab/utils@1.0.0
8
+ 优化文件上传逻辑
9
+
10
+ # @hzab/utils@0.0.1
9
11
  组件初始化
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/utils",
3
- "version": "1.0.1-beta1",
3
+ "version": "1.0.1",
4
4
  "description": "utils",
5
5
  "main": "src",
6
6
  "scripts": {
package/src/scan-qr.ts CHANGED
@@ -17,7 +17,7 @@ function objToBlob(obj: object, charset = "utf-8") {
17
17
 
18
18
  // 定义更清晰的类型
19
19
 
20
- interface GetCodeOptProps {
20
+ interface CodeOptProps {
21
21
  baseUrl?: string;
22
22
  env: "test" | "prod";
23
23
  }
@@ -30,7 +30,7 @@ interface GetCodeOptProps {
30
30
  */
31
31
  const getCodeInfo = async (
32
32
  id: string | number,
33
- opt: GetCodeOptProps
33
+ opt: CodeOptProps
34
34
  ): Promise<unknown> => {
35
35
  const { env, baseUrl } = opt;
36
36
  try {
@@ -47,6 +47,7 @@ const getCodeInfo = async (
47
47
 
48
48
 
49
49
 
50
+
50
51
  /**
51
52
  * 设置二维码信息
52
53
  * @param value 二维码信息对象
@@ -55,7 +56,11 @@ const getCodeInfo = async (
55
56
  */
56
57
  const setCodeInfo = async (
57
58
  value: object,
59
+ opt: CodeOptProps
60
+
58
61
  ): Promise<unknown> => {
62
+ const { env } = opt;
63
+
59
64
  try {
60
65
  const id = nanoidNumALetters();
61
66
  const file = objToBlob(value) as File;
@@ -63,10 +68,10 @@ const setCodeInfo = async (
63
68
  const uploadResult = await ossUploader.upload(file, {
64
69
  fileName: id,
65
70
  params: {
66
- dir: "/qr-code/test",
71
+ dir: `/qr-code/${env}`,
67
72
  },
68
- });
69
- const fileUrl = uploadResult?.fileUrl;
73
+ }) as any;
74
+ const fileUrl = uploadResult?.data?.data?.fileUrl;
70
75
  return {
71
76
  fileUrl,
72
77
  id
@@ -76,4 +81,5 @@ const setCodeInfo = async (
76
81
  }
77
82
  };
78
83
 
84
+
79
85
  export { getCodeInfo, setCodeInfo };