Page data processing method and device

文档序号:1937019 发布日期:2021-12-07 浏览:7次 中文

阅读说明:本技术 页面数据处理方法和装置 (Page data processing method and device ) 是由 王超 于 2020-06-08 设计创作,主要内容包括:本申请提供了一种页面数据处理方法和装置,所述方法包括:当确定当前页面为配置的指定页面时,确定所述当前页面的状态;当确定所述当前页面的状态为非激活状态时,将所述当前页面在global state中对应字段的数据作为所述当前页面的备份数据进行存储;当确定所述当前页面的状态为激活状态,且存在所述当前页面对应的备份数据时,将所述备份数据更新到所述当前页面在global state中对应字段中。该方法能够在性能不下降、资源不浪费的前提下,解决因相同类型页面对应同一数据源而导致页面显示出错,以及APP崩溃的问题,并能够提高用户体验。(The application provides a page data processing method and a device, wherein the method comprises the following steps: when the current page is determined to be the configured appointed page, determining the state of the current page; when the state of the current page is determined to be a non-activated state, storing data of a corresponding field of the current page in a global state as backup data of the current page; and when the state of the current page is determined to be an activated state and the backup data corresponding to the current page exists, updating the backup data to the corresponding field of the current page in the global state. The method can solve the problems of page display errors and APP breakdown caused by the fact that the same type of page corresponds to the same data source on the premise that the performance is not reduced and resources are not wasted, and can improve user experience.)

1. A page data processing method is characterized by comprising the following steps:

when the current page is determined to be the configured appointed page, determining the state of the current page;

when the state of the current page is determined to be the non-activated state, storing data of a corresponding field of the current page in a global state as backup data of the current page;

and when the state of the current page is determined to be an activated state and the backup data corresponding to the current page exists, updating the backup data to the corresponding field of the current page in the global state.

2. The method of claim 1, further comprising:

and when the current page and the pages except the current page are closed, clearing the data of the current page and the corresponding fields of the pages except the current page in the global state.

3. The method of claim 1, further comprising:

and when the current page is closed, if the current page corresponds to the backup data, deleting the backup data.

4. The method of claim 1, wherein the storing data of a corresponding field of the current page in a global state as backup data of the current page comprises:

storing data of a field corresponding to the current page in the global state as backup data into an instance variable corresponding to the current page;

the updating the backup data to the corresponding field of the current page in the global state includes:

and updating 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. The method according to any one of claims 1 to 4,

the specified page is a page which has the same type with the specified page and can be repeatedly opened.

6. A page data processing apparatus, characterized in that the apparatus comprises: the device comprises a configuration unit, a first determination unit, a second determination unit and a processing unit;

the configuration unit is used for configuring a specified page;

the first determining unit is used for determining whether the current page is a specified page configured by the configuration unit;

the second determining unit is used for determining the state of the current page when the first determining unit determines that the current page is the configured specified page;

the processing unit is configured to, when the second determining unit determines that the state of the current page is an inactive state, store data of a field corresponding to the current page in a global state as backup data of the current page; and when the second determining unit determines that the state of the current page is an activated state and the backup data corresponding to the current page exists, updating the backup data into a corresponding field of the current page in a global state.

7. The apparatus of claim 6,

the processing unit is further configured to, when the current page and the page other than the current page are closed, clear data of corresponding fields in a global state of the current page and the page other than the current page.

8. The apparatus of claim 6,

the processing unit is further configured to, when the current page is closed, delete the backup data if the current page corresponds to the backup data.

9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1-5 when executing the program.

10. A computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, is adapted to carry out the method of any one of claims 1 to 5.

Technical Field

The present invention relates to the field of information processing technologies, and in particular, to a method and an apparatus for processing page data.

Background

In the development process of ReactNative, a scenario is often encountered: there may be instances of repeated opens of pages of the same type. If the pages A1 and A2 are the same type of pages, directly jumping from the A1 page to the A2 page, and returning to the A1 page from the A2 page; or jump from the A1 page to the A2 page through n intermediate pages and then return from the A2 page to the A1 page.

