Page jump method, electronic device, and related apparatus
By generating a page routing table in electronic devices, storing page identifiers and creation methods, and directly loading page resources, the problem of page jump latency is solved, user experience is improved, and the development process is simplified.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2024-12-05
- Publication Date
- 2026-06-05
AI Technical Summary
Existing technologies often involve extended page transition times, resulting in excessively long user wait times and negatively impacting user experience.
By pre-generating a page routing table in electronic devices, storing page identifiers and creation methods, page resources can be loaded directly, avoiding the process of querying the actual page address based on the URL.
It reduces page redirection latency, improves user experience, simplifies the development process, and reduces the workload of developers.
Smart Images

Figure CN122153186A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of page navigation technology, and in particular to a page navigation method, electronic device, and related apparatus. Background Technology
[0002] Page navigation refers to navigating from one page to another, and it is widely used in various user interface (UI) applications. Currently, page navigation is usually implemented through configuration files, which include all the pages in the application, as well as page routing information. The page routing information is used to indicate the navigation method, navigation rules, etc.
[0003] Currently, page routing information can include the page's Uniform Resource Locator (URL). When a page redirects, the application can send the URL to the operating system. The operating system then queries the actual page address corresponding to the URL, loads page resources based on that address, and finally displays the page. However, the current page redirection time is long, resulting in extended waiting times for users. Summary of the Invention
[0004] This application provides a page redirection method, an electronic device, and related apparatus, which can reduce page redirection latency and user waiting time, thereby improving user experience.
[0005] Firstly, embodiments of this application provide a page navigation method. The executing entity of this method is an electronic device or a chip within an electronic device. The following description uses an electronic device as an example. In this method, the electronic device can display a first page. In response to a navigation instruction, the electronic device obtains a method for creating a second page, creates a second page according to the second page creation method, and displays the second page. The navigation instruction is used to indicate navigation from the first page to the second page. The method for creating the second page is the compiled output of the source code of the second page, and is used to create the second page.
[0006] In this embodiment, the electronic device can directly load the page according to the page creation method, without needing to query the actual page address corresponding to the URL and load page resources based on the actual page address, as is the case in the prior art when loading a page based on a Uniform Resource Locator (URL). This results in faster page loading speed and reduces user waiting time.
[0007] In one possible implementation, the electronic device stores a page routing table, which may include page identifiers indicating the page creation method. In response to a jump command, the electronic device can query the page routing table to see if it contains an identifier for a second page. If the page routing table contains the identifier for a second page, the electronic device can obtain the creation method for the second page based on the identifier in the page routing table. Thus, the electronic device can directly create the second page based on the creation method.
[0008] In this implementation, electronic devices can query the creation method of the second page according to the page routing table, which facilitates the rapid creation of the second page.
[0009] In this scenario, because the page's source code contains the page's address, and the compiled source code can be deployed on an electronic device, when the page routing table does not contain an identifier for the second page, the electronic device can obtain the second page's address from the compiled output of the page's source code. The electronic device can then load and display the second page based on this address. In this example, for instance, the operating system can load the second page's resources based on its address, create the second page based on those resources, and then display it.
[0010] In this implementation, if the page routing table does not contain the identifier of the second page, the electronic device can construct and display the second page based on the address of the second page in the compilation artifact of the page's source code, thus ensuring the display of the second page.
[0011] The following section will first introduce the page routing table:
[0012] In one possible implementation, during the application development phase, developers can write the application's source code. In this application, developers can add a first identifier at a preset location in the page's source code. This first identifier indicates that the page needs to generate a corresponding route registration method; that is, the first identifier is used to identify the page so that the page for which the route registration method is to be generated can be identified during the source code compilation phase. In other words, the first identifier indicates the route registration method for generating the page.
[0013] During the source code compilation phase, the compilation tool can compile the application's source code, converting it into a format such as a binary file that can be recognized by electronic devices. In this application, during the compilation process of the application's source code, the compilation tool can compile the application's source code, and the compilation tool can identify a first identifier. Based on this first identifier, and according to the source code of the page marked with the first identifier, a route registration method for the page is generated.
[0014] In one possible implementation, the page routing registration method includes a page identifier and a page creation method. The page creation method can be understood as the compiled output of the page's source code, and the page identifier is used to indicate the page, such as its name. In another possible implementation, the page routing registration method includes a page identifier and a second identifier. The second identifier can be seen as an index of the page creation method; different pages have different creation methods, therefore different pages have different second identifiers.
[0015] During application runtime, electronic devices can generate page routing tables based on the page's route registration method. Generating a page routing table can be understood as the electronic device mapping the content of the page's route registration method and storing it in the page routing table. For example, when the page's route registration method includes a page identifier and a page creation method, the electronic device can map the page identifier and the page creation method and store them in the page routing table. Similarly, when the page's route registration method includes a page identifier and a second identifier, the electronic device can map the page identifier and the second identifier and store them in the page routing table.
[0016] In this way, electronic devices can obtain the page routing table in advance, so as to prepare for subsequent page routing table queries.
[0017] In one possible implementation, taking a second page as an example, the page route registration method may include: an identifier for the second page and a creation method for the second page. In this implementation, before the second page is loaded, the electronic device can store the identifier for the second page and the creation method for the second page in a page routing table. For example, the electronic device can map the identifier for the second page and the creation method for the second page and store them in the page routing table. Alternatively,
[0018] For example, the page route registration method may include: an identifier of the second page and a second identifier. In this implementation, before the second page is loaded, the electronic device can store the identifier of the second page and the second identifier in a page routing table. For example, the electronic device can map the identifier of the second page and the second identifier and store them in the page routing table.
[0019] In this implementation method, the second page can be loaded before it is imported. In this application, the electronic device can store the identifier of the second page and the creation method of the second page, or the identifier of the second page and the second identifier, in the page routing table before the second page is loaded (i.e., before it is imported). This way, when the second page is loaded, the electronic device can directly query the page routing table to obtain the creation method of the second page, achieving the goal of quickly creating the second page.
[0020] In addition, in this implementation method, the developer adds a first identifier to the source code for subsequent generation of page route registration methods and page routing tables. Adding the identifier to the source code eliminates the need to configure additional page names, URLs, or other information, making the configuration simple. Furthermore, if the page name or URL changes, there is no need to re-edit the source code, which can reduce the workload of the developer.
[0021] The above describes the process by which an electronic device obtains the page routing table. The following describes the process by which an electronic device uses the page routing table:
[0022] In one possible implementation, a routing lookup table is used to indicate the mapping between page identifiers and page creation methods; that is, the routing lookup table includes page identifiers and the page creation methods mapped to those page identifiers. In this example, in response to a jump instruction, the electronic device can use the creation method mapped to the identifier of the second page in the routing lookup table as the creation method of the second page.
[0023] In one possible implementation, a routing lookup table is used to indicate the mapping between a page's identifier and a second identifier, where the second identifier is used to index the page's creation method. That is, the routing lookup table includes both the page's identifier and its second identifier. The page's identifier can be the page's name, and the second identifier can be considered an index used to index the page's creation method. In this example, in response to a jump instruction, the electronic device can use the second identifier mapped from the second page's identifier in the routing lookup table as the second identifier of the second page, and then index the second page's creation method based on that second identifier.
[0024] In this implementation, since the electronic device has already obtained the routing lookup table in advance, when the page jumps, it can directly obtain the page creation method based on the routing lookup table and directly create the page, which can improve the page loading speed.
[0025] The above example uses an electronic device as the execution subject to illustrate the page navigation method provided in this application. The following describes the page navigation method provided in this application from the perspective of internal module interaction within an electronic device. The technical implementation principle and beneficial effects can be referred to the above description:
[0026] In one possible implementation, the electronic device includes an application and an operating system, with the second page being a page within the application.
[0027] Before the second page is loaded, the application can send a registration request to the operating system. For example, in response to the registration request, the operating system can store the identifier of the second page and the creation method of the second page in the page routing table, based on the routing registration method of the second page. The routing registration method of the second page includes the identifier of the second page and the creation method of the second page; or,
[0028] For example, in response to a registration request, the operating system can store the identifier of the second page and the second identifier of the second page in the page routing table according to the routing registration method of the second page. The routing registration method of the second page includes the identifier of the second page and the second identifier of the second page.
[0029] In one possible implementation, in response to a jump instruction, the application can send a jump request to the operating system, indicating that a second page should be displayed. In response to the jump request, the operating system can obtain a method for creating the second page, enabling the electronic device to create and display the second page based on that method.
[0030] The method by which the operating system obtains the creation of the second page can be found in the description of the method by which the electronic device obtains the creation of the second page.
[0031] In a second aspect, embodiments of this application provide an electronic device, including a processor and a memory, wherein the memory is used to store code instructions and the processor is used to execute the code instructions to perform the methods described in the first aspect or any possible implementation thereof.
[0032] Thirdly, embodiments of this application provide a computer-readable storage medium storing a computer program or instructions that, when executed on a computer, cause the computer to perform the methods described in the first aspect or any possible implementation thereof.
[0033] Fourthly, embodiments of this application provide a computer program product including a computer program, which, when run on a computer, causes the computer to perform the methods described in the first aspect or any possible implementation of the first aspect.
[0034] Fifthly, this application provides a chip or chip system including at least one processor and a communication interface. The communication interface and the at least one processor are interconnected via a circuit. The at least one processor is used to run computer programs or instructions to perform the methods described in the first aspect or any possible implementation thereof. The communication interface in the chip can be an input / output interface, pins, or circuits, etc.
[0035] In one possible implementation, the chip or chip system described above in this application further includes at least one memory storing instructions. The memory can be an internal storage unit of the chip, such as a register or cache, or it can be a storage unit of the chip itself (e.g., read-only memory, random access memory, etc.).
[0036] It should be understood that the second to fifth aspects of this application correspond to the technical solutions of the first aspect of this application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation are similar, and will not be repeated here. Attached Figure Description
[0037] Figure 1A This is a diagram illustrating page navigation.
[0038] Figure 1B This is another illustration of page navigation;
[0039] Figure 2 A flowchart for configuring a page;
[0040] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0041] Figure 4 A flowchart illustrating one embodiment of the page redirection method provided in this application;
[0042] Figure 5 A flowchart illustrating another embodiment of the page redirection method provided in this application;
[0043] Figure 6 A schematic diagram illustrating page navigation provided in an embodiment of this application;
[0044] Figure 7 A flowchart illustrating another embodiment of the page redirection method provided in this application;
[0045] Figure 8 This is another structural schematic diagram of the electronic device provided in the embodiments of this application. Detailed Implementation
[0046] To facilitate understanding, the relevant terms and concepts involved in the embodiments of this application will be introduced below:
[0047] 1. Page Routing Framework: A framework used to manage and control navigation and navigation between pages. It allows developers to define paths between pages, enabling navigation from one page to another. The page routing framework also handles data transfer between pages, ensuring data is correctly passed and received across different pages. Furthermore, it manages the page lifecycle, including page loading, showing, hiding, and unloading.
[0048] 2. Configuration file: In this embodiment, the configuration file used to define page navigation refers to the configuration file used to define page navigation. Taking page navigation in an application as an example, in some embodiments, the configuration file may include all pages in the application, page routing information, and page configuration options, etc.
[0049] 3. Page routing information: This indicates the page's redirection method, redirection rules, etc. For example, page routing information may include: page name, page path, and page parameters, etc.
[0050] 4. Page configuration options: These indicate the page display method and transition animations, etc. Page display methods include split-screen, full-screen, etc.
[0051] 5. Module: A module is a functional part used to organize and encapsulate code, providing interfaces for interaction with other modules. In some embodiments, a module can be a single file or a set of files, depending on how the code is organized. Modules allow code to be divided into different parts, making the code easier to manage and reuse.
[0052] 6. Component: A component is a software unit that can be deployed, run, and upgraded independently. It typically contains code to implement a specific function and the necessary resource files. Components emphasize cross-project usability, meaning they can be reused in different systems or projects.
[0053] In some embodiments, modules are divided from a logical functional perspective, emphasizing functional independence and integrity, while components are divided from a physical implementation perspective, emphasizing code reusability and maintainability. Modules typically have strong dependencies on each other, while components are relatively independent. Modules are usually coarser in granularity, containing multiple related functions or sub-modules, while components are relatively finer in granularity, including code and resource files that implement specific functions.
[0054] For example, embodiments of this application relate to page navigation. Taking a page as an example, page components are the basic units for building a page. Components are typically reusable, independent blocks of code that encapsulate specific functions or interface elements. The advantage of components lies in their improved code reusability and maintainability. For instance, developers can create a set of generic component libraries that can then be reused across different pages.
[0055] A page contains a wide variety of components, including but not limited to: container view components, basic content components, form components, multimedia components, and others. For example, container view components are used for layout and to house other components. Basic content components are used to display text content. Form components are used to receive user input. Multimedia components are used to display images, videos, and audio content. Other components, such as buttons, progress bars, text boxes, and images, are used to provide additional functionality and UI elements.
[0056] 7. Component Declaration: Used to define components. For example, a component declaration can define the structure and functionality of a component.
[0057] 8. Activity: An Activity is a single-screen interface within an application used to display the user interface (UI) and handle user interactions. An Activity is one of the basic building blocks of an application and plays a crucial role in interacting with the user. Each Activity represents an independent task or action, and users can switch and navigate between different Activities.
[0058] For example, an Activity defines its user interface through a layout file, which can include various UI components such as buttons, text boxes, and images. These UI components together constitute the Activity's user interface, enabling users to interact with the application. An Activity can receive user input, such as clicking a button or entering text, and can then execute corresponding logic based on the user's actions. For instance, when a user clicks a button, the Activity can launch a new Activity or display a dialog box.
[0059] 9. Annotations: Also known as metadata, annotations are special markers in code used to add extra information. Annotations can be read and processed at compile time, load time, and runtime to provide additional functionality or behavior. Annotations themselves do not directly affect the logic of the code, but can be used in the background by compilers, development tools, or other frameworks.
[0060] 10. Application Cold Start: When an application starts, there is no background process for that application on the electronic device. The operating system on the electronic device creates a new process and assigns it to the application. This method of starting an application is called a cold start. Application cold starts usually occur when the application is opened for the first time, or when the application is restarted after its process has been destroyed.
[0061] In contrast to a cold start, there is a warm start. A warm start can be understood as follows: when an application starts, its process exists in the background of the electronic device. The operating system of the electronic device can resume the application's page from that process. This method of starting an application is called a warm start. A warm start typically occurs when an application switches from the background to the foreground, and its process already exists in the background.
[0062] Compared to a warm start, a cold start takes longer.
[0063] 11. Import: During an application's cold start, the operating system needs to create the application's process and allocate corresponding resources. In this process, the application needs to import necessary modules, components, libraries, and other resources to implement its functions and business logic. Through import, the application can ensure that all necessary modules, components, libraries, and other resources are imported at startup, thereby avoiding errors or exceptions caused by missing resources during subsequent execution. Importing modules, components, libraries, and other resources can be understood as the application loading these resources into the electronic device's memory.
[0064] In some embodiments, `import` involves not only importing modules, libraries, and other resources, but also initializing global variables and configurations. These global variables and configurations are crucial for the proper functioning of the application, such as database connection information, application programming interface (API) keys, and log levels. Through `import`, the application can set these global variables and configurations at startup, ensuring their availability during subsequent execution.
[0065] This application embodiment involves an import page, which can be understood as a component of the import page, preparing for the display of the page.
[0066] 12. Page Redirection: Page redirection in this application embodiment may include, but is not limited to: redirection from one page to another completely new page, or redirection of part of the content within a page. For example, taking page redirection in a news application, and using a mobile phone as an example, Figure 1A This demonstrates how a news app navigates from one page to a completely new page. Figure 1BThis demonstrates a redirect within a page of a news application.
[0067] For example, let's take news apps as an example. Figure 1A The image 'a' in the document displays the homepage of a news application. (See reference...) Figure 1A In the context of news apps, the homepage can include: a search box 11, a navigation bar 12, a content bar 13, and a tag bar 14. When a user enters information in the search box 11, the news app will display the page corresponding to that search result. The navigation bar 12 can include different types of news channels; users can select a news channel to switch to that channel's page. The content bar 13 displays recommended news content from the news app. Figure 1A In example 'a', content bar 13 includes content 1 and content 2. Tab bar 14 may include options such as "Home", "Videos", "Messages", and "My", and users can click on these options to switch to different content sections in the news application.
[0068] Reference Figure 1A In option 'a', when a user clicks the "Messages" option in tab 14, the phone can jump from the homepage of a news app to the messages page. (See reference...) Figure 1A In section b, the message page can include system messages from news applications, as well as messages from authors the user follows.
[0069] Figure 1B a in Figure 1A The 'a' in the same letter can be referred to as 'a'. Figure 1A See the description in section 'a'. (Refer to...) Figure 1B In the context of item 'a', content 1 within content bar 13 can include animated news images. The homepage of news applications can then rotate through these animated news images, meaning that a portion of the content on the homepage of a news application will be redirected. It should be understood that... Figure 1B In the image, 'a' and 'b' are two frames from a news animation (such as GIF 1 and GIF 2). Figure 2 Let's take an example to illustrate.
[0070] 13. User Interface:
[0071] The term "user interface" or "interface" in this application refers to the medium through which an application or operating system interacts and exchanges information with a user. It facilitates the conversion between the internal form of information and a form acceptable to the user. A user interface is source code written in a specific computer language such as Java or Extensible Markup Language (XML). This source code is parsed and rendered on an electronic device, ultimately presenting content that the user can recognize. A common form of user interface is the graphical user interface (GUI), which refers to a user interface related to computer operation displayed graphically. It can be visible interface elements such as text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, and widgets displayed on the screen of an electronic device.
[0072] 14. Electronic devices:
[0073] The electronic device in this application embodiment is a device with a display screen, which is used to display pages and navigate between pages. In some embodiments, the electronic device may be referred to as user equipment (UE), terminal, etc. For example, the electronic device may be a mobile phone, tablet, personal digital assistant (PDA), handheld device with wireless communication function, computing device, in-vehicle device or wearable device, virtual reality (VR) terminal device, augmented reality (AR) terminal device, wireless terminal in industrial control, wireless terminal in smart home, etc. The form of the electronic device is not specifically limited in this application embodiment.
[0074] Currently, different operating systems can use different page routing frameworks. Page routing frameworks are used to manage and control navigation and transitions between pages. For example, in the Android operating system, commonly used page routing frameworks include Jetpack Navigation and ARouter; in the iOS operating system, commonly used page routing frameworks include Router and DeepLinkKit; and in the HarmonyOS operating system, commonly used page routing frameworks include Navigation and Router.
[0075] Page routing frameworks typically require configuration files to define page navigation. Taking page navigation within an application as an example, in some implementations, the configuration file may include all pages in the application, page routing information, and page configuration options. Configuration files can use different formats, such as Extensible Markup Language (XML), JavaScript Object Notation (JSON), or YAML.
[0076] Currently, the way to develop configuration files for page routing frameworks is not flexible enough. For example, in scenarios such as page modification, deletion, or addition, developers have to re-edit the configuration files, which involves a large amount of development work and is not easy to maintain.
[0077] The following example uses the ARouter page routing framework on the Android operating system, taking the addition of a page to an application as an example. Figure 2 This describes the current process of developers modifying configuration files:
[0078] Step 1: Add configuration and dependencies to the modules that need to be integrated.
[0079] A module can be understood as a component within a new page, and a module within a page can be understood as a component within a page. For example, a new page might include product information, and the modules within that page could include a product information module. When creating a new page, developers can configure the product information module with the product information and the code libraries that the product information depends on. This way, when the application displays the page, it can retrieve the relevant product information from that code library and display it on the page.
[0080] Step 2: Initialize the software development kit (SDK)
[0081] The SDK can be the SDK for ARouter. Initializing the SDK can be understood as starting ARouter to prepare for subsequent page navigation.
[0082] Step 3, add annotations to the target Activity
[0083] The target Activity is used to manage and control newly added pages. Adding annotations to the target Activity can include: 1. Adding a marker to the new page, indicating that the new page uses ARouter; 2. Adding auxiliary annotations to the new page. These auxiliary annotations typically describe the page's code, styles, or scripts.
[0084] Step 4: Configure other modules that use ARouter. Configuration details are the same as in Step 1.
[0085] In some embodiments, a new page may include multiple modules. For each module, the developer needs to configure it, as described in step 1.
[0086] Currently, taking adding a new page as an example, developers have to re-edit the configuration file, adding multiple configurations, and each specific configuration is quite cumbersome, resulting in a large development workload, a high risk of errors, and difficulty in maintenance. Furthermore, adding a new page uses ARouter, making it difficult to port to pages using other page routing frameworks.
[0087] To address the above issues, annotations can be used in page routing configuration. Annotations allow developers to add annotations at specific locations in the source code to define page routing rules. These source code annotations typically include information such as the page path, request method, and parameters. The page path indicates the route from one page to another. For example, the page path can be the Uniform Resource Locator (URL) of the target page, and the target page can be that "other page." The request method can be, for example, GET, POST, etc. Page parameters can include, but are not limited to, the content of the page.
[0088] For example, the following source code (1) illustrates this type of annotation:
[0089] @abcd(Name,1;URL,xxx.xx.xx;…)
[0090] Component 123 {Component 123 specific code}
[0091] }
[0092] …Source code (1)
[0093] Referring to the source code (1), taking a page containing component 123 as an example, "123" is the name of the component. The source code of the page can include the specific implementation code of component 123. In the source code, the developer needs to configure annotations for the page, which need to include the page name such as "Name,1", the page path such as "URL,xxx.xx.xx", and other annotation information.
[0094] In this example, the processor (such as a central processing unit (CPU)) can generate a routing table based on the source code. The routing table can include the page name and the page URL. In response to a user action, when the application determines that a page needs to be navigated to, it can query the routing table to find the page URL and then look up the actual page address based on that URL. The application can then provide the actual page address to the operating system, which can load the page resources and display the page based on that address.
[0095] In this example, by using annotations, developers can define page routing rules directly in the source code without writing additional configuration files. This simplifies the configuration process and reduces the possibility of configuration errors and maintenance complexity. Furthermore, developers can dynamically add, modify, or delete corresponding routing rules in the source code when adding, modifying, or deleting pages, further reducing their workload.
[0096] However, in this example, because developers need to configure information such as the page name and URL in the annotations, if the page name or URL is changed, developers will need to modify the annotations in the source code, which will increase their workload.
[0097] To address the above issues, this application provides a page redirection method. In this method, an identifier can be added to the source code. During the source code compilation process, a page routing registration method can be generated based on this identifier. The routing registration method includes the page identifier and a page creation method. When a user requests redirection to this page, the page can be directly loaded based on the page creation method. In this application, on the one hand, adding the identifier to the source code eliminates the need to configure additional page names, URLs, or other information, simplifying configuration. Furthermore, if the page name or URL changes, the source code does not need to be re-edited, reducing the workload for developers. On the other hand, in this application, the page routing registration method is generated during the compilation stage. This method can include a page creation method for directly loading the page, eliminating the need for querying the actual page address based on the URL and loading page resources based on that address, as is done in existing technologies. This results in faster page loading and reduces user waiting time.
[0098] Before introducing the page redirection method provided in the embodiments of this application, the structure of the electronic device provided in the embodiments of this application will be introduced first. Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. (Refer to...) Figure 3 Electronic devices can include applications and operating systems.
[0099] Applications can include, but are not limited to, system applications and third-party applications. System applications may include gallery applications, settings applications, etc. Third-party applications may include video applications, audio applications, social applications, news applications, shopping applications, etc. The applications in the following examples are user-operated applications; users can operate the applications to trigger page navigation within them.
[0100] In some examples, the page navigation method in this application embodiment can be applied to navigation between pages within an application or between pages between applications.
[0101] The operating system is used to create processes for applications during application cold starts, so that the applications can run. Additionally, the operating system can provide services to application processes.
[0102] exist Figure 3 Based on the structure of the electronic device shown, the page navigation method provided in this application will be described below with reference to specific embodiments. These embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0103] In some embodiments, the page redirection method provided in this application can be divided into three stages: Stage 1: source code development stage; Stage 2: source code compilation stage; Stage 3: application runtime stage. (Refer to...) Figure 4 During the source code development phase, developers can add a primary identifier to the page. During the source code compilation phase, the compilation tools can generate the page's route registration method based on the primary identifier. During application runtime, the operating system can load the page according to the page's route registration method.
[0104] In some embodiments, stages 1 and 2 can be viewed as the application preparation stage. Stage 3 can be viewed as the application usage stage.
[0105] The following uses the source code of the application as an example to explain each stage in detail:
[0106] Phase 1: Source Code Development Phase
[0107] During the application development phase, developers can write the application's source code. The application's source code can include the source code for each page of the application, as well as information such as the page's address. The page's source code is used to implement the page, and the page's address is used to locate and load the page. For example, the page's address can include, but is not limited to, URLs or links.
[0108] It should be understood that the source code of each page of the application, as well as the page address and other information, are the original configurations in the application's source code, and are not new configurations added in this application embodiment.
[0109] For example, the source code of the application's homepage is shown in the following source code (2):
[0110] struct HomePage {
[0111] build(){
[0112] Button()
[0113] .onClick() => {
[0114] NavigationStack.pushpath({
[0115] }) Source code (2)
[0116] The source code of the page may include the source code of the components on the page. Taking source code (2) as an example, the page may include a button component, and the source code of the button component is used to implement the button component. For example, the source code of the button component is used to define the name, type, color, size, position on the page, and other information of the button component. It should be understood that the specific source code of the button component is not shown in source code (2).
[0117] Here, NavigationStack.pushpath represents the address of the page. Based on this address, you can jump to that page, as described in the above embodiments.
[0118] In this embodiment, developers can add a first identifier at a preset location in the source code of each page. The first identifier is used to indicate that the page needs to generate a corresponding route registration method; that is, the first identifier is used to identify the page so that the page to generate the route registration method can be identified during the source code compilation stage.
[0119] In some embodiments, the default location of the page's source code may be: above the component class or above the method in the page's source code, or a location defined by the developer.
[0120] In some embodiments, the first identifier can be a custom number, mark, etc. In this application embodiment, the first identifier can be the same for different pages.
[0121] In some embodiments, the first identifier can be an annotation. An annotation could be, for example, @NavDestination.
[0122] For example, developers can add the first identifier @NavDestination to the page in the source code (2) to obtain the following source code (3):
[0123] @NavDestination
[0124] struct HomePage {
[0125] build(){
[0126] Button()
[0127] .onClick() => {
[0128] NavigationStack.pushpath({
[0129] }) Source code (3)
[0130] In this embodiment, in the scenario of adding a new application page, the developer can add the page's source code to the application's source code and add a first identifier at a preset location in the page's source code. In the scenario of deleting an application page, the developer can delete the page's source code and the page's first identifier from the application's source code. In the scenario of modifying an application page, the developer can modify the page's source code within the application's source code; this does not necessarily involve changing the first identifier.
[0131] Phase 2: Source Code Compilation Phase
[0132] Once the application's source code is developed, the compilation tool can compile the application's source code and convert it into a binary file or other format that electronic devices can recognize, making it easier for electronic devices to run the application based on the binary file.
[0133] During the compilation process, the compilation tool can compile the application's source code. Compared to existing source code compilation processes, in this embodiment, the compilation tool can also identify a first identifier in the source code and generate a route registration method for each page based on the source code of each page. In some embodiments, after compiling the application's source code, the compilation tool can obtain the compilation product of the application's source code and the route registration method for each page in the application.
[0134] Taking a page as an example, in some embodiments, the page's route registration method may include the page's identifier and the page's creation method.
[0135] The page identifier can be the page name, number, etc. When compiling the page's source code, the compiler can extract the page identifier from the source code.
[0136] The page creation method is used to create (load) a page. In some embodiments, the page creation method may include: a compiled output of the page's source code. The page's source code indicates the page's basic structure, content, etc., and may also include the source code of components within the page. Correspondingly, the compiled output of the page's source code may also indicate the page's basic structure, content, etc., and may include the compiled output of the source code of components within the page.
[0137] In this example, the compiled artifacts of the page's source code can be used to create (load) the page. For instance, an application can create components in the page based on the compiled artifacts of the source code of the components in the page, and the application can also lay out the components in the page based on the page's basic structure, content, etc., to create the page.
[0138] In some embodiments, when compiling the source code of a page, the compilation tool can use the compiled output of the source code as the method for creating the page.
[0139] In some embodiments, the compilation tool can also provide a corresponding index for the creation method of each page in the application; that is, each page creation method corresponds to an index, which can be called a second identifier. In other words, each page creation method corresponds to a second identifier. The second identifier is used to indicate the page creation method, i.e., the compiled product of the page's source code. The second identifier is used to indicate the page creation method; for example, based on the second identifier, the page creation method can be determined.
[0140] In this example, the route registration method may include a page identifier and a second identifier.
[0141] For example, the following example shows the result obtained after the compilation tool compiles the source code of the page:
[0142] {The compiled output of the page's source code}
[0143] }
[0144] registerDestinationRoute(struct Name, struct Creator, otherIofo)
[0145] Here, {compiled artifacts of the page's source code} indicates the compiled artifacts of the source code, that is, the artifacts obtained after the application's source code is compiled. registerDestinationRoute(struct Name, struct Creator, otherIofo) represents the page's route registration method, where struct Name represents the page's identifier, and struct Creator represents the page's creation method or a second identifier.
[0146] Phase 3: Application Operation Phase
[0147] In this embodiment of the application, before the application loads the page, the operating system can execute the compilation output of the compilation tool, that is, the operating system executes the page's route registration method.
[0148] Different pages may load at different times. For example, for the application homepage, the electronic device needs to display the homepage after a cold start. Therefore, the operating system can execute the application homepage route registration method during a cold start to directly display the application homepage after the cold start. For example, refer to... Figure 1A In step b, after a cold start of the application, the electronic device does not need to display the message page. Therefore, the operating system does not need to execute the message page routing registration method during the application's cold start. After the electronic device displays the application's homepage, the user can click the "Messages" option in tab bar 14 at any time to trigger the display of the message page. Therefore, the operating system can execute the message page routing registration method when the electronic device displays the application's homepage, so that the electronic device can quickly display the message page when the user clicks the "Messages" option in tab bar 14.
[0149] This application does not exhaustively list the times when the operating system executes the route registration method for each page. It can be understood that, in this application embodiment, the operating system can execute the route registration method for the page before the page is loaded, so as to achieve the purpose of the application being able to respond quickly when the page needs to be displayed.
[0150] In some embodiments, when a page is imported, the operating system can execute the page's route registration method. Imported pages can be referred to the description in the above embodiments.
[0151] The operating system's page route registration method can be understood as follows: the operating system maps the page's identifier to the page's creation method and stores this mapping in the page routing table. Alternatively, the operating system's page route registration method can be understood as follows: the operating system maps the page's identifier to the page's secondary identifier and stores this mapping in the page routing table.
[0152] Figure 5This is a flowchart illustrating another embodiment of the page redirection method provided in this application. (Refer to...) Figure 5 The page redirection method provided in this application embodiment may include:
[0153] S501, displaying the first page.
[0154] The first page can be considered the page before the page jump. The first page can be any page; in some embodiments, when the page jump involves a page within the application, the first page can be any page within the application. For example, refer to... Figure 1A The first page can be the homepage of a video application.
[0155] S502, in response to the jump instruction, obtain the method for creating the second page. The jump instruction is used to indicate a jump from the first page to the second page.
[0156] The jump command is used to indicate that you should jump from the first page to the second page.
[0157] In some embodiments, the jump instruction can be an instruction triggered by a user action.
[0158] For example, the user's action could be an action on the first page, such as the user pressing a button on the first page, triggering a redirection to the second page. (See reference...) Figure 1A In the examples 'a' and 'b', clicking the "Messages" option in tab 14 on the homepage will trigger a redirect to the messages page, which can be considered a second page. In this example, the user's actions on the first page can trigger the electronic device to receive a redirect command.
[0159] For example, a user's action could be their voice. In a reading app, a user could say "turn the page," which could trigger a jump from the current page to the next. In this example, the user's voice could trigger the electronic device to receive the jump command.
[0160] In some embodiments, the jump instruction can be an instruction within an electronic device (such as an application). For example, see [link to example]. Figure 1B News apps can display a carousel of animated news images on their homepage. In this example, the news app can pre-set a jump command for the homepage carousel of animated news images. For example, this jump command might instruct a news image to play at preset intervals.
[0161] This application does not impose any restrictions on the implementation of jump instructions; the above examples are merely illustrative.
[0162] In response to a jump command, the electronic device can determine whether to jump from the first page to the second page. To display the second page, the electronic device can query the page routing table based on the identifier of the second page to obtain the method for creating the second page.
[0163] In some embodiments, when the page routing table includes a mapping relationship between page identifiers and page creation methods, the electronic device can use the creation method mapped to the identifier of the second page in the page routing table as the creation method of the second page. In some embodiments, when the page routing table includes a mapping relationship between page identifiers and second page identifiers, the electronic device can use the second identifier mapped to the identifier of the second page in the page routing table as the second identifier of the second page, and the electronic device can index to the creation method of the second page based on the second identifier to obtain the creation method of the second page.
[0164] S503, create a second page according to the method for creating a second page, and display the second page.
[0165] The method for creating a second page allows an electronic device to directly create (load) a second page without needing to query the actual page address corresponding to the URL or load page resources based on the actual page address. In this embodiment, after the electronic device creates the second page, it can display the second page.
[0166] Figure 6 by Figure 1A Using the scenario shown below as an example, briefly describe the process of an electronic device jumping from the first page to the second page:
[0167] It should be understood that Figure 6 a and c in the middle are respectively Figure 1A The 'a' and 'b' in the text are the same; you can refer to... Figure 1A The descriptions in sections a and b. Refer to... Figure 6 In the example 'a', the first page is the homepage of a video application. When the user clicks the "Messages" option in tab 14 of the homepage, the electronic device receives a redirect command. In response to this command, the electronic device determines that the second page is the messages page. (See also...) Figure 6 In option b, the electronic device can query the page routing table to obtain the method for creating the message page. The electronic device can then create and display the message page according to this method, such as... Figure 6 As shown in c in the figure.
[0168] In this embodiment, during the application development phase, developers can add a first identifier at a preset location in the page's source code. During the compilation phase, the compilation tool can generate a page's route registration method based on the first identifier. When the page is imported, the operating system can map the page's identifier to the page's creation method based on the page's route registration method and store this mapping in the page routing table. After these preparations, when the application loads a page (such as a second page), the electronic device can query the page routing table to obtain the second page's creation method and directly create (load) the page based on that method. In this embodiment, on the one hand, developers add a first identifier in the source code to indicate the page for which a route registration method is to be generated, without needing to configure additional page names, URLs, or other information. This simplifies configuration and reduces the workload for developers. On the other hand, the electronic device can directly load the page based on its creation method, without needing to query the actual page address corresponding to the URL and load page resources based on the actual page address, as is done in the prior art. This results in faster page loading and reduces user waiting time.
[0169] Figure 5 The examples provided illustrate the page navigation method offered in this application from the perspective of an electronic device. The following section describes the page navigation method from the perspective of interaction between applications and the operating system in an electronic device. (Refer to...) Figure 7 The page redirection method provided in this application embodiment may include:
[0170] Step 1A: Add the first identifier to the application's source code.
[0171] Step 1A can be referred to the description in Stage 1.
[0172] Step 1B: Compile the application's source code to obtain the compilation artifacts and the page's route registration method.
[0173] Step 1B can be referred to the description in Stage 2.
[0174] Step 1C: Before the second page is loaded, the application sends a registration request to the operating system.
[0175] Before the second page is loaded, it can be understood as before the second page is actually used, such as when importing the second page. The application sends a registration request to the operating system to instruct the operating system to generate a page routing table.
[0176] In step 1D, in response to the registration request, the operating system stores the identifier of the second page and the creation method of the second page in the page routing table according to the routing registration method of the second page, or stores the identifier of the second page and the second identifier of the second page in the page routing table.
[0177] Step 1D can be referred to the description in stage 3.
[0178] Step 1E: In response to the jump instruction, the application sends a jump request to the operating system, which is used to indicate the display of the second page.
[0179] The jump instruction can be found in the description in S502. The jump request is used to instruct the operating system to display the second page, which can be found in [reference needed]. Figure 5 The description in the example shown.
[0180] Step 1F: In response to the redirection request, the operating system queries the page routing table to see if it contains the identifier of the second page. If yes, proceed to step 1G; otherwise, proceed to step 1H.
[0181] Step 1G: The operating system obtains the method for creating the second page, and creates and displays the second page according to the method for creating the second page.
[0182] Steps 1F-1G can be referred to the description in S503.
[0183] In step 1H, the operating system obtains the address of the second page, loads the second page based on the address, and displays the second page.
[0184] If the page routing table does not contain an identifier for the second page, the operating system cannot directly create the page based on the second page creation method. In this embodiment, based on the description in stage 1 above, the source code of the second page may include the address of the second page, and correspondingly, the compiled output may also include the address of the second page. The operating system can obtain the address of the second page from the compiled output and display the second page according to the address of the second page.
[0185] For example, the operating system can load the resources of the second page based on the address of the second page, and construct and display the second page based on the resources of the second page.
[0186] It should be understood that step 1A may be included in stage 1, step 1B may be included in stage 2, and steps 1C-1 may be included in stage 3. Stages 1, 2, and 3 may refer to the description in the above embodiments.
[0187] It should be understood that the embodiments of this application have the same technical principles and beneficial effects as the embodiments described above, and the beneficial effects can be referred to the description in the embodiments above.
[0188] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0189] This application provides an electronic device, with reference to... Figure 8 The electronic device may include a processor 801 (e.g., a CPU) and a memory 802. The memory 802 may include high-speed random-access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device. The memory 802 may store various instructions for performing various processing functions and implementing the method steps of this application.
[0190] Optionally, the electronic device involved in this application may further include: a power supply 803, a communication bus 804, and a communication port 805. The communication port 805 is used to enable communication between the electronic device and other peripherals. In this embodiment, the memory 802 is used to store computer-executable program code, which includes instructions. When the processor 801 executes the instructions, the instructions cause the processor 801 of the electronic device to perform the actions described in the above method embodiment. The implementation principle and technical effects are similar and will not be repeated here.
[0191] Optionally, the electronic device involved in this application may further include: a display screen 806. The display screen 806 is used to display the interface of the electronic device.
[0192] In other embodiments of this application, the electronic device may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0193] This application provides a chip. The chip includes a processor, which is used to call a computer program in memory to execute the technical solutions in the above embodiments. Its implementation principle and technical effects are similar to those in the related embodiments described above, and will not be repeated here.
[0194] This application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, it implements the methods described above. The methods described in the above embodiments can be implemented wholly or partially by software, hardware, firmware, or any combination thereof. If implemented in software, the functionality can be stored as one or more instructions or code on or transmitted over the computer-readable medium. The computer-readable medium can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium accessible by a computer.
[0195] In one possible implementation, a computer-readable medium may include random access memory (RAM), read-only memory (ROM), compact disc read-only memory (CD-ROM) or other optical disc storage, magnetic disk storage or other magnetic storage devices, or any other medium intended to carry or store required program code in the form of instructions or data structures, and accessible by a computer. Furthermore, any connection is appropriately referred to as a computer-readable medium. For example, if software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. As used herein, disks and optical discs include optical discs, laser discs, optical discs, digital versatile discs (DVDs), floppy disks, and Blu-ray discs, where disks typically reproduce data magnetically, while optical discs optically reproduce data using lasers. Combinations of the above should also be included within the scope of computer-readable media.
[0196] This application provides a computer program product, which includes a computer program that, when run, causes a computer to perform the above-described method.
[0197] It should be noted that the modules or components described in the above embodiments can be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more digital signal processors (DSPs), or one or more field-programmable gate arrays (FPGAs), etc. Furthermore, when a module is implemented through processing element scheduler code, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processors capable of calling program code, such as a controller. Additionally, these modules can be integrated together to implement a system-on-a-chip (SOC).
[0198] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0199] The term "multiple" in this document refers to two or more. The term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Furthermore, the character " / " in this document generally indicates an "or" relationship between the preceding and following related objects; in formulas, " / " indicates a "division" relationship. Additionally, it should be understood that in the description of this application, words such as "first" and "second" are used only for descriptive purposes and should not be construed as indicating or implying relative importance or order.
[0200] It is understood that the various numerical designations used in the embodiments of this application are merely for descriptive convenience and are not intended to limit the scope of the embodiments of this application.
[0201] It is understood that, in the embodiments of this application, the order of the above-mentioned process numbers does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
Claims
1. A page redirection method, characterized in that, Applied to electronic devices, the method includes: Display the first page; In response to a jump instruction, a method for creating a second page is obtained, wherein the jump instruction is used to indicate a jump from the first page to the second page, and the method for creating the second page is a compilation product of the source code of the second page; Create the second page according to the method for creating the second page, and then display the second page.
2. The method according to claim 1, characterized in that, The method for obtaining the creation of the second page includes: Check if the page routing table contains the identifier of the second page; If so, obtain the creation method of the second page based on the identifier of the second page.
3. The method according to claim 2, characterized in that, The routing lookup table is used to indicate the mapping between page identifiers and page creation methods; The method for obtaining the creation method of the second page based on the identifier of the second page includes: In the routing query table, the method for creating the identifier mapping of the second page is used as the method for creating the second page.
4. The method according to claim 2, characterized in that, The routing lookup table is used to indicate the mapping between the page's identifier and the second identifier, whereby the second identifier is used to index the page's creation method. The method for obtaining the creation method of the second page based on the identifier of the second page includes: In the routing lookup table, the second identifier mapped to the identifier of the second page is used as the second identifier of the second page; The method for indexing the creation of the second page is based on the second identifier of the second page.
5. The method according to any one of claims 2-4, characterized in that, The method further includes: Before the second page is loaded, the identifier of the second page and the method for creating the second page are stored in the page routing table; or, Before the second page is loaded, the identifier of the second page and the second identifier of the second page are stored in the page routing table.
6. The method according to claim 5, characterized in that, The second page before it is loaded is as follows: when the second page is imported.
7. The method according to claim 5 or 6, characterized in that, The electronic device includes an application and an operating system, and the second page is a page within the application; the method further includes, before the second page is loaded: The application sends a registration request to the operating system; The step of storing the identifier of the second page and the method for creating the second page in the page routing table includes: In response to the registration request, the operating system stores the identifier of the second page and the creation method of the second page in the page routing table according to the routing registration method of the second page, wherein the routing registration method of the second page includes the identifier of the second page and the creation method of the second page; or, In response to the registration request, the operating system stores the identifier of the second page and the second identifier of the second page in the page routing table according to the routing registration method of the second page. The routing registration method of the second page includes the identifier of the second page and the second identifier of the second page.
8. The method according to claim 7, characterized in that, The route registration method of the second page is generated during the compilation phase based on the source code of the second page. The source code of the second page includes a first identifier, which is used to indicate the route registration method for generating the second page.
9. The method according to claim 7 or 8, characterized in that, The method for obtaining the creation of the second page in response to a redirection instruction includes: In response to the jump instruction, the application sends a jump request to the operating system, the jump request being used to instruct the display of the second page; In response to the redirection request, the operating system obtains the method for creating the second page.
10. The method according to claim 2, characterized in that, The method further includes: If the page routing table does not contain the identifier of the second page, obtain the address of the second page; The second page is loaded and displayed based on its address.
11. An electronic device, characterized in that, The electronic device includes: one or more processors and memory; The memory is coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the electronic device to perform the method as described in any one of claims 1-10.
12. A chip system, characterized in that, The chip system is applied to an electronic device, the chip system including one or more processors, the one or more processors being used to invoke computer instructions to cause the electronic device to perform the method as described in any one of claims 1-10.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-10.
14. A computer program product, characterized in that, The computer program product includes computer program code that, when run on an electronic device, causes the electronic device to perform the method as described in any one of claims 1-10.