High-performance cross-module routing configuration method, system and equipment based on Gawan system

By automatically generating route configuration functions and files, the problem of repeatedly writing the same code in HarmonyOS app development is solved, improving development efficiency and configuration accuracy, and achieving high-performance cross-module route configuration.

CN120950142APending Publication Date: 2025-11-14CHONGQING CHANGAN AUTOMOBILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511043736.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-28
Publication Date
2025-11-14

AI Technical Summary

Technical Problem

In the development of HarmonyOS apps, in order to achieve routing between modules, developers need to repeatedly write a large amount of code with the same structure, which increases the complexity of routing configuration and reduces development efficiency.

Method used

By obtaining the absolute path address of the routing folder, the text content of the routing file is parsed into an abstract syntax tree. The abstract syntax tree is then used to calculate the routing path and method name, automatically generating routing configuration functions and files, replacing the manual creation of builder functions and modification of configuration files.

Benefits of technology

It reduces the amount of code developers need to write for route configuration, improves development efficiency and the accuracy of route configuration, and simplifies the route path declaration process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120950142A_ABST
    Figure CN120950142A_ABST
Patent Text Reader

Abstract

The invention relates to a high-performance cross-module routing configuration method, system and equipment based on a swan monk system. The method comprises the following steps: acquiring a routing folder relative address sent by a developer through a routing decorator; obtaining an absolute path address of the routing file folder in the computer based on the relative address of the routing file folder, determining all file paths of all routing files in the routing file folder according to the absolute path address of the routing file folder, and determining all file paths of all routing files in the routing file folder according to all file paths of all routing files. Correspondingly analyzing the text content of each routing file into an abstract syntax tree; and calculating a routing path and a routing method name by using all the abstract syntax trees, generating a routing configuration function and a routing configuration file according to the routing path and the routing method name, and performing routing configuration. The problem that developers need to repeatedly write a large number of codes of the same structure in order to achieve the routing jump function between the modules in the development process of the Nan Mongolian app is solved, and the development efficiency and the routing configuration accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of HarmonyOS component routing technology, specifically to a high-performance cross-module routing configuration method, system, and device based on HarmonyOS. Background Technology

[0002] In HarmonyOS app development, multi-module collaborative development is a widely adopted system architecture. However, creating and maintaining routes between modules, and navigating between pages via routes, presents significant challenges. HarmonyOS officially recommends using dynamic routing to address routing issues in multi-module collaborative development. However, using this solution involves several steps, such as... Figure 1 As shown:

[0003] 1. Create a new builder function outside the route component to wrap the route component;

[0004] 2. Create a new file named router_map.json in the specified directory to store information such as the route path and builder function for each page;

[0005] 3. For each new page, steps one and two need to be repeated;

[0006] 4. Configure the routerMap value in the module.json5 file in the module root directory, pointing to the address of router_map.json;

[0007] 5. For each new module, the above four steps need to be repeated for the routing pages within that module;

[0008] 6. After importing the dependencies of each module as needed in the main module of the app, you can use the routing object to implement routing jumps within modules and between modules.

[0009] The above steps reveal that during HarmonyOS app development, in order to enable routing between modules, developers need to repeatedly write a large amount of code with the same structure, such as the builder function, the router_map.json file, and the module.json5 configuration file. This code, which has the same structure but must be written, increases the complexity of routing configuration and greatly reduces the developer's development efficiency. Summary of the Invention

[0010] One objective of this invention is to provide a high-performance cross-module routing configuration method based on the HarmonyOS system, in order to solve the problem that developers need to repeatedly write a large amount of structurally identical code to implement the routing jump function between modules during the development of HarmonyOS apps; a second objective is to provide a high-performance cross-module routing configuration system based on the HarmonyOS system; a third objective is to provide an electronic device; and a fourth objective is to provide a computer-readable storage medium.

[0011] To achieve the above objectives, the technical solution adopted by the present invention is as follows:

