Page updating method and device, storage medium and computer program product

By responding to the update request of the target page in the mini program, determining its status and update method, and formulating targeted page update strategies, it solves the problem of resource waste and page lag when sharing and updating multi-page data, and improves data update efficiency and User experience.

CN118567770APending Publication Date: 2024-08-30CHINA TELECOM BESTPAY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410701869.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

In the field of small program development, the problem of resource waste and page lag caused by synchronization mechanism when sharing and updating multi-page data has not been effectively solved.

Method used

By responding to the update request of the target page, determine its page status and update method, and formulate a page update strategy based on this information, including storing the data to be updated in the queue to wait for update in the hidden state, or updating immediately in the displayed state to avoid unnecessary data synchronization.

Benefits of technology

It reduces unnecessary data updates, improves data update efficiency, avoids waste of resources and page freezes when the amount of data is large, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118567770A
    Figure CN118567770A
Patent Text Reader

Abstract

The invention discloses a page updating method and device, a storage medium and a computer program product. The method relates to the technical field of computers, and comprises the following steps: in response to an updating request for a target page in an application program, determining a page state and an updating mode of the target page; based on a page state and an updating mode, determining a page updating strategy of the target page, the page state being used for describing whether the target page is in a display state or a hidden state, and the updating mode being used for indicating whether the target page needs to be updated when the access request is received; and updating the target page based on the page updating strategy. According to the method and the device, the technical problems that in the prior art, under the condition that shared data exists in multiple pages, shared data updating is carried out on the multiple pages at the same time, and resource waste and page lagging are easily caused when the data size is large are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a page updating method, device, storage medium and computer program product. Background Art

[0002] In application development, such as mini-program development, there is a need for multi-page applications, in which some global data needs to be shared and updated between multiple pages. When dealing with such multi-page data sharing and updating, the current mini-program development framework usually updates data in mini-programs synchronously, which means that when the data on one page changes, other pages are also updated immediately. This synchronization mechanism may cause performance issues, especially when the amount of data is large, which will cause resource waste and page jams.

[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0004] The embodiments of the present invention provide a page update method, device, storage medium and computer program product to at least solve the technical problem in the related art that when there is shared data on multiple pages, multiple pages simultaneously update shared data, which easily causes waste of resources and page jams when the data volume is large.

[0005] According to one aspect of an embodiment of the present invention, a page update method is provided, comprising: in response to an update request for a target page in an application, determining a page state and an update method of the target page; based on the page state and the update method, determining a page update policy of the target page, wherein the page state is used to describe whether the target page is in a display state or a hidden state, and the update method is used to indicate whether the target page needs to be updated when an access request is received; and based on the page update policy, updating the target page.

[0006] Optionally, determining the page update strategy of the target page based on the page status and the update method includes: when the page status is the hidden state and the update method is that the target page needs to be updated when the access request is received, determining the page update strategy as: storing the target page's to-be-updated data and page instance in a target queue waiting for update; or when the page status is the displayed state, or the update method is that the target page does not need to be updated when the access request is received, determining the page update strategy as: executing page update when the update request is received.

[0007] Optionally, determining the page state of the target page includes: when it is detected that a first life cycle function corresponding to the target page is triggered, determining that the page state of the target page is the display state, wherein the first life cycle function is a life cycle function triggered when the target page switches from background operation to foreground display; or when it is detected that a second life cycle function corresponding to the target page is triggered, determining that the page state of the target page is the hidden state, wherein the second life cycle function is a life cycle function triggered when the target page switches from foreground display to background operation.

[0008] Optionally, when the page update strategy is to store the target page's updated data and page instance in a target queue for updating, after updating the target page based on the page update strategy, the method further includes: updating the target page when detecting that the page state switches from the hidden state to the displayed state, or receiving the access request for the target page.

[0009] Optionally, updating the target page based on the page update strategy includes: obtaining target data for updating the target page; determining current data corresponding to the target data from the page instance of the target page; performing a difference comparison between the target data and the current data to obtain a difference comparison result; obtaining the data to be updated corresponding to the target page based on the difference comparison result; and updating the data to be updated to the page instance based on the page update strategy to update the target page.

[0010] Optionally, based on the page update strategy, the data to be updated is updated to the page instance, and the target page is updated, including: generating a data path key name according to the difference comparison result, wherein the data path key name is used to indicate the target data location of the data to be updated in the page instance; based on the page update strategy and the data path key name, the data to be updated is updated to the target data location in the page instance, and the target page is updated.

