Page data processing method and device

By performing data backup and recovery processing of page status in ReactNative, the data problem when jumping and returning to the same type of page is solved, the user experience and performance are improved, and the resource waste and server pressure caused by frequent data requests are avoided. .

CN113760599BActive Publication Date: 2024-10-18BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010511889.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-08
Publication Date
2024-10-18
Estimated Expiration
2040-06-08

AI Technical Summary

Technical Problem

During the development process of ReactNative, the same type of page may cause data to be overwritten or lost when jumping and returning, resulting in page display errors or APP crashes. Moreover, the existing solution requires frequent data requests, which increases the pressure on the server and wastes resources. Affect user experience.

Method used

Perform data backup when the page status is inactive, and perform data recovery when the status is activated to ensure the consistency and correctness of page data and avoid frequent data requests.

Benefits of technology

Without performance degradation and resource waste, it solves the problems of page display errors and APP crashes, improves user experience, and ensures the correctness and stability of page data through data processing for designated pages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113760599B_ABST
    Figure CN113760599B_ABST
Patent Text Reader

Abstract

The present application provides a method and device for processing page data, the method comprising: when it is determined that the current page is a specified page of the configuration, determining the state of the current page; when it is determined that the state of the current page is an inactive state, storing the data of the corresponding field of the current page in the global state as the backup data of the current page; when it is determined that the state of the current page is an active state, and there is backup data corresponding to the current page, updating the backup data to the corresponding field of the current page in the global state. This method can solve the problem of page display errors and APP crashes caused by the same type of pages corresponding to the same data source without performance degradation and resource waste, and can improve user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information processing technology, and in particular to a page data processing method and device. Background Art

[0002] In the process of developing ReactNative, we often encounter such a scenario: pages of the same type may be opened repeatedly. Assume that pages A1 and A2 are of the same type, and page A1 jumps directly to page A2, and then page A2 returns to page A1; or page A1 jumps to page A2 through n intermediate pages, and then page A2 returns to page A1.

[0003] In the process of implementing the present application, the inventors found that when jumping to A2, the data requested by the A2 page will overwrite the corresponding data of the A1 page in the global state; at this time, when returning from A2 to A1, if no processing is performed when leaving A2, the A1 page displays the data corresponding to the A2 page. If the data corresponding to the A2 page is cleared at the same time when leaving the A2 page, the A1 page will display a blank page or an error page, which may sometimes even cause the APP to crash.

[0004] The existing implementation is usually: jump normally within the module, but every time the page status isActive=True, that is, enter componentDidFocus, reload the data, update the global state and refresh the page. Although multiple instances of the same type of page correspond to the same data source, each time the corresponding page is in the foreground, the latest data corresponding to the page is obtained;

[0005] This solution requires re-requesting data every time the page is in the foreground, which will result in many invalid requests, increasing the pressure on the server and causing performance degradation, and causing unnecessary waste of resources. More importantly, it affects the user experience. Summary of the invention

[0006] In view of this, the present application provides a page data processing method and device, which can solve the problems of page display errors and APP crashes caused by the same type of pages corresponding to the same data source without reducing performance and wasting resources, and can improve user experience.

[0007] To solve the above technical problems, the technical solution of this application is implemented as follows:

[0008] In one embodiment, a page data processing method is provided, the method comprising:

[0009] When it is determined that the current page is a configured designated page, determining a state of the current page;

[0010] When it is determined that the state of the current page is an inactive state, storing the data of the corresponding field of the current page in the global state as the backup data of the current page;

[0011] When it is determined that the state of the current page is an activated state and there is backup data corresponding to the current page, the backup data is updated to a corresponding field of the current page in the global state.

[0012] In another embodiment, a page data processing device is provided, the device comprising: a configuration unit, a first determination unit, a second determination unit, and a processing unit;

[0013] The configuration unit is used to configure a specified page;

[0014] The first determining unit is used to determine whether the current page is a designated page configured by the configuring unit;

[0015] The second determining unit is configured to determine a state of the current page when the first determining unit determines that the current page is a configured designated page;

