Page navigation method, computer program product, device, storage medium and computer equipment
By automatically configuring the navigation node and destination page in the Hongmeng system and using page identifiers to achieve page jump, the problem of developers needing to manually add navigation nodes is solved, reducing development difficulty and achieving routing jump compatibility.
Patent Information
- Application Number
- CN202411121896.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-15
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-08-15
AI Technical Summary
In the Hongmeng system, developers need to manually add Navigation nodes and NavDestination nodes to manage page navigation, resulting in increased development difficulty and routing jumping methods that are not compatible with other systems.
By setting the navigation container page and creating a navigation destination page after the application is started, the Navigation node and NavDestination node are automatically configured, and the page identification is used to achieve page jump and display, encapsulating the page navigation logic of the Hongmeng system, so that developers do not need to deal with it. Low-level navigation details.
It reduces the difficulty and development workload of application software under the Hongmeng system, making the routing jump method compatible with other systems.
Smart Images

Figure CN118642708B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a page navigation method, interface, device, storage medium and computer equipment. Background Art
[0002] In the development environment of HarmonyOS, when using the built-in Navigation framework to manage routing and jumps between pages, the page structure needs to follow some specific rules. Specifically, in order for the page to navigate correctly in HarmonyOS, developers need to explicitly add Navigation nodes and NavDestination nodes in the page code.
[0003] The Navigation node can be understood as the navigation container of the entire application, which is responsible for managing the jumps and navigation logic between pages. The NavDestination node is a specific destination, representing a navigable page or component in the application. These two nodes play a key role in Hongmeng's Navigation framework. They define how pages are connected and how to respond to user navigation operations.
[0004] However, for developers who focus on code logic, dealing with these underlying navigation details may distract them from core functions, making it impossible for developers to describe their page flow and navigation requirements in a more natural way, thereby increasing the difficulty and workload of developing applications under the Hongmeng system. At the same time, it also makes the routing jump method of applications under the Hongmeng system incompatible with other systems. Summary of the invention
[0005] In view of this, the embodiments of the present application provide a page navigation method, interface, device, storage medium and computer equipment, the main purpose of which is to solve the technical problems that the workload of application software development under the Hongmeng system is large and the routing jump method is not compatible with other systems.
[0006] According to one aspect of the present application, a page navigation method is provided, the method comprising:
[0007] After the application is started, the startup page of the application is set as the navigation container page, wherein the root node of the navigation container page includes the system native Navigation node;
[0008] In response to an opening instruction of a target page, a page identifier of the target page is obtained, and a navigation destination page is created, wherein a root node of the navigation destination page includes a system native NavDestination node;
[0009] Based on the page identifier of the target page, the target page is loaded through the navigation destination page, and the target page is displayed.
[0010] According to another aspect of the present application, a page navigation interface is provided, which implements the above-mentioned page navigation method when executed by a processor. The reference parameter of the page navigation interface is a page identifier, and the page navigation interface is used to display a target page corresponding to the page identifier based on the page identifier.
[0011] According to another aspect of the present application, a page navigation device is provided, the device comprising:
[0012] A navigation container page setting module, used to set the startup page of the application as the navigation container page after the application is started, wherein the root node of the navigation container page includes the system native Navigation node;
[0013] A navigation destination page creation module, used to obtain a page identifier of the target page in response to an opening instruction of the target page, and create a navigation destination page, wherein the root node of the navigation destination page includes a system native NavDestination node;
[0014] The target page loading and display module is used to load the target page through the navigation destination page based on the page identifier of the target page and display the target page.
[0015] According to another aspect of the present application, a storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned page navigation method is implemented.
[0016] According to another aspect of the present application, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the above-mentioned page navigation method when executing the program.
[0017] By means of the above technical solution, a page navigation method, interface, device, storage medium and computer device provided in the embodiment of the present application can automatically configure the Navigation node required for page navigation after the application is started by setting the startup page of the application as the navigation container page. By creating a navigation destination page when the target page of the application is opened, the NavDestination node required for page navigation can be automatically configured when the target page is opened. Further, by obtaining the page identifier of the target page and loading the information related to the target page in the navigation destination page, the jump and display of the target page can be realized. The above method encapsulates the Navigation node and NavDestination node required for page navigation of the Hongmeng system in the routing framework layer of the application, so that developers do not need to deal with the underlying navigation details when developing page navigation programs, so that they can focus on the core functions of the application, thereby reducing the development difficulty and development workload of application software under the Hongmeng system, and at the same time, it also makes the routing jump method of the application software under the Hongmeng system compatible with other systems.
[0018] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0020] Figure 1 A schematic diagram showing a flow chart of a page navigation method provided in an embodiment of the present application is shown;
[0021] Figure 2 A schematic diagram showing a flow chart of another page navigation method provided in an embodiment of the present application is shown;
[0022] Figure 3 A schematic diagram of a process of synthesizing a navigation configuration file through a routing configuration file provided in an embodiment of the present application is shown;
[0023] Figure 4 A schematic structural diagram of a page navigation device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0024] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0025] When using the Navigation framework of the Hongmeng system as the basic routing mechanism. In order to meet the specifications of the Hongmeng Navigation framework, the page structure must follow a specific format: first, the global should contain a single Navigation node as a navigation container, and secondly, each page start point must be configured with a corresponding navdestination node to support the page navigation function. Based on this, page developers need to adapt existing pages and declare the Navigation node and the corresponding NavDestination node in the code to ensure that they meet the framework requirements. However, the transformation process of the page code increases the redundant work in the development process, reduces the development efficiency of developers, and increases the development workload of developers.
[0026] In addition, the routing jump method of applications under the Hongmeng system is also not compatible with other systems. The reason is that the applications of other systems currently use page identifiers to achieve page jumps, among which page identifiers are mainly sent down through servers. Since the page navigation logic of the Hongmeng system is different from that of other systems, it is necessary to set up a separate set of page navigation logic for the Hongmeng system. However, the existing page navigation logic of the Hongmeng system cannot directly achieve page jumps through page identifiers.
[0027] In view of the above problems, in one embodiment, Figure 1 As shown, a page navigation method is provided, which is described by taking the method applied to the routing framework layer of a client application as an example, and includes the following steps:
[0028] Step 101: after the application is started, the startup page of the application is set as a navigation container page, wherein the root node of the navigation container page includes a system native Navigation node.
[0029] Specifically, the user can start the application by clicking the icon of the application displayed in the client. After the application is started, the startup page of the application can be set as the navigation container page. Among them, the startup page refers to the first page set to be displayed after the application is started, usually the home page of the application. The routing framework layer can set the startup page of the application as the navigation container page by intercepting the routing destination parameter in the registered routing function that is automatically executed when the application starts, so that the Navigation node can be automatically executed in the process of setting the navigation container page after the application starts. It should be noted that application startup refers to the situation where a closed application is opened in the client, not the situation where an open application is called in the client.
[0030] In this embodiment, the root node of the navigation container page includes the system native Navigation node, and the routing framework layer can automatically create the navigation container page after the application is started. Therefore, the routing framework layer can automatically execute the Navigation node in the process of creating the navigation container page, so that developers do not need to declare the Navigation node in the code when developing page jump programs, thereby reducing the development workload.
[0031] Step 102, in response to the target page opening instruction, obtain the page identifier of the target page, and create a navigation destination page, wherein the root node of the navigation destination page includes the system native NavDestination node.
[0032] Specifically, after the application is started, the user can initiate an opening instruction for any page in the application based on actual needs. At this time, the routing framework layer can respond to the opening instruction for any page (ie, the target page), obtain the page identifier of the target page, and create a navigation destination page.
[0033] In this embodiment, the root node of the navigation destination page includes the system-native NavDestination node, and the routing framework layer can automatically create the navigation destination page upon receiving the opening instruction of the target page, and automatically execute the NavDestination node in the process of creating the navigation destination page. Therefore, when the developer develops the page jump program, he does not need to declare the NavDestination node in the page jump code, and the NavDestination node can be automatically executed when the page jumps, thereby reducing the development workload.
[0034] Step 103: Based on the page identifier of the target page, the target page is loaded through the navigation destination page, and the target page is displayed.
[0035] Specifically, in the process of instantiating the navigation destination page, the routing framework layer can intercept the page creation function, and set the reference parameter of the page creation function to the code file of the target page, and then display the target page by instantiating the code file of the target page. Among them, the code file of the target page can be loaded through the page identifier of the target page after intercepting the page creation function. This embodiment can dynamically load the page information of the target page through the page creation function by modifying the reference parameter of the page creation function in the process of instantiating the navigation destination page, thereby realizing the dynamic display of the target page.
[0036] In this embodiment, the routing framework layer can automatically execute the Navigation node after the application is started, and automatically execute the NavDestination node when the page jumps. Therefore, developers do not need to declare the Navigation node and the NavDestination node in the page development code, but only need to set the mapping relationship between the page identifier and the page code of each page to achieve the jump between pages. In this way, the application under the Hongmeng system can directly receive the page identifier sent by the server and jump to the page, which improves the compatibility of the application and reduces the development workload of developers.
[0037] The technical solution provided in this embodiment can automatically configure the Navigation node required for page navigation after the application is started by setting the startup page of the application as the navigation container page. By creating a navigation destination page when the target page of the application is opened, the NavDestination node required for page navigation can be automatically configured when the target page is opened. Furthermore, by obtaining the page identifier of the target page and loading the information related to the target page in the navigation destination page, the jump and dynamic display of the target page can be achieved. The above method encapsulates the Navigation node and NavDestination node required for page navigation of the Hongmeng system in the routing framework layer of the application, so that developers do not need to deal with the underlying navigation details when developing page navigation programs, so that they can focus on the core functions of the application, thereby reducing the development difficulty and development workload of application software under the Hongmeng system, and also makes the routing jump method of application software under the Hongmeng system compatible with other systems.
[0038] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, another page navigation method is provided, taking the method applied to the routing framework layer of the client application as an example, as shown in FIG. Figure 2 As shown, the method includes:
[0039] Step 201: after the application is started, a navigation configuration file is loaded into the memory of the application, wherein the navigation configuration file stores a mapping relationship between a page identifier and a code path.
[0040] Specifically, after the application is started, the routing framework layer can load the pre-configured navigation configuration file into the memory of the application software, and obtain the real path (page) of the binary code of each page in the application according to the mapping relationship between the page identifier (such as the scheme in the URI) and the code path saved in the navigation configuration file, so that the code file (i.e., class file) corresponding to each page identifier can be created through the real path (page) of the binary code of each page. Among them, URI (Uniform Resource Identifier) refers to a string used to identify code resources, which contains a series of components. One of the key parts is the scheme (or schema). Scheme is the initial component of the URI, which specifies the naming and positioning mechanism used to interpret the rest of the URI.
[0041] Optionally, navigation configuration files can be generated during the compilation phase of the application. Figure 3 ,The navigation configuration file can be generated by the following method: ,During the compilation phase of the application, the routing configuration file (config.json5) of each functional module (HarA, HarB, HarC) in the application is read.,Then, the routing configuration file (config.json5) of each functional module (HarA, HarB, HarC) is parsed and integrated to obtain the navigation configuration file (nav.json5) of the application (Hap).
[0042] In this embodiment, by automatically aggregating the routing configuration files (config.json5) of each functional module (Har) during the compilation phase and generating the navigation configuration file (nav.json5), developers only need to declare the routing configuration file (config.json5) under the root path of each functional module (har package) during the development process, and call the corresponding page navigation interface in the program, and the page jump can be realized through a simple page identification (scheme). The routing configuration file code example is as follows:
[0043] { "erouter": [
[0044] { "page": "src / main / ets / pages / HomePage.ets",
[0045] "scheme": "abc: / / home",
[0046] "launchMode": "standard",
[0047] "main": "Welcome"
[0048] } ]}
[0049] In the above code snippet, "page" is the source code path of the home page, and "scheme" is the page identifier of the home page. Developers can configure the mapping relationship between "page" and "scheme" in the routing configuration file (config.json5) to import the code path of the home page into the application's memory after the application starts, thereby creating a code file (i.e., class file) for the home page in the application.
[0050] Optionally, the method of parsing and integrating the routing configuration files of each functional module to obtain the navigation configuration file of the application can be implemented in the following way: first, the routing configuration files of each functional module are parsed to obtain the source code path corresponding to each page identifier in each functional module; then, based on the source code path corresponding to each page identifier in each functional module, the routing information table generated in the compilation stage is used to query the binary code path corresponding to each page identifier in each functional module; finally, the binary code path corresponding to each page identifier in each functional module is integrated to obtain the navigation configuration file of the application.
[0051] In this embodiment, in the process of packaging the application into an application package (Hap), the compiler can automatically collect the routing configuration files (config.json5 files) of all functional modules (Har) and merge them into a navigation configuration file (nav.json5 file). Among them, each entry in the navigation configuration file (nav.json5 file) defines the correspondence between the binary code path (page) and the page identifier (scheme) (that is, each entry represents a piece of routing information). Among them, the binary code path (page) is the file code path when loaded into the client application memory. This path can be obtained by mapping the page identifier (scheme) field in the routing configuration file (config.json5) of each functional module in the routing information table (filesInfo.txt) file. The page identifier (scheme) is directly inherited from the routing configuration file (config.json5 file) of each module, indicating the unique routing identifier uri.
[0052] This embodiment integrates the binary code path corresponding to each page identifier in the navigation configuration file and loads the navigation configuration file into the memory of the application. This makes it easy to find the code corresponding to each page identifier through the binary code path when the application starts, thereby creating a code file corresponding to each page identifier so that each page can be dynamically displayed during the operation of the application.
[0053] Step 202, traverse the code paths corresponding to the various page identifiers in the navigation configuration file, and create code files corresponding to the various page identifiers through the code paths corresponding to the various page identifiers.
[0054] Specifically, the routing framework layer can load the code of the page into the memory through the dynamic import capability provided by the system. Among them, dynamic import refers to the function of dynamically loading and executing modules or code snippets during the operation of the application. Compared with static import (which modules to import are determined before the program starts running), dynamic import enables the application to load necessary modules on demand according to the needs of runtime, thereby improving the flexibility and efficiency of the application operation. In this embodiment, the routing framework layer can obtain the source code corresponding to each page identifier through the code path corresponding to each page identifier recorded in the navigation configuration file, and then create a code file corresponding to each page identifier through the source code corresponding to each page identifier, thereby loading the code file corresponding to each page identifier into the memory of the application. The code example of creating the code file corresponding to each page identifier through the code path corresponding to each page identifier is as follows:
[0055] function getPageClass(pageName, pagePath) {
[0056] let module = await import(pagePath)
[0057] for (let [key, pageClass] of Object.entries(module)) {
[0058] if (key === pageName) {
[0059] return pageClass
[0060] }}}
[0061] From the above code, we can know that the first parameter pageName of the getPageClass() method represents the page identifier of the page, the second parameter pagePath represents the code path corresponding to the page identifier, and the pageClass returned by the getPageClass() method represents the created code file (i.e., class file) corresponding to the page identifier. Through the above function, the code paths corresponding to each page identifier in the navigation configuration file can be traversed, and the code files corresponding to each page identifier can be created through the code paths corresponding to each page identifier, thereby loading the code files of each page into the memory. Subsequently, the page class of each page can be instantiated through pageClass() to create an instance of the page, so as to dynamically display each page in the application software.
[0062] Step 203: intercept the native registration routing function of the system, and set the startup page of the application as the navigation container page through the registration routing function.
[0063] Specifically, after loading the code files of each page into the memory of the application, the system will automatically execute the registerNamedRoute method (i.e., register the routing function). The registerNamedRoute method is a registration mechanism executed after the page class is loaded, which is used to tell the system how to create and access a specific page instance, and is used to display the corresponding page when a certain routing path is requested.
[0064] In normal operation, when the registerNamedRoute method is called after the application is started, the generator function of the home page will be passed into the registerNamedRoute method as the first parameter, and the instance of the home page will be returned when it is called. As shown in the following program snippet, when the registerNamedRoute method is called, the function "() => newHomePage(undefined, {})" will be passed into the method as a parameter, and a HomePage instance will be created and returned, thereby displaying the home page of the application.
[0065] registerNamedRoute(
[0066] () =>new HomePage(undefined, {}),
[0067] "",
[0068] {pagePath: "pages / HomePage"});
[0069] However, in this embodiment, the routing framework layer will intercept the registration routing function (registerNamedRoute method), and save the routing destination parameter in the registration routing function (i.e., the first parameter of the registerNamedRoute method above, which is the generator function of the home page in the previous example) to the object of the navigation container page, and instantiate the navigation container page, and then set the routing destination parameter in the registration routing function to the instance of the navigation container page, and finally call the registration routing function to set the startup page to the navigation container page through the registration routing function. The code example of intercepting the registration routing function is as follows:
[0070] export function hook_registerNamedRoute() { / / Intercept registerNamedRoute
[0071] let src = registerNamedRoute; / / Save the original registerNamedRoute
[0072] registerNamedRoute = (...args) =>{ / / Define a new registerNamedRoute function
[0073] let genSrcPage = args[0]; / / Get the first parameter genSrcPage, where the first parameter is the generator function of the home page
[0074] args[0] = () =>{ return new NavigationPage(undefined, {"startupPage":genSrcPage})} / / The destination is tampered with the NavigationPage page, that is, it is tampered with the navigation container page, where the genScrPage variable saves the code file of the home page
[0075] src(...args); / / Execute the original function}}
[0076] The above code snippet is part of the interception registration route function hook_registerNamedRoute(). In this example, the first parameter of the registerNamedRoute function is saved to the object of the navigation container page (i.e., the NavigationPage function). The NavigationPage function can receive the generator function of the home page as a parameter and return a new instance of the navigation container page (NavigationPage instance) as the first parameter of the registerNamedRoute function. By doing so, the original generator function of the home page can be converted into an instance of a navigation container page, so that the rendering logic and navigation logic of the home page can be separated, making page jumps and management more convenient and flexible. It also allows developers to implement page navigation of the home page without declaring the Navigation node in the code when developing page jump programs, thereby reducing the workload of developers in page development.
[0077] Step 204, dynamically load the code file of the home page into the memory of the application, and call the system's native page opening interface based on the page identifier of the home page to initiate an opening instruction for the home page.
[0078] Specifically, at the beginning of the application startup, the home page of the application can be used as the first target page to be opened by the application. In this embodiment, at the beginning of the application startup, the code file of the home page can be dynamically loaded into the memory of the application, and then the system native page opening interface is called based on the page identifier of the home page to initiate the opening instruction of the home page. Among them, the code example of loading the code file of the home page is as follows:
[0079] windowStage.LoadContent('pages / home'); / / Load home page content
[0080] From the above code example, we can know that by calling the LoadContent method of the windowStage object and passing the page identifier 'pages / home' of the home page as a parameter to the LoadContent method, the code file of the home page can be dynamically loaded in the window. Among them, the LoadContent method can parse and present the code file (i.e. class file) under the specified path to generate the content displayed in the current window.
[0081] Furthermore, after loading the code file of the home page, the system's native page opening interface can be called to initiate the opening instruction of the home page, so as to facilitate the subsequent execution of related operations to open the home page. Among them, the code snippet for calling the system's native page opening interface and initiating the opening instruction of the home page is as follows:
[0082] aboutToAppear(): void { / / Call Hongmeng system API to open the home page
[0083] pathInfos.pushPathByName('home'); / / 'home' represents the page ID of the home page}
[0084] In this embodiment, by calling the system's native page opening interface to initiate a home page opening instruction, the routing framework layer can respond to the home page opening instruction and execute the home page opening operation.
[0085] Step 205, in response to the opening instruction of the home page, obtain the page identifier of the home page and create a navigation destination page.
[0086] Specifically, after receiving the opening instruction of the home page, the routing framework layer can respond to the opening instruction of the home page, obtain the page information of the home page (wherein the page information may include a page identifier and other information in the home page), and create a navigation destination page. The code example for creating a navigation destination page in response to the opening instruction of the home page is as follows:
[0087] navRouter(name: string, param: Object) { / / Open the corresponding NavDestinationPage page (i.e., open the navigation destination page) according to the received page opening signal and page parameters
[0088] NavDestinationPage(param); / / param parameter stores the page information of the home page}
[0089] Furthermore, after the navigation destination page is created, the navigation destination page may be instantiated, thereby dynamically loading the code file of the home page through the navigation destination page to display the home page.
[0090] Step 206, intercept the system's native page creation function, and based on the page identifier of the home page, load the code file of the home page, and instantiate the code file of the home page through the page creation function to display the home page.
[0091] Specifically, after creating the navigation destination page, the navigation destination page can be instantiated. The code example of instantiating the navigation destination page is as follows:
[0092] export struct NavDestinationPage { / / Navigation destination page function
[0093] build() {
[0094] NavDestination() {
[0095] Stack() {
[0096] getDynamicView()} / / Dynamically load the page function, which can dynamically load the code file of the target page and replace the page to be opened with the target page
[0097] .size({ width: '100%', height: '100%'}); / / Returns a page component with a full screen size, which contains the target page to be opened}}
[0098] As can be seen from the above code snippet, in the process of instantiating the navigation destination page, the code file of the target page can be dynamically loaded through the getDynamicView() method, and then the page to be opened is replaced with the home page to realize the display of the home page. In this step, the target page is the home page.
[0099] Specifically, in the process of instantiating the navigation destination page, the system will execute the page creation function ViewPU.create(), where the getDynamicView() method can intercept the system's native page creation function ViewPU.create, and based on the page ID of the home page, load the code file of the home page, and then set the code file of the home page as the reference parameter of the page creation function, and then instantiate the code file of the home page through the page creation function ViewPU.create, so as to realize the display of the home page. Among them, the code example of intercepting the page creation function through the getDynamicView() method is as follows:
[0100] function getDynamicView() { / / Dynamic loading page function
[0101] hook_ViewPUCreate()} / / Intercept page creation function}
[0102] From the above code snippet, we can see that the system will execute the intercept page creation function when calling the dynamic page loading function. The code example of the intercept page creation function is as follows:
[0103] export function hook_ViewPUCreate() { / / Intercept page creation function
[0104] let src = ViewPU.create; / / Save the original create function
[0105] ViewPU.create = (page) =>{ / / Define a new create function
[0106] let alterPage = genSrcPage(page); / / Call the genSrcPage function to get the code file of the target page
[0107] page if (alterPage) { page = alterPage;} / / If alterPage is not empty, replace the original parameters with the code file of the target page
[0108] src(page); / / Call the original create function to create the target page
[0109] return src;};} / / Return to the original create function
[0110] It can be seen from the above code snippets that in the process of instantiating the navigation destination page, the routing framework layer will intercept the page creation function, and modify the reference parameter of the page creation function to the code file of the target page, and then instantiate the code file of the target page through the page creation function to realize the dynamic display of the target page. Through the above method, the routing framework layer can dynamically modify the navigation destination page of the page creation function to the target page to be displayed when receiving the start instruction of the target page, so that the page creation process can be flexibly controlled, and the dynamic loading and display of the page can be realized. At the same time, it also makes it unnecessary for developers to declare the NavDestination node in the page jump code when developing the page jump program. In this step, the target page currently displayed by the application is the home page.
[0111] In addition, in this embodiment, after intercepting the page creation function, the routing framework layer can also save the original reference parameters of the page creation function, and return the original reference parameters of the page creation function after calling the page creation function and instantiating the code file of the target page through the page creation function.
[0112] It can be seen from the above code snippets that this embodiment saves the original reference parameters of the page creation function after intercepting the page creation function, and returns the original reference parameters after the call ends. The function of the original function can continue to be used in subsequent operations, so that when the page navigation destination is modified, it will not affect the normal use of other functions in the system, thereby improving the robustness of the code.
[0113] Step 207, in response to the opening instruction of the target page, obtain the page identifier of the target page and create a navigation destination page.
[0114] Specifically, after the home page is displayed, the user can initiate an opening instruction for any page in the application based on actual needs. At this time, the routing framework layer can respond to the opening instruction for any page (i.e., the target page), obtain the page identifier of the target page, and create a navigation destination page.
[0115] In this embodiment, each time the application opens a new target page, the routing framework layer creates a new navigation destination page. The creation process of the navigation destination page is the same as the opening process of the home page when the application is first opened. The specific operation steps are shown in step 205 and will not be repeated here.
[0116] Step 208, intercepting the system native page creation function, and based on the page identifier of the target page, loading the code file of the target page, instantiating the code file of the target page through the page creation function to display the target page.
[0117] Specifically, in the process of instantiating the navigation destination page, the routing framework layer can intercept the system's native page creation function, and then load the target page's code file based on the target page's page identifier, and then set the target page's code file as a reference parameter of the page creation function, and finally call the page creation function, and instantiate the target page's code file through the page creation function to display the target page.
[0118] In this embodiment, after intercepting the page creation function, the routing framework layer can also save the original reference parameters of the page creation function, and return the original reference parameters of the page creation function after calling the page creation function and instantiating the code file of the target page through the page creation function.
[0119] This embodiment can dynamically load and display any target page in the application by intercepting the page creation function, wherein the process of dynamic loading and display can be referred to step 206, which will not be repeated here.
[0120] The technical solution provided in this embodiment can load the code files of each page into the memory of the application by loading the navigation configuration file at the beginning of the application startup, so as to facilitate the dynamic loading and display of each page in the application. In addition, the above method encapsulates the Navigation node and NavDestination node required for page navigation of the Hongmeng system, so that developers do not need to deal with the underlying navigation details when developing page navigation programs, so that they can focus on the core functions of the application, thereby reducing the development difficulty and development workload of application software under the Hongmeng system, and also making the routing jump method of application software under the Hongmeng system compatible with other systems.
[0121] It should be noted that the information (including but not limited to device information, user information, etc.) and data (including but not limited to data for analysis, storage and display, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. In addition, the numbers corresponding to the various steps in the above embodiments only serve as identification and are not used as a limitation on the order in which the steps are executed. The order in which the steps are executed in each embodiment can be set according to actual conditions. In addition, the code snippets in the above steps are only used as an example to illustrate the specific implementation process of page navigation and are not used as a limitation on this embodiment.
[0122] Further, as Figure 1 and Figure 2 The specific implementation of the method shown, this embodiment provides a page navigation interface, which can implement the page navigation method described in any of the above embodiments when executed by the processor. The reference parameter of the page navigation interface is the page identifier of any page in the application. The above page navigation interface can be used to display the target page corresponding to the page identifier based on the page identifier.
[0123] For example, the following is the code sample for the home page written by the developer:
[0124] @Entry
[0125] @Component
[0126] export struct HomePage {
[0127] build() {
[0128] Column() {
[0129] Test("Home Page"})
[0130] }}
[0131] Furthermore, developers can call the routing API (Application Programming Interface) provided by the routing framework layer of the application in the code, and implement the jump to any page through the page navigation interface and page identifier (URI). The page navigation interface code example is as follows:
[0132] import { Scheme} from '@abc-ohos / erouter'
[0133] / / Jump to the home page
[0134] Scheme.fromUri('abc: / / home').dispatch()
[0135] From the above code, it can be seen that developers only need to call the above interface in the page development code, provide the page identifier (rui) of the page to be jumped, and set the mapping relationship between the page identifier of the above page and the source code file in the routing configuration file to realize the page jump function, thereby reducing the development workload and making the routing jump method of the application under the Hongmeng system compatible with other systems.
[0136] Further, as Figures 1 to 3 The specific implementation of the method shown in the embodiment of the present application provides a page navigation device, such as Figure 4 As shown, the device comprises:
[0137] The navigation container page setting module 31 can be used to set the startup page of the application as the navigation container page after the application is started, wherein the root node of the navigation container page includes the system native Navigation node;
[0138] The navigation destination page creation module 32 may be used to obtain the page identifier of the target page in response to the opening instruction of the target page, and create the navigation destination page, wherein the root node of the navigation destination page includes the system native NavDestination node;
[0139] The target page loading and displaying module 33 may be used to load the target page through the navigation destination page based on the page identifier of the target page, and display the target page.
[0140] In a specific application scenario, the navigation container page setting module 31 can be used to intercept the system's native registration routing function after the application is started, save the routing destination parameters in the registration routing function to the object of the navigation container page, and instantiate the navigation container page; set the routing destination parameters in the registration routing function to the instance of the navigation container page; call the registration routing function, and set the startup page to the navigation container page through the registration routing function.
[0141] In a specific application scenario, the device also includes a home page setting module 34, which can be used to dynamically load the code file of the home page into the memory of the application, and call the system native page opening interface based on the page identifier of the home page to initiate the opening instruction of the home page.
[0142] In a specific application scenario, the target page loading and display module 33 can be used to intercept the system's native page creation function in the process of instantiating the navigation destination page; dynamically load the target page's code file based on the target page's page identifier; set the target page's code file as a reference parameter of the page creation function; call the page creation function, and instantiate the target page's code file through the page creation function to display the target page.
[0143] In a specific application scenario, the target page loading and display module 33 can also be used to save the original reference parameters of the page creation function after the page creation function is intercepted; and after calling the page creation function and instantiating the code file of the target page through the page creation function, return the original reference parameters of the page creation function.
[0144] In a specific application scenario, the device also includes a navigation configuration file loading module 35, which can be used to load the navigation configuration file into the memory of the application after the application is started, wherein the navigation configuration file stores a mapping relationship between page identifiers and code paths; traverses the code paths corresponding to each of the page identifiers in the navigation configuration file, and creates a code file corresponding to each of the page identifiers through the code paths corresponding to each of the page identifiers.
[0145] In a specific application scenario, the navigation configuration file generation module 36 can be used to read the routing configuration files of each functional module in the application during the compilation phase of the application; parse and integrate the routing configuration files of each functional module to obtain the navigation configuration file of the application.
[0146] In a specific application scenario, the navigation configuration file generation module 36 can also be used to parse the routing configuration files of each of the functional modules to obtain the source code path corresponding to each page identifier in each of the functional modules; based on the source code path corresponding to each page identifier in each of the functional modules, the routing information table generated in the compilation phase is used to query the binary code path corresponding to each page identifier in each of the functional modules; the binary code paths corresponding to each page identifier in each of the functional modules are integrated to obtain the navigation configuration file of the application.
[0147] It should be noted that for other corresponding descriptions of the functional units involved in a page navigation device provided in an embodiment of the present application, reference can be made to Figures 1 to 3 The corresponding description in the method will not be repeated here.
[0148] The embodiment of the present application also provides a computer device, which can be a personal computer, a server, a network device, etc. The computer device includes a bus, a processor, a memory and a communication interface, and can also include an input and output interface and a display device. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store location information. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in each method embodiment are implemented.
[0149] Those skilled in the art will appreciate that the structure of the above-mentioned computer device is only a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components, or combine certain components, or have a different arrangement of components.
[0150] In one embodiment, a computer-readable storage medium is provided. The computer-readable storage medium may be non-volatile or volatile, and stores a computer program thereon. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0151] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0152] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0153] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0154] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A page navigation method, characterized in that: The method is applied to the routing framework layer of the client application, and the method comprises: After the application is started, the system native registration routing function is intercepted, and the startup page of the application is set as the navigation container page through the registration routing function, wherein the root node of the navigation container page includes the system native Navigation node; wherein the startup page of the application is set as the navigation container page through the registration routing function, including: setting the routing destination parameter in the registration routing function to the instance of the navigation container page, and calling the registration routing function to set the startup page as the navigation container page through the registration routing function; In response to the target page opening instruction, the page identifier of the target page is obtained, and a navigation destination page is created, wherein the root node of the navigation destination page includes a system-native NavDestination node; wherein the target page includes a home page, and when the target page is the home page, before creating the navigation destination page, the method further includes: dynamically loading the code file of the home page into the memory of the application, and calling the system-native page opening interface based on the page identifier of the home page to initiate the opening instruction of the home page; The native page creation function of the interception system is used to load the code file of the target page through the navigation destination page based on the page identifier of the target page, and the code file of the target page is instantiated through the page creation function to display the target page.
2. The page navigation method according to claim 1, characterized in that: After the application is started, the system native registration routing function is intercepted, and the startup page of the application is set as the navigation container page through the registration routing function, including: After the application is started, the system's native registration routing function is intercepted, the routing destination parameter in the registration routing function is saved to the object of the navigation container page, and the navigation container page is instantiated; Setting the routing destination parameter in the registered routing function to the instance of the navigation container page; The registered routing function is called, and the startup page is set as the navigation container page through the registered routing function.
3. The page navigation method according to claim 1, characterized in that: The native page creation function of the interception system loads the code file of the target page through the navigation destination page based on the page identifier of the target page, and instantiates the code file of the target page through the page creation function to display the target page, including: In the process of instantiating the navigation destination page, intercepting the system native page creation function; Based on the page identifier of the target page, dynamically load the code file of the target page; Setting the code file of the target page as a reference parameter of the page creation function; The page creation function is called, and the code file of the target page is instantiated through the page creation function to display the target page.
4. The page navigation method according to claim 3, characterized in that: After intercepting the native page creation function of the system, the method further includes: Save the original reference parameters of the page creation function; After calling the page creation function and instantiating the code file of the target page through the page creation function, the method further includes: Returns the original reference parameter of the page creation function.
5. The page navigation method according to any one of claims 1 to 4, characterized in that: Before setting the startup page of the application as the navigation container page, the method further includes: After the application is started, loading a navigation configuration file into the memory of the application, wherein the navigation configuration file stores a mapping relationship between the page identifier and the code path; The code paths corresponding to the page identifiers in the navigation configuration file are traversed, and a code file corresponding to each page identifier is created through the code paths corresponding to each page identifier.
6. The page navigation method according to claim 5, characterized in that: The navigation configuration file is generated during the compilation phase of the application; The method for generating the navigation configuration file comprises: During the compilation phase of the application, the routing configuration files of the functional modules in the application are read; The routing configuration files of the functional modules are parsed and integrated to obtain the navigation configuration file of the application program.
7. The page navigation method according to claim 6, characterized in that: The parsing and integration of the routing configuration files of the functional modules to obtain the navigation configuration file of the application program includes: Parsing the routing configuration files of the functional modules to obtain the source code paths corresponding to the page identifiers in the functional modules; Based on the source code path corresponding to each page identifier in each of the functional modules, query the binary code path corresponding to each page identifier in each of the functional modules through the routing information table generated in the compilation stage; The binary code paths corresponding to the page identifiers in the functional modules are integrated to obtain a navigation configuration file of the application program.
8. A page navigation interface computer program product, characterized in that: The page navigation interface computer program product implements the page navigation method described in any one of claims 1 to 7 when executed by a processor, wherein a reference parameter of the page navigation interface is a page identifier, and the page navigation interface is used to display a target page corresponding to the page identifier based on the page identifier.
9. A page navigation device, characterized in that: The device is arranged at the routing framework layer of the client application, and the device comprises: A navigation container page setting module is used to intercept the system native registration routing function after the application is started, and set the application startup page as the navigation container page through the registration routing function, wherein the root node of the navigation container page includes the system native Navigation node; wherein the application startup page is set as the navigation container page through the registration routing function, including: setting the routing destination parameter in the registration routing function to the instance of the navigation container page, and calling the registration routing function to set the startup page as the navigation container page through the registration routing function; A navigation destination page creation module, used to obtain the page identifier of the target page in response to the target page opening instruction, and create the navigation destination page, wherein the root node of the navigation destination page includes the system native NavDestination node; wherein the target page includes a home page, and when the target page is the home page, before creating the navigation destination page, the device further includes a home page setting module, used to dynamically load the code file of the home page into the memory of the application program, and call the system native page opening interface based on the page identifier of the home page to initiate the opening instruction of the home page; The target page loading and display module is used to intercept the system's native page creation function, load the target page's code file through the navigation destination page based on the page identifier of the target page, and instantiate the target page's code file through the page creation function to display the target page.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the page navigation method according to any one of claims 1 to 7 is implemented.
11. A computer device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the page navigation method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Page navigation method and apparatus for hybrid APP, terminal and storage medium
CN107679061A
Project development method and device, electronic equipment and storage medium
CN114995800A
Page navigation method and device, computer equipment and storage medium
CN117742852A
Navigation system
JP2006177758A
Page rendering method, apparatus, and device, and computer readable storage medium
WO2022033055A1