In the process of implementing the present application, the inventor finds that when jumping to a2, the data requested by the a2 page will overwrite the data corresponding to the a1 page in the global state; at this time, when returning to a1 from a2, if no processing is performed when leaving a2, the a1 page shows data corresponding to the a2 page, and if leaving the a2 page and cleaning data corresponding to the a2 page, the a1 page shows a blank page or a wrong page, which may even cause APP crash.

The existing implementations are generally: normal jumps occur within the module, but each time the component DidFocus is entered with the page state isActive True, the data is reloaded, the global state (global state) is updated and the page is refreshed. Although a plurality of instances of the same type page correspond to the same data source, the latest data corresponding to the page is acquired when the corresponding page is in the foreground each time;

according to the scheme, data is required to be requested again every time the page is in the foreground, so that a plurality of invalid requests are caused, the pressure of the server is increased, the performance is reduced, unnecessary resource waste is caused, and more importantly, the user experience is influenced.

Disclosure of Invention

In view of this, the present application provides a page data processing method and apparatus, which can solve the problems of page display errors and APP crashes caused by the same type of page corresponding to the same data source on the premise of not decreasing performance and not wasting resources, and can improve user experience.

In order to solve the technical problem, the technical scheme of the application is realized as follows:

in one embodiment, a page data processing method is provided, the method comprising:

when the current page is determined to be the configured appointed page, determining the state of the current page;

when the state of the current page is determined to be a non-activated state, storing data of a corresponding field of the current page in a global state as backup data of the current page;

and when the state of the current page is determined to be an activated state and the backup data corresponding to the current page exists, updating the backup data to the corresponding field of the current page in the global state.

In another embodiment, there is provided a page data processing apparatus, including: the device comprises a configuration unit, a first determination unit, a second determination unit and a processing unit;

the configuration unit is used for configuring a specified page;

the first determining unit is used for determining whether the current page is a specified page configured by the configuration unit;

the second determining unit is used for determining the state of the current page when the first determining unit determines that the current page is the configured specified page;

the processing unit is configured to, when the second determining unit determines that the state of the current page is an inactive state, store data of a field corresponding to the current page in a global state as backup data of the current page; and when the second determining unit determines that the state of the current page is an activated state and the backup data corresponding to the current page exists, updating the backup data into a corresponding field of the current page in a global state.

In another embodiment, an electronic device is provided that includes a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the page data processing method when executing the program.

In another embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when being executed by a processor, carries out the steps of the page data processing method.

According to the technical scheme, the pages which are of the same type and can be repeatedly opened are set as the designated pages, data backup is carried out on the designated pages when the designated pages are in the non-activated state, backup data recovery is carried out when the designated pages are in the activated state, the problems that page display errors and APP breakdown are caused due to the fact that the same type of pages correspond to the same data source can be solved on the premise that performance is not reduced and resources are not wasted, and user experience can be improved.

Drawings

In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive labor.

FIG. 1 is a schematic diagram illustrating a page data processing flow according to an embodiment of the present application;

FIG. 2 is a schematic view of a page data processing flow in the second embodiment of the present application;

FIG. 3 is a schematic diagram of an apparatus for implementing the above technique in an embodiment of the present application;

fig. 4 is a schematic physical structure diagram of an electronic device according to an embodiment of the present application.

Detailed Description

The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.

The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprising" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements explicitly listed, but may include other steps or elements not explicitly listed or inherent to such process, method, article, or apparatus.

The technical solution of the present invention will be described in detail with specific examples. Several of the following embodiments may be combined with each other and some details of the same or similar concepts or processes may not be repeated in some embodiments.

The embodiment of the application provides a page data processing method, which is applied to a page data processing device, and can be simply called as a processing device hereinafter. The device can be deployed on a piece of equipment, such as a server and a PC.