[0016] The processing unit is used to store the data of the corresponding field of the current page in the global state as backup data of the current page when the second determination unit determines that the state of the current page is an inactive state; and to update the backup data to the corresponding field of the current page in the global state when the second determination unit determines that the state of the current page is an active state and there is backup data corresponding to the current page.

[0017] In another embodiment, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the page data processing method when executing the program.

[0018] In another embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of the page data processing method are implemented.

[0019] It can be seen from the above technical solution that in the above embodiment, pages of the same type that will be opened repeatedly are set as designated pages, and data of the designated pages is backed up when their status is in an inactive state, and the backup data is restored when their status is in an active state. This can solve the problem of page display errors and APP crashes caused by pages of the same type corresponding to the same data source without reducing performance or wasting resources, and can improve user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be 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 any creative labor.

[0021] Figure 1 This is a schematic diagram of the page data processing flow in Example 1 of the present application;

[0022] Figure 2 This is a schematic diagram of the page data processing flow in the second embodiment of the present application;

[0023] Figure 3 This is a schematic diagram of the structure of a device applied to the above technology in an embodiment of the present application;

[0024] Figure 4 A schematic diagram of the physical structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0026] The terms "first", "second", "third", "fourth", etc. (if any) 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 interchangeable 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, for example. 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.

[0027] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0028] In an embodiment of the present application, a page data processing method is provided, which is applied to a page data processing device, which may be referred to as a processing device hereinafter. The device may be deployed on a device, such as a server or a PC.

[0029] React components go through three processes in a web page: creation, update, and deletion. Their life cycle also goes through three processes:

[0030] Mounting: The component is rendered in the DOM for the first time.

[0031] Update process (Update) The component re-renders.

[0032] Unmounting process (Unmount) The component is deleted in the DOM.

[0033] These three processes are explained in detail below.

[0034] Loading process:

[0035] The loading process is the first time a component is rendered in the DOM, and the following functions are called in sequence:

[0036] constructor, getInitialState, getDefaultProps, componentWillMount, render, componentDidMount;

[0037] Among them, the constructor function is the constructor of the component, and its main functions are:

[0038] 1. Initialize state;

[0039] 2. Bind the this environment of the function (you can also not bind it, the function can use the arrow function in ES6 to bind this to the current component instance).

[0040] The getInitialState and getDefaultProps functions are not used in ES6 React components. One is to set the initial state and the other is to set the default properties.

[0041] componentWillMount occurs when the component is about to be loaded. Even if you reset the State, it is too late and will not cause redrawing. Therefore, the content of componentWillMount can be completely executed in the constructor.

[0042] The render function is a pure function. You cannot change the props and state of the component in the render function. The component must have a render function because other functions have default implementations, but the render function does not. If the component does not need to render the interface, return null or false in render.

[0043] componentDidMount: When the thing returned by the render function has been rendered, the componentDidMount function will be triggered. This function is a frequently used function.

[0044] Update process:

[0045] The update process is to trigger the update of the component when the props or state of the component changes. Call the following functions in sequence:

[0046] componentWillReceiveProps, shouldComponentUpdate, componentWillUpdate, render, componentDidUpdate;

[0047] in,

[0048] componentWillReceiveProps(nextProps): As long as the render function of the parent component is called, the child component in its render function will trigger the componentWillReceiveProps function.

[0049] shouldComponentUpdate(nextProps, nextState): Specifies when re-rendering is required to improve React component performance.

[0050] componentWillUpdate, componentDidUpdate: Similar to componentWillMount and componentDidMount, one before render and one after render.

[0051] Uninstallation process:

[0052] The uninstall process only involves the following functions: componentWillUnmount;

[0053] Because there is no need to do any operations on the component after uninstalling it, the componentWillUnmount function only needs to perform some operations before deleting the component.

[0054] In the embodiment of the present application, different operations are added for different states of the page. Specifically, when the page state is in an inactive state, a data backup operation is added; when the page state is in an active state, a data recovery operation is added; to implement page data processing, so as to solve the problem encountered in ReactNative development that the same type of pages correspond to the same data source, resulting in page display errors.