[0011] Optionally, there are multiple target pages, and the multiple target pages have the same data update range or data update category.

[0012] According to another aspect of an embodiment of the present invention, a page update device is also provided, including: a response module, used to determine the page status and update method of the target page in response to an update request for the target page in an application; a policy determination module, used to determine the page update policy of the target page based on the page status and the update method, wherein the page status is used to describe whether the target page is in a displayed state or a hidden state, and the update method is used to indicate whether the target page needs to be updated when an access request is received; and a page update module, used to update the target page based on the page update policy.

[0013] According to another aspect of an embodiment of the present invention, a non-volatile storage medium is provided, wherein the non-volatile storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing any one of the page updating methods.

[0014] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the steps of any one of the page updating methods are implemented.

[0015] In an embodiment of the present invention, by responding to an update request for a target page in an application, the page state and update method of the target page are determined; based on the page state and the update method, the page update strategy of the target page is determined, wherein the page state is used to describe whether the target page is in a display state or a hidden state, and the update method is used to indicate whether the target page needs to be updated when an access request is received; based on the page update strategy, the target page is updated, thereby achieving the purpose of determining the page update strategy according to the page state and the preset update method, and performing targeted page updates, thereby achieving the technical effect of reducing unnecessary data updates and improving data update efficiency, and further solving the technical problem in the related art that when there is shared data in multiple pages, multiple pages simultaneously update shared data, which easily causes waste of resources and page jams when the data volume is large. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0017] Figure 1 is a flow chart of a page updating method according to an embodiment of the present invention;

[0018] Figure 2 is a flow chart of an optional page updating method according to an embodiment of the present invention;

[0019] Figure 3 is a flow chart of another optional page updating method according to an embodiment of the present invention;

[0020] Figure 4 is a schematic diagram of a page updating device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0021] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0023] First, to facilitate understanding of the embodiments of the present invention, some terms or nouns involved in the present invention are explained below:

[0024] Mini programs are lightweight applications that are usually created by third-party developers or organizations to run on mobile devices. They usually do not require users to install them in advance because they run in a specific application container or runtime environment.

[0025] The rendering layer and the logic layer are divided into the rendering layer and the logic layer. The applet markup language template and the applet style sheet work in the rendering layer, and the JavaScript script (JS script) works in the logic layer. The rendering layer and the logic layer of the program are managed by two threads respectively: the rendering layer interface uses the web view WebView for rendering; the logic layer uses the JsCore thread to run the JS script. A small program has multiple interfaces, so there are multiple WebView threads in the rendering layer. The communication between these two threads will be transferred through the client, and the network request sent by the logic layer is also forwarded locally.

[0026] Rewrite the update function setData, a common method in mini programs, which is used to update the data of the page and re-render the page. It is one of the core methods provided by the mini program framework and is used to bind data to the view of the page.

[0027] The mini program life cycle refers to the execution of specific life cycle functions in a certain phase and sequence during the development and operation of the mini program. These functions define the behavior and logic of the mini program at different phases.

[0028] The onShow function is triggered when the page is displayed. When the mini program is started or enters the foreground from the background, the onShow lifecycle function is triggered. In this function, you can perform operations that need to be performed when the mini program interface is displayed, such as updating data, page rendering, etc.

[0029] The onHide function is triggered when the page is hidden. When the Mini Program enters the background from the foreground, the onHide lifecycle function is triggered. It is usually used to process the logic of the Mini Program when it is running in the background, such as clearing timers, pausing audio playback, etc.

[0030] In application development, such as mini-program development, there is a demand for multi-page applications, in which some global data needs to be shared and updated between multiple pages. The current mini-program development framework has the following problems in dealing with this multi-page data sharing and updating: 1) Synchronous data update mechanism: Data updates in mini-programs are usually performed synchronously, which means that when the data of one page changes, other pages are also updated immediately. This synchronization mechanism may cause performance problems, especially when the amount of data is large, which will cause resource waste and page jams. 2) Single display of pages: Mini-programs usually only allow one page to be displayed at the same time, but in actual applications, there may be a demand for multiple pages, some of which may need to maintain real-time data updates, while other pages may be in the background. At this time, the data update is not visible to the user, but it still causes performance loss.

