CN111563219B - State management method and device for web application - Google Patents

State management method and device for web application Download PDF

Info

Publication number
CN111563219B
CN111563219B CN202010313118.5A CN202010313118A CN111563219B CN 111563219 B CN111563219 B CN 111563219B CN 202010313118 A CN202010313118 A CN 202010313118A CN 111563219 B CN111563219 B CN 111563219B
Authority
CN
China
Prior art keywords
data
historical
browser
state data
web application
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010313118.5A
Other languages
Chinese (zh)
Other versions
CN111563219A (en
Inventor
杨鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Mininglamp Software System Co ltd
Original Assignee
Beijing Mininglamp Software System Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Mininglamp Software System Co ltd filed Critical Beijing Mininglamp Software System Co ltd
Priority to CN202010313118.5A priority Critical patent/CN111563219B/en
Publication of CN111563219A publication Critical patent/CN111563219A/en
Application granted granted Critical
Publication of CN111563219B publication Critical patent/CN111563219B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution

Abstract

A method and a device for managing the state of a web application comprise the following steps: the web application on the browser stores historical state data through a data writing interface provided by the universal history class; when the web application receives the state change instruction, the stored historical state data is obtained through a data reading interface provided by the universal history class, and corresponding operation is executed. Because the web application on the browser can write and acquire the historical state data and operate corresponding to the state change instruction through the universal historical class, the state management of all the web applications is realized by calling one class, so that the state management of the web application is facilitated.

Description

State management method and device for web application
Technical Field
The present disclosure relates to web application management technologies, and in particular, to a method and apparatus for managing a state of a web application.
Background
In real life, the web browser is not just used to present a web page. A web application can be implemented by means of a web browser many times.
In the related art, each web application defines a set of state management methods to implement state management of the corresponding web application.
However, since a set of state management methods needs to be defined for each web application, it is troublesome to not utilize state management of the web application.
Disclosure of Invention
The application provides a method and a device for managing the state of web applications, which can enable all web applications to call one class for state management, thereby facilitating the state management of the web applications.
The application provides a state management method of web application, comprising the following steps:
the web application on the browser stores historical state data through a data writing interface provided by the universal history class;
and when the web application receives the state change instruction, acquiring the stored historical state data through a data reading interface provided by the universal history class and executing corresponding operation.
After the web application on the browser saves the history state data through the data writing interface provided by the general history class, the method further comprises the following steps:
the web application deletes the stored history state data through a data deletion interface provided by the general history class.
The state change instruction includes at least one of: back to the last step of historical state data instruction, forward to the next step of historical state data instruction, obtain a back historical state instruction, and obtain a forward historical state instruction.
The generic history class defines basic configuration information including at least one of: a storage mode of the historical state data of the web application, a maximum number of storage steps of the historical state data of the web application; wherein the storage mode includes: a memory Storage mode and a Storage mode.
The basic configuration information further includes at least one of: an address of a server that remains synchronized with the browser, and an interval of historical state data between the browser and the server.
The generic history class also defines internal attribute information including at least one of: an index for pointing to current historical state data and a historical state data list; the historical state data list is used for storing the historical state data when the storage mode of the historical state data of the web application is a memory storage mode.
When the basic configuration information defined by the general history class includes the interval synchronization number of the history state data between the browser and the server, the internal attribute further includes: the number of asynchronous steps of the historical state data of the browser and the server.
After the web application on the browser saves the historical state data through a data writing interface provided by the general history class or the web application deletes the saved historical state data through a data deleting interface provided by the general history class, the method further comprises the following steps:
when the number of the asynchronous steps of the browser and the server is larger than the number of the synchronous steps of the interval of the historical state data between the browser and the server, the browser acquires the time stamp of the latest historical data stored by the browser and the time stamp of the latest historical data stored by the server;
when the time stamp of the latest historical data stored by the browser is earlier than the time stamp of the latest historical data stored by the server, the browser synchronizes all historical data of the browser by using all historical data of the server;
when the time stamp of the latest historical data stored by the browser is later than the time stamp of the latest historical data stored by the server, the browser synchronizes all the historical data stored by the browser with the server.
The generic history class distinguishes historical state data of different instances of different web applications through web application identifications and instance identifications communicated by the provided interface to preserve historical data for multiple instances of multiple web applications.
The application also provides a terminal, comprising: a memory and a processor, the memory storing a program of a browser, which when executed by the processor performs the method of state management of a web application as described in any one of the above.
Compared with the related art, one of the technical schemes has the following advantages or beneficial effects: because the web application on the browser can write and acquire the historical state data and operate corresponding to the state change instruction through the universal historical class, the state management of all the web applications is realized by calling one class, so that the state management of the web application is facilitated.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the application. The objectives and other advantages of the application will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
The accompanying drawings are included to provide an understanding of the principles of the application, and are incorporated in and constitute a part of this specification, illustrate embodiments of the application and together with the description serve to explain, without limitation, the principles of the application.
Fig. 1 is a flow chart of a method for managing a state of a web application according to an embodiment of the present application;
fig. 2 is a schematic diagram of a process of writing historical state data according to an embodiment of the present application.
Detailed Description
The present application has been described in terms of several embodiments, but the description is illustrative and not restrictive, and it will be apparent to those of ordinary skill in the art that many more embodiments and implementations are possible within the scope of the described embodiments. Although many possible combinations of features are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are possible. Any feature or element of any embodiment may be used in combination with or in place of any other feature or element of any other embodiment unless specifically limited.
The present application includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The disclosed embodiments, features and elements of the present application may also be combined with any conventional features or elements to form a unique inventive arrangement as defined by the claims. Any feature or element of any embodiment may also be combined with features or elements from other inventive arrangements to form another unique inventive arrangement as defined in the claims. It is therefore to be understood that any of the features shown and/or discussed in the present application may be implemented alone or in any suitable combination. Accordingly, the embodiments are not to be restricted except in light of the attached claims and their equivalents. Further, various modifications and changes may be made within the scope of the appended claims.
Furthermore, in describing representative embodiments, the specification may have presented the method and/or process as a particular sequence of steps. However, to the extent that the method or process does not rely on the particular order of steps set forth herein, the method or process should not be limited to the particular sequence of steps described. Other sequences of steps are possible as will be appreciated by those of ordinary skill in the art. Accordingly, the particular order of the steps set forth in the specification should not be construed as limitations on the claims. Furthermore, the claims directed to the method and/or process should not be limited to the performance of their steps in the order written, and one skilled in the art can readily appreciate that the sequences may be varied and still remain within the spirit and scope of the embodiments of the present application.
The embodiment of the application provides a state management method of a web application, as shown in fig. 1, comprising the following steps:
step 101, a web application on a browser stores historical state data through a data writing interface provided by a general historical class.
In one illustrative example, generic refers to being applicable to a variety of different web applications.
In an illustrative example, the data write interface provided by the generic history class may be named push (), and one piece of history state data may be written each time the interface is called.
And 102, when the web application receives a state change instruction, acquiring the stored historical state data through a data reading interface provided by the universal history class and executing corresponding operation.
In one illustrative example, the data read interface provided by the generic history class may be named getAllData ().
According to the state management method of the web application, the web application on the browser can write and acquire the historical state data and operate corresponding to the state change instruction through the universal historical class, so that state management is realized for all the web applications by calling one class, and the state management of the web application is facilitated.
In one illustrative example, after the web application on the browser saves the historical state data through the data write interface provided by the generic history class, further comprising:
the web application deletes the saved history state data through a data deletion interface provided by the general history class.
In one illustrative example, the data deletion interface provided by the generic history class may be named clear ().
In one illustrative example, the state change instruction includes at least one of: back to the last step of historical state data instruction, forward to the next step of historical state data instruction, obtain a back historical state instruction, and obtain a forward historical state instruction.
In one illustrative example, the rollback to last step historical state data instruction may be named as goBack (); the advance to next step historical state data instruction may be named go forward (); the get back history state instruction may be named getb ack status (), where getb ack status () has a return value, returns true or false, where true indicates that back may be performed, and false indicates that back may not be performed; the get forward history state instruction may be named getForward State (), where getForward State () has a return value, either return true or false, true indicating that forward may be performed, false indicating that forward may not be performed.
In an exemplary embodiment, the web application on the browser stores the historical state data through a data writing interface provided by the general history class, when the user issues a state change instruction received by the web application after returning to the previous step of the historical state data instruction, the web application acquires the stored historical state data through a data reading interface provided by the general history class, and performs corresponding operation to enable the automatic state to return to the previous step.
In one illustrative example, the generic history class is defined with basic configuration information including at least one of: a storage mode of the historical state data of the web application and a maximum storage step number of the historical state data of the web application; wherein the storage mode includes: a memory Storage mode and a Storage mode.
In one illustrative example, the memory is stored by default, but Storage may be selected if the amount of historical state data is relatively large or the user requires that the historical state data not be lost at the time of a browser refresh or reenter of the application.
In one illustrative example, the storage mode of the historical state data of the web application may be denoted as "stoagemode:", and the maximum number of storage steps of the historical state data of the web application may be denoted as "maxSize:".
In one illustrative example, the basic configuration information further includes at least one of: addresses of servers that remain synchronized with the browser, and intervals of historical state data between the browser and the server.
In one illustrative example, the address of the server that remains synchronized with the browser may be denoted as "remoteAddress:", and the number of interval syncs of historical state data between servers may be denoted as "syncStep:".
In one illustrative example, the generic history class further defines internal attribute information including at least one of: an index for pointing to current historical state data and a historical state data list; the historical state data list is used for storing the historical state data when the storage mode of the historical state data of the web application is a memory storage mode.
In one illustrative example, the index for pointing to current historical state data may be denoted as "historyIndex:", and the index for pointing to current historical state data and the list of historical state data may be denoted as "historyList: [ ].
In one illustrative example, a rollback to last step historical state data instruction, or go back (), and a forward to next step historical state data instruction, or go forward (), is to find the corresponding historical state data by an index to point to the current historical state data, or historyIndex, e.g., rollback to last step historical state data, then historyIndex minus 1, and then return the history state data after the historyIndex minus 1; the history state data after the history state data is added with 1 is returned after the history state data is added with 1; and meanwhile, corresponding boundary judgment can be added, for example, when the boundary is exceeded, empty data is returned.
In one illustrative example, if the selected historical state data is stored in memory, then the historical state data is actually stored in an internal attribute of the generic history class, i.e., a list of historical state data; if the historical state data is stored in the Storage, calling a localform open source component to store the historical state data in the Storage, wherein the localform can be judged according to a browser, and if the browser supports an IndexdDB, the IndexdDB is used for storing, and the IndexdDB can break through the Storage size limit of 5M.
In an illustrative example, where the baseboard configuration information includes a maximum number of stored steps of historical state data of the web application and an index for pointing to current historical state data, the following determination is made each time the push method is performed: if the step number of the history state data after the new history state data is written exceeds the maximum storage step number of the history state data of the web application; if the maximum storage step number is not exceeded, directly writing new historical state data; if the number of stored steps exceeds the maximum, removing the historical state data of the earliest step, and then saving the historical state data of the latest step, wherein the method can be realized by the following codes:
in an exemplary embodiment, assuming that the maximum number of stored steps of the configured history state data is 30 steps, respectively denoted by 1 and 2 …, if the number of steps of the history state data after writing the new history state data is greater than 30 steps, the history state data of the earliest step, i.e., step 1, is removed, and then the history state data of the latest step, i.e., step 31, is saved, and a schematic process of writing the history state data may be as shown in fig. 2.
In an exemplary embodiment, when the basic configuration information defined by the generic history class includes a synchronization number of intervals of history state data between the browser and the server, the internal attribute further includes: the number of asynchronous steps of the historical state data of the browser and server.
In one illustrative example, the number of unsynchronized steps of the historical state data of the browser and server may be expressed as "nosynctep: ".
In an exemplary embodiment, after the web application on the browser saves the history state data through the data writing interface provided by the general history class or after the web application deletes the saved history state data through the data deleting interface provided by the general history class, the method further includes:
when the number of the asynchronous steps of the browser and the server is not larger than the number of the synchronous steps of the interval of the history state data between the browser and the server, the browser acquires the time stamp of the latest history data stored by the browser and the time stamp of the latest history data stored by the server.
When the time stamp of the latest history data stored by the browser is earlier than the time stamp of the latest history data stored by the server, the browser synchronizes all the history data of itself with all the history data of the server.
When the time stamp of the latest historical data stored by the browser is later than that of the latest historical data stored by the server, the browser synchronizes all the historical data stored by the browser on the server.
In one illustrative example, synchronization is started each time new historical state data (i.e., push new historical state data) is written, the number of non-syncs (i.e., nosynctep) of the historical state data of the browser and the server is increased by 1, when the number of non-syncs (i.e., nosynctep) of the historical state data of the browser and the server is greater than the defined number of intervals (i.e., syncStep) of the historical state data between the servers, and if synchronization succeeds, the number of non-syncs (i.e., nosynctep) of the historical state data of the browser and the server is cleared to 0.
In an exemplary embodiment, the ajax request is adopted for synchronization, and MD5 verification is performed on historical state data on both sides of the browser and the server during each synchronization, so that the integrity of the data is ensured, and the historical state data is prevented from being tampered before synchronization.
In an exemplary embodiment, the historical state data on the earlier side of the timestamp of the latest historical data is overlaid with the historical state data on the later side of the timestamp of the latest historical data, so that on the one hand, the new historical state data can be backed up on the server side, and on the other hand, when the user changes the new browser, the operation that the user previously made on the old browser for the web application can be obtained by backing up the historical state data from the server side.
In one exemplary instance, the generic history class distinguishes historical state data of different instances of different web applications through web application identifications and instance identifications passed by the provided interface to preserve historical data for multiple instances of multiple web applications.
In one illustrative example, a generic history class may be applied to an instance by:
const appHistory=new History(key,{
information on the configuration
})
The embodiment of the application also provides a terminal c terminal, which comprises: the device comprises a memory and a processor, wherein the memory stores a program of a browser, and the program of the browser executes the method described in any embodiment.
Those of ordinary skill in the art will appreciate that all or some of the steps, systems, functional modules/units in the apparatus, and methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between the functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed cooperatively by several physical components. Some or all of the components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as known to those skilled in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Furthermore, as is well known to those of ordinary skill in the art, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media.

Claims (7)

1. A method of state management of a web application, comprising:
the web application on the browser stores historical state data through a data writing interface provided by the universal history class;
when the web application receives a state change instruction, acquiring stored historical state data through a data reading interface provided by the general history class and executing corresponding operation;
after the web application on the browser saves the history state data through the data writing interface provided by the general history class, the method further comprises the following steps:
the web application deletes the stored historical state data through a data deletion interface provided by the general history class;
the general history class is defined with basic configuration information and internal attribute information, when the basic configuration information defined by the general history class comprises the interval synchronization number of history state data between a browser and a server, the internal attribute comprises: an asynchronous number of historical state data for the browser and the server;
after the web application on the browser saves the historical state data through a data writing interface provided by the general history class or the web application deletes the saved historical state data through a data deleting interface provided by the general history class, the method further comprises the following steps:
when the number of the asynchronous steps of the browser and the server is larger than the number of the synchronous steps of the interval of the historical state data between the browser and the server, the browser acquires the time stamp of the latest historical data stored by the browser and the time stamp of the latest historical data stored by the server;
when the time stamp of the latest historical data stored by the browser is earlier than the time stamp of the latest historical data stored by the server, the browser synchronizes all historical data of the browser by using all historical data of the server;
when the time stamp of the latest historical data stored by the browser is later than the time stamp of the latest historical data stored by the server, the browser synchronizes all the historical data stored by the browser with the server.
2. The method of claim 1, wherein the state change instruction comprises at least one of: back to the last step of historical state data instruction, forward to the next step of historical state data instruction, obtain a back historical state instruction, and obtain a forward historical state instruction.
3. The method of claim 1, wherein the basic configuration information comprises at least one of: a storage mode of the historical state data of the web application, a maximum number of storage steps of the historical state data of the web application; wherein the storage mode includes: a memory Storage mode and a Storage mode.
4. A method according to claim 3, wherein the basic configuration information further comprises at least one of: an address of a server that remains synchronized with the browser, and an interval of historical state data between the browser and the server.
5. The method of claim 1, wherein the internal attribute information comprises at least one of: an index for pointing to current historical state data and a historical state data list; the historical state data list is used for storing the historical state data when the storage mode of the historical state data of the web application is a memory storage mode.
6. The method of any of claims 1-5, wherein the generic history class distinguishes between history state data of different instances of different web applications through web application identifications and instance identifications communicated by the provided interface to save history data for multiple instances of multiple web applications.
7. A terminal, comprising: a memory and a processor, the memory having stored therein a program of a browser, which when executed by the processor performs the method of any of claims 1-6.
CN202010313118.5A 2020-04-20 2020-04-20 State management method and device for web application Active CN111563219B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010313118.5A CN111563219B (en) 2020-04-20 2020-04-20 State management method and device for web application

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010313118.5A CN111563219B (en) 2020-04-20 2020-04-20 State management method and device for web application

Publications (2)

Publication Number Publication Date
CN111563219A CN111563219A (en) 2020-08-21
CN111563219B true CN111563219B (en) 2023-10-20

Family

ID=72070532

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010313118.5A Active CN111563219B (en) 2020-04-20 2020-04-20 State management method and device for web application

Country Status (1)

Country Link
CN (1) CN111563219B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101685451A (en) * 2008-09-27 2010-03-31 国际商业机器公司 Method for monitoring events in browser, event monitoring device and browser equipment
CN102654831A (en) * 2011-03-04 2012-09-05 百度在线网络技术(北京)有限公司 Device and method for intensively controlling WEB page event and state
CN105453520A (en) * 2013-07-15 2016-03-30 微软技术许可有限责任公司 Techniques to manage state information for a web service

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100005053A1 (en) * 2008-07-04 2010-01-07 Estes Philip F Method for enabling discrete back/forward actions within a dynamic web application

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101685451A (en) * 2008-09-27 2010-03-31 国际商业机器公司 Method for monitoring events in browser, event monitoring device and browser equipment
CN102654831A (en) * 2011-03-04 2012-09-05 百度在线网络技术(北京)有限公司 Device and method for intensively controlling WEB page event and state
CN105453520A (en) * 2013-07-15 2016-03-30 微软技术许可有限责任公司 Techniques to manage state information for a web service

Also Published As

Publication number Publication date
CN111563219A (en) 2020-08-21

Similar Documents

Publication Publication Date Title
US11799959B2 (en) Data processing method, apparatus, and system
US8250033B1 (en) Replication of a data set using differential snapshots
US11907078B2 (en) Data backup method, apparatus, and system
JP2005018738A (en) Method and apparatus for backup and recovery using storage based journaling
CN103197988A (en) Data backup and recovery method, device and database system
CN108595119B (en) Data synchronization method and distributed system
CN110647514A (en) Metadata updating method and device and metadata server
CN115599807A (en) Data access method, device, application server and storage medium
CN108304144B (en) Data writing-in and reading method and system, and data reading-writing system
CN111563219B (en) State management method and device for web application
CN113641446A (en) Memory snapshot creating method, device and equipment and readable storage medium
CN113190325A (en) Container creation method and device
CN110795031A (en) Data deduplication method, device and system based on full flash storage
CN103177026A (en) Data management method and data management system
CN109213444A (en) File memory method and device, storage medium, terminal
CN110955639A (en) Data processing method and device
CN113535477A (en) Method and equipment for data disaster recovery
CN110688258A (en) Snapshot creating method and device
CN107704208B (en) Method, device and medium for repairing metadata
CN112131433B (en) Interval counting query method and device
CN117539409B (en) Query acceleration method and device based on data cache, medium and electronic equipment
CN114442943B (en) Data migration method, system and equipment
CN117130871B (en) Parallel playback method and device for database logs and nonvolatile storage medium
CN116743781A (en) Data management method, data management device, and computer-readable storage medium
CN101158970A (en) Documentary processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant