Browse Source

选择厂商

徐勤民 2 months ago
parent
commit
919151b0fa
4 changed files with 30 additions and 1 deletions
  1. 8 0
      CHANGELOG.md
  2. 1 0
      Index.ets
  3. 1 1
      src/main/ets/http/HttpHelper.ts
  4. 20 0
      src/main/ets/utils/ToolsHelperForTS.ts

+ 8 - 0
CHANGELOG.md

@@ -1,4 +1,12 @@
 
+# [v1.0.4] 2024.xx.xx
+
+------
+> - 优化缓存工具
+> - 网络工具优化
+> - 本次更新内容较多,请自行查看文档
+>
+
 # [v1.0.3] 2024.10.15
 
 ------

+ 1 - 0
Index.ets

@@ -2,6 +2,7 @@
  * 常用工具
  */
 export { ToolsHelper } from './src/main/ets/utils/ToolsHelper'
+export { ToolsHelperForTS } from './src/main/ets/utils/ToolsHelperForTS'
 export { AlgorithmHelper } from './src/main/ets/utils/AlgorithmHelper'
 
 /**

+ 1 - 1
src/main/ets/http/HttpHelper.ts

@@ -11,7 +11,7 @@ type HttpParamsGet = {
 }
 type HttpParamsPost = {
   url: string
-  data?: Object
+  data?: string | Object | ArrayBuffer
   query?: Record<string, string> | Object
   headers?: Record<string, string>
 }

+ 20 - 0
src/main/ets/utils/ToolsHelperForTS.ts

@@ -0,0 +1,20 @@
+import { HashMap } from "@kit.ArkTS";
+
+/**
+ * 常用方法,部分方法,在ets里面不能用
+ */
+export class ToolsHelperForTS {
+  // Map转为Record
+  static mapToRecord(myMap: HashMap<string, string>): Record<string, string> {
+    return Object.fromEntries(myMap.entries()) as Record<string, string>;
+  }
+
+  // Record转为Map
+  static recordToMap(myRecord: Record<string, string>): HashMap<string, string> {
+    let myMap: HashMap<string, string> = new HashMap();
+    for (const key in myRecord) {
+      myMap.set(key, myRecord[key]);
+    }
+    return myMap;
+  }
+}