[0031] Lazy Update is a commonly used technique in computer science and software development, especially in multi-threaded and distributed systems. Its core idea is to update data only when necessary, rather than in real time. This can reduce unnecessary data synchronization and update operations, and improve system performance and efficiency. In related technologies, developers usually use the following methods to solve the problem of lazy update of multi-page data: 1) Global data management: Developers will use global variables or global data management tools to store and manage data that needs to be shared between multiple pages. These tools allow one-way flow of data, and when the data is updated, it will trigger the re-rendering of the page. Although this method can solve the problem of data sharing, it cannot solve the problem of lazy update of multi-page data, and still faces synchronous update and performance problems. 2) Manual control of data update: Developers need to manually write code to control the update of data, usually triggering the pulling and updating of data when the page switches or the background enters the foreground. This method requires developers to maintain complex logic and is prone to errors.

[0032] However, the solutions of related technologies have the following technical problems: 1) Performance problems: The synchronous data update mechanism may cause performance problems, especially in the case of large data volume and frequent updates, which will affect the user experience. 2) Development complexity: Manual control of data updates requires developers to write complex logic codes, which is prone to errors and increases the difficulty of development. 3) Resource waste: In the case of multiple pages, data updates on the background pages are unnecessary, but the existing technology does not provide an effective mechanism to avoid such resource waste.

[0033] In response to the above problems, an embodiment of the present invention provides a method embodiment for updating a page. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0034] Figure 1 is a flow chart of a page updating method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:

[0035] Step S102, in response to an update request for a target page in the application, determining a page state and an update mode of the target page, wherein the page state is used to describe whether the target page is displayed or hidden, and the update mode is used to indicate whether the target page needs to be updated when an access request is received;

[0036] Optionally, the application can be a mini-program, and the corresponding target page is the mini-program page. The display state is the state in which the target page is displayed in the foreground of the terminal where the application is located, and the hidden state is the state in which the target page is displayed in the background. The update mode is used to indicate whether the target page needs to be updated when an access request is received. It can also be understood as whether the update mode of the target page is a lazy update mode, in which the lazy update refers to the operation of delaying the data update of the target page until the user requests access again or needs the data. That is, if the update mode is lazy update, the target page needs to be updated when an access request for the target page is received; if the update mode is not lazy update, there is no need to update the target page when an access request for the target page is received. It is only necessary to update the target page when an update request for the target page is received.

[0037] In an optional embodiment, there are multiple target pages, and the multiple target pages have the same data update range or data update category, that is, the multiple target pages have shared data, and the received update request for the target page is an update request for the shared data in the multiple target pages.

[0038] Optionally, the multiple target pages are screened from all pages of an application, such as a mini-program. A notification function notify can be set, which accepts a namespace, a lazy update flag, and a batch flag as parameters. The namespace is used to identify the scope of data update or the category of data update. Its function is to classify or group data update operations so that different processes can be performed according to different namespaces when data is updated. The introduction of namespaces can make data updates more flexible and controllable; the lazy update flag is used to indicate whether the update method of the corresponding page is lazy update; the batch flag is used to indicate whether the page update is a batch update, such as whether to update shared data for multiple target pages, and shared data is data that exists in multiple target pages. According to the lazy update flag and the status of the current page, decide whether to perform data update immediately. If lazy update is not required or the current page is the currently displayed page, the page update is performed immediately.

[0039] Optionally, the notify function will traverse all pages in the mini program, including the current page and background pages, and determine multiple target pages that need to update shared data from all pages of the mini program based on the namespace and / or batch identifier, for subsequent execution of shared data update requests for multiple target pages.

[0040] In an optional embodiment, determining the page status of a target page includes: when detecting that a first life cycle function corresponding to the target page is triggered, determining that the page status of the target page is a display status, wherein the first life cycle function is a life cycle function triggered when the target page switches from background operation to foreground display; or when detecting that a second life cycle function corresponding to the target page is triggered, determining that the page status of the target page is a hidden status, wherein the second life cycle function is a life cycle function triggered when the target page switches from foreground display to background operation.