[0012] A high-performance cross-module routing configuration method based on the HarmonyOS system includes the following steps: obtaining the relative address of the routing folder sent by the developer through a pre-built routing decorator; obtaining the absolute path address of the routing folder within the computer based on the relative address of the routing folder, determining the file paths of all routing files within the routing folder according to the absolute path address of the routing folder, and parsing the text content of each routing file into an abstract syntax tree according to the file paths of all routing files; calculating the routing path and routing method name using all abstract syntax trees, generating a routing configuration function and a routing configuration file according to the routing path and the routing method name, and performing routing configuration according to the routing configuration function and the routing configuration file.

[0013] Based on the above technical means, the route path is declared through a simple configuration method. Before the app is compiled to the test platform, the plug-in execution mechanism of the HarmonyOS system is used to execute the automated script engine, parse the route configuration information required by the HarmonyOS dynamic routing scheme, and automatically generate the relevant route configuration files. This replaces the developer's manual operation of creating builder functions for each route component and saving route information in the router_map.json file, which improves development efficiency and the accuracy of route configuration.

[0014] Furthermore, the step of generating the route configuration function and route configuration file based on the route path and route method name includes: generating the route configuration function based on the route method name, wherein the route configuration function is a builder function; writing the content of the builder function into the ETS file, and saving the path information, builder function name, and route path information of the ETS file into the route configuration file, and modifying the route mapping table value in the configuration file format to the address of the route configuration file.

[0015] Based on the above technical means, the builder function is automatically generated based on the routing method name, avoiding the need to manually write repetitive route registration code. The content of the builder function is written into the ETS file, so when modifying the routing behavior, there is no need to change the business code, only the builder function in the ETS file needs to be updated.

[0016] Furthermore, the step of calculating the route path and route method name using all abstract syntax trees includes: traversing the first-level child nodes with abstract syntax trees, determining whether a decorator node exists in the first-level child node based on the type attribute of the first-level child node; when a decorator node is detected in the first-level child node for the first time, and the number of the decorator node is greater than or equal to a preset value, then the decorator node is determined to be the first decorator, and it is determined whether the first decorator is a function expression and whether the name of the first decorator matches the preset route decorator name; if the first decorator is a function expression and the name of the first decorator matches the preset route decorator name, then it is determined whether the parameters of the first decorator include a route path; if the parameters of the first decorator include the route path, then the route path is extracted, and the route method name is obtained based on the type attribute of the first decorator.

[0017] Based on the above technical means, by traversing the first-level child nodes of the AST, the decorator node can be accurately located, eliminating problems such as path spelling errors and missing decorators that may occur when manually writing route configuration files.

[0018] Furthermore, obtaining the absolute path address of the routing folder within the computer includes: concatenating the current project address and the relative address of the routing folder to obtain the absolute path address of the routing folder within the computer.

[0019] Based on the above technical means, the path is automatically concatenated and the absolute path is dynamically generated, ensuring that the code can run in any environment and reducing path spelling errors.

[0020] Furthermore, determining all file paths of all routing files within the routing folder based on the absolute path address of the routing folder includes: extracting the source code file paths with the .ets extension from the absolute path address of the routing folder and the source code file paths with the .ets extension from the paths of all subfolders under the absolute path address of the routing folder, thereby obtaining all file paths of all routing files within the routing folder.

[0021] Based on the above technical means, by recursively traversing the routing folder and all its subfolders, it is ensured that all levels of .ets files are captured, avoiding omissions in manual maintenance. By filtering such files, non-routing files (such as .js, .ts, or configuration files) can be avoided, preventing runtime errors.

[0022] A high-performance cross-module routing configuration system based on HarmonyOS includes: an acquisition module for acquiring the relative address of a routing folder sent by a developer through a pre-built routing decorator; a parsing module for obtaining the absolute path address of the routing folder within the computer based on the relative address of the routing folder, determining the file paths of all routing files within the routing folder based on the absolute path address of the routing folder, and parsing the text content of each routing file into an abstract syntax tree based on the file paths of all routing files; and a routing configuration module for calculating the routing path and routing method name using all abstract syntax trees, generating a routing configuration function and a routing configuration file based on the routing path and the routing method name, and performing routing configuration based on the routing configuration function and the routing configuration file.

