Page switching method and device, computer equipment and storage medium
By triggering interception events before page switching in the micro front-end architecture system and executing responses, the problem of route interception logic failure caused by application uninstallation is solved, effective interception of routes before page switching is achieved, network requests are reduced, and the SDK package is passed Realize decentralized routing management and improve system stability and interactive experience.
Patent Information
- Application Number
- CN202410569294.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-09
- Publication Date
- 2024-09-17
AI Technical Summary
In a system based on micro front-end architecture, routing interception logic fails due to application unloading when switching pages, affecting subsequent functions. Existing real-time saving methods have problems with excessive network requests and system congestion.
By obtaining the address of the current page and triggering the corresponding interception event before the page switch, the interception response is executed to ensure that the routing interception logic is effectively executed before the page switch, to avoid application uninstallation from affecting subsequent functions, and through the software development toolkit to encapsulate the interception registration method and Scheduling method to achieve decentralized route interception.
It effectively avoids the impact of application uninstallation on functions when switching pages, reduces network requests, improves system stability and interactive experience, and flexibly executes different interception responses according to business needs.
Smart Images

Figure CN118656156A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a page switching method, device, computer equipment, storage medium and computer program product. Background Art
[0002] The system built based on the micro-frontend architecture includes the main application and sub-applications, and objects often switch back and forth between multiple pages in the system. If the page switch occurs inside the main application or the sub-application, the page switch will only be executed when certain logical conditions are met, otherwise it will stay on the current page. Because in the system based on the micro-frontend architecture, the main application and sub-application each have independent routing systems, the logical condition judgment before the page switch is performed by the routing interception logic inside each application.
[0003] However, if the page switch occurs between the main sub-application, or between different sub-applications, the current application may be uninstalled to release resources so that the pages in the new application can be loaded and displayed. The uninstallation of the current application will also uninstall the routing interception logic inside the current application, causing the routing interception logic before the page switch to fail, affecting subsequent functions. Summary of the invention
[0004] Provided are a page switching method, apparatus, computer equipment, computer-readable storage medium, and computer program product, which can intercept routes before page switching, thereby avoiding the problem of applications being uninstalled and affecting subsequent functions.
[0005] The present application provides a page switching method, which is applied to a computer device, in which a system built using a micro-frontend architecture is deployed, including:
[0006] When a page switching instruction is received, a first address of a first page currently located is obtained, and a second address of a second page to be switched to as indicated by the page switching instruction is determined, wherein the first page is a page of a first application in the system, and the second page is a page of a second application in the system;
[0007] If the first address exists in the registration pool corresponding to the system, an interception event corresponding to the first address is triggered;
[0008] A corresponding interception response is executed based on the interception event, and a switch is made from the first page to the second page based on a response result of the interception response.
[0009] The present application also provides a page switching device, which is applied to a computer device, in which a system built using a micro-frontend architecture is deployed, including:
[0010] an acquisition module, configured to acquire a first address of a currently located first page and determine a second address of a second page to be switched to by the page switching instruction when a page switching instruction is received, wherein the first page is a page of a first application in the system and the second page is a page of a second application in the system;
[0011] A trigger module, configured to trigger an interception event corresponding to the first address if the first address exists in a registration pool corresponding to the system;
[0012] The switching module is used to execute a corresponding interception response based on the interception event, and switch from the first page to the second page based on the response result of the interception response.
[0013] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned new word recognition method when executing the computer program.
[0014] A computer-readable storage medium stores a computer program, which implements the steps of the above-mentioned new word recognition method when executed by a processor.
[0015] A computer program product comprises a computer program, wherein when the computer program is executed by a processor, the steps of the new word recognition method are implemented.
[0016] The above-mentioned page switching method, device, computer equipment, storage medium and computer program product are applied to computer equipment. A system built with a micro-frontend architecture is deployed in the computer equipment. When a page switching instruction is received, the first address of the current first page is obtained, and the second address of the second page to be switched indicated by the page switching instruction is determined, which is conducive to switching from the first page to the second page indicated by the second address; if the first address exists in the registration pool corresponding to the system, then before the page is switched, the interception event corresponding to the first address is triggered and the corresponding interception response is executed. The execution of the interception response is equivalent to routing interception of the first page; since the system includes a first application and a second application, the registration pool is corresponding to the system and can be used by the first application and the second application together. The triggering of the interception event corresponding to the first address is only related to whether the first address exists in the registration pool, and does not depend on a specific application. Therefore, it is not affected by application uninstallation; at the same time, each interception event has a corresponding interception response, and interception events of different first addresses correspond to different interception responses, which is conducive to executing different interception responses according to the interception requirements of different pages; since the interception response corresponding to the first page is effectively executed before the page is switched, the page is switched based on the response result of the interception response. Even if the application is uninstalled, it will not affect subsequent functions. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 A diagram of an application environment of a page switching method in an embodiment;
[0019] Figure 2 A schematic diagram of a page switching method in an embodiment;
[0020] Figure 3 is a schematic diagram of a preset protocol in an embodiment;
[0021] Figure 4 A schematic diagram of registration logic of an interception registration method in one embodiment;
[0022] Figure 5 A schematic diagram of application logic of a software development kit in one embodiment;
[0023] Figure 6 A schematic diagram of scheduling logic of an updated page switching method in one embodiment;
[0024] Figure 7 A schematic diagram of a system built using a micro front-end architecture in one embodiment;
[0025] Figure 8 A schematic diagram of a system built using a micro front-end architecture in another embodiment;
[0026] Fig. 9 is a structural block diagram of a page switching device in an embodiment;
[0027] Fig.10 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0028] For ease of understanding, the following professional terms are explained here and will not be repeated later.
[0029] Micro front-end architecture: a web (World Wide Web) front-end architecture, where multiple micro front-end applications developed by different technology stacks and released independently can be built together into a complete system. The system built with the micro front-end architecture includes the main application and sub-applications. Users can access the functions of the main application and each sub-application through a unified interface integrated in the main application, or access the sub-application separately through an independent domain name.
[0030] URL: Uniform Resource Locator, a uniform resource locator system, is a method of indicating the location of information on the World Wide Web service program of the Internet.
[0031] SDK: Software Development Kit, a collection of documents, examples, and tools to assist in the development of a certain type of software. It can be packaged for download, installation, and use in other projects.
[0032] In order to better understand a page switching method, apparatus, computer device, storage medium and computer program product provided in the embodiments of the present application, the application environment applicable to the embodiments of the present application is first described below.
[0033] In a system built with a micro-frontend architecture, the routing system refers to the mapping relationship between page addresses and page components. When page switching occurs between main and sub-applications, or between different sub-applications, since the main application and the main and sub-applications in the system have independent routing systems, the logical condition judgment before page switching is performed in the routing interception logic of each application. Taking the Vue technology stack as an example: beforeRouteLeave (routing hook function) indicates that the current page is about to be left. During the execution of the routing hook function, it can be determined whether to actually leave the current page based on its specific logic.
[0034] This kind of page switching between main and sub-applications, or between different sub-applications, will uninstall the application where the current page is located, and simultaneously uninstall the routing instance used for routing interception in the application, causing the routing interception logic to fail. That is, no matter what the internal logic of the routing interception logic is, the page will switch. For the objects of the system, it is a system defect that the routing interception is not performed before the application is uninstalled when switching pages within the system. At the same time, the failure of routing interception logic may also affect subsequent functions. For example, the routing interception logic is used to save the current page before the page switches. When the object modifies the content of the page, the page is not saved before the page switches due to the failure of routing interception. Therefore, it will have a certain impact on subsequent functions.
[0035] To address this problem, related technologies mainly circumvent it from a product perspective, that is, by adopting a method of real-time saving of changes. Once the data in the page is updated or changed, it is saved in real time. This avoids the prompt for saving when leaving the page. It can also avoid the problem of pages being uninstalled and affecting subsequent functions when switching between different applications in a system built with a micro-frontend architecture.
[0036] However, this approach has the following disadvantages:
[0037] 1. If it involves saving the page to the backend system, this real-time saving method will generate a large number of network requests;
[0038] 2. If the amount of data transmitted by the storage interface is too large or the transmission time is too long, this real-time storage method will cause system congestion and other problems;
[0039] 3. If the object is only making draft test changes in the page, after saving in real time, the object needs to manually restore the content in the page, and it cannot be restored automatically.
[0040] Based on this, please see Figure 1 , Figure 1 A schematic diagram of an application environment of the page switching method provided by an embodiment of the present application is shown. As an implementation mode, the page switching method provided by the embodiment of the present application can be applied to the same electronic device, in which a system constructed using a micro front-end architecture is deployed. The electronic device can be as follows: Figure 1 The server 110 shown in the figure can be connected to the terminal device 120 through a network. The network is used to provide a medium for a communication link between the server 110 and the terminal device 120. The network can include various connection types, such as a wired communication link, a wireless communication link, etc., which are not limited in the embodiments of the present application. Optionally, in other embodiments, the electronic device can also be a smart phone, a laptop computer, etc.
[0041] It should be understood that Figure 1 The server 110, network and terminal device 120 are merely illustrative. Depending on the implementation requirements, there may be any number of servers, networks and terminal devices. For example, the server 110 may be a physical server or a server cluster composed of multiple servers, and the terminal device 120 may be a mobile phone, a tablet, a desktop computer, a laptop computer, and the like. It is understood that the embodiments of the present application may also allow multiple terminal devices 120 to access the server 110 at the same time.
[0042] In some embodiments, the terminal device 120 can obtain the first address of the first page currently located, and determine the second address of the second page to be switched as indicated by the page switching instruction, when receiving the page switching instruction, the first page is the page of the first application in the system, and the second page is the page of the second application in the system. Further, the terminal device 120 sends the first address and the second address to the server 110 through the network, and after the server 110 receives the first address and the second address, it can switch from the first page to the second page through the page switching method of the embodiment of the present application.
[0043] As another implementation, the page switching method provided in the embodiment of the present application can be applied to different computer devices. For example, when computer device A receives a page switching instruction, it obtains the first address and the second address, computer device B triggers an interception event corresponding to the first address, and computer device C executes a corresponding interception response and switches from the first page to the second page, etc. The embodiment of the present application does not limit this.
[0044] In an exemplary embodiment, Figure 2 As shown, a page switching method is provided, and the method is applied to a computer device, and a system built using a micro-frontend architecture is deployed in the computer device as an example for explanation, which specifically includes the following S202 to S206. Among them:
[0045] S202, when a page switching instruction is received, obtain the first address of the current first page, and determine the second address of the second page to be switched indicated by the page switching instruction, the first page is the page of the first application in the system, and the second page is the page of the second application in the system.
[0046] Among them, in the system built with the micro-frontend architecture, the computer device transforms the single-page front-end application from a traditional single monomer application to a system aggregated by multiple small front-end applications. For example, it can be a browser system built with the micro-frontend architecture. The system includes a main application and sub-applications. The main application is generally resident and is mainly responsible for the layout of the entire system, registration of sub-applications, and routing management. The sub-applications are mainly independent single-page applications split according to business. For example, the navigation bar part of the system belongs to the main application, and the other parts belong to each sub-application. Exemplarily, the sub-applications can include order sub-applications, marketing sub-applications, and product sub-applications. In the system built with the micro-frontend architecture, the main application and sub-applications, as well as different sub-applications, can communicate.
[0047] The first application and the second application are different applications in the system. For example, they may be a main application and a sub-application in a system built using a micro-frontend architecture, or they may be different sub-applications in a system built using a micro-frontend architecture.
[0048] The first page is the current page, that is, the page currently activated in the system. The first address is the page address of the first page. In some embodiments, the first address can be the URL of the first application.
[0049] In other embodiments, in a multi-instance scenario, some sub-applications may use history mode routing, and other sub-applications may use memory mode routing. The computer device determines the activated sub-application, and when the activated sub-application uses history mode routing, the computer device uses the URL of the system as the first address, and when the activated sub-application uses memory mode routing, the computer device obtains the current routing address from the memory routing of the activated sub-application and uses it as the first address.
[0050] The page switching instruction is generated when a request to switch to the second page of the second application is received when the computer is on the first page, and is used to indicate the second address of the second page to be switched. In some embodiments, the page switching instruction may be generated when a selection operation of the object on the second page is received. For example, when the first page is a page of sub-application A, in response to an object clicking an area in the second application B (e.g., a top navigation bar) or an address link of the second application B, the computer device generates a page switching instruction.
[0051] In other embodiments, the page switching instruction may also be generated when a method in the main application is called in the first page, or a method in other sub-applications is called.
[0052] The second address is the page address of the second page, for example, may be the URL of the second page.
[0053] In some embodiments, the page switching instruction carries the second address of the second page, and the computer device uses a parsing method corresponding to the page switching instruction to parse the page switching instruction to obtain the second address.
[0054] S204: If the first address exists in the registration pool corresponding to the system, trigger an interception event corresponding to the first address.
[0055] The registration pool is a preset storage space stored in the system, which is used to store data such as the address of the page that needs to be routed. The registration pool in the system can be used by the main application and the sub-application. For example, the main application and each sub-application can perform registration operations or query operations in the registration pool. In some embodiments, the registration pool can be stored in the system's session storage.
[0056] In some embodiments, the computer device may use a preset protocol to determine the name, data structure, storage address, and code structure of the registration entity of the registration pool. Figure 3The figure shows a schematic diagram of a preset protocol in an embodiment. The preset protocol specifies that: the name of the registration pool is needInterceptedActions; the data structure is an array, which can be used to store multiple registration entities; the storage address is windows.sesstionStorage, which represents the local cache sesstionStorage; the code structure of the registration entity can be a JS object, and the registration entity includes a URL attribute and an interception processing logic handleIntercept. The field meaning of the URL attribute is the address of a specific page that needs to be routed and intercepted, and the interception processing logic handleIntercept means the operation that needs to be performed after the page corresponding to the URL is intercepted. For example, the interception processing logic can determine whether to switch pages based on the selection operation of the object, and switch pages after the object confirms the switch.
[0057] The computer device queries the page address stored in the registration pool of the system to determine whether the first address exists in the registration pool. The first address exists in the registration pool, indicating that the main application or sub-application corresponding to the first address is registered in the registration pool, and the first address is the address of the page that needs to be routed intercepted.
[0058] In a system built with a micro-frontend architecture using traditional technology, sub-applications are often registered in the main application, and the sub-applications are highly dependent on the main application. In the embodiment of the present application, since the registration pool is stored in the system's cache, the main application and the sub-application can share the registration pool, avoiding dependence on the main application or a specific sub-application, and achieving decentralization of the registration process.
[0059] The interception event is used to indicate the type of interception response that needs to be executed before the page is switched, corresponding to the interception processing logic registered in the registration pool. For example, the types of interception events include interception prompt type, page save type, etc.
[0060] Since different sub-applications usually correspond to different business functions, the page address corresponds to the interception processing logic one by one. The main application or sub-application registers the interception processing logic in the registration pool, and the content of the interception processing logic can be customized according to the corresponding business function requirements.
[0061] When a page switching instruction is received and it is determined that the first address exists in the system's registration pool, the computer device will automatically trigger an interception event corresponding to the first address, thereby performing corresponding routing interception operations before the page switches, thereby avoiding the problem of the system being uninstalled during the page switch and affecting subsequent functions.
[0062] S206, executing a corresponding interception response based on the interception event, and switching from the first page to the second page based on a response result of the interception response.
[0063] The intercept response may be an operation automatically performed by the computer device after the intercept event is triggered. For example, generating intercept prompt information, saving the current page, generating a selection page, etc. The intercept response is determined based on the type of the intercept event triggered. For example, if the type of the intercept event is the intercept prompt type, the corresponding intercept response is generating intercept prompt information.
[0064] The response result is the result obtained by the computer device after the intercept response is executed. Based on the intercept response executed by the computer device, the response result can be obtained by the computer device by default, after certain data processing, or after the object outputs selection information. For example, the intercept response is to generate intercept prompt information, and the response result is obtained by the computer device by default. For example, the intercept response is to save the current page, and the response result is obtained after the computer device saves the page. For example, the intercept response is to generate a selection page, and the response result is obtained by the computer device after obtaining the selection information output by the object based on the selection page.
[0065] Switching from the first page to the second page includes: switching from the first page of sub-application A to the second page of sub-application B. Alternatively, switching from the first page of sub-application A to the second page of the main application. Alternatively, switching from the first page of sub-application A to the second page of the main application.
[0066] The computer device will switch from the first page to the second page, or not switch pages, according to the specific response result. For example, if the response result is that the page is saved successfully by default, the computer device may switch from the first page to the second page, and if the response result is that the page is saved by default, the computer device may remain on the first page without switching pages. In some embodiments, the computer device may also generate prompt information of successful or failed page saving.
[0067] In a system built with a micro-frontend architecture, when pages are switched between different sub-applications or between main and sub-applications, an interception event matching the first address can be automatically triggered, and the first page can be saved before the page is switched, or the object can be prompted whether it agrees to save the page before switching, thus avoiding the problem of application uninstallation caused by page switching and affecting subsequent functions.
[0068] At the same time, compared with the method of saving pages in real time in the related art, the page method in the embodiment of the present application can confirm whether the page is saved based on the selection of the object, without the need for real-time saving, which can avoid the problem of generating a large number of network requests.
[0069] The above-mentioned page switching method is applied to a computer device, in which a system built with a micro-frontend architecture is deployed. When a page switching instruction is received, the first address of the current first page is obtained, and the second address of the second page to be switched indicated by the page switching instruction is determined, which is conducive to switching from the first page to the second page indicated by the second address; if the first address exists in the registration pool corresponding to the system, then before the page is switched, the interception event corresponding to the first address is triggered and the corresponding interception response is executed, and the execution of the interception response is equivalent to routing interception of the first page; since the system includes a first application and a second application, the registration pool is corresponding to the system and can be used by the first application and the second application together, and the triggering of the interception event corresponding to the first address is only related to whether the first address exists in the registration pool, and does not depend on a specific application, and therefore, is not affected by application uninstallation; at the same time, each interception event has a corresponding interception response, and interception events of different first addresses correspond to different interception responses, which is conducive to executing different interception responses according to the interception requirements of different pages; since the interception response corresponding to the first page is effectively executed before the page is switched, the page is switched based on the response result of the interception response, and even if the application is uninstalled, it will not affect subsequent functions.
[0070] Since the first address exists in the registration pool of the system and is the page address that requires routing interception, before the first address is switched to a page, the interception event corresponding to the first address can be triggered, that is, the interception processing logic corresponding to the first address in the registration pool is executed, and the corresponding interception response is executed, thereby performing routing interception before the page is switched, thereby avoiding the problem of the system being uninstalled and affecting subsequent functions.
[0071] In an exemplary embodiment, the interception response includes at least one of the following: generating interception prompt information, saving the current page, and generating a selection page; the selection page is used to select the saving of the current page, and the interception prompt information is used to prompt the object that the current page will be switched.
[0072] The selection page is a page generated after the intercept response is executed, and the selection page includes at least two selection buttons. For example, the selection buttons include a save button and a do not save button. The computer device determines whether to save the current page in response to the object's selection of the selection button.
[0073] The interception prompt information is information that prompts the object that the current page will be switched. For example, it can be displayed in the form of a prompt window or a prompt text message.
[0074] The current page is the page currently activated by the system. The computer device saves the current page to ensure that the information in the current page is not lost. Even if the current page is uninstalled, since the system has saved the page in advance, it can avoid affecting subsequent functions.
[0075] In this embodiment, since the interception response is automatically executed by the computer device after the interception event is triggered, the computer device can perform route interception by generating interception prompt information, saving the current page, or generating a selection page before switching pages to avoid affecting subsequent functions.
[0076] In an exemplary embodiment, when the type of the interception event is an interception prompt type, the interception response is to generate interception prompt information; when the type of the interception event is a page save type, the interception response is to save the current page; when the type of the interception event is a page save selection type, the interception response is to generate a selection page.
[0077] Among them, since each page corresponds to an interception event, the interception event can be flexibly adjusted according to the business function. For different interception events, the computer device executes the interception response corresponding to the interception event, thereby realizing route interception matching the business needs.
[0078] The following uses the interception event types of interception prompt type, page save type and page save selection type as examples for explanation. It can be understood that the interception events are not limited to the above three types, and the corresponding interception responses based on the interception events are not limited to the following methods.
[0079] In some embodiments, the business requirement is to prompt the system object before the page is switched. Accordingly, the type of interception event corresponding to the triggered first address is an interception prompt type, indicating that the interception processing logic corresponding to the first address is used to generate interception prompt information. After the interception processing logic is triggered, the computer device automatically executes an interception response to generate interception prompt information. The interception prompt information is used to prompt the object that the current page will be switched. Exemplarily, the interception prompt information can be "the current page will switch to page B", "the current page will be unloaded", etc.
[0080] In some embodiments, the business requirement is: save the page by default before switching the page. Accordingly, the type of the interception event triggered is the page save type, indicating that the interception processing logic corresponding to the first address is used to save the current page. After the interception processing logic is triggered, the computer device automatically executes an interception response to save the current page.
[0081] In some embodiments, the business requirement is: the selection of the object needs to be determined before the page is switched. Accordingly, the type of the interception event triggered is the page save selection type, indicating that the interception processing logic corresponding to the first address is used to obtain the selection information of the object. After the interception processing logic is triggered, the computer device automatically executes the interception response for generating the selection page.
[0082] In this embodiment, by executing the corresponding intercept response after the interception event corresponding to the different page addresses is triggered, it is equivalent to that the routing interception logic is effectively executed, which is conducive to timely prompting the object that the system may uninstall before the page switches, and improving the interactive experience of the object to the system. Alternatively, before the page switches, the current page is saved by default, and the content of the page can be saved in time according to business needs. Alternatively, before the page switches, the object's selection information for saving the page is obtained, and the actual choice of the object is fully considered. If the object makes a draft test change in the page, it can avoid the problem of not being able to automatically restore the page after saving the page according to the object's choice of not saving the page; if the changes made by the object in the page may affect subsequent functions, it can automatically save the page according to the object's choice of saving the page, and even if the application is uninstalled, it will not affect subsequent functions.
[0083] In order to implement route interception before page switching of different applications in a system built with a micro-frontend architecture, the response result of the interception response needs to be considered before the page switching, so as to avoid the problem of the system being uninstalled and affecting subsequent functions.
[0084] In an exemplary embodiment, switching from the first page to the second page based on the response result of the intercept response includes: when the response result of the intercept response is a prompt of success or not saving the page, switching from the first page to the second page; when the response result of the intercept response is that the page is saved successfully by default, switching from the first page to the second page after the first page is saved successfully; when the response result of the intercept response is to choose to save the page, saving the first page and switching from the first page to the second page.
[0085] Among them, since the corresponding intercept response will be executed after different intercept events are triggered, the computer device can obtain a response result corresponding to the intercept response. The response result is used to characterize the routing interception situation of the current page. Take the response result including any one of prompt success, not saving the page, page default saving success, and selecting to save the page as an example for explanation. It can be understood that for different intercept events, the response results of the intercept response are not limited to the above four types.
[0086] When the interception response is to generate interception prompt information, since the relevant interception prompt information has been provided to the object, the page switching operation can be performed directly, and the corresponding response result includes any one of prompt success and prompt failure. In the case where the response result is prompt success, the computer device switches from the first page to the second page. In the case where the response result is prompt failure, the computer device does not switch pages and remains on the first page.
[0087] When the intercept response is to save the current page, the response result includes the default page save success and the default page save failure. When the response result is the default page save success, the computer device switches from the first page to the second page after the first page is successfully saved. When the response result is the default page save failure, the computer device does not switch pages and remains on the first page.
[0088] When the intercept response is to generate a selection page, the response result includes any one of selecting to save the page and selecting not to save the page. Exemplarily, the selection page includes a save button and a do not save button. If the object clicks the save button, the response result obtained by the computer device is to select to save the page, and the computer device saves the first page and switches from the first page to the second page. If the object clicks the do not save button, the response result obtained by the computer device is to select not to save the page, and the page is not switched, and the computer device remains on the first page.
[0089] In this embodiment, for the response results of different interception responses, it is confirmed whether to switch pages directly or whether to save the page before switching pages. The computer device can provide an interception prompt for the object, save the current page by default, or save or not save the page according to the object's selection. Since the interception response is effectively executed, it is equivalent to executing the routing interception logic. Therefore, it can avoid the problem of the system being uninstalled and affecting subsequent functions.
[0090] In order to register the first address and the interception processing logic corresponding to the first address into the registration pool, avoid dependence on the main application or a specific sub-application, and realize the decentralization of the registration process, it is considered to use a software development kit to encapsulate the interception registration method.
[0091] In an exemplary embodiment, before receiving a page switching instruction, the page switching method also includes: encapsulating an interception registration method in a software development kit according to a preset protocol; if any page address in the system has an interception requirement, downloading the software development kit in the application corresponding to the page address; when the application corresponding to the page address is initialized, the page address in the software development kit and the interception processing logic corresponding to the page address are passed into the interception registration method as entity objects to be registered.
[0092] Among them, the interception registration method is used for each application to register its own interception processing logic. Figure 4 The figure shows a registration logic diagram of an interception registration method in one embodiment. Among them, the computer device first calls the interception registration method, passes in the page address and the interception processing logic, and then determines whether there is a registration pool in the system cache. If there is no registration pool, for example, all applications in the system (including the main application and the sub-application) have not registered the interception processing logic, then a new registration pool needs to be created. Then the entity to be registered is added to the registration pool, and this registration is the first registration in the system. If there is a registration pool in the local cache of the system, it is determined whether the entity to be registered already exists in the registration pool. If not, the entity to be registered is added to the registration pool. If it exists, the entity to be registered can be used to overwrite and replace the existing registration entity.
[0093] The software development kit may be an SDK package. The computer device may encapsulate the interception registration method in the SDK package according to the predetermined protocol, for reference Figure 3 The preset protocol stipulates that the interception registration method interceptedUrlRegistor is provided in the SDK package. The SDK package does not need to rely on the main application or specific sub-applications. All applications (including the main application and sub-applications) can be introduced and used. The SDK package can be encapsulated before receiving the page switching instruction.
[0094] The page address has an interception requirement, which means that the page corresponding to the page address has a requirement for routing interception before the page is switched. For example, if the first page corresponding to the first address has object input content, in this case, the first address often has an interception requirement. For another example, the first page corresponding to the first address only has display information. In this case, page uninstallation does not affect subsequent functions, and the first address does not have an interception requirement.
[0095] Any page address in the system can be the page address of the main application or the sub-application. When any page address has an interception requirement, the SDK package is downloaded in the application corresponding to the page address, thereby introducing the interception registration method in the SDK package. Figure 5 The figure shows an application logic diagram of an SDK package in an embodiment. The SDK package is downloaded in an application with interception requirements, and the interception registration method encapsulated in the SDK package is used to register the page address and interception processing logic. The interception scheduling method encapsulated in the SDK package is used to update the initial page switching method, and determine whether to switch pages according to the result returned by the interception scheduling method.
[0096] In some embodiments, the download of the SDK package can be performed when the system is initialized, and can also be performed when it is detected that the page address has an interception requirement. For the interception processing logic that already exists in the registration pool, it can be triggered as an interception event after receiving the page switching instruction. The page address and the interception processing logic corresponding to the page address can be used as entities to be registered, and the computer device is passed into the interception registration method when the application corresponding to the page address is initialized.
[0097] In this embodiment, by encapsulating the interception registration method in a software development kit, due to the encapsulation and downloading of the software development kit, there is no need to rely on the main application or a specific sub-application, and each application can be introduced and used, thereby achieving decentralization of the registration process. At the same time, the software development kit needs to be downloaded only for page addresses with interception requirements, avoiding unnecessary routing interception for page addresses that do not have interception requirements. The page address and the interception processing logic corresponding to the page address can be passed into the interception registration method when the system is initialized, so that when the page is switched, the interception processing logic corresponding to the first address can be called to implement the routing interception function.
[0098] In an exemplary embodiment, the registration pool stores the page address of at least one application of the system and the interception processing logic corresponding to the page address.
[0099] Among them, in some embodiments, there may be no registration pool in the cache of the system. Therefore, the computer device can query the cache of the system by calling the interception registration method in the interception scheduling method to determine whether there is a registration pool in the cache. In the case that there is no registration pool in the cache, it is necessary to create an initial registration pool, and add the first address and the interception processing logic corresponding to the first address to the initial registration pool to obtain the registration pool and implement the first registration of the registration pool. In the case that there is a registration pool in the cache of the system, the registration pool is searched to determine whether the first address exists in the registration pool.
[0100] In some embodiments, since the registration pool stores the page address of at least one application of the system and the interception processing logic corresponding to the page address, the computer device can also execute the interception scheduling method, search the registration pool, determine whether there is a registered page address matching the first address in the registration pool, and determine that the first address exists in the registration pool if there is a registered page address matching the first address in the registration pool. If there is no registered page address matching the first address in the registration pool, determine that the first address does not exist in the registration pool.
[0101] In this embodiment, for the first registration of the registration pool, a new registration pool needs to be created. For non-first registration, the registration pool can be searched to determine whether the first address exists in the registration pool. Since whether the first address exists in the registration pool is determined by the interception registration method in the interception scheduling method, the interception scheduling method and the interception registration method are both encapsulated in the SDK package, and the page address is registered in the registration pool. This method of storing the page address and the routing interception logic corresponding to the page address in the registration pool is conducive to ensuring that the triggering of the interception event is only related to whether the first address exists in the registration pool, does not depend on a specific application, is conducive to the decentralization of routing interception, and can avoid routing interception failure.
[0102] In an exemplary embodiment, the page switching method further includes: if the first address has an interception requirement and the first address does not exist in the registration pool, adding the first address and the interception processing logic corresponding to the first address to the registration pool.
[0103] For a first address that has an interception requirement but does not exist in the registration pool, the computer device adds the first address and the interception processing logic corresponding to the first address to the registration pool.
[0104] In this embodiment, the registration entity is registered in the registration pool, which is conducive to using the interception processing logic that matches the business needs to perform route interception before switching the page of the first address. The registration pool is stored in the system cache and does not depend on the main application or specific sub-application, which realizes the decentralization of the registration process and the interception process, which is conducive to avoiding the failure of route interception.
[0105] In an exemplary embodiment, the page switching method further includes: if the first address does not exist in the registration pool, switching from the first page to the second page.
[0106] Among them, when no registered page address matching the first address is found in the registration pool, it indicates that the first address does not exist in the registration pool, and the first address does not need to be routed intercepted. The computer device can switch from the first page to the second page according to the page switching method.
[0107] In this embodiment, for the first address not registered in the registration pool, the first address has no interception requirement and can directly switch pages. Therefore, the computer device only performs routing interception on the page addresses registered in the registration pool, and can avoid intercepting page addresses that do not require routing interception.
[0108] In an exemplary embodiment, before receiving a page switching instruction, the page switching method also includes: encapsulating an interception scheduling method in a software development kit according to a preset protocol; if any page address in the system has an interception requirement, downloading the software development kit in the application corresponding to the page address; when the application corresponding to the page address is initialized, updating the initial page switching method according to the interception scheduling method in the software development kit to obtain an updated page switching method; the updated page switching method has the function of triggering an interception event corresponding to the first address before the first page switches to the second page.
[0109] The interception scheduling method can be encapsulated in a software development kit according to a preset protocol. The software development kit can be an SDK package, see Figure 3 The preset protocol stipulates that the SDK package provides an interception scheduling method urlScheduler. The SDK package can be encapsulated before receiving the page switching instruction.
[0110] Any page address in the system can be the page address of the main application or the sub-application. When any page address has an interception requirement, the SDK package is downloaded in the application corresponding to the page address, thereby introducing the interception scheduling method. Figure 4 , download the SDK package in the system with interception requirements. The interception scheduling method encapsulated in the SDK package is used to update the initial page switching method. After the updated page switching method is executed, it is determined whether to switch the page based on the return result of the method.
[0111] In some embodiments, the SDK package may be downloaded when the system is initialized, or when it is detected that a page address has an interception requirement.
[0112] In some embodiments, the interception registration method and interception scheduling method provided by the SDK package can be directly implemented in the main application, and can be called in the main application itself, or the two methods can be passed to the sub-application when the sub-application is registered. However, this approach is a centralized solution, which is strictly bound to the main application. At the same time, if it involves multiple layers of nested sub-applications, it needs to be transparently transmitted layer by layer, which is not flexible enough.
[0113] The interception scheduling method can be triggered after receiving a page switching instruction. After the interception scheduling method is triggered, it can be used to intercept, pause, and interrupt the page switching of each application (including the main application and sub-application) itself.
[0114] In a system built with a micro-frontend architecture, the initial page switching method of each application is set according to its own routing instance. There is no unified scheduling method, and the initial page switching between applications cannot affect each other, resulting in the page switching of different applications being out of the application scenario. Therefore, the computer device is uniformly deployed according to the interception scheduling method provided in the SDK package. Specifically, the initial page switching method of each application can be updated based on the interception scheduling method to obtain an updated page switching method, so that each updated page switching method must be uniformly scheduled by the internal logic of the interception scheduling method.
[0115] For page switching of different applications, the update of the page switching method needs to be applied to the system globally to ensure the success of page switching of different applications. Therefore, the computer device can perform a global update on the page switching method.
[0116] like Figure 6 The figure shows a schematic diagram of the scheduling logic of the updated page switching method in one embodiment. Among them, the updated page switching method is executed after receiving the page switching instruction, and has the function of triggering the interception event corresponding to the first address before the first page switches to the second page. In the scheduling logic, the second address and parameters of the second page to be switched are temporarily stored, and it is determined whether the first address of the current first page exists in the registration pool of the system. If so, the interception event corresponding to the first address is obtained from the registration pool, and the interception event corresponding to the first address is triggered, and the corresponding interception response is executed based on the interception event. Based on the response result of the interception response, switch from the first page to the second page. For example, if the response result is true, the page is switched, and if the response result is false, the page is not switched. If the first address does not exist in the registration pool, it indicates that the first address does not have an interception requirement, and the page can be switched directly.
[0117] In this embodiment, by encapsulating the interception scheduling method in a software development kit, since the encapsulation and downloading of the software development kit does not need to rely on the main application or a specific sub-application, each application can be introduced and used, which is conducive to the decentralization of the interception process. At the same time, the software development kit is only needed to download the page address with interception requirements, avoiding unnecessary routing interception for page addresses that do not have interception requirements. After the initial page switching method is updated using the interception scheduling method, it is possible to unify the scheduling logic in combination with specific business needs, and avoid the problem of being out of touch with the application scenario when switching pages of different applications.
[0118] In an exemplary embodiment, the initial page switching method is updated according to the interception scheduling method to obtain an updated page switching method, including: taking the initial page switching method as a parameter of the interception scheduling method and passing it into the interception scheduling method; and taking the obtained page switching method wrapped by the interception scheduling method as the updated page switching method.
[0119] Among them, the main purpose of updating the page switching method is to schedule the initial page switching method through a unified scheduling logic. The updating method can be: taking the initial page switching method as a parameter of the interception scheduling method, and passing it into the interception scheduling method, so as to wrap the initial page switching method with the interception scheduling method, and obtain the page switching method wrapped by the interception scheduling method, which is the updated page switching method.
[0120] In some embodiments, the process of updating the initial page switching method can be represented by the following schematic code:
[0121] import {urlScheduler} from 'interceptSDK'
[0122] const push = history.push;
[0123] history.prototype.push = urlScheduler(push)
[0124] The meaning of the code is: first, import the interception scheduling method urlScheduler from the SDK package named "interceptSDK"; then, temporarily store the initial page switching method in the parameter push, the system uses history routing, and the page switching method is history.push; finally, use push as a parameter to call the interception scheduling method urlScheduler and return a new page switching method, which is the updated page switching method.
[0125] From the above examples, we can see that after the page switching method push of each system is wrapped by the interception scheduling method urlScheduler, an updated page switching method is generated, and the page switching will be processed by the interception scheduling method urlScheduler. The interception scheduling method urlScheduler is encapsulated in the SDK package and can be flexibly downloaded and used according to needs, and the page switching process can be uniformly scheduled.
[0126] In this embodiment, by updating the initial page switching method, the updated page switching method first executes the scheduling logic when it is executed, and then decides whether to switch pages based on the result of the scheduling logic. The updated page switching method can trigger an interception event corresponding to the first address before switching pages, thereby performing routing interception on the first page. For example, if the object needs to select whether to save the page, the selection result of the object is obtained to determine whether to save the page before switching pages. In addition, since the interception scheduling method is encapsulated in the SDK package, the decentralization of routing interception is achieved, which is conducive to avoiding the failure of routing interception.
[0127] In a specific embodiment, the page switching method in the embodiment of the present application can be applied to a computer device, in which a system built using a micro-front-end architecture is deployed, the system including a main application and sub-applications, the navigation bar part of the system belongs to the main application, and the other parts belong to each sub-application.
[0128] like Figure 7 The figure shows a schematic diagram of a system built with a micro front-end architecture in one embodiment. The system built with a micro front-end architecture may be an online marketing system, and the navigation bar in the main application is used to switch between various sub-applications, which may include order sub-applications, marketing sub-applications, and product sub-applications.
[0129] like Figure 8 The schematic diagram of a system constructed using a micro front-end architecture in another embodiment is shown. The system constructed using a micro front-end architecture can also be a navigation system, where the navigation bar in the main application is used for route search and traffic search, and the sub-applications include a route display sub-application, a traffic information display sub-application, and the like.
[0130] The page switching method of the present application comprises the following steps:
[0131] Step 1: According to the preset agreement, agree and standardize the overall design and field content.
[0132] First, the preset protocol stipulates the registration pool involved in the embodiment of the present application: the field name of the registration pool is needInterceptedActions; the data structure is an array, which can be used to store multiple registration entities; the storage address is windows.sesstionStorage, which represents the local cache sesstionStorage; the code structure of the registration entity can be a JS object, and the registration entity includes a URL attribute and an interception processing logic handleIntercept. The field meaning of the URL attribute is a specific page address that needs to be routed intercepted, and the interception processing logic handleIntercept means the operation that needs to be performed after the page corresponding to the URL is intercepted. For example, the interception processing logic can be used to determine whether to switch pages based on the selection operation of the object, and the page is switched after the object confirms the switch. Storing the interception processing logic in the local cache of the system can enable each application to share it, without relying on the main application or a specific sub-application, to achieve decentralization of route interception.
[0133] Secondly, the preset protocol stipulates the composition of the SDK package, which mainly encapsulates: the interception registration method interceptedUrlRegistor and the interception scheduling method urlScheduler.
[0134] Among them, the interception registration method is used for each application to save its own page address and interception processing logic to the registration pool. The logic of the interception registration method itself is: first determine whether there is a registration pool needInterceptedActions in the cache of the system. If there is no registration pool (for example, all applications have not registered the page address and interception processing logic before, and this is the first registration in all applications), first create a new initial registration pool. Then add the entity to be registered to the initial registration pool to obtain the registration pool. If a registration pool already exists in the system's cache, determine whether the entity to be registered exists in the registration pool. If it already exists in the registration pool, the entity to be registered will overwrite the registered entity. If it does not exist in the registration pool, the entity to be registered will be directly added to the registration pool.
[0135] The interception scheduling method is used for each application to intercept, suspend, and interrupt their respective page switching. In a system built with a micro-frontend architecture, the page switching of each application is routed according to its own routing instance. There is no unified scheduling method, and the switching of each application cannot affect each other, resulting in the page switching between different applications being out of the application scenario. Therefore, the SDK package provides an interception scheduling method urlScheduler for unified deployment, and the initial page switching method is updated using the interception scheduling method to obtain the updated page switching method. All page switching methods wrapped with the interception scheduling method must be uniformly scheduled by the internal logic of urlScheduler. The updated page switching method is executed when a page switching instruction is received, and has the function of triggering an interception event corresponding to the first address before the first page switches to the second page. The specific scheduling logic can be: temporarily store the first address and parameters of the first page, determine whether the first address exists in the registration pool of the system, and if so, obtain the interception event corresponding to the first address from the registration pool, trigger the interception event corresponding to the first address, execute the corresponding interception response based on the interception event, and switch from the first page to the second page based on the response result of the interception response. For example, if the response result is true, the page is switched, and if the response result is false, the page is not switched. If the first address does not exist in the registration pool of the system, it indicates that the first address does not have an interception requirement, and the page can be switched directly.
[0136] Step 2: According to the preset protocol, encapsulate the interception registration method and the interception scheduling method in the software development kit. The software development kit can be an SDK package, which encapsulates a class through javascript, and the class provides the interception registration method and the interception scheduling method. The encapsulated class can be packaged and compressed into an npm package, and the npm package is published to the package management warehouse. When used by various systems, it can be downloaded and used through the npm install command.
[0137] Step 3: If any page address in the system has an interception requirement (for example, switching from a page in sub-application A to a page in sub-application B, the object's consent must be obtained before the page switch. If the object disagrees, the page switch cannot be performed), then download the SDK package in the application corresponding to the page address, introduce the interception registration method in the SDK package, and when the application corresponding to the page address is initialized, pass the page address and the interception processing logic corresponding to the page address as the entity object to be registered to the interception registration method in the software development kit, and update the initial page switching method according to the interception scheduling method to obtain the updated page switching method.
[0138] Step 4: When receiving a page switching instruction, call the updated page switching method so that it first executes the interception scheduling method when it is executed, and then decides whether to switch the page according to the result of the interception scheduling method. The purpose is to determine whether the first page has an interception requirement (for example, the object needs to be saved and confirmed, and whether to switch) and whether the first address exists in the system's registration pool before switching between pages of different applications, and then trigger the interception event corresponding to the first address, execute the corresponding interception response based on the interception event, and determine whether to save the page and switch the page according to the response result of the interception response.
[0139] There is no order requirement for steps 1 to 3. When each system adopts a component-based page switching method instead of a method-based page switching method, the component-based method can be changed to a method-based method, or it can be wrapped by a high-order component, and the processing method of step 3 is adopted inside the high-order component.
[0140] The above-mentioned page switching method is applied to a computer device, in which a system built with a micro-frontend architecture is deployed. When a page switching instruction is received, the first address of the current first page is obtained, and the second address of the second page to be switched indicated by the page switching instruction is determined, which is conducive to switching from the first page to the second page indicated by the second address; if the first address exists in the registration pool corresponding to the system, then before the page is switched, the interception event corresponding to the first address is triggered and the corresponding interception response is executed, and the execution of the interception response is equivalent to routing interception of the first page; since the system includes a first application and a second application, the registration pool is corresponding to the system and can be used by the first application and the second application together, and the triggering of the interception event corresponding to the first address is only related to whether the first address exists in the registration pool, and does not depend on a specific application, and therefore, is not affected by application uninstallation; at the same time, each interception event has a corresponding interception response, and interception events of different first addresses correspond to different interception responses, which is conducive to executing different interception responses according to the interception requirements of different pages; since the interception response corresponding to the first page is effectively executed before the page is switched, the page is switched based on the response result of the interception response, and even if the application is uninstalled, it will not affect subsequent functions. In a related technology, the method of saving pages in real time needs to send a save request to the server after detecting data changes, and send save requests to the server multiple times, and will not be confirmed by the object, which is inconsistent with the object's requirements. Multiple communications with the server will also cause a waste of bandwidth resources. In another related technology, the solution without prompting to save makes it impossible for the object to get a prompt whether to save after leaving after modification and editing, but directly saves the page or does not save the page, which is a very unfriendly interactive behavior. The method of the embodiment of the present application realizes that in a system built with a micro-frontend architecture, a registration pool is designed in the cache of the system. Each application can selectively register according to its own business needs and the provided SDK package, and realizes routing interception of page switching between different applications in a micro-frontend environment. In a system built with a micro-frontend architecture, all pages are in one system for the object. Regardless of the page switching between the main sub-application and the different sub-applications, interception processing can be achieved before the page switching. The solution of combining the system local cache with the SDK package effectively removes centralization, and can be flexibly downloaded and applied in each application as needed.
[0141] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0142] Based on the same inventive concept, the embodiment of the present application also provides a page switching device for implementing the page switching method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more page switching device embodiments provided below can refer to the limitations of the page switching method above, and will not be repeated here.
[0143] In an exemplary embodiment, Fig. 9 As shown, a page switching device 100 is provided, which is applied to a computer device, in which a system constructed using a micro-frontend architecture is deployed, including: an acquisition module 120, a trigger module 140 and a switching module 160, wherein:
[0144] The acquisition module 120 is used to acquire the first address of the current first page and determine the second address of the second page to be switched according to the page switching instruction when receiving the page switching instruction, wherein the first page is the page of the first application in the system and the second page is the page of the second application in the system;
[0145] A trigger module 140, configured to trigger an interception event corresponding to the first address if the first address exists in a registration pool corresponding to the system;
[0146] The switching module 160 is used to execute a corresponding interception response based on the interception event, and switch from the first page to the second page based on a response result of the interception response.
[0147] In some embodiments, the interception response includes at least one of the following: generating interception prompt information, saving the current page, and generating a selection page; the selection page is used to select the saving of the current page, and the interception prompt information is used to prompt the object that the current page will be switched.
[0148] In some embodiments, when the type of the interception event is an interception prompt type, the interception response is to generate interception prompt information; when the type of the interception event is a page save type, the interception response is to save the current page; when the type of the interception event is a page save selection type, the interception response is to generate a selection page.
[0149] In some embodiments, based on the response result of the intercept response, the switching module 160 switches from the first page to the second page, and is further configured to:
[0150] When the response result of the intercept response is a prompt of success or a choice not to save the page, switch from the first page to the second page; when the response result of the intercept response is a default successful saving of the page, after the first page is saved successfully, switch from the first page to the second page; when the response result of the intercept response is a choice to save the page, save the first page and switch from the first page to the second page.
[0151] In some embodiments, the registration pool stores the page address of at least one application of the system and the interception processing logic corresponding to the page address.
[0152] In some embodiments, before receiving the page switching instruction, the page switching device 100 further includes a registration module, and the registration module is used to:
[0153] According to the preset protocol, the interception registration method is encapsulated in the software development kit; if any page address in the system has an interception requirement, the software development kit is downloaded in the application corresponding to the page address; when the application corresponding to the page address is initialized, the page address and the interception processing logic corresponding to the page address are passed into the interception registration method in the software development kit as the entity object to be registered.
[0154] In some embodiments, in terms of determining whether the first address exists in a registration pool of the system, the registration module is further configured to:
[0155] Determine whether there is a registration pool in the system's cache; if there is no registration pool in the system's cache, create a new initial registration pool, obtain the interception processing logic corresponding to the first address, and add the first address and the interception processing logic corresponding to the first address to the initial registration pool to obtain the registration pool; if there is a registration pool in the system's cache, search the registration pool to determine whether the first address exists in the registration pool.
[0156] In some embodiments, the page switching device 100 further includes a registration module, and the registration module is further used to:
[0157] If the first address has an interception requirement and the first address does not exist in the registration pool, the first address and the interception processing logic corresponding to the first address are added to the registration pool.
[0158] In some embodiments, the switching module 160 is further configured to:
[0159] If the first address does not exist in the registration pool, switch from the first page to the second page.
[0160] In some embodiments, before receiving the page switching instruction, the page switching device 100 further includes a scheduling module, and the scheduling module is used to:
[0161] According to a preset protocol, the interception scheduling method is encapsulated in a software development kit; if any page address in the system has an interception requirement, the software development kit is downloaded in the application corresponding to the page address; when the application corresponding to the page address is initialized, the initial page switching method is updated according to the interception scheduling method in the software development kit to obtain an updated page switching method; the updated page switching method has the function of triggering an interception event corresponding to the first address before the first page switches to the second page.
[0162] In some embodiments, according to the interception scheduling method in the software development kit, the initial page switching method is updated to obtain an updated page switching method, and the scheduling module is further used to:
[0163] The initial page switching method is used as a parameter of the interception scheduling method and is passed into the interception scheduling method; the obtained page switching method wrapped by the interception scheduling method is used as the updated page switching method.
[0164] The above-mentioned page switching device is applied to a computer device, in which a system built with a micro-frontend architecture is deployed. When a page switching instruction is received, the first address of the current first page is obtained, and the second address of the second page to be switched indicated by the page switching instruction is determined, which is conducive to switching from the first page to the second page indicated by the second address; if the first address exists in the registration pool corresponding to the system, then before the page is switched, the interception event corresponding to the first address is triggered and the corresponding interception response is executed, and the execution of the interception response is equivalent to routing interception of the first page; since the system includes a first application and a second application, the registration pool is corresponding to the system and can be used by the first application and the second application together, and the triggering of the interception event corresponding to the first address is only related to whether the first address exists in the registration pool, and does not depend on a specific application, and therefore, is not affected by application uninstallation; at the same time, each interception event has a corresponding interception response, and interception events of different first addresses correspond to different interception responses, which is conducive to executing different interception responses according to the interception requirements of different pages; since the interception response corresponding to the first page is effectively executed before the page is switched, the page is switched based on the response result of the interception response, and even if the application is uninstalled, it will not affect the subsequent functions.
[0165] Each module in the above-mentioned page switching device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0166] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Fig.10 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. 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 input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a page switching method is realized. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen 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 button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0167] Those skilled in the art will understand that Fig.10 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0168] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0169] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0170] In one embodiment, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0171] 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, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0172] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0173] 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.
[0174] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A page switching method, characterized in that: Applied to a computer device, wherein a system constructed using a micro-frontend architecture is deployed in the computer device, the method comprising: When a page switching instruction is received, obtaining a first address of a first page currently located, and determining a second address of a second page to be switched to by the page switching instruction, wherein the first page is a page of a first application in the system, and the second page is a page of a second application in the system; If the first address exists in the registration pool corresponding to the system, triggering an interception event corresponding to the first address; A corresponding interception response is executed based on the interception event, and a switch is made from the first page to the second page based on a response result of the interception response.
2. The method according to claim 1, characterized in that The intercept response includes at least one of the following: generating intercept prompt information, saving the current page and generating a selection page; the selection page is used to select the saving of the current page, and the intercept prompt information is used to prompt the object that the current page will be switched.
3. The method according to claim 2, characterized in that In the case where the type of the interception event is an interception prompt type, the interception response is to generate interception prompt information; In the case where the type of the interception event is a page saving type, the interception response is to save the current page; In the case where the type of the interception event is a page save selection type, the interception response is to generate a selection page.
4. The method according to claim 1, characterized in that The switching from the first page to the second page based on the response result of the intercept response includes: When the response result of the intercept response is a prompt of success or a choice not to save the page, switching from the first page to the second page; In the case where the response result of the intercept response is that the page is saved successfully by default, after the first page is saved successfully, switching from the first page to the second page; When the response result of the intercept response is to select to save the page, the first page is saved, and the first page is switched to the second page.
5. The method according to claim 1, characterized in that The registration pool stores the page address of at least one application of the system and the interception processing logic corresponding to the page address.
6. The method according to claim 1, characterized in that The method further comprises: If the first address has an interception requirement and the first address does not exist in the registration pool, the first address and the interception processing logic corresponding to the first address are added to the registration pool.
7. A page switching device, characterized in that: Applied to a computer device, wherein a system constructed using a micro-frontend architecture is deployed in the computer device, the device comprising: an acquisition module, configured to acquire a first address of a currently located first page and determine a second address of a second page to be switched to by the page switching instruction upon receiving the page switching instruction, wherein the first page is a page of a first application in the system and the second page is a page of a second application in the system; a triggering module, configured to trigger an interception event corresponding to the first address if the first address exists in a registration pool corresponding to the system; A switching module is used to execute a corresponding interception response based on the interception event, and switch from the first page to the second page based on a response result of the interception response.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. 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 6 are implemented.
10. A computer program product, comprising a computer program, 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 6 are implemented.