[0041] Optionally, the first life cycle function can trigger the onShow function when the page is displayed, that is, when the target page changes from a hidden state to a displayed state, that is, when it enters the foreground from the background; the second life cycle function can trigger the onHide function when the page is hidden, that is, when the target page changes from a displayed state to a hidden state, that is, when it enters the background from the foreground. Based on this, the page registration function Page can be rewritten and the page status marking function can be injected, wherein the page registration function is used to register the display page of the application; the page status marking function determines whether the page state of the target page is a display state or a hidden state by intercepting and detecting the triggering state of the first life cycle function and the second life cycle function. For example, when the page status marking function intercepts and detects that the first life cycle function (such as the onShow function) is triggered, the page state is determined to be a display state; when the state marking function intercepts and detects that the second life cycle function (such as the onHide function) is triggered, the page state is determined to be a hidden state.

[0042] It should be noted that the method of marking the page status as display status and hidden status by intercepting the first life cycle function and the second life cycle function (such as onShow function and onHide function) is mainly used to track the display status of the target page. This method can help developers better understand the display status of the page, so that they can perform some operations or process some logic at the right time. By marking the display status of the page, developers can clearly know whether the page is currently in a display state or a hidden state. At the same time, when the page status changes, the update timing of the page can be controlled according to the display status of the page, thereby improving the performance and response speed of the page.

[0043] Step S104, determining a page update strategy for the target page based on the page status and update mode;

[0044] Optionally, a variety of different page update strategies can be derived based on different page states and update methods. According to the page update strategies, it can be determined whether the target page needs to be updated immediately after receiving an update request for the target page.

[0045] In an optional embodiment, a page update strategy of a target page is determined based on a page status and an update method, including: when the page status is a hidden state and the update method is such that the target page needs to be updated when an access request is received, the page update strategy is determined as follows: storing the target page's to-be-updated data and page instance in a target queue and waiting for update; or when the page status is a displayed state, or the update method is such that the target page does not need to be updated when an access request is received, the page update strategy is determined as follows: executing a page update when an update request is received.

[0046] Optionally, the page update strategy may include but is not limited to: executing a page update upon receiving an update request, that is, immediately updating the relevant data in the target page after receiving an update request for the target page; storing the target page's to-be-updated data and page instance in the target queue waiting for update, that is, converting the update of the target page into a transaction queue mechanism, and not immediately updating the target page after receiving an update request for the target page, but storing the target page update-related data (i.e., the to-be-updated data and page instance) in the target queue accordingly, and updating the target page after meeting the corresponding conditions. In the above method, when updating the shared data in multiple target pages, by obtaining the page status and update method corresponding to the multiple target pages respectively, the page update strategy of each target page is obtained in a targeted manner to perform page update, and it is decided whether to immediately execute the update of the target page, or to store the relevant data corresponding to the target page in the target queue waiting for update. The above method can realize the time-sharing update of shared data, reduce the pressure of data update, and avoid updating multiple target pages at the same time when the amount of data is large, causing page jams.

[0047] Step S106: updating the target page based on the page update strategy.

[0048] Optionally, based on the page update strategy, you can decide whether to immediately execute the update of the target page, or store the relevant data corresponding to the target page in the target queue and wait for update. When updating the shared data of multiple target pages, you can implement time-sharing updates of multiple target pages to avoid excessive computing pressure caused by simultaneous updates of multiple target pages, as well as page freezes and other problems.

[0049] In an optional embodiment, when the page update strategy is to store the target page's updated data and page instance in a target queue waiting for update, after updating the target page based on the page update strategy, the method further includes: updating the target page when it is detected that the page state switches from a hidden state to a displayed state, or when an access request for the target page is received.

[0050] Optionally, for the target page stored in the target queue waiting for update, it is necessary to detect the page status of the target page and whether an access request for the target page is received in real time to determine whether the update condition is met. If it is detected that the page status is switched from a hidden state to a displayed state, or an access request for the target page is received, the update operation of the target page is started to complete the update of the target page. The above method can realize the delayed update of the target page data, that is, the data update of the target page is completed when the target page needs it. The above method can reduce the pressure of batch update of pages, and at the same time ensure that the pages used subsequently are pages including the latest updated data.

[0051] In an optional embodiment, based on a page update strategy, a target page is updated, including: obtaining target data for updating the target page; determining current data corresponding to the target data from a page instance of the target page; performing a difference comparison between the target data and the current data to obtain a difference comparison result; obtaining data to be updated corresponding to the target page based on the difference comparison result; based on the page update strategy, updating the data to be updated to the page instance to update the target page.

[0052] Optionally, when updating the target page, the target data given may be the update data for one of the items in the target page, that is, the amount of target data to be updated is greater than the amount of data actually changed in the target page. Based on this, the current data corresponding to the target data can be determined from the page instance of the target page, and the current data is compared with the target data. The compared difference data is used as the data to be updated. When updating the target page, only the filtered data to be updated needs to be updated, and there is no need to update all the target data. The above method can reduce the amount of data update, thereby improving the update efficiency and reducing the pressure of data update calculation.

[0053] In an optional embodiment, based on the page update strategy, the data to be updated is updated to the page instance, and the target page is updated, including: generating a data path key name according to the difference comparison result, wherein the data path key name is used to indicate the target data location of the data to be updated in the page instance; based on the page update strategy and the data path key name, the data to be updated is updated to the target data location in the page instance, and the target page is updated.

[0054] Optionally, a data path key name can be set. Through this data path key name, the target data location of the data to be updated in the page instance can be quickly determined. These data path key names represent the root key of the data path, so as to facilitate subsequent data updates on the target page and improve the data update efficiency of the target page.

[0055] Optionally, rewrite the update function setData to convert the synchronous execution mechanism into a transaction queue mechanism. First, wrap the setData function of the applet by wrapping the data setting function wrapSetData. The wrapSetData function is used to wrap the given data into an object and set it to the specified attribute. The wrapSetData function is usually used to encapsulate data so that it is more convenient to operate and process in the applet. Some additional operations will be performed before and after the data is updated. Specifically, inside the wrapped setData function, a data difference comparison will be performed first. Compare the difference between the current target data and the corresponding current data in the page instance, paying special attention to the changes in nested objects and arrays in the data structure. This difference comparison operation helps to determine which data has changed to avoid unnecessary updates. The difference comparison generates a data path key name specific to the applet to mark the location of the changed data, that is, the target data location. These data path key names represent the root key of the data path for subsequent data update processing. According to the difference comparison results, the data object to be updated, that is, the data to be updated, is generated, and the wrapped setData function is executed. In this way, only the changed data part will be updated, reducing unnecessary update overhead.

[0056] Through the above steps S102 to S106, the purpose of determining the page update strategy according to the page status and the preset update method and performing targeted page updates can be achieved, thereby achieving the technical effect of reducing unnecessary data updates and improving data update efficiency, and further solving the technical problem in the related technology that when there is shared data on multiple pages, multiple pages simultaneously update shared data, which easily causes waste of resources and page freezes when the data volume is large.

[0057] Based on the above embodiments and optional embodiments, the present invention proposes an optional implementation mode: Figure 2 is a flow chart of an optional page updating method according to an embodiment of the present invention. Figure 3 is a flowchart of another optional page updating method according to an embodiment of the present invention. Figure 2 and Figure 3 As shown, the method includes:

[0058] S1. Rewrite the page registration function Page and inject the page status mark function, where the page registration function is used to register the display page of the application. Specifically include:

[0059] S11. Intercept the first life cycle function, i.e., the onShow function, and mark the page status as the display status (triggered when the mini program (such as the target page) is started, or enters the foreground display from the background);

[0060] S12. Intercept the second life cycle function, i.e., the onHide function, and mark the page as hidden (triggered when the mini program (such as the target page) enters the background from the foreground);

[0061] S13, initialize the transaction queue transactionQueue;

[0062] The timing of data update is subsequently determined based on the visibility state of the page, that is, whether the page is displayed or hidden.

[0063] S2. Rewrite the update function setData to convert the synchronous execution mechanism into a transaction queue mechanism. First, wrap the setData function of the applet through the wrapping set data function wrapSetData. The wrapSetData function is used to wrap the given data into an object and set it to the specified attribute. The wrapSetData function is usually used to encapsulate data for easier operation and processing in the program. It will perform some additional operations before and after the data is updated. It includes the following sub-steps:

[0064] S21. Difference comparison: Inside the wrapped setData function, the data difference comparison is first performed. The difference between the current target data and the corresponding current data in the page instance is compared, with special attention paid to the changes in nested objects and arrays in the data structure. This difference comparison operation helps to determine which data has changed to avoid unnecessary updates.

[0065] S22. Mark the root key of the data path: The difference comparison will generate a data path key name specific to the applet, which is used to mark the changed data location, that is, the target data location. These data path key names represent the root key of the data path for subsequent data update processing.