The React component can go through three processes of creation, update and deletion in the webpage, and the life cycle of the React component also goes through three processes:

the load Process (Mount) component is rendered in the DOM for the first time.

The Update procedure (Update) component re-renders.

The uninstall process (Unmount) component is deleted in the DOM.

These three processes are explained in detail below.

And (3) loading:

the loading process is a process of rendering the component in the DOM for the first time, and the following functions are called in sequence:

constructor、getInitialState、getDefaultProps、componentWillMount、render、componentDidMount;

wherein, the constractor function is the constructor of the component, and the main functions are:

1. initializing a state;

2. the this context of the function is bound (it may or may not be bound, the function binds this to the current component instance using the arrow function in ES 6).

The getInitialState and getDefaultProps functions are not used in the React component of ES6, one to set the initial state and one to set default properties.

The content of componentWillMount can be fully executed in the constractor, since it will not cause redraws even if the remount state is already late when the componentWillMount is about to load.

The render function is a pure function, and it is not possible to change the stages and states of the components in the render function. There must be a render function in the component because other functions have default implementations, while render functions do not. If the component does not need to render the interface, null or false can be returned in render.

componentDidMount: when the render function returns that it has rendered, the componentDidMount function is triggered. This function is a frequently used function.

And (3) updating:

the updating process is to trigger the updating of the component when the status or the props of the component is changed. The following functions are called in sequence:

componentWillReceiveProps、shouldComponentUpdate、componentWillUpdate、render、componentDidUpdate;

wherein the content of the first and second substances,

componentWillReceivProps (nextProps): whenever the render function of a parent component is called, the child component in its render function will trigger the componentWillReceivProps function.

shouldComponentUpdate (nextProps, nextState): specifying when re-rendering is required for improving reach component performance.

componentWillUpdate, componentDidUpdate: similar to componentWillMount and componentDidMount, one before render and one after render.

And (3) unloading process:

the unloading process involves only the following functions: componentwilllunmount;

because no operation is required on the component after the component is unloaded, the componentWillUnmount function is only required to perform some operations before the component is deleted.

In the embodiment of the application, different operations are added according to different states of a page, specifically, when the page state is an inactive state, a data backup operation is added; when the page state is an activated state, increasing data recovery operation; the method and the device realize the processing of the page data so as to solve the problem that the page display error is caused by the fact that the same type of page corresponds to the same data source in the ReactNative development.

The page state is an activated state, namely the page state isActive is true; the page state is inactive, i.e. the page state isActive is false.

When directly entering a current page, advancing from one page to the current page or returning to the current page from the previous page, the state of the current page is an activated state;

and when the current page exits, the current page returns to the previous page, or the current page enters the next page, the state of the current page is a non-activated state.

The following describes in detail a process of processing page data implemented in the embodiments of the present application, with reference to the accompanying drawings:

first, some designated pages need to be configured, the designated pages will execute the page data processing given in the embodiment of the present application, and pages that are not configured as designated pages do not execute the page data processing given in the embodiment of the present application, which is implemented as before.

In a specific implementation, a page that is of the same type as the specified page and is to be repeatedly opened is configured as the specified page, that is, the specified page is a page that is of the same type as the specified page and is to be repeatedly opened. For example, the number of the designated page identifiers, that is, the designated page identifiers, configured here may be one or multiple.

If the pages A1 and A2 are the same type of pages, directly jumping from the page A1 to the page A2, and returning to the page A1 from the page A2; or jumping from the A1 page to the A2 page through n middle pages, and returning to the A1 page from the A2 page; the page data processing in the embodiment of the present application is performed with respect to the a1 page.

Redux is used for data management of the Reactnative application, and the Reactnative page data is obtained from the store of Redux (the corresponding state in the store is called globalState).

When the web page enters the ReactNative page for the first time, a network request is initiated to acquire data required by the current page, and then the data is stored in a field corresponding to the current page in the globalState.