[0023] Furthermore, the routing configuration module is also used to: generate the routing configuration function based on the routing method name, wherein the routing configuration function is a builder function; write the content of the builder function into the ETS file, and save the path information of the ETS file, the builder function name, and the routing path information into the routing configuration file, and modify the routing mapping table value in the configuration file format to the address of the routing configuration file.

[0024] Furthermore, the routing configuration module is also used to: traverse the first-level child nodes of the abstract syntax tree, and determine whether there are decorator nodes in the first-level child nodes according to the type attribute of the first-level child nodes; when a decorator node is detected in the first-level child nodes for the first time, and the number of the decorator nodes is greater than or equal to a preset value, then the decorator node is determined to be the first decorator, and it is determined whether the first decorator is a function expression and whether the name of the first decorator matches the preset route decorator name; if the first decorator is a function expression and the name of the first decorator matches the preset route decorator name, then it is determined whether the parameters of the first decorator include a route path; if the parameters of the first decorator include the route path, then the route path is extracted, and the route method name is obtained according to the type attribute of the first decorator.

[0025] Furthermore, the parsing module is also used to: concatenate the current project address and the relative address of the routing folder to obtain the absolute path address of the routing folder within the computer.

[0026] Furthermore, the parsing module is also used to: extract the source code file paths with the .ets extension from the absolute path address of the routing folder and the source code file paths with the .ets extension from the paths of all subfolders under the absolute path address of the routing folder, to obtain all file paths of all routing files in the routing folder.

[0027] An electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the high-performance cross-module routing configuration method based on the HarmonyOS system as described in the above embodiments.

[0028] A computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to implement the high-performance cross-module routing configuration method based on the HarmonyOS system as described in the above embodiments.

[0029] The beneficial effects of this invention are:

[0030] (1) Declare the route path through a simple configuration method. Before the app is compiled to the test platform, use the plugin execution mechanism of the HarmonyOS system to execute the automated script engine, parse the route configuration information required by the HarmonyOS dynamic routing scheme, and automatically generate the relevant files of the route configuration. This replaces the developer's manual operation of creating a builder function for each route component and saving route information in the router_map.json file. Attached Figure Description

[0031] Figure 1 This is a diagram illustrating the manual maintenance of routing configuration relationships in the HarmonyOS dynamic routing scheme in the background technology.

[0032] Figure 2 A flowchart of a high-performance cross-module routing configuration method based on the HarmonyOS system provided by the present invention;

[0033] Figure 3 This is a schematic diagram illustrating the relationship for completing the routing configuration according to the present invention;

[0034] Figure 4 This is a schematic diagram of the automated script engine architecture of the present invention;

[0035] Figure 5 This is a flowchart of the high-performance cross-module routing configuration method based on the HarmonyOS system of the present invention;

[0036] Figure 6 This is a flowchart of the algorithm for calculating routing configuration information based on the AST syntax tree of the present invention;

[0037] Figure 7This is a flowchart illustrating the operation of the automated script engine in the high-performance cross-module routing configuration method based on the HarmonyOS system of the present invention.

[0038] Figure 8 This is a schematic diagram of the high-performance cross-module routing configuration system based on the HarmonyOS system of the present invention;

[0039] Figure 9 This is a schematic diagram of the electronic device structure of the present invention.

[0040] Among them, 100-acquisition module; 200-parsing module; 300-routing configuration module; 901-memory; 902-processor; 903-communication interface. Detailed Implementation

[0041] The embodiments of the present invention will be described below with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention and not for limiting the scope of protection of the present invention.

[0042] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0043] like Figure 2 As shown in the figure, this embodiment proposes a high-performance cross-module routing configuration method based on the HarmonyOS system.

[0044] Figure 3 To complete the routing configuration diagram, developers first need to install the automation script engine. Then, in each module, they need to configure the script engine's entry point and use route decorators to decorate route functions in the routing page. Before the developer compiles the app to the test platform, the automation script engine will be automatically triggered. This engine will automatically generate the route configuration-related builder functions, the router_map file, and modify the routerMap value in the module.json5 configuration file.

[0045] The other modules are handled in the same way.