[0066] S23, execute the setData function: according to the difference comparison result, generate the data object to be updated, that is, the data to be updated, and execute the packaged setData function. In this way, only the changed data part will be updated, reducing unnecessary update overhead.

[0067] S24. Processing computed properties: If computed properties are defined in a page or component, the difference comparison and data merging of the computed properties will also be performed. If the value of the computed property changes, the corresponding update operation will also be triggered.

[0068] S25, queue: Pack the data to be updated and the current page instance and add them to the transaction queue, that is, the target queue transactionQueue waiting to be updated.

[0069] S3, update notification, this step involves notifying the page or component to perform data update operations to ensure data consistency and validity. Specifically include:

[0070] S31. Notification function notify: The notification function notify is used to trigger the data update in the page. It accepts a namespace (namespace), a lazy update flag (lazy) and a batch flag (batch) as parameters.

[0071] S32. Traverse all pages: The notify function traverses all pages in all applications such as applets, including the current page and background pages. For each page, it performs the following operations:

[0072] S33. Add the namespace to the pending transaction queue: According to the namespace, add the namespace that needs to perform data update to the pending transaction queue (hasTransaction) of the page.

[0073] S34, judging whether to execute immediately: according to the lazy update flag (lazy) and the state of the current page, decide whether to execute data update immediately. If lazy update is not required or the current page is the current display page, execute page update immediately.

[0074] S35. Notify group updates: If you need to notify a specific group of page updates, you can use the notifyGroup function, which accepts the page instance (pageIns), group name (groupName), and batch flag (batch) as parameters.

[0075] S36, Execute transaction: Finally, at the appropriate time, execute the data update operation in the transaction queue to be executed. This ensures the consistency and timeliness of the data and reduces unnecessary waste of resources.

[0076] It should be noted that in this embodiment, the display status of the page is monitored by injecting a hook function into the page cycle, and the change and update timing of the data is accurately controlled by rewriting setData, and then the synchronous execution mechanism is converted to a transaction queue mechanism, so as to accurately determine whether to execute the transaction according to the page status. First, rewrite the page registration function Page, and inject the page status marking function into the onShow function and onHide function of the page. In addition, inject the transaction execution function, that is, according to the page status, determine whether to execute the updated data in batches. Then, rewrite the update function setData, convert the synchronous execution mechanism to a transaction queue mechanism, and decide whether to enter the waiting queue or execute synchronously immediately according to the status of the page during the update. Finally, the page switching status is monitored globally, only the transactions associated with the current page are updated, and update notifications are made to ensure the consistency and validity of the data. Thereby, lazy update of data in the case of multiple pages of the applet is realized, and the efficiency of data update and user experience are improved.

[0077] The technical highlights of the embodiments of the present invention are as follows: 1) The page lifecycle hook is injected to accurately mark the page status: the logic of marking the page status is injected into the page registration function of the mini program, and the periodic functions such as onShow and onHide are used to mark the display and hiding status of the page. 2) Rewrite the setData function to accurately control the timing of data update: rewrite the native setData function of the mini program to realize the automatic difference update of data and convert the synchronous execution mechanism into a transaction queue mechanism. 3) Difference comparison and data update strategy: use the difference comparison algorithm to determine the changes in data, especially pay attention to the changes in nested objects and arrays, avoid unnecessary updates, and improve data update efficiency. 4) The synchronous execution mechanism is converted into a transaction queue mechanism: add the data update operation to the transaction queue, and decide whether to execute immediately or enter the waiting queue according to the page status, reduce resource usage, and improve performance. 5) Global data update notification ensures data consistency: globally monitor the page switching status, and only update the transactions associated with the current page to ensure data consistency and validity, and avoid unnecessary updates to the background page.

[0078] The embodiments of the present invention can achieve at least one of the following effects: 1) Improve data update efficiency: Through difference comparison and transaction queue mechanism, reduce unnecessary data updates, improve data update efficiency, reduce the number of user interface (UI) rendering times, and optimize user experience. 2) Reduce resource consumption: Reduce unnecessary updates and renderings, reduce the consumption of resources such as CPU and memory, and improve the performance and response speed of mini-programs. 3) Realize lazy data updates: Update data only when needed, avoid unnecessary data updates, reduce network transmission and server pressure, and improve the overall efficiency of the application. 4) Improve user experience: By accurately controlling the timing of data updates, ensure that users have a smooth operating experience during the use of mini-programs, and avoid freezes or unsmoothness caused by data updates. In summary, the embodiments of the present invention can effectively solve the problem of lazy updates of multi-page data in mini-programs, improve data update efficiency and user experience, and ensure data consistency and accuracy.