For example, the corresponding field in the globalState corresponding to the page a is a, and after the network request of the page a is successful, the data is stored in the field a of the globalState.

In the specific implementation, the data requested to be obtained by the network is not limited, and this is only an example.

Example one

Referring to fig. 1, fig. 1 is a schematic view illustrating a page data processing flow according to an embodiment of the present application. The method comprises the following specific steps:

step 101, when determining that the current page is a configured appointed page, determining the state of the current page.

The current page here is the page for which data is to be processed.

In specific implementation, whether the current page is configured as a specified page is determined, that is, whether the page identifier of the current page is configured when the specified page is configured is determined; if so, determining the state of the current page, otherwise, not performing additional processing in the embodiment of the application, namely, implementing according to the existing method.

When determining the state of the current page, the determination may be made according to whether the page state isActive is true or false.

And 102, when the state of the current page is determined to be the non-activated state, storing data of a field corresponding to the current page in the global state as backup data of the current page, and ending the process.

Step 103, when the state of the current page is determined to be an activated state and backup data corresponding to the current page exists, updating the backup data to a corresponding field of the current page in a global state.

When the state of the current page is determined to be an activated state and the backup data corresponding to the current page does not exist, in the embodiment of the application, no additional processing is performed, that is, the implementation is performed according to the prior art, which indicates that a data request needs to be performed when the current page enters the page for the first time and that data backup does not need to be performed.

According to the method and the device, the page which is of the same type and can be repeatedly opened is set as the designated page, data backup is carried out when the designated page is in the non-activated state, backup data recovery is carried out when the designated page is in the activated state, the problems that page display is wrong and APP crashes due to the fact that the page of the same type corresponds to the same data source can be solved on the premise that performance is not reduced and resources are not wasted, and user experience can be improved.

Example two

Referring to fig. 2, fig. 2 is a schematic view illustrating a processing flow of page data in the second embodiment of the present application. The method comprises the following specific steps:

step 201, when the current page is determined to be the configured appointed page, determining the state of the current page.

The current page here is the page for which data is to be processed.

In specific implementation, whether the current page is configured as a specified page is determined, that is, whether the page identifier of the current page is configured when the specified page is configured is determined; if so, determining the state of the current page, otherwise, not performing additional processing in the embodiment of the application, namely, implementing according to the existing method.

When determining the state of the current page, the determination may be made according to whether the page state isActive is true or false.

Step 202, when the state of the current page is determined to be the inactive state, storing the data of the corresponding field of the current page in the global state as backup data into the instance variable corresponding to the current page. The flow is ended.

In the case of backing up the data to the instance variables corresponding to the page when the page is designated, the multiple instances of the page of the same type can correspond to different data sources, so that the backup data can be restored when the page is opened again, and the problem of page error display cannot occur.

Step 203, when it is determined that the state of the current page is the activated state and the backup data corresponding to the current page exists, updating the backup data in the instance variable corresponding to the current page to a corresponding field of the current page in the global state.

When the state of the current page is determined to be an activated state and the backup data corresponding to the current page does not exist, in the embodiment of the application, no additional processing is performed, that is, the implementation is performed according to the prior art, which indicates that a data request needs to be performed when the current page enters the page for the first time and that data backup does not need to be performed.

In the embodiment of the application, pages which are of the same type and can be repeatedly opened are set as designated pages, and when the designated pages are in an inactive state, data are backed up into instance variables corresponding to the pages, so that multiple instances of the pages of the same type correspond to different data sources; when the state is the activated state, backup data recovery is carried out, the problems that page display is wrong and APP crashes due to the fact that the same type of pages correspond to the same data source can be solved on the premise that performance is not reduced and resources are not wasted, and user experience can be improved.

EXAMPLE III

And when the current page and the pages except the current page are closed, clearing the data of the current page and the corresponding fields of the pages except the current page in the global state.

Such an operation is implemented to prevent a problem of displaying the content of a previously opened page from occurring when the page is opened again, thereby degrading the user experience.