[0046] Figure 4This diagram illustrates the architecture of the automated script engine in a high-performance cross-module routing configuration scheme based on the HarmonyOS system. The automated script engine relies on the fs module and path module provided by the HarmonyOS system, as well as third-party modules: the TypeScript module and the EJS module.

[0047] Among them, the fs module is used to handle file read and write operations, the path module is used to handle file address information, typescript is used to parse the text content of route files, and ejs is used to dynamically concatenate builder function information.

[0048] In the user operation layer, the only things users need to manually write are the hvigorfile.ts configuration file and the route file. The hvigorfile.ts configuration file specifies the relative address of the route folder and passes the automation script engine to the plugin array, providing the necessary parameters for the execution of the automation script engine.

[0049] Automation layer: Through calculations within the automation script engine, it generates builder functions, router_map.json files, and modifies attribute values ​​within the module.json5 file.

[0050] In step S201, the relative address of the route folder sent by the developer through the pre-built route decorator is obtained.

[0051] In step S202, the absolute path address of the routing folder within the computer is obtained based on the relative address of the routing folder. The file paths of all routing files within the routing folder are determined based on the absolute path address of the routing folder. The text content of each routing file is parsed into an abstract syntax tree based on the file paths of all routing files.

[0052] In step S203, the routing path and routing method name are calculated using all abstract syntax trees, and a routing configuration function and a routing configuration file are generated based on the routing path and routing method name. The routing is then configured based on the routing configuration function and the routing configuration file.

[0053] Specifically, such as Figure 5 As shown, Figure 5 Here is the overall flowchart for a high-performance cross-module routing configuration solution based on HarmonyOS:

[0054] Step S501: In the hvigorfile.ts configuration file under the root directory of each module, the developer specifies the relative address of the routing folder within that module to the automation script engine, and passes the entry point of the automation script engine to the plugin array.

[0055] Step S502: The developer adds a route decorator on the line before the route component in each route page and passes the route path as a parameter;

[0056] Step S503: Compile the app and run it on the test platform. The HarmonyOS development tool DevEco provides a plugin execution mechanism. Before compiling the app, it will first execute the method passed into the plugin array in step S501, that is, execute the automated script engine.

[0057] Step S504: Automatically generate the route configuration functions and route configuration files required for dynamic routing through the automation script engine, including the builder function, the router_map.json file, and modify the routerMap value inside the module.json5 file.

[0058] Specifically, in some embodiments, obtaining the absolute path address of the routing folder within the computer includes: concatenating the current project address and the relative address of the routing folder to obtain the absolute path address of the routing folder within the computer.

[0059] When the automation script engine starts executing, it first parses the relative address of the route folder passed in by the developer.

[0060] Then, using the path module built into the HarmonyOS system, the absolute path address of the folder on the computer is obtained by concatenating the current project address and the route folder address.

[0061] Based on the above technical means, the path is automatically concatenated and the absolute path is dynamically generated, ensuring that the code can run in any environment and reducing path spelling errors.

[0062] Furthermore, in some embodiments, determining all file paths of all routing files within the routing folder based on the absolute path address of the routing folder includes: extracting the source code file paths with the .ets extension from the absolute path address of the routing folder and the source code file paths with the .ets extension from the paths of all subfolders under the absolute path address of the routing folder, thereby obtaining all file paths of all routing files within the routing folder.

[0063] Specifically, the fs file processing module built into the HarmonyOS system is used to read the absolute path address of the routing folder on the computer, and obtain the paths of all subfolders under the absolute path address of the routing folder and the paths of Harmonyarkts files with the .ets extension. For each subfolder, the paths of all Harmonyarkts files with the .ets extension are read, thereby obtaining the file paths of all routing files in the routing folder.

[0064] Based on the above technical means, by recursively traversing the routing folder and all its subfolders, it is ensured that all levels of .ets files are captured, avoiding omissions in manual maintenance. By filtering such files, non-routing files (such as .js, .ts, or configuration files) can be avoided, preventing runtime errors.