[0079] In this embodiment, a page update device is also provided, which is used to implement the above embodiments and preferred implementations, and will not be repeated here. As used below, the terms "module" and "device" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0080] According to an embodiment of the present invention, a device embodiment for implementing the above page updating method is also provided. Figure 4 is a schematic diagram of the structure of a page updating device according to an embodiment of the present invention. Figure 4 As shown, the above-mentioned page updating device includes: a response module 400, a strategy determination module 402, and a page updating module 404, wherein:

[0081] A response module 400 is used to respond to an update request for a target page in an application program and determine a page state and an update method of the target page;

[0082] A policy determination module 402, connected to the response module 400, is used to determine a page update policy of a target page based on a page state and an update mode, wherein the page state is used to describe whether the target page is displayed or hidden, and the update mode is used to indicate whether the target page needs to be updated when an access request is received;

[0083] The page update module 404 is connected to the policy determination module 402 and is used to update the target page based on the page update policy.

[0084] In an embodiment of the present invention, a response module 400 is set up to respond to an update request for a target page in an application and determine the page state and update method of the target page; a policy determination module 402 is connected to the response module 400 and is used to determine the page update policy of the target page based on the page state and the update method, wherein the page state is used to describe whether the target page is in a display state or a hidden state, and the update method is used to indicate whether the target page needs to be updated when an access request is received; a page update module 404 is connected to the policy determination module 402 and is used to update the target page based on the page update policy, thereby achieving the purpose of determining the page update policy according to the page state and the preset update method and performing targeted page updates, thereby achieving the technical effect of reducing unnecessary data updates and improving data update efficiency, and further solving the technical problem in the related art that when there is shared data in multiple pages, multiple pages simultaneously update shared data, which easily causes waste of resources and page jams when the data volume is large.

[0085] It should be noted that the above modules can be implemented by software or hardware. For example, for the latter, it can be implemented in the following ways: the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0086] It should be noted that the above-mentioned response module 400, policy determination module 402, and page update module 404 correspond to steps S102 to S106 in the embodiment, and the examples and application scenarios implemented by the above-mentioned modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned embodiment. It should be noted that the above-mentioned modules can be run in a computer terminal as part of the device.

[0087] It should be noted that the optional or preferred implementation of this embodiment can refer to the relevant description in the embodiment, which will not be repeated here.

[0088] The above-mentioned page update device may also include a processor and a memory. The above-mentioned response module 400, policy determination module 402, page update module 404, etc. are all stored in the memory as program modules, and the processor executes the above-mentioned program modules stored in the memory to implement corresponding functions.

[0089] The processor includes a kernel, which retrieves the corresponding program module from the memory. The kernel may be one or more. The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. The memory includes at least one memory chip.

[0090] According to an embodiment of the present application, an embodiment of a non-volatile storage medium is also provided. Optionally, in this embodiment, the non-volatile storage medium includes a stored program, wherein when the program is executed, the device where the non-volatile storage medium is located is controlled to execute any of the above page update methods.

[0091] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group, and the non-volatile storage medium includes a stored program.

[0092] Optionally, when the program is running, the device where the non-volatile storage medium is located is controlled to perform the following functions: in response to an update request for a target page in an application, determine the page status and update method of the target page; based on the page status and update method, determine the page update policy of the target page, wherein the page status is used to describe whether the target page is displayed or hidden, and the update method is used to indicate whether the target page needs to be updated when an access request is received; based on the page update policy, update the target page.

[0093] According to an embodiment of the present application, an embodiment of a processor is also provided. Optionally, in this embodiment, the processor is used to run a program, wherein the program executes any one of the page update methods when it is run.

[0094] According to an embodiment of the present application, an embodiment of a computer program product is also provided. Optionally, in this embodiment, the computer program product includes a computer program, and when the computer program is executed by a processor, the computer program implements any of the steps of the page updating method described above.

