CN111563219A - State management method and device for web application - Google Patents
State management method and device for web application Download PDFInfo
- Publication number
- CN111563219A CN111563219A CN202010313118.5A CN202010313118A CN111563219A CN 111563219 A CN111563219 A CN 111563219A CN 202010313118 A CN202010313118 A CN 202010313118A CN 111563219 A CN111563219 A CN 111563219A
- Authority
- CN
- China
- Prior art keywords
- data
- historical
- browser
- state data
- historical state
- 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.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/958—Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
- G06F9/449—Object-oriented method invocation or resolution
Abstract
A state management method and device for web applications comprise the following steps: the web application on the browser saves the historical state data through a data writing interface provided by a general 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. Because the web applications on the browser can write and acquire historical state data and operate corresponding to the state change instruction through the universal historical class, state management of all the web applications is realized by calling one class, and the state management of the web applications is facilitated.
Description
Technical Field
The present disclosure relates to web application management technologies, and in particular, to a method and an apparatus for managing a state of a web application.
Background
In real life, web browsers are now used to present more than just one web page. A web application is many times implemented with a web browser.
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 not to utilize the state management of the web application.
Disclosure of Invention
The application provides a state management method and device for web applications, which can enable all the 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 a web application, which comprises the following steps:
the web application on the browser saves the historical state data through a data writing interface provided by a general history class;
and 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.
After the web application on the browser saves the historical state data through a data writing interface provided by the general history class, the method further comprises the following steps:
and the web application deletes the stored historical state data through a data deletion interface provided by the universal history class.
The state change instruction includes at least one of: and returning to the previous historical state data instruction, advancing to the next historical state data instruction, obtaining a backward historical state instruction and obtaining an forward historical state instruction.
The general history class is defined with basic configuration information, and the basic configuration information comprises at least one of the following information: 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 comprises: a memory Storage mode and a Storage mode.
The basic configuration information further includes at least one of: the address of the server that is kept synchronized with the browser and the interval synchronization step count of the historical state data between the browser and the server.
The general history class is further defined with internal attribute information, and the internal attribute information comprises at least one of the following: 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 step number of the history state data between the browser and the server, the internal attribute further includes: unsynchronized steps of 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 a general history class, or after 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 unsynchronized step number of the browser and the server is larger than the interval synchronization step number of the historical state data between the browser and the server, the browser acquires a timestamp of the latest historical data stored by the browser and a timestamp of the latest historical data stored by the server;
when the timestamp of the latest historical data stored by the browser is earlier than the timestamp of the latest historical data stored by the server, the browser synchronizes all historical data of the browser with all historical data of the server;
and when the timestamp of the latest historical data stored by the browser is later than the timestamp of the latest historical data stored by the server, the browser synchronizes all the historical data stored by the browser on the server.
The universal history class distinguishes historical state data of different instances of different web applications by web application identifications and instance identifications passed through an interface provided to maintain historical data for multiple instances of multiple web applications.
The present application further provides a terminal, including: a memory in which a program of a browser is stored and a processor, the program of the browser executing the state management method of the web application as described in any one of the above when executed by the processor.
Compared with the related art, one of the technical solutions has the following advantages or beneficial effects: because the web applications on the browser can write and acquire historical state data and operate corresponding to the state change instruction through the universal historical class, state management of all the web applications is realized by calling one class, and the state management of the web applications 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 the practice of the application. The objectives and other advantages of the application may 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 present disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the examples serve to explain the principles of the disclosure and not to limit the disclosure.
Fig. 1 is a schematic flowchart 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 disclosure.
Detailed Description
The present application describes embodiments, but the description is illustrative rather than limiting 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 embodiments described herein. 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 instead of any other feature or element in any other embodiment, unless expressly limited otherwise.
The present application includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The embodiments, features and elements disclosed in this application may also be combined with any conventional features or elements to form a unique inventive concept as defined by the claims. Any feature or element of any embodiment may also be combined with features or elements from other inventive aspects to form yet another unique inventive aspect, as defined by the claims. Thus, it should be understood that any of the features shown and/or discussed in this application may be implemented alone or in any suitable combination. Accordingly, the embodiments are not limited except as by the appended claims and their equivalents. Furthermore, various modifications and changes may be made within the scope of the appended claims.
Further, 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 orders of steps are possible as will be understood by those of ordinary skill in the art. Therefore, the particular order of the steps set forth in the specification should not be construed as limitations on the claims. Further, 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.
An embodiment of the present application provides a state management method for a web application, as shown in fig. 1, the method includes:
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 to the interface each time the interface is called.
And 102, 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.
In an illustrative example, the data read interface provided by the generic history class may be named getAllData ().
According to the state management method for the web application, the web application on the browser can write and acquire historical state data and perform operation corresponding to the state change instruction through the universal historical class, so that all the web applications can realize state management by calling one class, and the state management of the web applications is facilitated.
In an exemplary embodiment, after the web application on the browser saves the historical state data through the data writing interface provided by the general history class, the method further comprises:
the web application deletes the saved historical state data through a data deletion interface provided by the generic history class.
In an 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: and returning to the previous historical state data instruction, advancing to the next historical state data instruction, obtaining a backward historical state instruction and obtaining an forward historical state instruction.
In one illustrative example, the rollback to previous historical state data instruction may be named goBack (); the proceed to next step historical state data instruction may be named goForward (); the instruction for obtaining the back history state can be named getBacktatus (), wherein the getBacktatus () has a return value and returns true or false, wherein true represents that back can be performed, and false represents that back cannot be performed; the get forward history state instruction may be named getForward status (), where getForward status () has a return value, either a true, which indicates that forward may be performed, or a false, which indicates that forward may not be performed.
In an exemplary embodiment, a web application on a browser saves historical state data through a data writing interface provided by a general history class, and when a user issues a command to back to the previous step of historical state data and the web application receives a state change command, the web application acquires the saved historical state data through a data reading interface provided by the general history class and performs corresponding operation so that the automatic state is backed to the previous step.
In one illustrative example, the generic history class is defined with basic configuration information including at least one of: the storage mode of the historical state data of the web application and the maximum storage step number of the historical state data of the web application are obtained; wherein the storage mode includes: a memory Storage mode and a Storage mode.
In an exemplary embodiment, the historical state data is stored in the memory by default, but if the data size of the historical state data is large or the user requires that the historical state data is not lost when the browser is refreshed or re-enters the application, the Storage can be selected for Storage.
In an illustrative example, the storage schema of the historical state data of the web application may be represented as "storageMode:" and the maximum number of storage steps of the historical state data of the web application may be represented as "maxSize:".
In one illustrative example, the basic configuration information further includes at least one of: the address of the server that is kept synchronized with the browser and the interval synchronization step count of the historical state data between the browser and the server.
In one illustrative example, the address of the server that is synchronized with the browser can be represented as "remoteAddress:", and the interval synchronization step number of the history state data between the servers can be represented as "syncStep:".
In one illustrative example, the generic history class further defines internal attribute information, the 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 used to point to the current historical state data may be represented as "historyIndex:", and the index used to point to the current historical state data and the historical state data list may be represented as "historyList [ ]".
In an exemplary example, the instruction to go back to the previous historical state data, i.e., gosack (), and the instruction to go forward to the next historical state data, i.e., goForward (), find the corresponding historical state data through the index, i.e., historyIndex, used for pointing to the current historical state data, e.g., when going back to the previous historical state data, the historyIndex is decreased by 1, and then the historical state data after being decreased by 1 is returned; adding 1 to the historyIndex when the historical state data of the next step is advanced, and then returning the historical state data after the historyIndex is added with 1; meanwhile, corresponding boundary judgment can be added, for example, when the boundary is exceeded, a null 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 general history class, i.e., the historical state data list; and if the selection historical state data is stored in the Storage, calling localforage to open a source component to store the data in the Storage, wherein localforage is judged according to the browser, and if the browser supports IndexDB, adopting IndexDB for Storage, wherein the IndexDB can break through the Storage size limit of 5M.
In an exemplary example, in a case where the substrate configuration information includes a maximum storage step number of history state data of the web application and an index for pointing to current history state data, the following determination is made every time the push method is executed: if the step number of the historical state data after the new historical state data is written in exceeds the maximum storage step number of the historical state data of the web application; if the maximum storage step number is not exceeded, directly writing new historical state data; if the maximum storage step number is exceeded, removing the historical state data of the earliest step, and then saving the historical state data of the latest step, which can be realized by the following codes:
in an exemplary example, assuming that the maximum storage step number of the configured historical state data is 30 steps, which are respectively represented by 1 and 2 … 30, if the step number of the historical state data after writing new historical state data is greater than 30 steps, the historical state data of the earliest step, namely the 1 st step, is removed, and then the historical state data of the latest step, namely the 31 st step, is saved, and the process diagram of writing the historical state data can be as shown in fig. 2.
In an exemplary embodiment, when the basic configuration information of the generic history class definition includes an interval synchronization step number of the history status data between the browser and the server, the internal attribute further includes: unsynchronized steps of historical state data of the browser and the server.
In an exemplary instance, the unsynchronized step count of the historical state data of the browser and server may be represented as "noSyncStep: ".
In an exemplary embodiment, after the web application on the browser saves the historical state data through a data writing interface provided by the general history class or after the web application deletes the saved historical state data through a data deleting interface provided by the general history class, the method further includes:
and when the unsynchronized step number of the browser and the server is larger than the interval synchronization step number of the historical state data between the browser and the server, the browser acquires the timestamp of the latest historical data stored by the browser and the timestamp of the latest historical data stored by the server.
And when the timestamp of the latest historical data stored by the browser is earlier than the timestamp of the latest historical data stored by the server, the browser synchronizes all historical data of the browser with all historical data of the server.
And when the timestamp of the latest historical data stored by the browser is later than the timestamp of the latest historical data stored by the server, the browser synchronizes all the historical data stored by the browser on the server.
In an exemplary embodiment, the unsynchronized step count (i.e., noSyncStep) of the history state data of the browser and the server is increased by 1 each time new history state data (i.e., push new history state data) is written, and when the unsynchronized step count (i.e., noSyncStep) of the history state data of the browser and the server is greater than a defined interval synchronization step count (i.e., syncStep) of the history state data between the servers, synchronization is started, and if the synchronization is successful, the unsynchronized step count (i.e., noSyncStep) of the history state data of the browser and the server is cleared by 0.
In an illustrative example, synchronization adopts ajax request, and MD5 verification is carried out on historical state data on both sides of a browser and a server during each synchronization, so that the integrity of the data is guaranteed, and the historical state data is prevented from being tampered before synchronization.
In an exemplary instance, the historical state data on the earlier-time-stamped side of the latest historical data is overwritten with the historical state data on the later-time-stamped side of the latest historical data, so that the new historical state data can be backed up on the server side on the one hand, and the operation of the user on the web application previously made on the old browser can be obtained by backing up the historical state data from the server side when the user changes the new browser on the other hand.
In an exemplary embodiment, the universal history class distinguishes historical state data of different instances of different web applications by a web application identification and an instance identification communicated through an interface provided to maintain historical data for multiple instances of multiple web applications.
In one illustrative example, a generic history class may be applied to an instance by the following, where a key represents a unique identification of the current instance:
const appHistory=new History(key,{
// configuration information
})
The embodiment of the present application further provides a terminal c, including: a memory in which a program of a browser is stored and a processor, which when executed by the processor performs the method as described in any of the embodiments above.
It will be understood by those of ordinary skill in the art that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between 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 by several physical components in cooperation. 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 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 is well known to those of ordinary skill 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 accessed by a computer. In addition, 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 as known to those skilled in the art.
Claims (10)
1. A method of state management for a web application, comprising:
the web application on the browser saves the historical state data through a data writing interface provided by a general history class;
and 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.
2. The method of claim 1, wherein after the web application on the browser saves the historical state data via a data write interface provided by a generic history class, further comprising:
and the web application deletes the stored historical state data through a data deletion interface provided by the universal history class.
3. The method of claim 1, wherein the state change instruction comprises at least one of: and returning to the previous historical state data instruction, advancing to the next historical state data instruction, obtaining a backward historical state instruction and obtaining an forward historical state instruction.
4. The method of claim 2, wherein the generic history class defines basic configuration information, the basic configuration information comprising 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 comprises: a memory Storage mode and a Storage mode.
5. The method of claim 4, wherein the basic configuration information further comprises at least one of: the address of the server that is kept synchronized with the browser and the interval synchronization step count of the historical state data between the browser and the server.
6. The method of claim 4, wherein the generic history class further defines internal attribute information, the internal attribute information comprising 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.
7. The method according to claim 6, wherein when the basic configuration information of the generic history class definition includes the interval synchronization step number of the history status data between the browser and the server, the internal attribute further includes: unsynchronized steps of historical state data of the browser and the server.
8. The method of claim 7, wherein after the web application on the browser saves the historical state data through a data write interface provided by a general history class or after the web application deletes the saved historical state data through a data delete interface provided by the general history class, the method further comprises:
when the unsynchronized step number of the browser and the server is larger than the interval synchronization step number of the historical state data between the browser and the server, the browser acquires a timestamp of the latest historical data stored by the browser and a timestamp of the latest historical data stored by the server;
when the timestamp of the latest historical data stored by the browser is earlier than the timestamp of the latest historical data stored by the server, the browser synchronizes all historical data of the browser with all historical data of the server;
and when the timestamp of the latest historical data stored by the browser is later than the timestamp of the latest historical data stored by the server, the browser synchronizes all the historical data stored by the browser on the server.
9. The method of any of claims 1-8, wherein the generic history class distinguishes historical state data for different instances of different web applications by a web application identification and an instance identification passed through an interface provided to maintain historical data for multiple instances of multiple web applications.
10. A terminal, comprising: a memory in which a program of a browser is stored and a processor, which when executed by the processor performs the method according to any one of claims 1-9.
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 true CN111563219A (en) | 2020-08-21 |
CN111563219B 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 (4)
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 |
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 |
-
2020
- 2020-04-20 CN CN202010313118.5A patent/CN111563219B/en active Active
Patent Citations (4)
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 |
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 |
---|---|
CN111563219B (en) | 2023-10-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11157370B2 (en) | Consistent backup of a distributed database system | |
CN111506251B (en) | Data processing method and device, SMR storage system and storage medium | |
CN108460045B (en) | Snapshot processing method and distributed block storage system | |
US11907078B2 (en) | Data backup method, apparatus, and system | |
CN103197988A (en) | Data backup and recovery method, device and database system | |
CN109614055B (en) | Snapshot creating method and device, electronic equipment and machine-readable storage medium | |
CN111651127A (en) | Monitoring data storage method and device based on shingled magnetic recording disk | |
KR101674176B1 (en) | Method and apparatus for fsync system call processing using ordered mode journaling with file unit | |
CN103268291A (en) | Method for delaying persistent indexing metadata in flash memory storage system | |
CN114721594A (en) | Distributed storage method, device, equipment and machine readable storage medium | |
CN108304144B (en) | Data writing-in and reading method and system, and data reading-writing system | |
CN113190325A (en) | Container creation method and device | |
CN111563219A (en) | State management method and device for web application | |
CN110795031A (en) | Data deduplication method, device and system based on full flash storage | |
CN103177026A (en) | Data management method and data management system | |
CN113687783B (en) | Object aggregation method, system, device and computer storage medium | |
CN109213444A (en) | File memory method and device, storage medium, terminal | |
CN110162534B (en) | Data management method and data storage system | |
CN114647658A (en) | Data retrieval method, device, equipment and machine-readable storage medium | |
CN114217741A (en) | Storage method of storage device and storage device | |
CN108959501B (en) | Method and device for deleting ES index | |
CN110879762A (en) | Cloud backup deleting method and locally-stored cloud backup deleting method | |
CN113849574A (en) | Data processing method, front end and computer readable storage medium | |
CN117539409B (en) | Query acceleration method and device based on data cache, medium and electronic equipment | |
CN115774740B (en) | Database snapshot query method, system and storage medium |
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 |