[0065] Furthermore, in some embodiments, generating a route configuration function and a route configuration file based on the route path and route method name includes: generating a route configuration function based on the route method name, wherein the route configuration function is a builder function; writing the content of the builder function to an ETS file, and saving the path information of the ETS file, the builder function name, and the route path information to the route configuration file; and modifying the route mapping table value in the configuration file format to the address of the route configuration file.

[0066] Specifically, after obtaining the file paths of all routing files in the routing folder, the fs module is used to read the text content of the routing files; based on the file paths of all routing files, the text content of each routing file is parsed into an abstract syntax tree (AST) using the typescript module;

[0067] The route path and route component method name are calculated from the AST syntax tree;

[0068] Further, using the ejs module, combined with the method name of the route component, the content of the builder function is generated. Through the fs module, the content of the builder function is written to the ets file. Then, the path information of the ets file, the builder function name, and the route path information are saved to the router_map.json file. Finally, the routerMap value of module.json5 is modified to the address of router_map.json.

[0069] Based on the above technical means, the builder function is automatically generated based on the routing method name, avoiding the need to manually write repetitive route registration code. The content of the builder function is written into the ETS file, so when modifying the routing behavior, there is no need to change the business code, only the builder function in the ETS file needs to be updated.

[0070] In some embodiments, the routing path and routing method name are calculated using all abstract syntax trees (ASTs), including: traversing the first-level child nodes of the ASTs; determining whether a decorator node exists in a first-level child node based on its type attribute; when a decorator node is detected for the first time in a first-level child node, and the number of decorator nodes is greater than or equal to a preset value, the decorator node is determined to be the first decorator, and it is determined whether the first decorator is a function expression and whether the name of the first decorator matches the preset routing decorator name; if the first decorator is a function expression and its name matches the preset routing decorator name, it is determined whether the parameters of the first decorator include a routing path; if the parameters of the first decorator include a routing path, the routing path is extracted, and the routing method name is obtained based on the type attribute of the first decorator.

[0071] The preset value can be a threshold set by the user, a threshold obtained through a limited number of experiments, or a threshold obtained through a limited number of computer simulations. For ease of explanation, the preset value is set to 2 in this embodiment of the invention.

[0072] The steps for calculating the route path and route method name using all abstract syntax trees are as follows: Figure 6 As shown:

[0073] Step S601: Parse the text content of the routing file into an Abstract Syntax Tree (AST) structure using the TypeScript module;

[0074] Step S602: Loop through the first-level child nodes of each syntax tree and determine whether the first-level child node is a decorator node based on the kind attribute (i.e., the type attribute) of the child node.

[0075] Step S603: When a decorator node in a first-level child node is detected for the first time, and the number of decorator nodes is greater than or equal to 2, the information of the first decorator is then evaluated.

[0076] Step S604: If the first decorator is a function expression and the name of the decorator is the name of the route decorator, then proceed to the next step of parsing parameters;

[0077] Step S605: Determine whether the parameters of the first decorator contain a route path. If the parameters of the first decorator contain a route path, retrieve the route path and proceed to the next step.

[0078] Step S606: Based on the kind attribute, obtain the name of the first exported method under the first decorator, which is the name of the route method;

[0079] Step S607: Return the routing path and routing method name information to the outside.

[0080] Based on the above technical means, by traversing the first-level child nodes of the AST, the decorator node can be accurately located, eliminating problems such as path spelling errors and missing decorators that may occur when manually writing route configuration files.

[0081] To enable those skilled in the art to further understand the high-performance cross-module routing configuration method based on the HarmonyOS system in the embodiments of the present invention, the following detailed description is provided in conjunction with specific embodiments, such as... Figure 7 As shown, Figure 7 This is a flowchart illustrating the operation of the automated script engine in a high-performance cross-module routing configuration scheme based on the HarmonyOS system.

[0082] Step S701: When the automation script engine starts executing, the engine will first parse the relative address of the route folder passed in by the developer;

[0083] Step S702: Then, using the path module built into the HarmonyOS system, the absolute path address of the folder on the computer is obtained by concatenating the current project address and the route folder address;

[0084] Step S703: Next, use the fs file processing module built into the HarmonyOS system to read the absolute path address obtained in step S702, obtain the paths of all subfolders under that address and the paths of HarmonyOS arkts files with the .ets extension. For the subfolders, continue to execute step S703 until all HarmonyOS arkts files with the .ets extension are read.