[0055] Among them, the page status is active, that is, the page status isActive is true; the page status is inactive, that is, the page status isActive is false.

[0056] When entering the current page directly, entering the current page from another page, or returning to the current page from the previous page, the state of the current page is the active state;

[0057] When exiting the current page, returning to the previous page from the current page, or entering the next page from the current page, the state of the current page is inactive.

[0058] The following is a detailed description of the page data processing process implemented in the embodiment of the present application in conjunction with the accompanying drawings:

[0059] First, some designated pages need to be configured. Only these designated pages will execute the page data processing given in the embodiments of the present application. Pages that are not configured as designated pages will not execute the page data processing given in the embodiments of the present application and can be implemented according to the existing ones.

[0060] In a specific implementation, a page that is of the same type as the specified page and will be opened repeatedly will be configured as a specified page, that is, a page that is of the same type as the specified page and will be opened repeatedly. For example, the number of the specified page identifiers configured here, that is, the number of the specified page identifiers, can be one or more.

[0061] If pages A1 and A2 are pages of the same type, page A1 jumps directly to page A2, and then page A2 returns to page A1; or page A1 jumps to page A2 via n intermediate pages, and then page A2 returns to page A1; then the page data processing in the embodiment of the present application will be executed for page A1.

[0062] ReactNative applications use Redux for data management, and ReactNative page data is obtained from the Redux store (the corresponding state in the store is called globalState).

[0063] When you first enter the ReactNative page, a network request is initiated to obtain the data required for the current page, and then the data is saved in the corresponding field of the current page in globalState.

[0064] For example, the corresponding field in globalState of page A is a. After the network request of page A is successful, the data will be saved in field a of globalState.

[0065] In specific implementation, it is not limited to the data obtained by network request, and this is just an example.

[0066] Embodiment 1

[0067] See also Figure 1 , Figure 1 This is a schematic diagram of the page data processing flow in Example 1 of this application. The specific steps are:

[0068] Step 101: When it is determined that the current page is a configured designated page, the state of the current page is determined.

[0069] The current page here is the page whose data is to be processed.

[0070] In the specific implementation, determine whether the current page is configured as the specified page, that is, determine whether the page identifier of the current page is configured when configuring the specified page; if so, determine the status of the current page, otherwise, the embodiment of the present application does not perform additional processing, that is, it can be implemented according to the existing method.

[0071] When determining the status of the current page, it can be determined based on whether the page status isActive is true or false.

[0072] Step 102, when it is determined that the state of the current page is an inactive state, the data of the corresponding field of the current page in the globalstate is stored as the backup data of the current page, and this process ends.

[0073] Step 103: When it is determined that the state of the current page is an activated state and there is backup data corresponding to the current page, the backup data is updated to a corresponding field of the current page in the global state.

[0074] When it is determined that the state of the current page is activated and there is no backup data corresponding to the current page, no additional processing is performed in the embodiment of the present application, that is, the existing implementation can be followed, indicating that the first time the page is entered, a data request is required, and no data backup is required.

[0075] In the embodiment of the present application, pages of the same type that will be opened repeatedly are set as designated pages. When the designated page is in an inactive state, data is backed up, and when the designated page is in an active state, the backup data is restored. This can solve the problem of page display errors and APP crashes caused by pages of the same type corresponding to the same data source without reducing performance or wasting resources, and can improve user experience.

[0076] Embodiment 2

[0077] See also Figure 2 , Figure 2 This is a schematic diagram of the page data processing flow in the second embodiment of this application. The specific steps are:

[0078] Step 201: When it is determined that the current page is a configured designated page, the state of the current page is determined.

[0079] The current page here is the page whose data is to be processed.

[0080] In the specific implementation, determine whether the current page is configured as the specified page, that is, determine whether the page identifier of the current page is configured when configuring the specified page; if so, determine the status of the current page, otherwise, the embodiment of the present application does not perform additional processing, that is, it can be implemented according to the existing method.

[0081] When determining the status of the current page, it can be determined based on whether the page status isActive is true or false.

