diff --git a/README.md b/README.md index 6b070ae30f09ddab09a2ab1a7f4faf3b7fa9b383..af0045cf44b643456257bc7e298ed9478c8c2d3c 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ - @ohos.taskpool (启动任务池) - @ohos.uri (URI字符串解析) - @ohos.util (util工具函数) +- @ohos.ArkTSUtils (ArkTSUtils工具函数) - @ohos.util.ArrayList (线性容器ArrayList) - @ohos.util.Deque (线性容器Deque) - @ohos.util.HashMap (非线性容器HashMap) @@ -34,7 +35,6 @@ 1. 首页展示语言基础类库各个子模块菜单,点击进入对应的模块页面。 2. 各个子模块界面中点击功能按钮完成各个功能。 3. Util中有二级菜单,点击进入对应的二级界面,包含: - * StringCode:字符串编解码,点击功能按钮完成各个功能。 * RationnalNumber:有理数比较,点击功能按钮完成各个功能。 * LRUCache:LRU缓冲区,点击功能按钮完成各个功能。 @@ -42,22 +42,25 @@ * Base64Helper:Base64编解码,点击功能按钮完成各个功能。 * TypeCheck:类型检查,点击功能按钮完成各个功能。 * JsonFunction:Json常用方法,点击功能按钮完成各个功能。 -4. Xml & ConvertXml界面中,点击功能按钮完成各个功能。 -5. TaskPool界面中,点击Execute task执行任务,点击Cancel task取消任务。 -6. Url界面中,点击功能按钮完成各个功能。 -7. ArrayList界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 -8. Deque界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 -9. HashMap界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 -10. HashSet界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 -11. LightWeightMap界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 -12. LightWeightSet界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 -13. LinkedList界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 -14. List界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 -15. PlainArray界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 -16. Queue界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 -17. Stack界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 -18. TreeMap界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 -19. TreeSet界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +4. ArkTSUtil中有二级菜单,点击进入对应的二级界面,包含: + * AsonFunction:将ISendable数据类型序列化和反序列化。 +5. Xml & ConvertXml界面中,点击功能按钮完成各个功能。 +6. TaskPool界面中,点击Execute task执行任务,点击Cancel task取消任务。 +7. Url界面中,点击功能按钮完成各个功能。 +8. Url界面中,点击按钮完成uri解析。 +9. ArrayList界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +10. Deque界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +11. HashMap界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +12. HashSet界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +13. LightWeightMap界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +14. LightWeightSet界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +15. LinkedList界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +16. List界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +17. PlainArray界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +18. Queue界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +19. Stack界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +20. TreeMap界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 +21. TreeSet界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。 ### 工程目录 @@ -87,6 +90,7 @@ LanguageBaseClassLibrary │ ├──feature/capabilities/src/main/ets //功能集 │ ├──capabilities //各个子模块功能组件 +│ │ ├──ArkTSUtil.ets //ArkTSUtil功能组件 │ │ ├──ArrayListView.ets //ArrayList功能组件 │ │ ├──ConvertXml.ets //ConvertXml功能组件 │ │ ├──DequeView.ets //DequeView功能组件 @@ -102,6 +106,7 @@ LanguageBaseClassLibrary │ │ ├──TaskPool.ets //TaskPool功能组件 │ │ ├──TreeMapView.ets //TreeMapView功能组件 │ │ ├──TreeSetView.ets //TreeSetView功能组件 +│ │ ├──Uri.ets //Uri功能组件 │ │ ├──Url.ets //Url功能组件 │ │ └──Util.ets │ ├──components @@ -154,7 +159,8 @@ LanguageBaseClassLibrary 2. Xml & ConvertXml:使用xml和convertxml实现xml的解析和生成以及xml转换为js对象,点击按钮实现对应的功能。 3. TaskPool:使用taskpool实现创建后台任务(Task),并对所创建的任务进行如任务执行、任务取消的操作。 4. Url:使用URL对URL字符串的查找参数进行了增删改查的一系列操作,使得读者对URL的结构用途更加明了,点击按钮实现对应的功能。 -5. Util,使用util中不同的功能函数实现以下功能: +5. Uri: 使用URI字符串解析的功能将URI字符串进行解析。 +6. Util,使用util中不同的功能函数实现以下功能: * StringCode:字符串编解码。 * RationnalNumber:有理数比较。 * LRUCache:LRU缓冲区。 @@ -162,19 +168,20 @@ LanguageBaseClassLibrary * Base64Helper:Base64编解码。 * TypeCheck:类型检查。 * JsonFunction:Json对象转字符串,以及对Json数据的增删改查等方法。 -6. ArrayList:展示线性容器ArrayList的数据类型的使用,包括添加、删除。 -7. Deque:展示线性容器Deque的数据类型的使用,包括头部插入、头部删除、尾部删除。 -8. HashMap:展示非线性容器HashMap的数据类型的使用,包括添加键值对、删除键值对。 -9. HashSet:展示非线性容器HashSet的数据类型的使用,包括添加、删除。 -10. LightWeightMap:展示非线性容器LightWeightMap的数据类型的使用,包括添加键值对、删除键值对。 -11. LightWeightSet:展示非线性容器LightWeightSet的数据类型的使用,包括添加、删除。 -12. LinkedList:展示线性容器LinkedList的数据类型的使用,包括尾部添加、头部删除、尾部删除。 -13. List:展示线性容器List的数据类型的使用,包括添加、删除。 -14. PlainArray:展示非线性容器PlainArray的数据类型的使用,包括添加、删除。 -15. Queue:展示线性容器Queue的数据类型的使用,包括尾部添加、头部删除。 -16. Stack:展示线性容器Stack的数据类型的使用,包括尾部添加、尾部删除。 -17. TreeMap:展示非线性容器TreeMap的数据类型的使用,包括添加键值对、删除键值对。 -18. TreeSet:展示非线性容器TreeSet的数据类型的使用,包括添加、删除。 +7. ArkTSUtil,使用ArkTSUtil的功能函数实现ISendable类型数据的序列化与反序列化。 +8. ArrayList:展示线性容器ArrayList的数据类型的使用,包括添加、删除。 +9. Deque:展示线性容器Deque的数据类型的使用,包括头部插入、头部删除、尾部删除。 +10. HashMap:展示非线性容器HashMap的数据类型的使用,包括添加键值对、删除键值对。 +11. HashSet:展示非线性容器HashSet的数据类型的使用,包括添加、删除。 +12. LightWeightMap:展示非线性容器LightWeightMap的数据类型的使用,包括添加键值对、删除键值对。 +13. LightWeightSet:展示非线性容器LightWeightSet的数据类型的使用,包括添加、删除。 +14. LinkedList:展示线性容器LinkedList的数据类型的使用,包括尾部添加、头部删除、尾部删除。 +15. List:展示线性容器List的数据类型的使用,包括添加、删除。 +16. PlainArray:展示非线性容器PlainArray的数据类型的使用,包括添加、删除。 +17. Queue:展示线性容器Queue的数据类型的使用,包括尾部添加、头部删除。 +18. Stack:展示线性容器Stack的数据类型的使用,包括尾部添加、尾部删除。 +19. TreeMap:展示非线性容器TreeMap的数据类型的使用,包括添加键值对、删除键值对。 +20. TreeSet:展示非线性容器TreeSet的数据类型的使用,包括添加、删除。 ### 相关权限 diff --git a/common/src/main/resources/base/element/string.json b/common/src/main/resources/base/element/string.json index 40c0b8513dcc0dba8071cca3a263e6cab1a2aa1a..854c608d5671f2d5929abb2bb4794feca0054f3c 100644 --- a/common/src/main/resources/base/element/string.json +++ b/common/src/main/resources/base/element/string.json @@ -14,19 +14,19 @@ }, { "name": "hash_map", - "value": "HashMap (NoLinear Container HashMap)" + "value": "HashMap (NonLinear Container HashMap)" }, { "name": "hash_set", - "value": "HashSet (NoLinear Container HashSet)" + "value": "HashSet (NonLinear Container HashSet)" }, { "name": "light_weight_map", - "value": "LightWeightMap (NoLinear Container LightWeightMap)" + "value": "LightWeightMap (NonLinear Container LightWeightMap)" }, { "name": "light_weight_set", - "value": "LightWeightSet (NoLinear Container LightWeightSet)" + "value": "LightWeightSet (NonLinear Container LightWeightSet)" }, { "name": "linked_list", @@ -42,7 +42,7 @@ }, { "name": "plain_array", - "value": "PlainArray (NoLinear Container PlainArray)" + "value": "PlainArray (NonLinear Container PlainArray)" }, { "name": "queue", @@ -54,11 +54,11 @@ }, { "name": "tree_map", - "value": "TreeMap (NoLinear Container TreeMap)" + "value": "TreeMap (NonLinear Container TreeMap)" }, { "name": "tree_set", - "value": "TreeSet (NoLinear Container TreeSet)" + "value": "TreeSet (NonLinear Container TreeSet)" } ] } diff --git a/common/src/main/resources/en_US/element/string.json b/common/src/main/resources/en_US/element/string.json index 40c0b8513dcc0dba8071cca3a263e6cab1a2aa1a..854c608d5671f2d5929abb2bb4794feca0054f3c 100644 --- a/common/src/main/resources/en_US/element/string.json +++ b/common/src/main/resources/en_US/element/string.json @@ -14,19 +14,19 @@ }, { "name": "hash_map", - "value": "HashMap (NoLinear Container HashMap)" + "value": "HashMap (NonLinear Container HashMap)" }, { "name": "hash_set", - "value": "HashSet (NoLinear Container HashSet)" + "value": "HashSet (NonLinear Container HashSet)" }, { "name": "light_weight_map", - "value": "LightWeightMap (NoLinear Container LightWeightMap)" + "value": "LightWeightMap (NonLinear Container LightWeightMap)" }, { "name": "light_weight_set", - "value": "LightWeightSet (NoLinear Container LightWeightSet)" + "value": "LightWeightSet (NonLinear Container LightWeightSet)" }, { "name": "linked_list", @@ -42,7 +42,7 @@ }, { "name": "plain_array", - "value": "PlainArray (NoLinear Container PlainArray)" + "value": "PlainArray (NonLinear Container PlainArray)" }, { "name": "queue", @@ -54,11 +54,11 @@ }, { "name": "tree_map", - "value": "TreeMap (NoLinear Container TreeMap)" + "value": "TreeMap (NonLinear Container TreeMap)" }, { "name": "tree_set", - "value": "TreeSet (NoLinear Container TreeSet)" + "value": "TreeSet (NonLinear Container TreeSet)" } ] } diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index fa80c410e3e1e2f268ec1880654c8752f2472573..e552273852a42ee063f8a3070c27790698ea8c1d 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -43,7 +43,7 @@ export default class EntryAbility extends UIAbility { logger.info(TAG, 'window width: ' + windowWidth + ', window width vp: ' + windowWidthVp + ', breakpoint: ' + curBp); AppStorage.setOrCreate('currentBreakpoint', curBp); AppStorage.setOrCreate('windowWidth', windowWidthVp); - AppStorage.setOrCreate('isSplitMode', curBp === 'sm' ? false : true); + AppStorage.setOrCreate('isSplitMode', curBp === 'sm' || 'md' ? false : true); } onDestroy(): void { diff --git a/entry/src/main/ets/pages/components/Capabilities.ets b/entry/src/main/ets/pages/components/Capabilities.ets index 061e2341b0df8f51002823423213fe7c048a97ae..7ebc8bd22ff94236677899e90e9c1046b699b6f8 100644 --- a/entry/src/main/ets/pages/components/Capabilities.ets +++ b/entry/src/main/ets/pages/components/Capabilities.ets @@ -19,7 +19,9 @@ import { ArrayListView, ConvertXml, Url, + Uri, Util, + ArkTSUtil, TaskPool, DequeView, HashMapView, @@ -45,57 +47,45 @@ export struct Capabilities { .strokeWidth('1px') .color($r('sys.color.ohos_id_color_list_separator')) Column() { - // 此处根据选中的菜单,显示对应的页面内容 + // The page content is displayed according to the selected menu. if (this.selectedLabel === getString($r('app.string.xml'))) { ConvertXml() - } - else if (this.selectedLabel === getString($r('app.string.url'))) { + } else if (this.selectedLabel === getString($r('app.string.url'))) { Url() - } - else if (this.selectedLabel === getString($r('app.string.array_list'))) { + } else if (this.selectedLabel === getString($r('app.string.uri'))) { + Uri() + } else if (this.selectedLabel === getString($r('app.string.array_list'))) { ArrayListView() - } - else if (this.selectedLabel === getString($r('app.string.task_pool'))) { + } else if (this.selectedLabel === getString($r('app.string.task_pool'))) { TaskPool() - } - else if (this.selectedLabel === getString($r('app.string.deque'))) { + } else if (this.selectedLabel === getString($r('app.string.deque'))) { DequeView() - } - else if (this.selectedLabel === getString($r('app.string.hash_map'))) { + } else if (this.selectedLabel === getString($r('app.string.hash_map'))) { HashMapView() - } - else if (this.selectedLabel === getString($r('app.string.hash_set'))) { + } else if (this.selectedLabel === getString($r('app.string.hash_set'))) { HashSetView() - } - else if (this.selectedLabel === getString($r('app.string.light_weight_map'))) { + } else if (this.selectedLabel === getString($r('app.string.light_weight_map'))) { LightWeightMapView() - } - else if (this.selectedLabel === getString($r('app.string.light_weight_set'))) { + } else if (this.selectedLabel === getString($r('app.string.light_weight_set'))) { LightWeightSetView() - } - else if (this.selectedLabel === getString($r('app.string.linked_list'))) { + } else if (this.selectedLabel === getString($r('app.string.linked_list'))) { LinkedListView() - } - else if (this.selectedLabel === getString($r('app.string.list'))) { + } else if (this.selectedLabel === getString($r('app.string.list'))) { ListView() - } - else if (this.selectedLabel === getString($r('app.string.plain_array'))) { + } else if (this.selectedLabel === getString($r('app.string.plain_array'))) { PlainArrayView() - } - else if (this.selectedLabel === getString($r('app.string.queue'))) { + } else if (this.selectedLabel === getString($r('app.string.queue'))) { QueueView() - } - else if (this.selectedLabel === getString($r('app.string.stack'))) { + } else if (this.selectedLabel === getString($r('app.string.stack'))) { StackView() - } - else if (this.selectedLabel === getString($r('app.string.tree_map'))) { + } else if (this.selectedLabel === getString($r('app.string.tree_map'))) { TreeMapView() - } - else if (this.selectedLabel === getString($r('app.string.tree_set'))) { + } else if (this.selectedLabel === getString($r('app.string.tree_set'))) { TreeSetView() - } - else { + } else if (this.selectedLabel === getString($r('app.string.util'))) { Util() + } else { + ArkTSUtil() } } .padding({ left: 12, right: 12 }) diff --git a/entry/src/main/resources/base/element/strarray.json b/entry/src/main/resources/base/element/strarray.json index f7ca69c5a1d683021c0fc26931e862aa4d052d10..ba3683b9a1bf7fa57705a885ab3c4a9c73b1a160 100644 --- a/entry/src/main/resources/base/element/strarray.json +++ b/entry/src/main/resources/base/element/strarray.json @@ -13,35 +13,41 @@ { "value": "Url (URL String Parsing)" }, + { + "value": "Uri (URI String Parsing)" + }, { "value": "Util (util)" }, + { + "value": "ArkTSUtil (ArkTSUtil)" + }, { "value": "ArrayList (Linear Container ArrayList)" }, { - "value": "Deque (Linear Container ArrayList)" + "value": "Deque (Linear Container Deque)" }, { - "value": "HashMap (Nonlinear Container HashMap)" + "value": "HashMap (NonLinear Container HashMap)" }, { - "value": "HashSet (Nonlinear Container HashSet)" + "value": "HashSet (NonLinear Container HashSet)" }, { - "value": "LightWeightMap (Nonlinear Container LightWeightMap)" + "value": "LightWeightMap (NonLinear Container LightWeightMap)" }, { - "value": "LightWeightSet (Nonlinear Container LightWeightMap)" + "value": "LightWeightSet (NonLinear Container LightWeightSet)" }, { - "value": "LinkedList (Nonlinear Container LightWeightMap)" + "value": "LinkedList (Linear Container LinkedList)" }, { - "value": "List (Nonlinear Container LightWeightMap)" + "value": "List (Linear Container List)" }, { - "value": "PlainArray (Nonlinear Container PlainArray)" + "value": "PlainArray (NonLinear Container PlainArray)" }, { "value": "Queue (Linear Container Queue)" @@ -50,10 +56,10 @@ "value": "Stack (Linear Container Stack)" }, { - "value": "TreeMap (Nonlinear Container TreeMap)" + "value": "TreeMap (NonLinear Container TreeMap)" }, { - "value": "TreeSet (Nonlinear Container TreeSet)" + "value": "TreeSet (NonLinear Container TreeSet)" } ] } diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index f2e6b1aab376a2c6641e8ff45c6bc098b98d6ff5..e08b374aae1c0d6182b6eeb1f998045cc6daf17d 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -20,17 +20,25 @@ "name": "url", "value": "Url (URL String Parsing)" }, + { + "name": "uri", + "value": "Uri (URI String Parsing)" + }, { "name": "util", "value": "Util (util)" }, + { + "name": "arkts_util", + "value": "ArkTSUtil (ArkTSUtil)" + }, { "name": "array_list", "value": "ArrayList (Linear Container ArrayList)" }, { "name": "task_pool", - "value": "TaskPool (Start Task Pool)" + "value": "TaskPool (Using the Task Pool)" }, { "name": "deque", @@ -38,19 +46,19 @@ }, { "name": "hash_map", - "value": "HashMap (NoLinear Container HashMap)" + "value": "HashMap (NonLinear Container HashMap)" }, { "name": "hash_set", - "value": "HashSet (NoLinear Container HashSet)" + "value": "HashSet (NonLinear Container HashSet)" }, { "name": "light_weight_map", - "value": "LightWeightMap (NoLinear Container LightWeightMap)" + "value": "LightWeightMap (NonLinear Container LightWeightMap)" }, { "name": "light_weight_set", - "value": "LightWeightSet (NoLinear Container LightWeightSet)" + "value": "LightWeightSet (NonLinear Container LightWeightSet)" }, { "name": "linked_list", @@ -62,7 +70,7 @@ }, { "name": "plain_array", - "value": "PlainArray (NoLinear Container PlainArray)" + "value": "PlainArray (NonLinear Container PlainArray)" }, { "name": "queue", @@ -74,11 +82,11 @@ }, { "name": "tree_map", - "value": "TreeMap (NoLinear Container TreeMap)" + "value": "TreeMap (NonLinear Container TreeMap)" }, { "name": "tree_set", - "value": "TreeSet (NoLinear Container TreeSet)" + "value": "TreeSet (NonLinear Container TreeSet)" }, { "name": "age", diff --git a/entry/src/main/resources/en_US/element/strarray.json b/entry/src/main/resources/en_US/element/strarray.json index f7ca69c5a1d683021c0fc26931e862aa4d052d10..ba3683b9a1bf7fa57705a885ab3c4a9c73b1a160 100644 --- a/entry/src/main/resources/en_US/element/strarray.json +++ b/entry/src/main/resources/en_US/element/strarray.json @@ -13,35 +13,41 @@ { "value": "Url (URL String Parsing)" }, + { + "value": "Uri (URI String Parsing)" + }, { "value": "Util (util)" }, + { + "value": "ArkTSUtil (ArkTSUtil)" + }, { "value": "ArrayList (Linear Container ArrayList)" }, { - "value": "Deque (Linear Container ArrayList)" + "value": "Deque (Linear Container Deque)" }, { - "value": "HashMap (Nonlinear Container HashMap)" + "value": "HashMap (NonLinear Container HashMap)" }, { - "value": "HashSet (Nonlinear Container HashSet)" + "value": "HashSet (NonLinear Container HashSet)" }, { - "value": "LightWeightMap (Nonlinear Container LightWeightMap)" + "value": "LightWeightMap (NonLinear Container LightWeightMap)" }, { - "value": "LightWeightSet (Nonlinear Container LightWeightMap)" + "value": "LightWeightSet (NonLinear Container LightWeightSet)" }, { - "value": "LinkedList (Nonlinear Container LightWeightMap)" + "value": "LinkedList (Linear Container LinkedList)" }, { - "value": "List (Nonlinear Container LightWeightMap)" + "value": "List (Linear Container List)" }, { - "value": "PlainArray (Nonlinear Container PlainArray)" + "value": "PlainArray (NonLinear Container PlainArray)" }, { "value": "Queue (Linear Container Queue)" @@ -50,10 +56,10 @@ "value": "Stack (Linear Container Stack)" }, { - "value": "TreeMap (Nonlinear Container TreeMap)" + "value": "TreeMap (NonLinear Container TreeMap)" }, { - "value": "TreeSet (Nonlinear Container TreeSet)" + "value": "TreeSet (NonLinear Container TreeSet)" } ] } diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json index f2e6b1aab376a2c6641e8ff45c6bc098b98d6ff5..ea6be127b7d50bf650507aac12bb7fe758b85f34 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -20,17 +20,26 @@ "name": "url", "value": "Url (URL String Parsing)" }, + { + "name": "uri", + "value": "Uri (URI String Parsing)" + }, { "name": "util", "value": "Util (util)" }, + + { + "name": "arkts_util", + "value": "ArkTSUtil (ArkTSUtil)" + }, { "name": "array_list", "value": "ArrayList (Linear Container ArrayList)" }, { "name": "task_pool", - "value": "TaskPool (Start Task Pool)" + "value": "TaskPool (Using the Task Pool)" }, { "name": "deque", @@ -38,19 +47,19 @@ }, { "name": "hash_map", - "value": "HashMap (NoLinear Container HashMap)" + "value": "HashMap (NonLinear Container HashMap)" }, { "name": "hash_set", - "value": "HashSet (NoLinear Container HashSet)" + "value": "HashSet (NonLinear Container HashSet)" }, { "name": "light_weight_map", - "value": "LightWeightMap (NoLinear Container LightWeightMap)" + "value": "LightWeightMap (NonLinear Container LightWeightMap)" }, { "name": "light_weight_set", - "value": "LightWeightSet (NoLinear Container LightWeightSet)" + "value": "LightWeightSet (NonLinear Container LightWeightSet)" }, { "name": "linked_list", @@ -62,7 +71,7 @@ }, { "name": "plain_array", - "value": "PlainArray (NoLinear Container PlainArray)" + "value": "PlainArray (NonLinear Container PlainArray)" }, { "name": "queue", @@ -74,11 +83,11 @@ }, { "name": "tree_map", - "value": "TreeMap (NoLinear Container TreeMap)" + "value": "TreeMap (NonLinear Container TreeMap)" }, { "name": "tree_set", - "value": "TreeSet (NoLinear Container TreeSet)" + "value": "TreeSet (NonLinear Container TreeSet)" }, { "name": "age", diff --git a/entry/src/main/resources/zh_CN/element/strarray.json b/entry/src/main/resources/zh_CN/element/strarray.json index 19fd4a5d6afd6267795dbaec0e735f2958a89efa..fe4518d1303595e68b569d6559001b22b8837592 100644 --- a/entry/src/main/resources/zh_CN/element/strarray.json +++ b/entry/src/main/resources/zh_CN/element/strarray.json @@ -13,9 +13,15 @@ { "value": "Url (Url字符串解析)" }, + { + "value": "Uri (Uri字符串解析)" + }, { "value": "Util (util工具函数)" }, + { + "value": "ArkTSUtil (ArkTSUtil工具函数)" + }, { "value": "ArrayList (线性容器ArrayList)" }, diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index cca09a7d6f157ad71126b752b8cbc5291b9003ec..b9ad76c6b6e7acb149f29480c105da350a002831 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -20,10 +20,18 @@ "name": "url", "value": "Url (Url字符串解析)" }, + { + "name": "uri", + "value": "Uri (Uri字符串解析)" + }, { "name": "util", "value": "Util (util工具函数)" }, + { + "name": "arkts_util", + "value": "ArkTSUtil (ArkTSUtil工具函数)" + }, { "name": "array_list", "value": "ArrayList (线性容器ArrayList)" diff --git a/feature/capabilities/index.ets b/feature/capabilities/index.ets index 754c0f60ef6ff06227ea43ac5c3cacaf68c9e08c..50e9a59d75b7f42996f4a66b6bf9eb42a708246d 100644 --- a/feature/capabilities/index.ets +++ b/feature/capabilities/index.ets @@ -19,8 +19,12 @@ export { ConvertXml } from './src/main/ets/capabilities/ConvertXml'; export { Url } from './src/main/ets/capabilities/Url'; +export { Uri } from './src/main/ets/capabilities/Uri'; + export { Util } from './src/main/ets/capabilities/Util'; +export { ArkTSUtil } from './src/main/ets/capabilities/ArkTSUtil'; + export { TaskPool } from './src/main/ets/capabilities/TaskPool'; export { DequeView } from './src/main/ets/capabilities/DequeView'; diff --git a/feature/capabilities/src/main/ets/capabilities/ArkTSUtil.ets b/feature/capabilities/src/main/ets/capabilities/ArkTSUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..a657c03390fa37042a8fb7a3cb1d5c06d9d2ca51 --- /dev/null +++ b/feature/capabilities/src/main/ets/capabilities/ArkTSUtil.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { getString } from '@ohos/common'; +import { MenuList } from '@ohos/menuitems'; +import { AsonFunction } from '../components/arkTSUtilcomponents/AsonFunction'; + +@Component +export struct ArkTSUtil { + @StorageLink('selectedSecondLabel') selectedSecondLabel: string = ''; + + @Builder + ArkTSUtilCapabilities() { + if (this.selectedSecondLabel === getString($r('app.string.ason_function'))) { + AsonFunction() + } + } + + build() { + Column() { + MenuList({ menuList: $r('app.strarray.arkTs_util_menu'), secondLabel: true }) { + Column() { + Divider() + .strokeWidth('1px') + .color($r('sys.color.ohos_id_color_list_separator')) + this.ArkTSUtilCapabilities() + } + } + } + .margin({ left: -12, right: -12 }) + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/capabilities/Uri.ets b/feature/capabilities/src/main/ets/capabilities/Uri.ets new file mode 100644 index 0000000000000000000000000000000000000000..11b5d2314bae9aa074ca4c1049c89e5286ffdd9d --- /dev/null +++ b/feature/capabilities/src/main/ets/capabilities/Uri.ets @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { uri } from '@kit.ArkTS'; +import { promptAction } from '@kit.ArkUI'; +import { ColumnOperation } from '../components/ColumnOperation'; + +@Component +export struct Uri { + @State output: string = 'https://username:password@host:8080/directory/file?foo=1&bar=2#fragment'; + @State URI: uri.URI = new uri.URI(this.output); + @State host: string = ''; + @State fragment: string = ''; + @State path: string = ''; + @State scheme: string = ''; + @State userInfo: string = ''; + @State query: string = ''; + + UriResolution() { + if (this.output.indexOf('://') === -1) { + promptAction.showToast({ + message: 'Please enter a correct URI.', + duration: 3000 + }); + } else { + this.host = this.URI.host; + this.fragment = this.URI.fragment; + this.path = this.URI.path; + this.scheme = this.URI.scheme; + this.userInfo = this.URI.userInfo; + this.query = this.URI.query; + } + } + + build() { + Scroll() { + Column() { + Column() { + TextArea({ text: this.output }) + .onChange(value => { + if (value !== '') { + this.output = value; + this.URI = new uri.URI(value); + } + }) + .height(124) + .fontColor($r('app.color.textarea_color')) + .backgroundColor(Color.White) + + Row() { + Text($r('app.string.parsed_data')) + } + .width('100%') + .margin({ top: 16 }) + .justifyContent(FlexAlign.Start) + + Column() { + Row() { + Text('host:') + Text(this.host) + } + .width('100%') + .justifyContent(FlexAlign.Start) + + Row() { + Text('fragment:') + Text(this.fragment) + } + .width('100%') + .justifyContent(FlexAlign.Start) + .margin({ top: 8 }) + + Row() { + Text('path:') + Text(this.path) + } + .width('100%') + .justifyContent(FlexAlign.Start) + .margin({ top: 8 }) + + Row() { + Text('scheme:') + Text(this.scheme) + } + .width('100%') + .justifyContent(FlexAlign.Start) + .margin({ top: 8 }) + + Row() { + Text('userInfo:') + Text(this.userInfo) + } + .width('100%') + .justifyContent(FlexAlign.Start) + .margin({ top: 8 }) + + Row() { + Text('query:') + Text(this.query) + } + .width('100%') + .justifyContent(FlexAlign.Start) + .margin({ top: 8 }) + } + .borderRadius(16) + .backgroundColor(Color.White) + .margin({ top: 16 }) + .padding(16) + } + + Column() { + ColumnOperation({ operationRes: $r('app.strarray.uri_operations'), doOperation: this.doOperation }) + } + } + .width('100%') + .height('100%') + .padding(16) + .justifyContent(FlexAlign.SpaceBetween) + } + .scrollBar(BarState.Off) + .align(Alignment.Start) + } + + doOperation = (index: number) => { + switch (index) { + case 0: + this.UriResolution(); + break; + + default: + break; + } + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/capabilities/Util.ets b/feature/capabilities/src/main/ets/capabilities/Util.ets index f3fcbdd76c22efbe8f3e4fdefedd78db62282c00..910ee40b8ae7636c23da6f9896a828c364026f7e 100644 --- a/feature/capabilities/src/main/ets/capabilities/Util.ets +++ b/feature/capabilities/src/main/ets/capabilities/Util.ets @@ -54,7 +54,7 @@ export struct Util { build() { Column() { - MenuList({ menuList: $r('app.strarray.util_menu') }) { + MenuList({ menuList: $r('app.strarray.util_menu'), secondLabel: true }) { Column() { Divider() .strokeWidth('1px') diff --git a/feature/capabilities/src/main/ets/components/arkTSUtilcomponents/AsonFunction.ets b/feature/capabilities/src/main/ets/components/arkTSUtilcomponents/AsonFunction.ets new file mode 100644 index 0000000000000000000000000000000000000000..85af42ac3212ce71262b8c07a1028f04490a1c5c --- /dev/null +++ b/feature/capabilities/src/main/ets/components/arkTSUtilcomponents/AsonFunction.ets @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ArkTSUtils, lang } from '@kit.ArkTS'; +import { ColumnOperation } from '../ColumnOperation'; + +// Construct a custom Sendable data structure. +@Sendable +class CustomData implements lang.ISendable { + name: string; + age: number; + city: string; + + constructor(name: string, age: number, city: string) { + this.name = name; + this.age = age; + this.city = city; + } +} + +@Component +export struct AsonFunction { + @State jsonText: string = '{"name": "John", "age": 30, "city": "Chongqing"}'; + @State resulText: string = ''; + @State actionSheets: Array = []; + + build() { + Scroll() { + Column() { + Column() { + Row() { + Text(this.resulText) + } + .width('91%') + .height(124) + .padding(16) + .backgroundColor(Color.White) + .borderRadius(16) + .alignItems(VerticalAlign.Top) + } + + ColumnOperation({ operationRes: $r('app.strarray.ason_operations'), doOperation: this.doOperation }) + } + .height($r('app.string.text_width_full')) + .width($r('app.string.text_width_full')) + .padding(16) + .justifyContent(FlexAlign.SpaceBetween) + .backgroundColor($r('app.color.page_bg')) + } + .scrollBar(BarState.Off) + .align(Alignment.Start) + } + + doOperation = (index: number) => { + switch (index) { + case 0: + this.resulText = this.Serialization(); + break; + case 1: + this.resulText = this.Deserialize(); + break; + default: + break; + } + } + + Serialization() { + let normalObject: CustomData = new CustomData('John', 30, 'Chongqing'); + let str: string = ArkTSUtils.ASON.stringify(normalObject); + return str; + } + + Deserialize() { + let obj = ArkTSUtils.ASON.parse(this.jsonText) as lang.ISendable; + if (ArkTSUtils.isSendable(obj)) { + return 'result is Sendable'; + } else { + return 'result is not Sendable'; + } + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/components/utilcomponents/JsonFunction.ets b/feature/capabilities/src/main/ets/components/utilcomponents/JsonFunction.ets index cf075d9d29261e601d544ef58f55281453b885ef..2971e0a3dab984c9ec4be1b157c1e9da6ca84665 100644 --- a/feature/capabilities/src/main/ets/components/utilcomponents/JsonFunction.ets +++ b/feature/capabilities/src/main/ets/components/utilcomponents/JsonFunction.ets @@ -20,28 +20,45 @@ import { addAndUpdateAttribute, funJsonToString, funJsonToMap, - funMapToJson + funMapToJson, + deserializationLargeNum } from '../../util/JsonUtil'; @Component export struct JsonFunction { - @State resulText: string = '{"name":"John","age":30,"city":"Chongqing"}'; + @State resulText: string = ''; + @State numberText: string = '{"largeNumber":112233445566778899}'; + @State jsonText: string = '{"name":"John","age":30,"city":"Chongqing"}'; @State actionSheets: Array = []; + @State flag: boolean = true; build() { Scroll() { Column() { - TextArea({ text: this.resulText }) - .width($r('app.float.text_width')) - .height($r('app.float.text_height')) - .fontColor($r('app.color.textarea_color')) - .backgroundColor($r('app.color.bg_white')) + Column() { + Row() { + Text(this.resulText) + } + .width('91%') + .height(124) + .padding(16) + .backgroundColor(Color.White) + .borderRadius(16) + .alignItems(VerticalAlign.Top) + + Row() { + Text(this.flag ? this.jsonText : this.numberText) + .margin({ top: 12 }) + } + .width('91%') + .alignItems(VerticalAlign.Top) + } ColumnOperation({ operationRes: $r('app.strarray.json_operations'), doOperation: this.doOperation }) } .height($r('app.string.text_width_full')) .width($r('app.string.text_width_full')) - .padding($r('app.float.column_padding')) + .padding(16) .justifyContent(FlexAlign.SpaceBetween) .backgroundColor($r('app.color.page_bg')) } @@ -53,21 +70,31 @@ export struct JsonFunction { switch (index) { case 0: this.resulText = deleteAttribute(); + this.flag = true; break; case 1: this.resulText = searchAttribute(); + this.flag = true; break; case 2: this.resulText = addAndUpdateAttribute(); + this.flag = true; break; case 3: this.resulText = funJsonToString(); + this.flag = true; break; case 4: this.resulText = funJsonToMap(); + this.flag = true; break; case 5: this.resulText = funMapToJson(); + this.flag = true; + break; + case 6: + this.resulText = deserializationLargeNum(); + this.flag = false; break; default: break; diff --git a/feature/capabilities/src/main/ets/util/JsonUtil.ets b/feature/capabilities/src/main/ets/util/JsonUtil.ets index f33a7777e5a595c014e9773d604d2d4d0ad2248b..1f0c3249ce5036121b95a2cbb3e1c4f942a35a95 100644 --- a/feature/capabilities/src/main/ets/util/JsonUtil.ets +++ b/feature/capabilities/src/main/ets/util/JsonUtil.ets @@ -98,4 +98,20 @@ export function funMapToJson() { let info: string = JSON.stringify(jsonObject); logger.info(TAG, info); return info; +} + +let options: JSON.ParseOptions = { + bigIntMode: JSON.BigIntMode.PARSE_AS_BIGINT, +} + +export function deserializationLargeNum() { + let numberText = '{"largeNumber":112233445566778899}'; + let numberObj = JSON.parse(numberText, (key: string, value: Object | undefined | null): Object | undefined | null => { + if (key === 'largeNumber') { + return value; + } + return value; + }, options) as Object; + + return `${(numberObj as object)?.["largeNumber"]}`; } \ No newline at end of file diff --git a/feature/capabilities/src/main/resources/base/element/strarray.json b/feature/capabilities/src/main/resources/base/element/strarray.json index 7ac6b5b72df0eedf13ae0d87746b1c011ef09cb2..9c857a0138b4cb7abfdd2be53a70337216f8d555 100644 --- a/feature/capabilities/src/main/resources/base/element/strarray.json +++ b/feature/capabilities/src/main/resources/base/element/strarray.json @@ -26,6 +26,14 @@ } ] }, + { + "name": "arkTs_util_menu", + "value": [ + { + "value": "AsonFunction (Ason function)" + } + ] + }, { "name": "convert_xml_operations", "value": [ @@ -141,6 +149,14 @@ } ] }, + { + "name": "uri_operations", + "value": [ + { + "value": "URI resolution" + } + ] + }, { "name": "json_operations", "value": [ @@ -161,6 +177,20 @@ }, { "value": "Map转JSON" + }, + { + "value": "JSON反序列化使用大数字保留精度" + } + ] + }, + { + "name": "ason_operations", + "value": [ + { + "value": "Serialization" + }, + { + "value": "Deserialize" } ] } diff --git a/feature/capabilities/src/main/resources/base/element/string.json b/feature/capabilities/src/main/resources/base/element/string.json index 5caebd92dd7a467e9c24e57845f499677765203c..021f7411d7c1878ebb5034b3a8351d41104a2413 100644 --- a/feature/capabilities/src/main/resources/base/element/string.json +++ b/feature/capabilities/src/main/resources/base/element/string.json @@ -32,6 +32,10 @@ "name": "json_function", "value": "JsonFunction (Json function)" }, + { + "name": "ason_function", + "value": "AsonFunction (Ason function)" + }, { "name": "create_lru_cache", "value": "create LruCache success" @@ -395,6 +399,10 @@ { "name": "text_width_full", "value": "100%" + }, + { + "name": "parsed_data", + "value": "Parsed data:" } ] } diff --git a/feature/capabilities/src/main/resources/en_US/element/strarray.json b/feature/capabilities/src/main/resources/en_US/element/strarray.json index b740f0bd87093c2035d19125d9d914bd6b3c402a..6547289f4380c16db3b353b261af2f951e8c8ad8 100644 --- a/feature/capabilities/src/main/resources/en_US/element/strarray.json +++ b/feature/capabilities/src/main/resources/en_US/element/strarray.json @@ -26,6 +26,14 @@ } ] }, + { + "name": "arkTs_util_menu", + "value": [ + { + "value": "AsonFunction (Ason function)" + } + ] + }, { "name": "convert_xml_operations", "value": [ @@ -141,6 +149,14 @@ } ] }, + { + "name": "uri_operations", + "value": [ + { + "value": "URI resolution" + } + ] + }, { "name": "json_operations", "value": [ @@ -161,6 +177,20 @@ }, { "value": "Map of JSON" + }, + { + "value": "JSON deserialization uses large numbers to retain precision" + } + ] + }, + { + "name": "ason_operations", + "value": [ + { + "value": "Serialization" + }, + { + "value": "Deserialize" } ] } diff --git a/feature/capabilities/src/main/resources/en_US/element/string.json b/feature/capabilities/src/main/resources/en_US/element/string.json index 5caebd92dd7a467e9c24e57845f499677765203c..021f7411d7c1878ebb5034b3a8351d41104a2413 100644 --- a/feature/capabilities/src/main/resources/en_US/element/string.json +++ b/feature/capabilities/src/main/resources/en_US/element/string.json @@ -32,6 +32,10 @@ "name": "json_function", "value": "JsonFunction (Json function)" }, + { + "name": "ason_function", + "value": "AsonFunction (Ason function)" + }, { "name": "create_lru_cache", "value": "create LruCache success" @@ -395,6 +399,10 @@ { "name": "text_width_full", "value": "100%" + }, + { + "name": "parsed_data", + "value": "Parsed data:" } ] } diff --git a/feature/capabilities/src/main/resources/zh_CN/element/strarray.json b/feature/capabilities/src/main/resources/zh_CN/element/strarray.json index 666b76f69d8c5886dea1c4cb5c28de6d1dc95335..5c5b52f62f1f276c52654f088eccc83f17b5f8c8 100644 --- a/feature/capabilities/src/main/resources/zh_CN/element/strarray.json +++ b/feature/capabilities/src/main/resources/zh_CN/element/strarray.json @@ -26,6 +26,14 @@ } ] }, + { + "name": "arkTs_util_menu", + "value": [ + { + "value": "AsonFunction (Ason方法)" + } + ] + }, { "name": "convert_xml_operations", "value": [ @@ -141,6 +149,14 @@ } ] }, + { + "name": "uri_operations", + "value": [ + { + "value": "URI解析" + } + ] + }, { "name": "json_operations", "value": [ @@ -161,6 +177,20 @@ }, { "value": "Map转JSON" + }, + { + "value": "JSON反序列化使用大数字保留精度" + } + ] + }, + { + "name": "ason_operations", + "value": [ + { + "value": "序列化" + }, + { + "value": "反序列化" } ] } diff --git a/feature/capabilities/src/main/resources/zh_CN/element/string.json b/feature/capabilities/src/main/resources/zh_CN/element/string.json index 4c59ae42d47cc0d8502a3feb73b02b1507822b8d..84d35043e4ad4453136c9365ad0b1dcd8e08a386 100644 --- a/feature/capabilities/src/main/resources/zh_CN/element/string.json +++ b/feature/capabilities/src/main/resources/zh_CN/element/string.json @@ -32,6 +32,10 @@ "name": "json_function", "value": "JsonFunction (Json方法)" }, + { + "name": "ason_function", + "value": "AsonFunction (Ason方法)" + }, { "name": "create_lru_cache", "value": "创建LruCache成功" @@ -395,6 +399,10 @@ { "name": "text_width_full", "value": "100%" + }, + { + "name": "parsed_data", + "value": "解析的数据" } ] } diff --git a/feature/menuitems/src/main/ets/components/MenuNavRouter.ets b/feature/menuitems/src/main/ets/components/MenuNavRouter.ets index 6e6730fe6aa0387ea1a3303c5ca19cf79007d032..4b6d9bb6d01c911c376d0185e162ae8094511cda 100644 --- a/feature/menuitems/src/main/ets/components/MenuNavRouter.ets +++ b/feature/menuitems/src/main/ets/components/MenuNavRouter.ets @@ -27,6 +27,7 @@ export struct MenuNavRouter { @BuilderParam navDestination: () => void; private childList: Array = []; private addAction?: (title: string) => void; + private secondLabel?: boolean; @Builder CustomDivider() { @@ -55,8 +56,11 @@ export struct MenuNavRouter { } .onStateChange((isActivated: boolean) => { if (isActivated) { - this.selectedLabel = item; - this.selectedSecondLabel = item; + if (this.secondLabel) { + this.selectedSecondLabel = item; + } else { + this.selectedLabel = item; + } logger.info(TAG, `NavRouter isActivated= ${isActivated}, selectedLabel=${item}`); } }) diff --git a/feature/menuitems/src/main/ets/menulist/MenuList.ets b/feature/menuitems/src/main/ets/menulist/MenuList.ets index 7564921ef3b2baef9b49d38a43de8e2da99091df..76bfaa779bd4c15bd5481f77fb06feff1a47ba55 100644 --- a/feature/menuitems/src/main/ets/menulist/MenuList.ets +++ b/feature/menuitems/src/main/ets/menulist/MenuList.ets @@ -22,12 +22,13 @@ export struct MenuList { @BuilderParam childNavDestination: () => void; private menuList: Resource | undefined = undefined; private addAction?: (title: string) => void; + private secondLabel?: boolean; build() { List({ space: 12 }) { ListItem() { if (this.menuListData.length > 0) { - MenuNavRouter({ childList: this.menuListData, addAction: this.addAction }) { + MenuNavRouter({ childList: this.menuListData, secondLabel: this.secondLabel, addAction: this.addAction }) { this.childNavDestination() } } diff --git a/screenshots/devices/home.png b/screenshots/devices/home.png index 6f7fcf30a741d340db5c1bef3c3b70141c14719e..f1cdf6e6b52891d40b6937ce45c9cea1f5ed346b 100644 Binary files a/screenshots/devices/home.png and b/screenshots/devices/home.png differ