[0085] Step S704: After obtaining all file paths of all routing files, use the fs module to read the text content of all files;

[0086] Step S705: Parse the text content of all files read in step S704 into an AST syntax tree using the TypeScript module;

[0087] Step S706: Calculate the routing path and routing component method name from the AST syntax tree according to the specified algorithm;

[0088] Step S707: Using the ejs module, combined with the method name of the route component, generate the content of the builder function. Using the fs module, write the content of the builder function to the ets file. Then, save the path information of the ets file, the builder function name, and the route path information to the router_map.json file. Finally, modify the routerMap value of module.json5 to the address of router_map.json.

[0089] In summary, the content of this invention specifically includes the following three parts:

[0090] 1. Create a route decorator

[0091] This is achieved by creating a route decorator, which establishes an agreement with the developer. The developer uses this route decorator to pass custom route paths to the routing component internally.

[0092] 2. Automation Script Engine

[0093] The automated script engine receives the relative address of the routing folder from the developer, uses the fs and path modules provided by the HarmonyOS system to traverse all the routing files in the folder, and then uses the TypeScript module to translate the contents of the routing files into an AST syntax tree. By parsing the syntax tree, the routing path and routing component name are obtained. Then, the fs module generates the builder function, and the builder function name, routing path, and builder function address are written into the router_map.json file. Finally, the fs module modifies the routerMap value inside module.json5 to complete the routing configuration.

[0094] 3. Execute the plugin

[0095] In the hvigorfile.ts configuration file located in the module's root directory, pass in the entry point for the automation script engine, along with the relative address of the routing folder within the module. The next time the project is compiled, the HarmonyOS development tool will execute the automation script engine before compiling the app to complete the configuration of all routing components.

[0096] Before using this solution, each page in each module required manually creating a builder function and a router_map.json file. A builder function required 5 lines of code, and a router_map.json file contained at least 8 lines of code for routing information. Therefore, a developer had to write at least 13 lines of code related to routing configuration for each routing page. Assuming there were 10 modules, each with 10 pages, the developer would need to write 1300 lines of code. After using this solution, the developer only needs to add a route decorator before the routing component on each page, requiring only 100 lines of code. Compared to before, the amount of manually written code is reduced by 92%, significantly reducing the amount of code developers need to write for routing configuration and improving development efficiency and the accuracy of routing configuration.

[0097] This invention proposes a high-performance cross-module routing configuration method based on the HarmonyOS system. The method obtains the relative address of the routing folder sent by the developer through a pre-built routing decorator. Based on the relative address, it obtains the absolute path address of the routing folder within the computer. It then determines the file paths of all routing files within the routing folder based on the absolute path address. Based on the file paths of all routing files, it parses the text content of each routing file into an abstract syntax tree. Using all abstract syntax trees, it calculates the routing path and routing method name. Based on the routing path and routing method name, it generates routing configuration functions and routing configuration files for routing configuration. This invention declares routing paths through a simple configuration method. Before the app is compiled to the test platform, it utilizes the plugin execution mechanism of the HarmonyOS system to execute an automated script engine, parses the routing configuration information required by the HarmonyOS dynamic routing scheme, and automatically generates the relevant routing configuration files. This replaces the developer's manual creation of builder functions for each routing component and saving routing information in the `router_map.json` file. This solves the problem of developers repeatedly writing a large amount of structurally identical code to implement routing jumps between modules during HarmonyOS app development, reducing the amount of code developers need to write for routing configuration and improving development efficiency and the accuracy of routing configuration.

[0098] This embodiment also proposes a high-performance cross-module routing configuration system based on the HarmonyOS system, such as... Figure 8 As shown, the high-performance cross-module routing configuration system 10 based on HarmonyOS includes: an acquisition module 100, a parsing module 200, and a routing configuration module 300.