[0082] Step 202: When it is determined that the state of the current page is inactive, the data of the corresponding field of the current page in globalstate is stored as backup data in the instance variable corresponding to the current page. This process ends.

[0083] When backing up data for a specified page, back it up to the instance variable corresponding to the page. This allows multiple instances of the same type of page to correspond to different data sources. In this way, when the page is opened again, the backup data can be restored without the problem of page error display.

[0084] Step 203: when it is determined that the state of the current page is an activated state and there is backup data corresponding to the current page, the backup data in the instance variable corresponding to the current page is updated to the corresponding field of the current page in globalstate.

[0085] When it is determined that the state of the current page is activated and there is no backup data corresponding to the current page, no additional processing is performed in the embodiment of the present application, that is, the existing implementation can be followed, indicating that the first time the page is entered, a data request is required, and no data backup is required.

[0086] In the embodiment of the present application, pages of the same type that will be opened repeatedly are set as designated pages. When the designated page is in an inactive state, the data is backed up to the instance variables corresponding to the page, so that multiple instances of the same type of page correspond to different data sources; when the page is in an active state, the backup data is restored, which can solve the problem of page display errors and APP crashes caused by the same type of pages corresponding to the same data source without reducing performance or wasting resources, and can improve user experience.

[0087] Embodiment 3

[0088] When the current page and pages other than the current page are closed, data of corresponding fields of the current page and pages other than the current page in the global state are cleared.

[0089] This operation is implemented to avoid the problem of displaying the content of the previously opened page when the page is opened again, thereby reducing the user experience.

[0090] When the current page is closed, if the current page corresponds to backup data, the backup data is deleted.

[0091] This implementation can save storage resources.

[0092] Embodiment 4

[0093] When the present application is implemented, the data backup and data recovery processes in the first embodiment and the second embodiment can be respectively packaged into one method, taking the first embodiment as an example:

[0094] The content executed by step 102 is encapsulated as a data backup method, and the content executed by step 103 is encapsulated as a data recovery method. When the page status is in an inactive state, the data backup method can be directly called. When the page status is in an active state and there is backup data, the data recovery method can be directly called.

[0095] It is also possible to encapsulate the implementation of not processing the situation where there is no data backup into the data recovery method.

[0096] In the embodiment of the present application, two customized life cycle methods are added according to the state of the page, namely: componentDidFocus and componentWillUnfocus.

[0097] When the page state is active, that is, when the page state isActive is true, componentDidFocus is executed; when the page state is inactive, that is, when the page state isActive is false, componentWillUnfocus is executed.

[0098] Among them, when componentDidFocus is executed, the method of restoring data is called, and when componentWillUnfocus is executed, the method of backing up data is called.

[0099] This implementation is more in line with the implementation of react components, and the solution of encapsulating as a method and directly calling the method for execution can simplify the development process of react components and improve development efficiency.

[0100] Based on the same inventive concept, the present application also provides a page data processing device. Figure 3 , Figure 3 This is a schematic diagram of the structure of a device applied to the above technology in an embodiment of the present application. The device includes: a configuration unit 301, a first determination unit 302, a second determination unit 303 and a processing unit 304;

[0101] Configuration unit 301, used to configure a specified page;

[0102] A first determining unit 302 is used to determine whether the current page is a designated page configured by the configuring unit 301;

[0103] A second determining unit 303, configured to determine a state of the current page when the first determining unit 302 determines that the current page is a configured designated page;

[0104] The processing unit 304 is used to store the data of the corresponding field of the current page in the global state as the backup data of the current page when the second determination unit 303 determines that the state of the current page is an inactive state; when the second determination unit 303 determines that the state of the current page is an active state and there is backup data corresponding to the current page, update the backup data to the corresponding field of the current page in the global state.

[0105] Preferably,

[0106] The processing unit 304 is further configured to clear data of corresponding fields of the current page and pages other than the current page in the global state when the current page and pages other than the current page are closed.

[0107] Preferably,

[0108] The processing unit 304 is further configured to delete the backup data when closing the current page if the current page corresponds to the backup data.

[0109] Preferably,