And when the current page is closed, if the current page corresponds to the backup data, deleting the backup data.

Such an implementation can save storage resources.

Example four

In a specific implementation of the present application, the data backup and data recovery processes in the embodiment and the second embodiment may be respectively encapsulated as a method, taking the embodiment as an example:

the content executed in the step 102 is packaged as a data backup method, the content executed in the step 103 is packaged as a data recovery method, and when the page state is in an inactive state, the data backup method is directly called, and when the page state is in an active state and backup data exists, the data recovery method is directly called.

Or encapsulating the implementation that is not processed when no data backup exists into the data recovery method.

In the embodiment of the application, two self-defined life cycle methods are added according to the state of the page, which respectively comprise: componentDidFocus and componentWillUnfocus.

When the page state is an activated state, namely the page state isActive is true, executing componentDidFocus; when the page state is in the inactive state, that is, the page state isActive is false, the componentwilllunfocus is executed.

The method for restoring data is called when the componentDidFocus is executed, and the method for backing up data is called when the componentWillUnFocus is executed.

The implementation is more consistent with the implementation of the exact component, and the scheme of packaging the exact component as a method for directly calling the method execution can simplify the development process of the exact component and improve the development efficiency.

Based on the same inventive concept, the embodiment of the application also provides a page data processing device. Referring to fig. 3, fig. 3 is a schematic structural diagram of an apparatus applied to the above technology in the embodiment of the present application. The device comprises: a configuration unit 301, a first determination unit 302, a second determination unit 303, and a processing unit 304;

a configuration unit 301 configured to configure a designated page;

a first determining unit 302, configured to determine whether the current page is a specified page configured by the configuring unit 301;

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 specified page;

a processing unit 304, configured to, when the second determining unit 303 determines that the state of the current page is an inactive state, store data of a field corresponding to the current page in a global state as backup data of the current page; when the second determining unit 303 determines that the state of the current page is an active state and the backup data corresponding to the current page exists, updating the backup data to a corresponding field of the current page in a global state.

Preferably, the first and second electrodes are formed of a metal,

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

Preferably, the first and second electrodes are formed of a metal,

the processing unit 304 is further configured to, when the current page is closed, delete the backup data if the current page corresponds to the backup data.

Preferably, the first and second electrodes are formed of a metal,

the processing unit 304 is specifically configured to store data of a field, corresponding to the global state, of the current page as backup data in an instance variable corresponding to the current page; and updating the backup data in the instance variable corresponding to the current page to the corresponding field of the current page in the global state.

Preferably, the first and second electrodes are formed of a metal,

the specified page is a page which has the same type with the specified page and can be repeatedly opened.

The units of the above embodiments may be integrated into one body, or may be separately deployed; may be combined into one unit or further divided into a plurality of sub-units.

In another embodiment, an electronic device is also provided, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the steps of the page data processing method when executing the program.

In another embodiment, a computer readable storage medium is also provided, on which computer instructions are stored, which when executed by a processor may implement the steps in the page data processing method.

Fig. 4 is a schematic physical structure diagram of an electronic device according to an embodiment of the present application. As shown in fig. 4, the electronic device may include: a Processor (Processor)410, a communication Interface 420, a Memory (Memory)430 and a communication bus 440, wherein the Processor 410, the communication Interface 420 and the Memory 430 are communicated with each other via the communication bus 440. The processor 410 may call logic instructions in the memory 430 to perform the following method:

when the current page is determined to be the configured appointed page, determining the state of the current page;

when the state of the current page is determined to be a non-activated state, storing data of a corresponding field of the current page in a global state as backup data of the current page;

and when the state of the current page is determined to be an activated state and the backup data corresponding to the current page exists, updating the backup data to the corresponding field of the current page in the global state.

In addition, the logic instructions in the memory 430 may be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.

The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.

Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.

The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

13页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种数据库备份方法、数据库还原方法和相关装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!