[0099] The module includes: an acquisition module 100, which acquires the relative address of the route folder sent by the developer through a pre-built route decorator; a parsing module 200, which obtains the absolute path address of the route folder within the computer based on the relative address, determines the file paths of all route files within the route folder based on the absolute path address, and parses the text content of each route file into an abstract syntax tree based on the file paths of all route files; and a route configuration module 300, which calculates the route path and route method name using all abstract syntax trees, generates route configuration functions and route configuration files based on the route path and route method name, and performs route configuration based on the route configuration functions and route configuration files.

[0100] Furthermore, in some embodiments, the routing configuration module 300 is also used to: generate a routing configuration function based on the routing method name, wherein the routing configuration function is a builder function; write the content of the builder function to the ETS file, and save the path information of the ETS file, the builder function name, and the routing path information to the routing configuration file, and modify the routing mapping table value in the configuration file format to the address of the routing configuration file.

[0101] Furthermore, in some embodiments, the routing configuration module 300 is also used to: traverse the first-level child nodes of the abstract syntax tree, and determine whether there is a decorator node in the first-level child node according to the type attribute of the first-level child node; when a decorator node in the first-level child node is detected for the first time, and the number of decorator nodes is greater than or equal to a preset value, then the decorator node is determined to be the first decorator, and it is determined whether the first decorator is a function expression and whether the name of the first decorator matches the preset route decorator name; if the first decorator is a function expression and the name of the first decorator matches the preset route decorator name, then it is determined whether the parameters of the first decorator include a route path; if the parameters of the first decorator include a route path, then the route path is extracted, and the route method name is obtained according to the type attribute of the first decorator.

[0102] Furthermore, in some embodiments, the parsing module 200 is also used to: concatenate the current project address and the relative address of the routing folder to obtain the absolute path address of the routing folder within the computer.

[0103] Furthermore, in some embodiments, the parsing module 200 is also used to: extract the source code file paths with the .ets extension under the absolute path address of the routing folder and the source code file paths with the .ets extension in all subfolder paths under the absolute path address of the routing folder, to obtain all file paths of all routing files in the routing folder.

[0104] The high-performance cross-module routing configuration system based on HarmonyOS proposed in this embodiment of the invention obtains the relative address of the routing folder sent by the developer through a pre-built routing decorator; based on the relative address of the routing folder, it obtains the absolute path address of the routing folder within the computer; based on the absolute path address of the routing folder, it determines the file paths of all routing files within the routing folder; based on the file paths of all routing files, it parses the text content of each routing file into an abstract syntax tree; it uses all abstract syntax trees to calculate the routing path and routing method name; and it generates routing configuration functions and routing configuration files based on the routing path and routing method name for routing configuration. This solves the problem that developers need to repeatedly write a large amount of structurally identical code to implement the routing jump function between modules during HarmonyOS app development, reducing the amount of code developers need to write for routing configuration, improving development efficiency and the accuracy of routing configuration.

[0105] Figure 9 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. The electronic device may include:

[0106] The memory 901, the processor 902, and the computer program stored on the memory 901 and capable of running on the processor 902.

[0107] When the processor 902 executes the program, it implements the high-performance cross-module routing configuration method based on the HarmonyOS system provided in the above embodiments.

[0108] Furthermore, electronic devices also include:

[0109] Communication interface 903 is used for communication between memory 901 and processor 902.

[0110] The memory 901 is used to store computer programs that can run on the processor 902.

[0111] The memory 901 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0112] If the memory 901, processor 902, and communication interface 903 are implemented independently, then the communication interface 903, memory 901, and processor 902 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 9 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0113] Optionally, in a specific implementation, if the memory 901, processor 902, and communication interface 903 are integrated on a single chip, then the memory 901, processor 902, and communication interface 903 can communicate with each other through an internal interface.

[0114] The processor 902 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.

[0115] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described high-performance cross-module routing configuration method based on the HarmonyOS system.

[0116] The above embodiments are merely preferred embodiments provided to fully illustrate the present invention, and the scope of protection of the present invention is not limited thereto. Equivalent substitutions or modifications made by those skilled in the art based on the present invention are all within the scope of protection of the present invention.

Claims