[0110] The processing unit 304 is specifically used to store the data of the corresponding field of the current page in the global state as backup data in the instance variable corresponding to the current page; and update the backup data in the instance variable corresponding to the current page to the corresponding field of the current page in the global state.

[0111] Preferably,

[0112] The designated page is a page that is of the same type as the designated page and will be opened repeatedly.

[0113] The units in the above-mentioned embodiments may be integrated into one body or deployed separately; they may be combined into one unit or further divided into multiple sub-units.

[0114] In another embodiment, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the page data processing method when executing the program.

[0115] In another embodiment, a computer-readable storage medium is provided, on which computer instructions are stored. When the instructions are executed by a processor, the steps in the page data processing method can be implemented.

[0116] Figure 4 This is a schematic diagram of the physical structure of an electronic device provided in an embodiment of the present application. Figure 4 As shown, the electronic device may include: a processor (Processor) 410, a communication interface (Communications Interface) 420, a memory (Memory) 430 and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the following method:

[0117] When it is determined that the current page is a configured designated page, determining a state of the current page;

[0118] When it is determined that the state of the current page is an inactive state, storing the data of the corresponding field of the current page in the global state as the backup data of the current page;

[0119] When it is determined that the state of the current page is an activated state and there is backup data corresponding to the current page, the backup data is updated to a corresponding field of the current page in the global state.

[0120] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0121] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0122] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0123] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A page data processing method, characterized in that: The method comprises: When it is determined that the current page is a configured designated page, determining the state of the current page; the designated page is a page of the same type as the designated page and will be opened repeatedly; When entering the ReactNative page for the first time, initiate a network request to obtain the data required by the current page, and then save the data to the corresponding field of the current page in the global state; when it is determined that the state of the current page is inactive, store the data of the corresponding field of the current page in the global state as the backup data of the current page; When it is determined that the state of the current page is an activated state and there is no backup data corresponding to the current page, no data backup is performed; When it is determined that the state of the current page is an activated state and there is backup data corresponding to the current page, the backup data is updated to a corresponding field of the current page in the global state.

2. The method according to claim 1, characterized in that The method further comprises: When the current page and pages other than the current page are closed, data of corresponding fields of the current page and pages other than the current page in the global state are cleared.

3. The method according to claim 1, characterized in that The method further comprises: When the current page is closed, if the current page corresponds to backup data, the backup data is deleted.

4. The method according to claim 1, characterized in that: The storing the data of the corresponding field of the current page in the global state as the backup data of the current page includes: Store the data of the corresponding field of the current page in the global state as backup data in the instance variable corresponding to the current page; The updating of the backup data to a corresponding field of the current page in the global state includes: Update the backup data in the instance variable corresponding to the current page to the corresponding field of the current page in the global state.

5. A page data processing device, characterized in that: The device comprises: a configuration unit, a first determination unit, a second determination unit and a processing unit; The configuration unit is used to configure a specified page; the specified page is a page of the same type as the specified page and will be opened repeatedly; The first determining unit is used to determine whether the current page is a designated page configured by the configuring unit; The second determining unit is configured to determine a state of the current page when the first determining unit determines that the current page is a configured designated page; The processing unit is used to initiate a network request to obtain data required for the current page when entering the ReactNative page for the first time, and then save the data in the corresponding field of the current page in the global state; when the second determination unit determines that the state of the current page is an inactive state, the data of the corresponding field of the current page in the global state is stored as backup data of the current page; when it is determined that the state of the current page is an active state and there is no backup data corresponding to the current page, no data backup is performed; when the second determination unit determines that the state of the current page is an active state and there is backup data corresponding to the current page, the backup data is updated to the corresponding field of the current page in the global state.

6. The device according to claim 5, characterized in that The processing unit is further used to clear the data of the corresponding fields of the current page and the pages other than the current page in the global state when the current page and the pages other than the current page are closed.

7. The device according to claim 5, characterized in that The processing unit is further configured to delete the backup data when closing the current page if the current page corresponds to the backup data.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 4 is implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method described in any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Page turning method and apparatus, terminal device and storage medium

    CN108446061A

  • Page return method and device

    CN110020268A