Application program jumping method and device, computer equipment and storage medium
By uniformly analyzing unified resource identifiers and access protocols, combining modal jump routing framework and page navigation components, the complexity of traditional application jump methods is solved, and a simplified page jump process and improved development efficiency is achieved.
Patent Information
- Application Number
- CN202411983666.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-25
AI Technical Summary
Traditional application jump methods correspond to different APIs, resulting in increased development complexity and error probability.
By parsing the unified resource identifier, determining the access protocol and target page information, calling the modal jump routing framework or page navigation component according to the pre-configured jump type to perform page jumping, and processing different types of jump requests uniformly.
It reduces the complexity and repetition of code, provides flexible jumping methods, meets the page jumping needs in different scenarios, and improves development efficiency and user experience.
Smart Images

Figure CN119883423A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an application jump method, device, computer equipment and storage medium. Background Art
[0002] In application development, application jump refers to the process of switching from one application interface to another in the operating system environment, or the process of jumping from the current page to another page in the same application. It involves corresponding mechanisms, interfaces, and configurations to achieve the switching between pages or applications in different scenarios. There are many ways to implement page jumps and jumps between different applications, and the application interfaces involved are also different.
[0003] Therefore, in traditional technical solutions, different jump methods must use APIs (Application Programming Interface) corresponding to different mechanisms. During development, it is necessary to remember and switch to different interfaces to handle different types of jumps, which increases development complexity and the probability of errors. Summary of the invention
[0004] Based on this, it is necessary to provide an application jump method, device, computer equipment and storage medium to address the above technical problems.
[0005] In a first aspect, the present application provides an application jump method, comprising:
[0006] Respond to the jump request of the current application. When the jump request carries a uniform resource identifier, parse the uniform resource identifier to obtain the resource information to be accessed and the access protocol;
[0007] When the access protocol is consistent with the protocol pre-set in the current application, the target page information to be accessed is determined according to the resource information to be accessed;
[0008] Get the pre-configured jump type according to the target page information;
[0009] When the jump type is modal jump, the modal jump routing framework is called to jump the page;
[0010] When the jump type is non-modal jump, the page jump is performed through the page navigation component.
[0011] In one embodiment, the resource information to be accessed includes host information, the target page information includes a page identifier, and determining the target page information to be accessed according to the resource information to be accessed includes:
[0012] Mapping the host information to the page identifier according to the pre-created mapping relationship between the host information and the page identifier;
[0013] Get the pre-configured jump type based on the target page information, including:
[0014] Obtain page configuration information from the pre-created routing registration information table according to the page identifier;
[0015] Determine the page type of the target page according to the page configuration information;
[0016] When the page type is a page with a user interface, the jump type is obtained according to the page configuration information.
[0017] In one embodiment, the current application includes a main module and multiple sub-modules, and the application jump method further includes:
[0018] During the operation of the current application, the main module calls the routing registration functions of each submodule to obtain the routing registration information table returned by each submodule, and then merges the routing registration information tables returned by each submodule to obtain the routing registration information table.
[0019] In one embodiment, the resource information to be accessed further includes query parameters, the target page information further includes page parameters, and determining the target page information to be accessed according to the resource information to be accessed includes:
[0020] Parse query parameters from string format into key-value pairs;
[0021] Convert key-value pairs into page parameters;
[0022] Call the modal jump routing framework to jump to the page, including:
[0023] Call the routing framework of the modal jump so that the routing framework of the modal jump can jump to the page according to the page parameters.
[0024] In one embodiment, the application jump method further includes:
[0025] When the resource access protocol is inconsistent with the protocol pre-set in the current application, determine whether the uniform resource identifier meets the meta-service jump requirements;
[0026] When the uniform resource identifier meets the meta-service jump requirement, a new meta-service of the current application is opened according to the uniform resource identifier, so as to perform page jump in the new meta-service.
[0027] In one embodiment, the application jump method further includes:
[0028] Assemble jump information according to the resource information to be accessed and the resource access protocol;
[0029] Call the interceptor to check the jump information to determine whether the jump request needs to be intercepted;
[0030] When there is no need to intercept the jump request, it is determined whether the access protocol is consistent with the protocol preset in the current application.
[0031] In one embodiment, the application jump method further includes:
[0032] When the jump request carries target page information, jump information is generated according to the jump request;
[0033] Call the interceptor to check the jump information to determine whether the jump request needs to be intercepted;
[0034] When interception is not required, return to the step of obtaining a pre-configured jump type according to the target page information.
[0035] In a second aspect, an application program jump device includes:
[0036] A parsing module, used to respond to a jump request of the current application, and when the jump request carries a uniform resource identifier, parse the uniform resource identifier to obtain the resource information to be accessed and the access protocol;
[0037] A determination module, used to determine target page information to be accessed according to resource information to be accessed when the access protocol is consistent with the protocol pre-set in the current application;
[0038] An acquisition module, used to acquire a pre-configured jump type according to target page information;
[0039] The first jump module is used to call the routing framework of the modal jump to perform page jump when the jump type is a modal jump;
[0040] The second jump module is used to perform page jump through the page navigation component when the jump type is a non-modal jump.
[0041] In a third aspect, the present application provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the application jump method provided in any embodiment of the present application in the first aspect are implemented.
[0042] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the application jump method provided in any embodiment of the present application in the first aspect.
[0043] The above-mentioned application jump method, device, computer equipment and storage medium first identify the information carried in the jump request, if it is a uniform resource identifier, further extract the resource information to be accessed and the access protocol in the uniform resource identifier, further compare the access protocol with the pre-set protocol in the current application, when the comparison result is consistent, determine the target page information to be accessed according to the resource information to be accessed, and further obtain the pre-configured jump type according to the target page information. When the jump type is a modal jump, call the routing framework of the modal jump to jump the page, and when the jump type is a non-modal jump, the page is jumped through the page navigation component. Different jump methods in traditional technologies often correspond to different interfaces and processing logics, and the present application provides a unified processing method by uniformly parsing the uniform resource identifier and jumping according to the configured jump type, reducing the complexity and repetitiveness of the code, and the present application can flexibly select the modal jump or non-modal jump method according to the pre-configured jump type to meet the page jump requirements in different scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 A schematic diagram of a flow chart of an application jump method in some embodiments;
[0045] Figure 2 A schematic diagram of a flow chart of an application jump method in some embodiments;
[0046] Figure 3 is a structural block diagram of an application jump device in some embodiments;
[0047] Figure 4 1 is a diagram of the internal structure of a computer device in some embodiments. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0049] In a first aspect, the present application provides an application jump method, such as Figure 1 As shown, this method is applied to Figure 1 The terminal in is used as an example to illustrate, including the following steps:
[0050] Step S11, in response to a jump request of the current application, when the jump request carries a uniform resource identifier, the uniform resource identifier is parsed to obtain information about resources to be accessed and an access protocol.
[0051] Among them, application jump refers to the operation process of switching from the current interface or state of one application to the interface or state of another application, or switching from one page to another page within the same application when using an electronic device.
[0052] It can be seen that the application jump of the present application can specifically include the jump within the same application and the jump between different applications. Specifically, the jump within the same application means that the user switches between pages corresponding to different functional modules of the application in order to perform different functional operations, such as jumping from the product list page to the product details page, shopping cart page, etc. in an e-commerce application.
[0053] Jumping between different applications: In order to achieve more complex functions or tasks, it is necessary to switch between applications with different functions, such as clicking a merchant link in a map application to jump to the corresponding food recommendation application.
[0054] Among them, the jump request is a signal or instruction sent by the current application to indicate that a jump operation between pages or applications is to be performed. It can be triggered by user operations, such as clicking on interactive elements such as links and buttons on the page, or it may be automatically initiated by the program based on certain logic, such as automatically jumping to the next related page after completing a certain process, etc. It often contains some key information to clarify where to jump and how to jump.
[0055] Specifically, this application can monitor button click events. Specifically, in the interface layout code, a click listener is set for the corresponding button. When the user clicks the button, the corresponding callback function will be triggered. The call of this callback function can be regarded as receiving a jump request. The function will then determine which page to jump to based on the business logic.
[0056] This application can be processed by link click. Specifically, if there is a hyperlink element on the page, its click event should be monitored. When the user clicks the link, the click operation is captured, which is equivalent to receiving a jump request, and then the target information pointed to by the link is parsed to prepare for subsequent jumps.
[0057] This application can trigger a jump request through program logic:
[0058] For example, in a form-filling application, when the user fills in each required item in turn, the program will perform logical judgment in the code, and automatically trigger a jump request when the conditions are met, jumping the page to the submission result display page or the next related process page.
[0059] Alternatively, the present application can be used in an application scenario where a timer is set. When the time is up, the callback function of the timer is executed, and a jump request is initiated in the callback function to guide the page to jump to the corresponding page. For example, after the limited-time activity page expires, it automatically jumps to the activity end prompt page.
[0060] Among them, Uniform Resource Identifier (URI) is a string used to identify the name of an Internet resource. This identification allows users to interact with any resource (including local and Internet) through a specific protocol. URI is defined by a scheme that includes a certain syntax and related protocols.
[0061] The resource information to be accessed is data related to the resource to be accessed, such as the address or location identifier of the resource.
[0062] An access protocol (scheme) is an identifier that specifies the rules and methods for accessing specific resources. It defines the interaction specifications for communication and resource acquisition between the client (such as an application) and the server (or the corresponding resource provider in the application). Different schemes correspond to different access methods and processing logic. Common schemes such as "http" and "https" are used for network resource access, while there may be custom schemes in the application to distinguish different types of in-application jump operations, etc., telling the system or application what rules to use to parse and obtain the corresponding resources.
[0063] Specifically, the present application can use the corresponding method to create a URI object with a string representing a uniform resource identifier, extract the access protocol through the method for obtaining the protocol provided by the created URI object, and extract the resource information to be accessed using the corresponding method of obtaining the resource information to be accessed using the URI object.
[0064] Step S12: when the access protocol is consistent with the protocol preset in the current application, the target page information to be accessed is determined according to the resource information to be accessed.
[0065] In this application, we first need to compare whether the parsed access protocol is consistent with the protocol pre-set by the application. Only when they are consistent, it means that they comply with the established access rules in the application and we can proceed to the page jump related operations.
[0066] Then, based on the previously obtained information about the resources to be accessed, the target page information to be accessed next is accurately determined according to the established logic and rules within the application. Based on the target page information, the specific page to be jumped to can be accurately located among the many pages of the application, thus laying the foundation for the subsequent accurate completion of the page jump.
[0067] Target page information refers to relevant information that can be used to locate the target page, such as page identifier and page navigation information. For example, the page jump source, the location of the target page in the navigation stack, etc. This information has an important impact on the navigation logic and user experience of the application.
[0068] Specifically, the present application can perform a string comparison or other equivalent comparison operations on the access protocol parsed from the uniform resource identifier and the protocol pre-set in the current application to determine whether the two are consistent. Extract key information related to determining the target page from the resource information to be accessed. According to the mapping rules preset in the application, the extracted key information is converted into the corresponding target page information. In the page management module or routing mechanism of the application, the corresponding target page is searched according to the obtained page identifier.
[0069] Step S13, obtaining a pre-configured jump type according to the target page information.
[0070] The jump type refers to the classification definition of different ways or modes used when jumping from the current page to the target page in the application. It is mainly used to specify the specific behavior and effect of the page jump. For example, the jump type can include modal jump, non-modal jump, normal jump, and cross-application jump.
[0071] Specifically, the present application obtains a pre-configured jump type according to the target page information, which may specifically include:
[0072] Check the page configuration information. The page configuration information usually has a special field or attribute to identify whether the page jump mode is a modal jump. For example, there may be a Boolean type field named "modal" or "isModal". When the field value is true, it means that this page is a modal jump page; when it is false, it means that it is not a modal jump page.
[0073] Alternatively, check the jump parameter or flag. When assembling the jump information, a special parameter or flag may be set to specify whether it is a modal jump. When making a judgment, you can check the value of this parameter or flag. For example, a parameter named "modalFlag" is passed into the jump method. When the parameter is true, it indicates a modal jump; when it is false, it indicates a non-modal jump.
[0074] Or, based on business logic and jump requirements. If the business logic requires a new page to pop up on top of the current page, and the user needs to interact with the new page before returning to the original page, then this situation is usually a modal jump. For example, a login box, prompt box, information filling box, etc. pops up, and the user must complete the operation in the box, which is a modal jump.
[0075] Step S14, when the jump type is a modal jump, the modal jump routing framework is called to perform page jump.
[0076] Among them, the modal jump routing framework is a software architecture or tool set specifically used to implement the page jump function in the form of a modal window in application development. It provides a series of interfaces, methods, rules and mechanisms to manage the entire process of jumping from the current page to the target page in the form of a modal window, including the creation, display, interaction processing, closing of the modal window, and the interaction logic with the original page, so that developers can easily and efficiently implement the modal jump function and improve the user experience and interactivity of the application.
[0077] Specifically, the routing framework for modal jump can be the @ohos.route framework. The @ohos.router framework is a routing framework in the HarmonyOS operating system, which is mainly used to implement navigation and jump functions between pages. Among them, the functions of the @ohos.router framework include:
[0078] Flexible page navigation: supports multiple page jump methods, including normal jump, parameter jump, modal jump, etc., which can meet the page switching needs in different application scenarios.
[0079] Parameter passing and receiving: It is convenient to pass and receive various data parameters during the page jump process, so that the target page can perform corresponding initialization and data display according to the passed parameters.
[0080] Routing management: It provides a complete routing management mechanism, which can centrally manage and configure page routing, making it easier for developers to uniformly maintain and expand page jump logic.
[0081] In this application, when it is determined that the page jump type is a modal jump, a specific routing framework is needed to implement this function. The @ohos.router framework is such a routing framework that can be used for modal jumps. It means that during the development process, the functions and interfaces provided by the framework should be used to handle the modal jump operation from the current page to the target page in the prescribed manner, ensuring that the modal window can be correctly displayed, interacted, and closed, etc., to meet the interaction needs of the application in specific scenarios.
[0082] Specifically, the steps of calling the modal jump routing framework to perform page jump may include:
[0083] Step 1. Introduce the framework: Introduce the @ohos.router framework into the project. Depending on the specific development language and environment, add the framework to the project through the corresponding dependency management tool or import statement.
[0084] Step 2. Determine the jump type: In the code, make a judgment based on the jump type information obtained previously, and when it is determined to be a modal jump, perform subsequent operations.
[0085] Step 3. Call the framework interface: Use the modal jump related interface provided by the @ohos.router framework, pass in the target page information and other necessary parameters, and trigger the modal jump operation.
[0086] Step 4. Processing interaction logic: After the modal window is displayed, according to application requirements, use the interaction processing mechanism provided by the framework to process user operations in the modal window, such as clicking buttons, entering data, etc., and perform corresponding page jumps or data updates based on the operation results.
[0087] Step 5. Close the modal window: When the interactive operation of the modal window is completed, use the relevant functions of the framework to close the modal window according to the business logic, return to the original page or perform other subsequent operations.
[0088] Step S15: When the jump type is a non-modal jump, the page jump is performed through the page navigation component.
[0089] Among them, non-modal jump usually means that when switching pages, the display of the new page will not restrict the user's interaction with the original page or other pages. The user can switch and operate between different pages relatively freely, which corresponds to modal jump (often the pop-up of a new page will restrict the operation of the original page, etc.).
[0090] The page navigation component is a program module used to implement functions such as page jump guidance and switching, which helps the application to flow between different pages according to the set logic, making it convenient for users to browse different contents. Specifically, the page navigation component of the present application can be a NavPathStack component.
[0091] The NavPathStack component is a specific page navigation component. It generally manages the page jump order based on the stack data structure principle, similar to "stacking" the visited pages in order. It supports operations such as rolling back to the previous page, making it easy to track the page access path. It is often used to assist page navigation in mobile application or web application development.
[0092] In this application, when the page jump type is non-modal jump, the page navigation component is used to implement page switching, among which the NavPathStack component can act as a page navigation component. This application first clarifies the jump type, and then uses the appropriate navigation component to implement reasonable jumps between pages in certain steps, so that the flow between pages meets the corresponding interaction logic and functional requirements.
[0093] Specifically, the steps for implementing page jump through the page navigation component may include:
[0094] Correctly introduce the NavPathStack component-related libraries or code modules into the project to ensure that its functions can be used. According to the logic of the application page, set the corresponding relationship between different pages through the NavPathStack component for jumping, such as the specific path configuration from the home page to the details page. When it is determined that a non-modal jump is to be performed, call the corresponding jump method of the NavPathStack component, pass in the target page and other necessary parameters to achieve page switching. Based on the characteristics of the NavPathStack component stack, set up related interactions such as the back button to facilitate users to return to previously visited pages as needed.
[0095] In one of the embodiments, the resource information to be accessed includes host information, the target page information includes a page identifier, and the target page information to be accessed is determined based on the resource information to be accessed, including: mapping the host information to the page identifier based on a pre-created mapping relationship between the host information and the page identifier, and obtaining a pre-configured jump type based on the target page information, including: obtaining page configuration information from a pre-created routing registration information table based on the page identifier, determining the page type of the target page based on the page configuration information, and when the page type is a page with a user interface, obtaining the jump type based on the page configuration information.
[0096] The host information may include a host identifier and a host name, etc. The target page information may include a page identifier and may also include a page name.
[0097] Specifically, the application establishes a mapping relationship between host information and page identifiers in advance, and clearly specifies which host information (host value) corresponds to which specific page names. For example, configure "productHost" to correspond to the page identifier "PageID1", "userHost" to correspond to "PageID2", etc. This mapping can be stored in a configuration file or a constant, dictionary structure, etc. in the code.
[0098] When the access protocol is consistent with the protocol pre-set in the current application, the page name corresponding to the host information is found according to the mapping relationship between the host information and the page identifier. For example, if the extracted host is "productHost", the corresponding page name can be determined to be "PageID1" through mapping.
[0099] Among them, a page with a user interface refers to a page that can display visual content to users and accept user interaction operations. It provides users with an interface for operating and viewing information and is an important medium for users to interact with the system or application. Among them, a page with a user interface can be a UI page of Hongmeng operation.
[0100] The UI page of HarmonyOS refers to the user interface page designed and developed based on the HarmonyOS operating system. It follows the design specifications and interaction principles of the HarmonyOS system, and is built using the UI framework and components provided by the HarmonyOS system to present users with interactive experience and visual effects with HarmonyOS characteristics.
[0101] The routing registration information table is a data table or data structure used to store page-related information. It usually contains the page ID, page configuration information, etc., where the page ID is used as the primary key or index field to uniquely identify each page; the page configuration information can cover the page type, jump type, page layout, components used, related business logic configuration, permission settings and other detailed information related to page operation and display. Through this table, pages can be easily managed, queried and configured, so that the required page configuration information can be quickly obtained according to the page ID during system operation to perform operations such as page loading, display and interaction.
[0102] The route registration information table contains multiple descriptive data about different routes. Each piece of data corresponds to a specific route, and the target page pointed to by the route represented by one of the data is either a user interface (UI) page based on the Hongmeng operating system, which will display a visual interactive interface to the user; or a logical intermediate page without a user interface, which is mainly used for some data processing, logical operations or transitional functions in the background, and does not directly display visual content to the user. The page type of the corresponding target page is recorded in the route registration information table, whether it is a page with a user interface or a logical intermediate page without a user interface. The corresponding page type can be obtained by querying the route registration information table.
[0103] Furthermore, when the page type is a page with a user interface, the jump type is obtained according to the page configuration information.
[0104] The beneficial effects of this embodiment are:
[0105] Uniform Resource Identifier (URI) has a specific format specification, including different parts such as access protocol (scheme) and host information (host). Different components of URI carry different information. This design integrates these originally scattered information, such as host representing the source or identifier of the page and query parameters containing various parameters, according to their format specifications to form a complete information set that can be used for page jumps, avoiding information fragmentation and confusion, so that all information related to jumps can be managed and processed under a unified framework.
[0106] In addition, the present application can effectively convert this information by using the format specification of URI. For example, the host can be accurately mapped to the page identifier or page name, making it more consistent with the internal identification and management of pages in the application. This conversion is based on the semantics and functions of each part of the URI, ensuring the effective transmission and adaptation of information between different levels and links.
[0107] This application unifies the page jump function of the entire application by integrating, converting and reasonably utilizing the information of each part of the URI. No matter how diverse the trigger source of the page jump is, no matter how different the incoming URI information is, this unified conversion mechanism can accurately find the target page and pass the correct parameters, thus providing users with a consistent jump experience and facilitating developers to uniformly manage and maintain the jump logic.
[0108] It can be seen that the present application utilizes the format specification of the uniform resource identifier to uniformly convert all the information required for page jumps, etc., effectively and reasonably, thereby unifying the jump function.
[0109] In one of the embodiments, the current application includes a main module and multiple sub-modules, and the application jump method may also include: during the operation of the current application, calling the routing registration function of each sub-module through the main module, obtaining the routing registration information table returned by each sub-module, and merging the routing registration information tables returned by each sub-module to obtain the routing registration information table.
[0110] Among them, the application jump method of the present application can be applied to the Hongmeng system. In Hongmeng application development, the main module refers to the core part of the application. It contains the entry point of the application (that is, the first part that runs at startup), as well as some global configuration information. The main module is usually responsible for initializing the application environment, loading necessary resources, and may include some basic functions and services. Sub-modules are other functional modules outside the main module, each of which is responsible for implementing specific functions or business logic. By splitting different functions into multiple sub-modules, the code can be made clearer, easier to maintain and expand. Each sub-module can have its own resource files, layout files, and source code files. Sub-modules can communicate and exchange data through interfaces.
[0111] The routing registration function is a function used to register routing information to the routing module or routing mechanism in software development, especially in frameworks or systems involving routing management. It is mainly responsible for collecting, organizing and registering the routing relationships and related configuration information between different pages, components or functional modules in the application. This information includes routing paths, corresponding pages or components, routing parameters, routing guards, etc., so that the routing module can accurately find and load the corresponding pages or components according to user operations or requests, and realize navigation and jump functions between pages.
[0112] Usually, the API or method provided by the routing framework is called inside the function to pass the routing information to the routing module for registration in a specific format or data structure. For example, in some front-end frameworks, a code similar to router.addRoute({path:' / home',component:HomeComponent}) may be used to register a routing information, where router.addRoute is the registration method provided by the routing framework, and the entire line of code may be encapsulated in the routing registration function to register multiple routes through loops or other logic.
[0113] Specifically, in development, the submodule has its corresponding entry file Index.ets. First, the application jump method of this application needs to be encapsulated into a routing framework, and the routing framework is imported into this file in advance. The routing framework is like a set of rules and tools used to manage routing-related operations such as jumps between different pages and functional modules. Then implement the pre-set routing registration function in each submodule. The function of this function is to collect and organize the relevant settings related to routing in the submodule, and finally return the routing registration information through this function. This information contains the specific configuration and corresponding relationship related to routing in the submodule.
[0114] Among them, in the development of Hongmeng system, the entry file Index.ets of the submodule is usually the first code file loaded and executed when the submodule is started. It is generally responsible for initializing the resources and configuration related to the submodule, and starting some core business logic in the submodule, etc. It is a starting point for the outside world to enter the submodule and call its functions.
[0115] When the entire program starts running, it will call the routing registration function of the submodule to obtain the routing registration information table of the corresponding submodule, which records the routing configuration details of the submodule. Finally, the routing registration information table of this submodule is merged into the total routing registration information table of the current entire routing module, which is equivalent to integrating the routing conditions of each submodule together, making the routing system of the entire program more complete and unified, and facilitating the subsequent accurate page jumps based on these integrated information.
[0116] In another implementation, there is a manual operation method, which is to directly call the page registration function. Through this manual call, some of the previous automatic search and integration processes can be skipped, and the registration information of a specific page can be directly added to the routing registration information table of the routing framework, so that the routing conditions of individual pages can be more flexibly configured and added separately to meet some special page routing setting requirements.
[0117] The beneficial effects of this embodiment are:
[0118] In traditional methods, route registration often relies on route table configuration files, which need to be configured before the program runs. However, this solution uses runtime registration of route registration information tables, which means that the route registration information table is dynamically generated and registered during program operation, without the need to manually configure route table files in advance. This allows for more flexible adjustment of routes based on actual conditions, improving development flexibility and dynamism.
[0119] Automatically checking the code for correctness during the compilation phase can promptly discover errors in the routing registration information table and during use, such as whether the routing path is correct and whether parameter passing complies with specifications, avoiding omissions that may occur due to manual inspection, improving the quality and stability of the code, and reducing the probability of runtime errors.
[0120] In one embodiment, the application redirection method of the present application may further include a pre-step: initialization operation. The application redirection method of the present application may be encapsulated into a routing framework.
[0121] Specifically, the initialization operation may include:
[0122] The first step is to add the dependency of this routing framework in the oh-package.json5 project configuration file in the main module / submodule of the project.
[0123] The second step is to initialize the dynamic routing framework. Import the routing framework in the EntryAbility.ets file of the main module, and use the dynamic routing framework initialization related functions in the onCreate interface to initialize the routing framework.
[0124] Among them, the oh-package.json5 project configuration file is a file used to configure project-related information in Hongmeng system development, similar to project configuration files in other development environments. This file uses the json5 format, which is more flexible than the ordinary json format and can easily write some complex configurations. It can define project dependencies (such as the routing framework dependency mentioned here), module information, some configuration parameters of the project, etc., to guide project construction, operation, and integration between modules.
[0125] Specifically, the present application can find the directory location of the corresponding main module or the sub-module to which the routing framework dependency needs to be added in the directory structure of the project, and then determine the oh-package.json5 project configuration file under it. Open the oh-package.json5 project configuration file. Find the relevant part used to define the dependency in the oh-package.json5 project configuration file (usually with specific field identifiers such as "dependencies"), and add the dependency information of this routing framework in accordance with the prescribed format. Generally, the name of the routing framework and the corresponding version number and other contents should be accurately filled in to ensure that the dependency is added accurately, so that the routing framework can be correctly introduced for related initialization and other operations when the project is subsequently built.
[0126] Furthermore, in the development of Hongmeng system, EntryAbility.ets file is a very critical file, which usually represents the code file related to the entry capability (Entry Ability) of the application. Ability here is the meta-service in Hongmeng system, and Entry Ability is the capability component that is first loaded and executed when the application starts. It is mainly responsible for the startup initialization of the application, such as some necessary resource loading, component initialization, configuration-related initial state, etc., and EntryAbility.ets is a file that uses ETS language (a programming language used in Hongmeng system development, used to efficiently and concisely write component logic, etc.) to write the entry capability-related code.
[0127] The onCreate interface is an important interface in the life cycle of the Ability component in the Hongmeng system. In the specific scenario of Entry Ability, it will be automatically called when the application starts to create the capability component. Developers can write code in this interface to implement operations such as initializing system resources, configuring component properties, and starting related services. It is an important part of initializing related work during the application startup phase. It can ensure that the necessary preparations can be completed at the beginning of the application startup so that subsequent functions can run normally.
[0128] Specifically, find the EntryAbility.ets file. In the code directory structure of the Hongmeng system application project, locate the EntryAbility.ets file under the main module according to the module division and code organization rules of the project. The location of this file is usually part of the fixed directory structure that complies with the Hongmeng development specifications, generally in the source code directory of the corresponding main module.
[0129] Furthermore, import the routing framework. Import the dynamic routing framework to be used in the appropriate location of the EntryAbility.ets file (usually at the beginning of the file or other places that meet the code specifications) to ensure that the functions and functions provided by the framework can be correctly referenced in subsequent codes.
[0130] Furthermore, operate in the onCreate interface. Find the defined onCreate interface part in the EntryAbility.ets file (if not, you need to define this interface according to the Ability lifecycle specification developed by Hongmeng, including correct parameters and function signatures, etc.), and call the initialization related functions provided by the dynamic routing framework in the code block of this interface function to complete the initialization of the dynamic routing framework and ensure that the routing framework can function normally in subsequent page routing registration, page jump and other links.
[0131] In one of the embodiments, the resource information to be accessed also includes query parameters, and the target page information also includes page parameters. The target page information to be accessed is determined based on the resource information to be accessed, including: parsing the query parameters from a string format into key-value pairs, converting the key-value pairs into page parameters, and calling a modal jump routing framework to perform a page jump, including: calling the modal jump routing framework so that the modal jump routing framework performs a page jump according to the page parameters.
[0132] Query parameters (queryParams) are used to pass additional information to the server or other resources. This information can be search conditions, filter conditions, user input data, etc., so that the resource can perform corresponding processing or return specific results based on these parameters.
[0133] Page parameters are part of the target page information. They are obtained by parsing and converting the query parameters and exist in the form of key-value pairs. This makes it easier for the target page to directly use these parameters for page rendering, data loading, logic processing, and other operations.
[0134] Specifically, the application can parse the queryParams string.
[0135] QueryParams is usually passed in string form, containing multiple parameters in a format such as "param1=value1¶m2=value2". Use the string processing function provided by the programming language or a dedicated URL parsing library to parse it into a data structure in the form of key-value pairs.
[0136] Furthermore, according to the requirements of the page parameters, the data type of the parsed key-value pairs is converted. For example, a string type number is converted to an integer or floating point type, a string Boolean value is converted to a Boolean type, etc. Furthermore, the converted parameters are verified to ensure that they meet the value range and constraints of the page parameters. For example, whether the parameter value is within the specified enumeration range, whether it meets the length, format and other requirements, and the parameters that do not meet the requirements are processed accordingly, such as setting default values, giving error prompts, etc.
[0137] In one of the embodiments, the application jump method may also include: when the resource access protocol is inconsistent with the protocol pre-set in the current application, determining whether the uniform resource identifier meets the meta-service jump requirement; when the uniform resource identifier meets the meta-service jump requirement, opening a new meta-service of the current application according to the uniform resource identifier, so as to perform a page jump in the new meta-service.
[0138] Among them, this application can be applied to Hongmeng system. Hongmeng system is a full-scenario distributed operating system independently developed by Huawei. It adopts a microkernel architecture and has distributed capabilities. It can achieve hardware mutual assistance and resource sharing across multiple devices, adapt to a variety of terminal devices, and has an efficient task scheduling and resource management mechanism. It is currently mainly used in computers, cars, tablets, mobile devices, etc.
[0139] In the Harmony system, meta-service is a technology-oriented term. It is a component of an application that can independently provide specific functions or services to users. It is lightweight and can be independently deployed and run. It is an important part of the application ecosystem of the Harmony system.
[0140] Meta-service redirection requirements refer to a series of conditions or rules that a uniform resource identifier (URI) needs to meet. Only when the URI meets these conditions can the meta-service redirection operation be triggered. These requirements may involve aspects such as the format, protocol, and parameters contained in the URI.
[0141] The relationship between applications and meta-services in the Hongmeng system and a special application jump method. That is, under normal circumstances, an application has only one meta-service by default, but it can support multiple meta-services in special cases, and each application has at least one default meta-service. In this application, when the resource access protocol is inconsistent with the pre-set protocol in the current application, if the uniform resource identifier meets the meta-service jump requirements, the new meta-service of the current application can be opened according to the identifier, and then the page jump in the new meta-service can be realized, which provides a mechanism for flexible jump and interaction between different meta-services within the application.
[0142] Specifically, the present application may determine whether the uniform resource identifier meets the meta-service jump requirement by:
[0143] Check whether the protocol part of the uri matches the protocol type supported by the meta-service, such as the common "http", "https", "hap" and other protocols. Only when the protocols match can the jump requirements be met.
[0144] Ensure that the format of the URI is complete and contains necessary components, such as scheme, host, path, etc. Missing key parts may result in failure to parse and redirect correctly. Check whether the URI contains the parameters necessary for meta-service redirection, such as meta-service identification parameters, target page or function parameters, etc. The lack of these parameters may prevent the meta-service from accurately identifying and redirecting. Verify whether the parameter value is within the legal range specified by the meta-service. For example, some parameters may require specific data types, lengths, or conform to specific regular expressions. Confirm that the current application has been correctly installed and the relevant meta-service is enabled. If the application is not installed or the meta-service is disabled, the redirection cannot be performed even if the URI format is correct. Check whether you have the permissions required to perform the meta-service redirection, such as the permission to access certain sensitive data or perform specific operations. Insufficient permissions may result in redirection failure.
[0145] The beneficial effects of this embodiment are:
[0146] Ensure that only URIs that meet the requirements can trigger meta-service jumps, avoid system crashes or exceptions caused by illegal or irregular jump requests, and improve the overall stability and reliability of the system. Clear jump requirements ensure that users can accurately jump to the expected meta-service and target page, avoid jump errors or failure to reach the target, and improve the accuracy and convenience of user operations. Make judgments based on the system environment and configuration, so that meta-services can run under appropriate device and system conditions, avoid freezes or inability to run due to device unsupport or insufficient resources, and optimize the rational use of resources.
[0147] In one of the embodiments, the application jump method may also include: assembling jump information according to the resource information to be accessed and the resource access protocol, calling an interceptor to check the jump information to determine whether the jump request needs to be intercepted, and when the jump request does not need to be intercepted, determining whether the access protocol is consistent with the protocol pre-set in the current application.
[0148] Among them, in the application jump mechanism of Hongmeng system, the interceptor is a component or module used to check and process the jump information during the jump process. When a jump request occurs, it can decide whether to allow the jump request to continue according to preset rules and conditions, thus playing a role in intercepting and controlling the jump process.
[0149] Redirect information refers to a data set that extracts and assembles key information such as the scheme (access protocol) in the uniform resource identifier (URI) and the resource information to be accessed (host information and query parameters). This information includes details about the redirect target, redirect method, and parameters that may need to be passed, which are used to guide and control the redirect process of the application.
[0150] In this application, the key information in the uri is first extracted and assembled to form the jump information, and then the interceptor is used to check it to determine whether the jump request needs to be intercepted. If interception is not required, it is further determined whether the access protocol is consistent with the protocol pre-set in the current application, thereby determining the subsequent jump operation. This is a more complex and rigorous jump control mechanism that aims to improve the accuracy and security of the jump.
[0151] Specifically, the present application can extract information such as scheme, host, and queryParams from a given uri, and assemble them into jump information according to certain rules. The assembled jump information is passed to the interceptor, which performs a comprehensive check on the jump information based on its internal preset rules and logic to determine whether the jump request needs to be intercepted. If the interceptor determines that the jump request does not need to be intercepted, it continues to determine whether the access protocol is consistent with the protocol pre-set in the current application, providing a basis for subsequent jump operations.
[0152] The beneficial effects of this embodiment are:
[0153] By designing an interceptor, malicious jump requests can be effectively prevented. By checking the jump information, jump operations that may pose security risks can be discovered and intercepted in a timely manner to protect user privacy and system security. By assembling and checking the jump information in detail, the accuracy and completeness of the jump request can be ensured to avoid jump failures or wrong target jumps caused by incorrect information or irregular jumps. This design makes the jump process more standardized and controllable, making it easier for the system to uniformly manage and monitor jump requests. It also makes it easier for developers to troubleshoot and repair problems when they occur, improving the maintainability of the system.
[0154] In one of the embodiments, the application jump method may also include: when the jump request carries target page information, generating jump information according to the jump request, calling an interceptor to check the jump information to determine whether the jump request needs to be intercepted, and when interception is not required, returning to the step of obtaining a pre-configured jump type according to the target page information.
[0155] In this application, jump requests can be divided into two types, one is to jump through URI, and the other is to jump through page information such as page name or page logo.
[0156] For the second type, i.e. jumping through page information such as page name or page logo, it may be that a certain operation in the application triggers the need to open a specific page by page name, such as when a user clicks a menu option or button, and the name string of the target page is passed.
[0157] When receiving a jump request, the application first determines the type of jump request received. If it is a jump request using page information (such as a page name or page identifier), that is, a jump request carrying target page information in the jump request, the jump information is generated based on the page information. This may involve extracting data related to the page name or identifier, and organizing and packaging it into a standardized jump information format according to established rules, so that it contains key content required for subsequent processing.
[0158] The generated jump information is passed to the interceptor, which performs a comprehensive check on the jump information based on its preset inspection rules and logic, such as checking whether the information is complete, whether it meets security requirements, whether it is within the legal jump range, etc., to determine whether the jump request needs to be intercepted.
[0159] If the interceptor determines after checking that the jump request does not need to be intercepted, it returns to the step of obtaining the pre-configured jump type based on the target page information, that is, continues the subsequent regular process to obtain the corresponding jump type, so as to further perform accurate page jump operations based on the jump type.
[0160] In another embodiment, the present application can also redirect the page originally to be jumped to other pages according to business logic through an interceptor. For example, when a page is under maintenance, the access to the page is redirected to a prompt page to inform the user of the page maintenance status, thereby improving the flexibility and maintainability of the application.
[0161] In order to further illustrate the steps of the application jump method of the present application, a flowchart of the application jump method is provided. Figure 2 ,exist Figure 2In the example, the application redirection method may include: receiving a redirection request, the redirection request is a request for redirection through a URI, parsing information such as the scheme, host, and queryParams in the URI, assembling the information into redirection information, calling an interceptor to check the redirection information, and when the check result is successful (i.e., no interception is required), determining whether the parsed scheme is the scheme in the App (i.e., the current application); when the parsed scheme is not the scheme in the App, further determining whether the URI meets the Ability (i.e., meta-service) redirection requirement; if so, opening a new Ability through the system API; and when the parsed scheme is the sch in the App, eme, map host to the page name, convert queryParams into page parameters, and determine whether there is page configuration information. When there is page configuration information, check the page configuration information to determine whether the target page is a Hongmeng UI page or a logical intermediate page without a user interface. When the target page is a Hongmeng UI page, further determine whether the current jump is a modal jump or a non-modal jump. When it is a modal jump, call the @ohos.router framework for a modal jump. When it is a non-modal jump, jump through the NavPathStack component. When the target page is a logical intermediate page without a user interface, execute the intermediate page logic and obtain the jump result. When the jump fails, throw an exception. When the jump is successful, the process ends.
[0162] It can be seen that the use of this application can unify API calls. The originally scattered different jump methods such as @ohos.router, NavPathStack and Ability are unified. Developers no longer need to learn and use different APIs for different jump requirements. Instead, they use a unified interface for page jumps and jumps between apps, which greatly reduces the learning cost and development difficulty. The unified API reduces the complexity of the code and makes code maintenance easier.
[0163] In a second aspect, the present application provides an application jump device, such as Figure 3As shown, the application jump device includes: a parsing module 31, a determination module 32, an acquisition module 33, a first jump module 34 and a second jump module 35, wherein: the parsing module 31 is used to respond to the jump request of the current application, and when the jump request carries a uniform resource identifier, parse the uniform resource identifier to obtain the resource information to be accessed and the access protocol; the determination module 32 is used to determine the target page information to be accessed according to the resource information to be accessed when the access protocol is consistent with the protocol pre-set in the current application; the acquisition module 33 is used to obtain a pre-configured jump type according to the target page information; the first jump module 34 is used to call the modal jump routing framework to perform page jump when the jump type is a modal jump; the second jump module 35 is used to perform page jump through the page navigation component when the jump type is a non-modal jump.
[0164] In one of the embodiments, the resource information to be accessed includes host information, and the target page information includes a page identifier. The determination module 32 can map the host information to the page identifier based on a pre-created mapping relationship between the host information and the page identifier. The acquisition module 33 can obtain page configuration information from a pre-created routing registration information table based on the page identifier, determine the page type of the target page based on the page configuration information, and when the page type is a page with a user interface, obtain the jump type based on the page configuration information.
[0165] In one embodiment, the current application includes a main module and multiple sub-modules, and the acquisition module 33 can also: during the operation of the current application, call the page registration function of each sub-module through the main module to obtain the page registration information table returned by each sub-module, and merge the page registration information tables returned by each sub-module to obtain the page registration information table.
[0166] In one of the embodiments, the resource information to be accessed also includes query parameters, and the target page information also includes page parameters. The determination module 32 can parse the query parameters from a string format into key-value pairs, and convert the key-value pairs into page parameters. The first jump module 34 can call the routing framework of the modal jump so that the routing framework of the modal jump performs a page jump according to the page parameters.
[0167] In one of the embodiments, when the resource access protocol is inconsistent with the protocol pre-set in the current application, the parsing module 31 can determine whether the uniform resource identifier meets the meta-service jump requirement. When the uniform resource identifier meets the meta-service jump requirement, a new meta-service of the current application is opened according to the uniform resource identifier to perform a page jump in the new meta-service.
[0168] In one of the embodiments, the determination module 32 can also assemble jump information based on the resource information to be accessed and the resource access protocol, call the interceptor to check the jump information to determine whether the jump request needs to be intercepted, and when the jump request does not need to be intercepted, determine whether the access protocol is consistent with the protocol pre-set in the current application.
[0169] In one of the embodiments, the determination module 32 can also generate jump information according to the jump request when the jump request carries the target page information, call the interceptor to check the jump information to determine whether the jump request needs to be intercepted, and when no interception is required, return to the step of obtaining the pre-configured jump type according to the target page information.
[0170] In a third aspect, the present application provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the application jump method provided in any embodiment of the present application in the first aspect.
[0171] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. 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 and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. 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, an application jump method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0172] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the application jump method provided in any embodiment of the present application in the first aspect.
[0173] The computer readable storage medium may be Figure 4 A computer-readable storage medium in the computer device shown.
[0174] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through a computer program, and the above-mentioned 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 memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0175] 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.
[0176] The above 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 invention patent. 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 patent of the present application shall be subject to the attached claims.
Claims
1. An application jump method, characterized in that: The method comprises: In response to a jump request of the current application, when the jump request carries a uniform resource identifier, parsing the uniform resource identifier to obtain resource information to be accessed and an access protocol; When the access protocol is consistent with the protocol preset in the current application, determining the target page information to be accessed according to the resource information to be accessed; Acquire a pre-configured jump type according to the target page information; When the jump type is a modal jump, the modal jump routing framework is called to perform page jump; When the jump type is a non-modal jump, the page jump is performed through a page navigation component.
2. The method according to claim 1, characterized in that The resource information to be accessed includes host information and the target page information includes a page identifier, and determining the target page information to be accessed according to the resource information to be accessed includes: Mapping the host information to the page identifier according to a pre-created mapping relationship between the host information and the page identifier; The obtaining a pre-configured jump type according to the target page information includes: Acquire page configuration information from a pre-created routing registration information table according to the page identifier; Determine the page type of the target page according to the page configuration information; When the page type is a page with a user interface, the jump type is acquired according to the page configuration information.
3. The method according to claim 2, characterized in that The current application includes a main module and a plurality of submodules, and the method further includes: During the operation of the current application, the main module calls the routing registration function of each submodule to obtain the routing registration information table returned by each submodule, and the routing registration information tables returned by each submodule are merged to obtain the routing registration information table.
4. The method according to claim 2, characterized in that: The resource information to be accessed further includes a query parameter, the target page information further includes a page parameter, and determining the target page information to be accessed according to the resource information to be accessed includes: Parse the query parameters from string format into key-value pairs; Convert the key-value pair into the page parameter; The calling modal jump routing framework performs page jump, including: The routing framework of the modal jump is called so that the routing framework of the modal jump performs page jump according to the page parameters.
5. The method according to claim 1, characterized in that The method further comprises: When the resource access protocol is inconsistent with the protocol preset in the current application, determining whether the uniform resource identifier meets the meta-service jump requirement; When the uniform resource identifier meets the meta-service jump requirement, a new meta-service of the current application is opened according to the uniform resource identifier, so as to perform a page jump in the new meta-service.
6. The method according to claim 1, characterized in that The method further comprises: Assembling jump information according to the to-be-accessed resource information and the resource access protocol; Calling an interceptor to check the jump information to determine whether the jump request needs to be intercepted; When there is no need to intercept the jump request, it is determined whether the access protocol is consistent with a protocol preset in the current application.
7. The method according to claim 1, characterized in that The method further comprises: When the jump request carries the target page information, generating jump information according to the jump request; Calling an interceptor to check the jump information to determine whether the jump request needs to be intercepted; When interception is not required, return to the step of obtaining a pre-configured jump type according to the target page information.
8. An application jump device, characterized in that: The device comprises: A parsing module, used for responding to a jump request of the current application, and when the jump request carries a uniform resource identifier, parsing the uniform resource identifier to obtain resource information to be accessed and an access protocol; A determination module, used to determine target page information to be accessed according to the resource information to be accessed when the access protocol is consistent with a protocol preset in the current application; An acquisition module, used for acquiring a pre-configured jump type according to the target page information; A first jump module, used for calling a modal jump routing framework to perform page jump when the jump type is a modal jump; The second jump module is used to perform page jump through the page navigation component when the jump type is a non-modal jump.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Project management system based on Vue Router framework and page jumping method thereof
CN121255271A