[0095] Optionally, the above-mentioned computer program product, when executed on a data processing device, is suitable for executing a program that initializes the following method steps: in response to an update request for a target page in an application, determining the page status and update method of the target page; based on the page status and update method, determining the page update policy of the target page, wherein the page status is used to describe whether the target page is in a displayed state or a hidden state, and the update method is used to indicate whether the target page needs to be updated when an access request is received; based on the page update policy, updating the target page.

[0096] An embodiment of the present invention provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the following steps are implemented: in response to an update request for a target page in an application, a page state and an update method of the target page are determined; based on the page state and the update method, a page update policy of the target page is determined, wherein the page state is used to describe whether the target page is in a display state or a hidden state, and the update method is used to indicate whether the target page needs to be updated when an access request is received; based on the page update policy, the target page is updated.

[0097] The above sequence of the embodiments of the present invention is for description only and does not represent the superiority or inferiority of the embodiments.

[0098] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0099] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the above modules can be a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, modules or indirect coupling or communication connection of modules, which can be electrical or other forms.

[0100] The modules described above as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.

[0101] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of software functional modules.

[0102] If the above-mentioned integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable non-volatile storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a non-volatile storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the various embodiments of the present invention. The aforementioned non-volatile storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0103] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A page update method, It is characterized in that include: In response to an update request for a target page in an application, determining a page state and an update mode of the target page, wherein the page state is used to describe whether the target page is in a display state or a hidden state, and the update mode is used to indicate whether the target page needs to be updated when an access request is received; Determining a page update strategy for the target page based on the page status and the update method; Based on the page update strategy, the target page is updated.

2. The method according to claim 1, It is characterized in that The determining of the page update strategy of the target page based on the page state and the update mode includes: When the page state is the hidden state and the update mode is to update the target page when receiving the access request, the page update strategy is determined as follows: storing the target page's to-be-updated data and the page instance in a target queue to wait for update; or When the page state is the display state, or the update mode is that the target page does not need to be updated when the access request is received, the page update strategy is determined as: executing page update when the update request is received.

3. The method according to claim 1, It is characterized in that The determining the page status of the target page includes: In the case where it is detected that the first life cycle function corresponding to the target page is triggered, determining that the page state of the target page is the display state, wherein the first life cycle function is a life cycle function triggered when the target page switches from background operation to foreground display; or When it is detected that the second life cycle function corresponding to the target page is triggered, the page state of the target page is determined to be the hidden state, wherein the second life cycle function is a life cycle function triggered when the target page switches from foreground display to background operation.

4. The method according to claim 1, It is characterized in that In the case where the page update strategy is to store the to-be-updated data and the page instance of the target page in a target queue for waiting to be updated, after updating the target page based on the page update strategy, the method further includes: When it is detected that the page state is switched from the hidden state to the displayed state, or when the access request for the target page is received, the target page is updated.

5. The method according to claim 1, It is characterized in that The updating of the target page based on the page update strategy includes: Acquire target data for updating the target page; Determining current data corresponding to the target data from the page instance of the target page; Performing a difference comparison between the target data and the current data to obtain a difference comparison result; According to the difference comparison result, obtaining the to-be-updated data corresponding to the target page; Based on the page update strategy, the data to be updated is updated to the page instance, and the target page is updated.

6. The method according to claim 5, It is characterized in that The updating of the to-be-updated data to the page instance based on the page update strategy, and updating the target page, includes: Generate a data path key name according to the difference comparison result, wherein the data path key name is used to indicate a target data location of the data to be updated in the page instance; Based on the page update strategy and the data path key name, the data to be updated is updated to the target data location in the page instance, and the target page is updated.

7. The method according to any one of claims 1 to 6, It is characterized in that There are multiple target pages, and the multiple target pages have the same data update range or data update category.

8. A page updating device, It is characterized in that include: A response module, configured to determine, in response to an update request for a target page in an application, a page state and an update mode of the target page, wherein the page state is used to describe whether the target page is in a display state or a hidden state, and the update mode is used to indicate whether the target page needs to be updated when an access request is received; A strategy determination module, used to determine a page update strategy of the target page based on the page state and the update mode; The page update module is used to update the target page based on the page update strategy.

9. A non-volatile storage medium, It is characterized in that The non-volatile storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the page updating method according to any one of claims 1 to 7.

10. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the page updating method according to any one of claims 1 to 7 are implemented.