1. A high-performance cross-module routing configuration method based on the HarmonyOS system, characterized in that, Includes the following steps: Retrieve the relative address of the route folder sent by the developer via a pre-built route decorator; Based on the relative address of the routing folder, the absolute path address of the routing folder within the computer is obtained, and the file paths of all routing files within the routing folder are determined according to the absolute path address of the routing folder. Based on the file paths of all routing files, the text content of each routing file is parsed into an abstract syntax tree. Calculate the route path and route method name using all abstract syntax trees, generate a route configuration function and a route configuration file based on the route path and the route method name, and perform route configuration based on the route configuration function and the route configuration file.

2. The method according to claim 1, characterized in that, The step of generating the route configuration function and route configuration file based on the route path and route method name includes: The route configuration function is generated based on the route method name, and the route configuration function is a builder function. Write the contents of the builder function into the ETS file, and save the path information, builder function name, and routing path information of the ETS file into the routing configuration file. Modify the routing mapping table value in the configuration file format to the address of the routing configuration file.

3. The method according to claim 1, characterized in that, The calculation of route paths and route method names using all abstract syntax trees includes: Traverse the first-level child nodes of the abstract syntax tree and determine whether a decorator node exists in the first-level child node based on the type attribute of the first-level child node. When a decorator node in the first-level child node is detected for the first time, and the number of the decorator node is greater than or equal to a preset value, the decorator node is determined to be the first decorator, and it is determined whether the first decorator is a function expression and whether the name of the first decorator matches the preset route decorator name. If the first decorator is a function expression and the name of the first decorator matches the name of the preset route decorator, then determine whether the parameters of the first decorator include a route path; If the parameters of the first decorator include the route path, then the route path is extracted, and the route method name is obtained according to the type attribute of the first decorator.

4. The method according to claim 1, characterized in that, Obtaining the absolute path address of the routing folder within the computer includes: By concatenating the current project address and the relative address of the routing folder, the absolute path address of the routing folder within the computer can be obtained.

5. The method according to claim 1, characterized in that, Determining the file paths of all routing files within the routing folder based on the absolute path address of the routing folder includes: Extract the source code file paths with the .ets extension from the absolute path address of the routing folder and the source code file paths with the .ets extension from the paths of all subfolders under the absolute path address of the routing folder to obtain the file paths of all routing files in the routing folder.

6. A high-performance cross-module routing configuration system based on HarmonyOS, characterized in that, include: The `get` module is used to retrieve the relative address of the route folder sent by the developer through a pre-built route decorator; The parsing module is used to obtain the absolute path address of the routing folder in the computer based on the relative address of the routing folder, determine the file paths of all routing files in the routing folder according to the absolute path address of the routing folder, and parse the text content of each routing file into an abstract syntax tree according to the file paths of all routing files. The routing configuration module is used to calculate the routing path and routing method name using all abstract syntax trees, generate routing configuration functions and routing configuration files based on the routing path and routing method name, and perform routing configuration based on the routing configuration functions and routing configuration files.

7. The system according to claim 6, characterized in that, The routing configuration module is also used for: The route configuration function is generated based on the route method name, and the route configuration function is a builder function. Write the contents of the builder function into the ETS file, and save the path information, builder function name, and routing path information of the ETS file into the routing configuration file. Modify the routing mapping table value in the configuration file format to the address of the routing configuration file.

8. The system according to claim 6, characterized in that, The routing configuration module is also used for: Traverse the first-level child nodes of the abstract syntax tree and determine whether a decorator node exists in the first-level child node based on the type attribute of the first-level child node. When a decorator node in the first-level child node is detected for the first time, and the number of the decorator node is greater than or equal to a preset value, the decorator node is determined to be the first decorator, and it is determined whether the first decorator is a function expression and whether the name of the first decorator matches the preset route decorator name. If the first decorator is a function expression and the name of the first decorator matches the name of the preset route decorator, then determine whether the parameters of the first decorator include a route path; If the parameters of the first decorator include the route path, then the route path is extracted, and the route method name is obtained according to the type attribute of the first decorator.

9. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the high-performance cross-module routing configuration method based on the HarmonyOS system as described in any one of claims 1-5.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor to implement the high-performance cross-module routing configuration method based on HarmonyOS as described in any one of claims 1-5.