WO2017050145A1 - Method and device for executing web app under complete state mode - Google Patents
Method and device for executing web app under complete state mode Download PDFInfo
- Publication number
- WO2017050145A1 WO2017050145A1 PCT/CN2016/098813 CN2016098813W WO2017050145A1 WO 2017050145 A1 WO2017050145 A1 WO 2017050145A1 CN 2016098813 W CN2016098813 W CN 2016098813W WO 2017050145 A1 WO2017050145 A1 WO 2017050145A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- state
- class
- web app
- state class
- edit
- Prior art date
Links
Images
Classifications
-
- 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
Definitions
- the present application relates to the field of computer technology, and in particular, to a method for executing a full state mode web app and a device for executing a full state mode web app.
- a web app is an application that is accessed through a network (such as the Internet or an intranet); it can also mean that the computer software is hosted in a browser-supported environment or uses a browser-supported language (such as JavaScript, scripts) and relies on a web browser. Rendered application.
- the popularity of web apps is due to the popularity of web browsers and the user experience of using this thin and light client. Updates and maintenance can be implemented without having to download and install. It has the intrinsic properties of supporting cross-platform, which is the key reason why web apps are popular. Typical web app products include web mailboxes, web stores, wikis, and more. To implement the web app, the following key conditions must be met:
- the web app must provide an interface for the user to display data and user operations.
- the web app is edited and saved in a class, in which it is not necessary to first determine which part of the keyboard event and mouse event is enabled, and which part of the keyboard event and the mouse event are disabled, and save it.
- the behavior also needs to first determine which part of the keyboard event and mouse event is enabled, and which part of the keyboard event and mouse event are disabled.
- the editing behavior and the saving behavior are coupled to the judgment of the keyboard and mouse events, and the code amount is large.
- embodiments of the present application have been made in order to provide a method for executing a full state mode web app and a corresponding device for executing a full state mode web app that overcomes the above problems or at least partially solves the above problems. .
- the present application discloses a method for executing a full state mode web app, which includes:
- the web app is divided into states according to the attributes that determine the behavior change of the web app, and corresponding state classes are set for each state; wherein each state class includes related behaviors of the corresponding states, and states for state class jumps. Conversion logic
- the web app object executes a state class
- the related behavior of the state is executed, and according to the state transition logic of the state class, the web app object is jumped from the currently executed state class.
- Another state class corresponding to the state transition logic is executed.
- an apparatus for executing a full state mode web app including:
- a preset module configured to divide the web app into states according to attributes that determine changes in web app behavior, and set corresponding state classes for each state; wherein each state class includes related behaviors of corresponding states, and is used for State transition logic for state class jumps;
- a state execution module configured to: when a web app object executes a state class, perform a related behavior of the state in a state of the state class, and execute a web app object from the current state according to state transition logic of the state class The state class jumps to execute another state class corresponding to the state transition logic.
- the present application also discloses a full state mode web app, including:
- a state execution module configured to: when a web app object executes a state class, perform a related behavior of the state in a state of the state class, and execute a web app object from the current state according to state transition logic of the state class a state class that jumps to execute another state class corresponding to the state transition logic; wherein each state class is set according to a state of the web app, and the state of the web app is divided according to an attribute that determines a change in web app behavior Where each state class includes The relevant behavior of the corresponding state, as well as the state transition logic used for state class jumps.
- the embodiment of the present application divides the web app into states according to the attributes that determine the behavior change of the web app, and sets corresponding state classes for each state, each state class includes related behaviors of the corresponding states, and is used for state class jumps.
- the state transition logic, each state class is parallel and independent of each other.
- each state class of the web app object is executed independently, and does not intersect with other states. Therefore, the embodiment of the present application can run in a full state mode for the web app, and the conditional judgment block in the code is small, that is, the number of conditional judgment statements is small, dispersed into a specific state class, and the coupling is low.
- FIG. 1 is a flow chart showing the steps of a method embodiment of a web app executing a full state mode of the present application
- FIG. 2 is a flow chart showing the steps of another method embodiment of a web app executing a full state mode of the present application
- 2A is a diagram showing relationship between a state class and a base class and an environment class related to an implementation state class according to an embodiment of the present application;
- FIG. 2B is a diagram showing a conversion relationship of each state class in the embodiment of FIG. 2 in the embodiment of the present application;
- FIG. 3 is a flow chart showing the steps of another method embodiment of a web app executing a full state mode of the present application
- FIG. 3A is a diagram showing a conversion relationship of each state class in the embodiment of FIG. 3 according to an embodiment of the present application;
- FIG. 3B is an example of a pop-up window of the embodiment of FIG. 3 according to an embodiment of the present application.
- FIG. 4 is a structural block diagram of an apparatus embodiment of a web app executing a full state mode of the present application
- FIG. 5 is a structural block diagram of another apparatus embodiment of a web app executing a full state mode of the present application
- FIG. 6 is a structural block diagram of another apparatus embodiment of a web app executing a full state mode of the present application
- FIG. 7 is a structural block diagram of an embodiment of a full state mode web app of the present application.
- One of the core concepts of the embodiments of the present application is that, based on the state mode, the web app is divided into states according to attributes that determine the behavior change of the web app, and corresponding state classes are set for each state, and each state class includes a corresponding state. Related behavior, as well as state transition logic for state class jumps.
- each state class of the web app object is executed independently and does not intersect with other states. Therefore, the embodiment of the present application can run in the full state mode for the web app, and the condition judgment block in the code is small, dispersed into a specific state class, and the coupling is low.
- the new state can be easily added without a large amount of modification of the original code, and the scalability is high.
- the state mode is described as follows: In many cases, the behavior of an object depends on one or more dynamically changing attributes, the attribute is called a state, the object is called a stateful object, and the object state is Taken from a set of values defined in advance.
- a stateful object performs an action in the state class, it interacts with an external event, and then according to the state transition logic in that state, the object's internal state changes to another state, and the object performs the corresponding other The state class, so that the behavior of the object changes.
- FIG. 1 a flow chart of steps of a method for performing a full-state mode web app of the present application is shown, which may specifically include the following steps:
- Step 110 pre-determining the web app according to the attribute that determines the behavior change of the web app
- Each state and setting a corresponding state class for each state; wherein each state class includes a related behavior of the corresponding state, and state transition logic for the state class jump;
- the state refers to an attribute value of an attribute of a web app object instance
- the behavior refers to a function of a web object
- the behavior can be understood as a method.
- the method function activateKeyboard() is the behavior of enabling keyboard events.
- each state class includes related behaviors of the corresponding states, and state transition logic for state class jumps.
- the state class is, for example, an initial state class, a load state class, an edit state class, and a save state class.
- the state class may be divided according to actual needs, and may include any class, which is not limited in the embodiment of the present application.
- Each state transition logic triggers a jump of the state class according to a specific behavior in the corresponding state.
- Step 120 When the web app object executes a certain state class, in the state of the state class, the related behavior of the state is executed, and according to the state transition logic of the state class, the web app object is from the currently executed state class. The jump is to execute another state class corresponding to the state transition logic.
- a web app object can be created, which can be understood as an instance of the web app. Then set a start state class for the web app object, then the web app object can first execute the initial set state class, and then execute the state class related behavior, in the execution process, according to the state class State transition logic that jumps the web app object to execute another state class. Then, after the jump, the web app object executes the related behavior of the other state class, and jumps to execute the next state class according to the state transition logic of the state class during execution. Other cases and so on.
- step 110 may be preset offline, and step 120 is performed in a browser.
- the embodiment of the present application divides the web app into states according to the attributes that determine the behavior change of the web app, and sets corresponding state classes for each state, each state class includes related behaviors of the corresponding states, and is used for state class jumps. State transition logic, each state class The two are parallel and independent of each other.
- each state class of the web app object is executed independently and does not intersect with other states. Therefore, the embodiment of the present application can run in a full state mode for the web app, and the conditional judgment block in the code is small, that is, the number of conditional judgment statements is small, dispersed into a specific state class, and the coupling is low.
- the embodiment of the present application divides the state class into at least the following state classes: an initial state class, a load state class, an edit state class, and a save state class to perform the implementation of the present application.
- the process of the example is a state class that divides the state class into at least the following state classes: an initial state class, a load state class, an edit state class, and a save state class to perform the implementation of the present application. The process of the example.
- FIG. 2 a flow chart of steps of a method for performing a full-state mode web app of the present application is shown. Specifically, the method may include the following steps:
- Step 210 Pre-determine the web app into states according to the attributes that determine the behavior change of the web app, and set a corresponding state class for each state;
- the state class includes: an initial state class, a loading state class, an editing state class, and a save. a state class; wherein each state class includes a related behavior of the corresponding state, and state transition logic for the state class jump;
- the state refers to an attribute value of an attribute of a web app object instance
- the behavior refers to a function of a web object
- the behavior can be understood as a method.
- the method function activateKeyboard() is the behavior of enabling keyboard events.
- a web app may be divided into multiple state classes according to its logic, such as an initial state class, a load state class, an edit state class, a save state class, and each state class includes a corresponding state.
- an initial state class such as a load state class, an edit state class, a save state class, and each state class includes a corresponding state.
- Related behavior such as well as state transition logic for state class jumps.
- each state transition logic triggers a state class according to a specific behavior in the corresponding state Jump.
- the related behavior of the initialization state class may include: allocating space for various variables of the web app, assigning initial values to various variables, initializing a mouse, a keyboard, a network, and other asynchronous processing events, initializing an interface, etc., the first state thereof
- the conversion logic can include jumping to the execution load state class after assigning an initial value to all variables.
- the related behavior of the loading state class may include: loading various information, rendering a main interface of the web app, obtaining context data transmitted from the previous state, and the like, and the second state transition logic may include: a master in the web app After the interface is rendered, jump to the execution edit state class.
- the related behaviors of the editing state class may include: enabling a keyboard event, enabling a mouse event, receiving an event of clicking a save button, obtaining context data transmitted from a previous state, closing a web app, and the like, and the third state thereof.
- the conversion logic may include jumping to the execution save state class after receiving a click event on the save button.
- the related behavior of saving the state class may include: saving the content in the current web app to the storage area, canceling the save operation (eg, receiving the esc event), acquiring the context data transmitted from the previous state, and the fourth state transition.
- the logic may include jumping to the execution edit state class after the save is completed or after receiving the cancel save operation.
- FIG. 2A the embodiment of the present application can be set as shown in FIG. 2A:
- Context An interface that defines business logic, such as Request() in Figure 2A. Maintain an instance of a state class that generates a web app object.
- each state class inherits the above base class, that is, each state class is a subclass of the base class, and each state class implements a state with the Context.
- the state class includes an initial state class, a load state class, an edit state class, and a save state class.
- Step 220 Set the web app object to an initialization state according to the initial state class, perform an initialization state related behavior in a web app object in an initialization state, and jump the web app object to execution according to the first state transition logic.
- Load state class
- the generated web app object executes the initial state class. At this time, the properties of the web app are in the initial state.
- the related behaviors of various initial states encapsulated in the initial state class are executed, such as allocating space for various variables of the web app, assigning initial values to various variables, and the like. And after executing a specific behavior, jump to the execution load state class, as described above, after assigning an initial value to all variables, jump to the execution load state class.
- Step 230 Perform a related behavior of the loading state in the web app object in the loading state, and jump the web app object to the execution editing state class according to the second state transition logic;
- the related behavior of the loaded state encapsulated in the loaded state class is executed. Load various information as described above, render the main interface of the web app, and so on. And after executing a specific behavior, jump to the execution edit state class, as described above, after the main interface of the web app is rendered, jump to the execution edit state class.
- Step 240 in the edit state of the web app object, perform the relevant behavior of the edit state, and jump the web app object to the execution save state class according to the third state transition logic;
- the related behavior of the edit state encapsulated in the load state class is executed.
- jump to the execution save state class for example, after receiving the click event on the save button, jump to the execution save state class.
- the editing status class can encapsulate various interactions with the outside world, and the behavior can be encapsulated according to actual needs, which is not limited in this application.
- Step 250 Perform a related behavior of saving the state in the web app object in the saved state, and jump the web app object to the execution editing state class according to the fourth state transition logic.
- the related behavior of saving the state of the package encapsulated in the state class is executed. Save the contents of the current web app to the storage area as described above, cancel the save operation (eg, receive the esc event), and so on. And after executing a specific behavior, jump to the execution save state class, such as after the save is completed or after receiving the cancel save operation, jump to the execution edit state class.
- step 210 can be preset offline, while steps 220-250 are performed in the browser.
- the web app is divided into states according to attributes that determine the behavior change of the web app, and corresponding state classes are set for each state, that is, an initialization state class, a load state class, an edit state class, and a save state class.
- the state class includes the related behavior of the corresponding state, and the state transition logic for the state class jump.
- Each state class is parallel and independent of each other.
- each state class of the web app object is independent. Execution does not intersect with other states. Therefore, the embodiment of the present application can run in the full state mode for the web app, and the condition judgment block in the code is small, dispersed into a specific state class, and the coupling is low.
- the present application also provides a preferred embodiment:
- FIG. 3 a flow chart of steps of a method for performing a full-state mode web app of the present application is shown. Specifically, the method may include the following steps:
- Step 310 pre-determine the web app into states according to the attributes that determine the behavior change of the web app, and set a corresponding state class for each state;
- the state class includes: an initial state class, a loading state class, an editing state class, and a save.
- a state class at least one pop-up window state class; wherein each state class includes a related behavior of the corresponding state, and state transition logic for the state class jump;
- the present application can separately set a pop-up window state class for each pop-up window.
- a corresponding fifth state transition logic is set, and after receiving the corresponding operation in the main page, the web app object is jumped to execute the corresponding Popup window status class.
- the embodiment of the present application further includes:
- Step 302 Add a sticky attribute to the edit state class, and the sitcky attribute is used to edit the interface state corresponding to the edit state when the edit state class of the web app object is jumped to execute other state classes.
- the main page does not exist. It may mislead the user that the web app has a problem and affect the visibility of the interface. It is not convenient for the user to view information other than the pop-up portion of the main page. Then the application adds a sticky attribute, which ensures that the editing state jumps to other state classes, and the UI interface of the main interface is still displayed.
- the stickey attribute is implemented through the interface of the base class. If a state class has the value of the sticky attribute set to 1, the status class is not cleaned, and the interface element corresponding to the edit state is retained, such as a reserved map. 3B web app's pop-up window "new bucket" after the web app main page.
- the sticky attribute is set to 1 when the editing state class is executed, and other state classes can set the value to null.
- the base class is as follows:
- Step 320 Set the web app object to an initialization state according to the initial state class, perform an initialization state related behavior in a web app object in an initialization state, and jump the web app object to execute according to the first state transition logic.
- Load state class
- This step is similar to step 220 of the embodiment of FIG. 2 and will not be described here.
- Step 330 Perform a related behavior of the loading state in the web app object in the loading state, and jump the web app object to the execution editing state class according to the second state transition logic;
- This step is similar to step 330 of the embodiment of FIG. 2 and will not be described here.
- Step 340 in the edit state of the web app object, perform the relevant behavior of the edit state, and jump the web app object to execute the corresponding pop-up window state according to each fifth state transition logic, and the web app according to the third state transition logic
- the object jumps to the execution save state class
- windowPopup1State there are two pop-up window states after the edit state, namely windowPopup1State and windowPopup1State.
- the fifth state transition logic may be: when receiving the user's click operation on the bucket management bar, a new bucket window pops up, and the property of the web app object becomes a popup window.
- the state windowPopup1State If it is corresponding to the resource monitoring report column, the fifth state transition logic may be: when the user clicks on the resource monitoring report column, the property of the web app object of the resource monitoring report window is changed to the popup window state windowPopup1State.
- the step 340 further includes:
- This interface element can be understood as the main page of the web app.
- the embodiment of the present application further includes:
- step 342 in the edit state class, it is determined whether the web app object is jumped from the edit state class to the popup window state class; if it is jumped to the popup window state, the interface element corresponding to the edit state is retained.
- the object of the jump when jumping to other states in the editing state class, the object of the jump may also be determined. If the object to be jumped is not the state of the popup window, the editing state is cleared. For example, if the object to be jumped is saved, the sticky is set to null, and then the state of the web app is changed to the saved state, and the edit state is cleared.
- the interface element corresponding to the edit state is retained. For example, if the object of the jump is saved, the sticky is set to 1, and then the state of the web app is changed to the saved state, the edit state will not be completely cleaned, and the main page of the web app will be retained.
- Step 350 in the pop-up window state class, performs a related behavior of the pop-up window state class, and jumps the web app object to the execution edit state class according to the seventh state transition logic.
- the related behavior of the popup window state encapsulated in the popup window state class is executed.
- the windowPopup1State extends State of FIG. 3B, the mask is covered by the mask, and the user is not allowed. The act of performing an action that allows the user to perform actions such as inputting, submitting, canceling, and the like.
- a seventh state transition logic is also provided for jumping the state of the web app object from the pop-up window state to the edit state to perform various operations of the edit state class.
- the popup window state windowPopup1State extends State
- the seventh logic may be that when a click operation on the submit button is received or a click operation on the cancel button is received, the web app object is jumped to the execution edit state class. .
- Step 360 Perform a related behavior of saving the state in the web app object in the saved state, and jump the web app object to the execution editing state class according to the fourth state transition logic.
- This step is similar to step 250 of the embodiment of FIG. 2 and will not be described here.
- step 310 can be preset offline without being executed in the browser at 320-360.
- the embodiment of the present application divides the web app into states according to the attributes that determine the behavior change of the web app, and sets corresponding state classes for each state, each state class includes related behaviors of the corresponding states, and is used for state class jumps.
- the state transition logic, each state class is parallel and independent of each other.
- each state class of the web app object is executed independently, and does not intersect with other states. Therefore, the embodiment of the present application can run in the full state mode for the web app, and the condition judgment block in the code is small, dispersed into a specific state class, and the coupling is low.
- the editing and saving of the web app set the editing state class and the saving state class respectively, and directly enable the keyboard events and rats needed in the editing state class.
- the embodiment of the present application separates the pop-up window state from the edit state, and further decouples the web app.
- the following is a code example to discuss the principle that the extracted pop-up window state can be further decoupled:
- the pop-up window and other business logic are placed together in the edit state, the mask will be used to cover the content area at the bottom, and the user is not allowed to operate (as described in 2 of Figure 3B), but the user can actually pass The tab navigation shortcuts operate, and the web app cannot distinguish whether the operation is legal.
- there are two pop-up windows and both windows have to disable certain keyboard and mouse events, and then enable some keyboard and mouse events, and there is a coupling between the two and the external code.
- the window needs to be processed asynchronously, so there will be a lot of asynchronous processing code in the code, which increases the code coupling and increases the development difficulty.
- each pop-up window is independently a pop-up window state class
- the pseudo-codes of the edit state class, the pop-up window state class 1 and the pop-up window state class 2 are as follows:
- FIG. 4 a structural block diagram of an apparatus embodiment of a web app executing a full state mode of the present application is shown, which may specifically include the following modules:
- the preset module 410 is configured to divide the web app into states according to the attributes that determine the behavior change of the web app, and set corresponding state classes for each state; wherein each state class includes related behaviors of the corresponding states, and State transition logic for state class jumps;
- the state execution module 420 is adapted to perform a related behavior of the state in a state of the state class when the web app object executes a certain state class, and according to the state transition logic of the state class, the web app object is from the current state
- the executed state class jumps to execute another state class corresponding to the state transition logic.
- the embodiment of the present application divides the web app into states according to the attributes that determine the behavior change of the web app, and sets corresponding state classes for each state, each state class includes related behaviors of the corresponding states, and is used for state class jumps.
- the state transition logic, each state class is parallel and independent of each other.
- each state class of the web app object is executed independently, and does not intersect with other states. Therefore, the embodiment of the present application can run in a full state mode for the web app, and the conditional judgment block in the code is small, that is, the number of conditional judgment statements is small, dispersed into a specific state class, and the coupling is low.
- FIG. 5 there is shown a device for executing a full state mode web app of the present application.
- the structural block diagram of the embodiment may specifically include the following modules:
- the preset module 510 is configured to divide the web app into states according to the attributes that determine the behavior change of the web app, and set a corresponding state class for each state;
- the state class includes: an initial state class, a loading state class, and an editing State class, save state class; wherein each state class includes related behaviors of the corresponding state, and state transition logic for state class jumps;
- the state execution module 520 specifically includes:
- An initialization state module 521 configured to set the web app object to an initialization state according to the initial state class, perform an initialization state related behavior in a web app object in an initialization state, and convert the web app object according to the first state transition logic Jump to execute the load state class;
- the loading status module 522 is configured to execute a related behavior of the loading state in the web app object in the loading state, and jump the web app object to the execution editing state class according to the second state transition logic;
- the editing state module 523 is configured to execute a related behavior of the editing state in the web app object in the editing state, and jump the web app object to the execution saving state class according to the third state transition logic;
- the save state module 524 is configured to execute a related behavior of saving the state in the web app object in the saved state, and jump the web app object to execute the edit state class according to the fourth state transition logic.
- the web app is divided into states according to attributes that determine the behavior change of the web app, and corresponding state classes are set for each state, that is, an initialization state class, a load state class, an edit state class, and a save state class.
- the state class includes the related behavior of the corresponding state, and the state transition logic for the state class jump.
- Each state class is parallel and independent of each other.
- each state class of the web app object is independent. Execution does not intersect with other states. Therefore, the embodiment of the present application can run in the full state mode for the web app, and the condition judgment block in the code is small, dispersed into a specific state class, and the coupling is low.
- FIG. 6 there is shown another apparatus for executing a full state mode web app of the present application.
- the structural block diagram of the embodiment may specifically include the following modules:
- the preset module 610 is configured to divide the web app into states according to the attributes that determine the behavior change of the web app, and set a corresponding state class for each state;
- the state class includes: an initial state class, a loading state class, and an editing a state class, a save state class, and at least one popup window state class; wherein each state class includes a related behavior of the corresponding state, and state transition logic for the state class jump;
- the preset module 410 is further configured to: add a sticky attribute to the edit state class, where the sitcky attribute is used to edit the state of the web app object to perform other state classes. When you save the interface element corresponding to the editing state.
- the state transition logic triggers a jump of the state class according to one or more specific behaviors in the corresponding state.
- the status execution module 620 specifically includes:
- An initialization state module 621 configured to set the web app object to an initialization state according to the initial state class, perform an initialization state related behavior in a web app object in an initialization state, and convert the web app object according to the first state transition logic Jump to execute the load state class;
- the loading status module 622 is configured to execute a related behavior of the loading state in the web app object in the loading state, and jump the web app object to perform a corresponding pop-up window state according to each fifth state transition logic, and convert according to the second state Logic jumps the web app object to execute the edit state class;
- the editing status module 623 is configured to execute a related behavior of the editing state in the web app object in the editing state, and jump the web app object to the execution saving state class according to the third state transition logic;
- the edit status module 440 is further configured to:
- a pop-up window status module 624 configured to execute a related behavior of the pop-up window state class in the pop-up window state class, and jump the web app object to execute the edit state according to the seventh state transition logic State class.
- the save state module 625 is configured to execute a related behavior of saving the state in the web app object in the saved state, and jump the web app object to execute the edit state class according to the fourth state transition logic.
- the embodiment of the present application divides the web app into states according to the attributes that determine the behavior change of the web app, and sets corresponding state classes for each state, each state class includes related behaviors of the corresponding states, and is used for state class jumps.
- the state transition logic, each state class is parallel and independent of each other.
- each state class of the web app object is executed independently, and does not intersect with other states. Therefore, the embodiment of the present application can run in the full state mode for the web app, and the condition judgment block in the code is small, dispersed into a specific state class, and the coupling is low.
- the embodiment of the present application separates the state of each pop-up window from the editing state, further decouples the web app, and can easily shield the user from operating on the bottom content area in the pop-up window state, thereby greatly reducing development. Difficulty.
- FIG. 7 a structural block diagram of an embodiment of a full state mode web app of the present application is shown, which may specifically include the following modules:
- the state execution module 710 is adapted to perform a related behavior of the state in a state of the state class when the web app object executes a certain state class, and according to the state transition logic of the state class, the web app object is from the current state Executing a state class, jumping to perform another state class corresponding to the state transition logic; wherein each state class is set according to a state of the web app, and the state of the web app is performed according to an attribute determining a behavior change of the web app Division; where each state class includes the associated behavior of the corresponding state, and state transition logic for state class jumps.
- the web app may be divided into states according to attributes that determine the behavior change of the web app, and corresponding state classes are set for each state, where each state class includes related behaviors of the corresponding states. And state transition logic for state class jumps so that you can build a web app.
- the state execution module 710 can then be obtained.
- a web app object creation module may also be included for Create a web app object when you move the web app.
- a start state assignment module can also be included for assigning a web application object to the initial state class.
- the state transition logic triggers a jump of the state class according to one or more specific behaviors in the corresponding state.
- the state class includes: an initial state class, a load state class, an edit state class, and a save state class;
- the state execution module 710 includes:
- An initialization state module configured to set the web app object to an initialization state according to the initial state class, perform an initialization state related behavior in a web app object in an initialization state, and jump the web app object according to the first state transition logic Go to the execution load state class;
- a loading state module configured to execute a related behavior of the loading state in the web app object in the loading state, and jump the web app object to an execution editing state class according to the second state transition logic
- Editing a state module configured to perform an edit state related behavior in a web app object in an edit state, and jump the web app object to an execution save state class according to the third state transition logic;
- the save state module is configured to execute a related behavior of saving the state in the web app object in the saved state, and jump the web app object to execute the edit state class according to the fourth state transition logic.
- the status class further includes: at least one popup window status class;
- the edit status module is further configured to:
- the web app object is jumped to execute the corresponding popup state according to each fifth state transition logic.
- the method further includes:
- a pop-up window status module is configured to execute a related behavior of the pop-up window state class in the pop-up window state class, and jump the web app object to an execution edit state class according to the seventh state transition logic.
- the edit state class further includes a sticky attribute, and the sitcky attribute is used to edit the edit state class of the web app object to retain the edit state when executing other state classes. Interface elements.
- the edit status module is further configured to:
- the embodiment of the present application divides the web app into states according to the attributes that determine the behavior change of the web app, and sets corresponding state classes for each state, each state class includes related behaviors of the corresponding states, and is used for state class jumps.
- the state transition logic, each state class is parallel and independent of each other.
- each state class of the web app object is executed independently, and does not intersect with other states. Therefore, the embodiment of the present application can run in a full state mode for the web app, and the conditional judgment block in the code is small, that is, the number of conditional judgment statements is small, dispersed into a specific state class, and the coupling is low.
- the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.
- embodiments of the embodiments of the present application can be provided as a method, apparatus, or computer program product. Therefore, the embodiments of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Moreover, embodiments of the present application may employ computer usable storage media in one or more of the computer usable program code embodied therein. A form of computer program product implemented on a quality (including but not limited to disk storage, CD-ROM, optical storage, etc.).
- the computer device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
- the memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory.
- RAM random access memory
- ROM read only memory
- Memory is an example of a computer readable medium.
- Computer readable media includes both permanent and non-persistent, removable and non-removable media.
- Information storage can be implemented by any method or technology. The information can be computer readable instructions, data structures, modules of programs, or other data.
- Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory. (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disk read only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transportable media can be used to store information that can be accessed by a computing device.
- computer readable media does not include non-persistent computer readable media, such as modulated data signals and carrier waves.
- Embodiments of the present application are described with reference to flowcharts and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG.
- These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing terminal device to produce a machine such that instructions are executed by a processor of a computer or other programmable data processing terminal device
- Means are provided for implementing the functions specified in one or more of the flow or in one or more blocks of the flow chart.
- the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
- Instruction device implemented in a flowchart A function specified in a block or blocks of a process or multiple processes and/or block diagrams.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
Provided are a method for executing a web app under a complete state mode, a device for executing a web app under a complete state mode and an APP under a complete state mode, which relate to the technical field of computers. The method comprises: pre-dividing a web app into various states according to attributes which determine the behaviour change of the web app, and setting corresponding state classes for the various states, wherein each of the state classes comprises a related behaviour of a corresponding state and a state transition logic for state class jumping; and when a web app object executes a certain state class, in the state of the state class, executing the related behaviour of the state, and according to the state transition logic of the state class, the web app object jumping from the current executed state class to another state class corresponding to the state transition logic for execution. In the present application, a web app can run under a complete state mode, conditional judgement blocks in codes of the web app are small, and are dispersed into specific state classes, and therefore the coupling is low.
Description
本申请涉及计算机技术领域,特别是涉及一种执行完全状态模式的web app的方法和一种执行完全状态模式的web app的装置。The present application relates to the field of computer technology, and in particular, to a method for executing a full state mode web app and a device for executing a full state mode web app.
web app是一种通过网络(如互联网或内联网)访问的应用程序;也可以指计算机软件承载在浏览器支持环境下或使用浏览器支持语言(如JavaScript,脚本)并依赖于web浏览器来渲染的应用程序。web app的流行归功于网页浏览器的普及,以及使用这一轻薄客户端方便的用户体验。不必下载安装就可以实现更新和维护,具有支持跨平台的内在属性,是web app开始流行的关键原因。典型的web app产品包括web邮箱、web商店、wikis等等。要实现web app必须满足以下几点关键条件:A web app is an application that is accessed through a network (such as the Internet or an intranet); it can also mean that the computer software is hosted in a browser-supported environment or uses a browser-supported language (such as JavaScript, scripts) and relies on a web browser. Rendered application. The popularity of web apps is due to the popularity of web browsers and the user experience of using this thin and light client. Updates and maintenance can be implemented without having to download and install. It has the intrinsic properties of supporting cross-platform, which is the key reason why web apps are popular. Typical web app products include web mailboxes, web stores, wikis, and more. To implement the web app, the following key conditions must be met:
(1)用户交互。web app必须可以提供界面给用户进行数据展示和用户操作。(1) User interaction. The web app must provide an interface for the user to display data and user operations.
(2)数据交互。web app必须可以使用http协议通过互联网与web服务进行交互,如数据下载和上传(2) Data interaction. The web app must be able to interact with web services via the Internet using the http protocol, such as data downloads and uploads.
(3)安全保证。web app必须有能力识别用户身份和权限。(3) Security guarantee. The web app must have the ability to identify the user's identity and permissions.
但是在先技术中,对于web app,其对各个阶段的业务逻辑都在一起实现,其存在大量的条件语句,而巨大的条件语句是不受欢迎的,它们形成一大整块并且使得代码不够清晰,这又使得它们难以修改和扩展,耦合性高。比如,在先技术中,对web app的编辑和保存在一个类中,其中,保存时不需要先判断启用哪部分键盘事件和鼠标事件,并且禁用哪部分键盘事件和鼠标事件,而在进行保存行为时也需要先判断启用哪部分键盘事件和鼠标事件,并且禁用哪部分键盘事件和鼠标事件,编辑行为和保存行为对于键盘和鼠标事件的判断则存在耦合,并且代码量较多。
However, in the prior art, for the web app, the business logic of each stage is implemented together, and there are a large number of conditional statements, and the huge conditional statements are unpopular, they form a large whole piece and make the code insufficient. Clear, which in turn makes them difficult to modify and expand, and has high coupling. For example, in the prior art, the web app is edited and saved in a class, in which it is not necessary to first determine which part of the keyboard event and mouse event is enabled, and which part of the keyboard event and the mouse event are disabled, and save it. The behavior also needs to first determine which part of the keyboard event and mouse event is enabled, and which part of the keyboard event and mouse event are disabled. The editing behavior and the saving behavior are coupled to the judgment of the keyboard and mouse events, and the code amount is large.
发明内容Summary of the invention
鉴于上述问题,提出了本申请实施例以便提供一种克服上述问题或者至少部分地解决上述问题的一种执行完全状态模式的web app的方法和相应的一种执行完全状态模式的web app的装置。In view of the above problems, embodiments of the present application have been made in order to provide a method for executing a full state mode web app and a corresponding device for executing a full state mode web app that overcomes the above problems or at least partially solves the above problems. .
为了解决上述问题,本申请公开了一种执行完全状态模式的web app的方法,其特征在于,包括:In order to solve the above problem, the present application discloses a method for executing a full state mode web app, which includes:
预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类;其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑;The web app is divided into states according to the attributes that determine the behavior change of the web app, and corresponding state classes are set for each state; wherein each state class includes related behaviors of the corresponding states, and states for state class jumps. Conversion logic
当web app对象执行某个状态类时,在该状态类的状态中,执行所述状态的相关行为,并根据该状态类的状态转换逻辑,将web app对象从当前执行的状态类,跳转为执行与所述状态转换逻辑对应的另一状态类。When the web app object executes a state class, in the state of the state class, the related behavior of the state is executed, and according to the state transition logic of the state class, the web app object is jumped from the currently executed state class. Another state class corresponding to the state transition logic is executed.
为了解决上述问题,本申请还公开了一种执行完全状态模式的web app的装置,包括:In order to solve the above problem, the present application also discloses an apparatus for executing a full state mode web app, including:
预置模块,用于预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类;其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑;a preset module, configured to divide the web app into states according to attributes that determine changes in web app behavior, and set corresponding state classes for each state; wherein each state class includes related behaviors of corresponding states, and is used for State transition logic for state class jumps;
状态执行模块,适于当web app对象执行某个状态类时,在该状态类的状态中,执行所述状态的相关行为,并根据该状态类的状态转换逻辑,将web app对象从当前执行的状态类,跳转为执行与所述状态转换逻辑对应的另一状态类。a state execution module, configured to: when a web app object executes a state class, perform a related behavior of the state in a state of the state class, and execute a web app object from the current state according to state transition logic of the state class The state class jumps to execute another state class corresponding to the state transition logic.
为了解决上述问题,本申请还公开了一种完全状态模式web app,包括:In order to solve the above problem, the present application also discloses a full state mode web app, including:
状态执行模块,适于当web app对象执行某个状态类时,在该状态类的状态中,执行所述状态的相关行为,并根据该状态类的状态转换逻辑,将web app对象从当前执行的状态类,跳转为执行与所述状态转换逻辑对应的另一状态类;其中所述各个状态类根据web app的状态设置,所述web app的状态根据决定web app行为变化的属性进行划分;其中,每个状态类包括
相应状态的相关行为,以及用于状态类跳转的状态转换逻辑。a state execution module, configured to: when a web app object executes a state class, perform a related behavior of the state in a state of the state class, and execute a web app object from the current state according to state transition logic of the state class a state class that jumps to execute another state class corresponding to the state transition logic; wherein each state class is set according to a state of the web app, and the state of the web app is divided according to an attribute that determines a change in web app behavior Where each state class includes
The relevant behavior of the corresponding state, as well as the state transition logic used for state class jumps.
本申请实施例包括以下优点:Embodiments of the present application include the following advantages:
本申请实施例预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑,各个状态类之间是平行的,相互独立的,在web app执行时,web app对象的每个状态类独立执行,不和其他的状态存在交叉。因此,本申请实施例对于web app,能以完全状态模式进行运行,其代码中条件判断块小,即条件判断语句的数量少,分散到具体的状态类中,耦合性低。The embodiment of the present application divides the web app into states according to the attributes that determine the behavior change of the web app, and sets corresponding state classes for each state, each state class includes related behaviors of the corresponding states, and is used for state class jumps. The state transition logic, each state class is parallel and independent of each other. When the web app is executed, each state class of the web app object is executed independently, and does not intersect with other states. Therefore, the embodiment of the present application can run in a full state mode for the web app, and the conditional judgment block in the code is small, that is, the number of conditional judgment statements is small, dispersed into a specific state class, and the coupling is low.
比如,对web app的编辑和保存,分别设置编辑状态类和保存状态类,在编辑状态类中,直接启用其需要的键盘事件和鼠标事件、禁用其不需要的键盘事件和鼠标事件,然后进入保存状态类后,在保存状态类中直接启用其需要的键盘事件和鼠标事件、禁用其不需要的键盘事件和鼠标事件。由于两个状态是独立的,如此web app的保存状态和编辑状态之间对于键盘事件和鼠标事件的逻辑的就解耦了,也不存在大块化的条件判断语句,将大块化的条件判断语句分支化到各个状态类中。For example, to edit and save the web app, set the edit state class and the save state class respectively. In the edit state class, directly enable the keyboard events and mouse events it needs, disable its unwanted keyboard events and mouse events, and then enter After saving the state class, enable the keyboard and mouse events it needs directly in the save state class, disable its unwanted keyboard events and mouse events. Since the two states are independent, the logic between the save state and the edit state of the web app for the keyboard event and the mouse event is decoupled, and there is no large conditional judgment statement, and the condition of the chunking is The judgment statement is branched into each state class.
图1是本申请的一种执行完全状态模式的web app的方法实施例的步骤流程图;1 is a flow chart showing the steps of a method embodiment of a web app executing a full state mode of the present application;
图2是本申请的另一种执行完全状态模式的web app的方法实施例的步骤流程图;2 is a flow chart showing the steps of another method embodiment of a web app executing a full state mode of the present application;
图2A是本申请实施例的状态类以及实现状态类相关的基类、环境类之间的关系图;2A is a diagram showing relationship between a state class and a base class and an environment class related to an implementation state class according to an embodiment of the present application;
图2B是本申请实施例图2实施例的各状态类的转换关系图;2B is a diagram showing a conversion relationship of each state class in the embodiment of FIG. 2 in the embodiment of the present application;
图3是本申请的另一种执行完全状态模式的web app的方法实施例的步骤流程图;3 is a flow chart showing the steps of another method embodiment of a web app executing a full state mode of the present application;
图3A是本申请实施例图3实施例的各状态类的转换关系图;
FIG. 3A is a diagram showing a conversion relationship of each state class in the embodiment of FIG. 3 according to an embodiment of the present application; FIG.
图3B是本申请实施例图3实施例的弹出窗口示例;FIG. 3B is an example of a pop-up window of the embodiment of FIG. 3 according to an embodiment of the present application; FIG.
图4是本申请的一种执行完全状态模式的web app的装置实施例的结构框图;4 is a structural block diagram of an apparatus embodiment of a web app executing a full state mode of the present application;
图5是本申请的另一种执行完全状态模式的web app的装置实施例的结构框图;5 is a structural block diagram of another apparatus embodiment of a web app executing a full state mode of the present application;
图6是本申请的另一种执行完全状态模式的web app的装置实施例的结构框图;6 is a structural block diagram of another apparatus embodiment of a web app executing a full state mode of the present application;
图7是本申请的一种完全状态模式web app的实施例的结构框图。7 is a structural block diagram of an embodiment of a full state mode web app of the present application.
为使本申请的上述目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本申请作进一步详细的说明。The above described objects, features and advantages of the present application will become more apparent and understood.
本申请实施例的核心构思之一在于,基于状态模式,预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑。在web app执行时,web app对象的每个状态类独立执行,不和其他的状态存在交叉。因此,本申请实施例对于web app,能以完全状态模式进行运行,其代码中条件判断块小,分散到具体的状态类中,耦合性低。,并且,可以不用大量的修改原代码,即可很容易的增加新的状态,可扩展性高。One of the core concepts of the embodiments of the present application is that, based on the state mode, the web app is divided into states according to attributes that determine the behavior change of the web app, and corresponding state classes are set for each state, and each state class includes a corresponding state. Related behavior, as well as state transition logic for state class jumps. When the web app is executed, each state class of the web app object is executed independently and does not intersect with other states. Therefore, the embodiment of the present application can run in the full state mode for the web app, and the condition judgment block in the code is small, dispersed into a specific state class, and the coupling is low. Moreover, the new state can be easily added without a large amount of modification of the original code, and the scalability is high.
其中,所述状态模式的介绍如下:在很多情况下,一个对象的行为取决于一个或多个动态变化的属性,该属性叫做状态,该对象叫做有状态的(stateful)对象,该对象状态是从事先定义好的一系列值中取出的。当一个有状态对象,执行该状态类中的行为时,其与外部事件产生互动,继而根据该状态下的状态转换逻辑,该对象的内部状态会改变为其他状态,该对象会执行相应的其他状态类,从而使得对象的行为也随之发生变化。The state mode is described as follows: In many cases, the behavior of an object depends on one or more dynamically changing attributes, the attribute is called a state, the object is called a stateful object, and the object state is Taken from a set of values defined in advance. When a stateful object performs an action in the state class, it interacts with an external event, and then according to the state transition logic in that state, the object's internal state changes to another state, and the object performs the corresponding other The state class, so that the behavior of the object changes.
参照图1,其示出了本申请的一种执行完全状态模式的web app的方法实施例的步骤流程图,具体可以包括如下步骤:Referring to FIG. 1 , a flow chart of steps of a method for performing a full-state mode web app of the present application is shown, which may specifically include the following steps:
步骤110,预先根据决定web app行为变化的属性,将web app划分为
各个状态,并为各个状态设置对应的状态类;其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑; Step 110, pre-determining the web app according to the attribute that determines the behavior change of the web app
Each state, and setting a corresponding state class for each state; wherein each state class includes a related behavior of the corresponding state, and state transition logic for the state class jump;
所述状态,指web app对象实例的属性的属性值,所述行为,指web对象的功能,该行为可以理解为方法。比如方法function activateKeyboard(),为启用键盘事件的行为。The state refers to an attribute value of an attribute of a web app object instance, and the behavior refers to a function of a web object, and the behavior can be understood as a method. For example, the method function activateKeyboard() is the behavior of enabling keyboard events.
在本申请实施例中,对于一个web app,可以根据其逻辑将其分为多个状态类,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑。In the embodiment of the present application, for a web app, it may be divided into a plurality of state classes according to its logic, each state class includes related behaviors of the corresponding states, and state transition logic for state class jumps.
需要说明的是,所述状态类比如初始状态类、加载状态类、编辑状态类、保存状态类。当然,实际应用中,状态类可以根据实际需求划分,可以包括任意类,本申请实施例不对其加以限制。It should be noted that the state class is, for example, an initial state class, a load state class, an edit state class, and a save state class. Of course, in the actual application, the state class may be divided according to actual needs, and may include any class, which is not limited in the embodiment of the present application.
其中,每个状态转换逻辑根据相应状态下的一个具体行为触发状态类的跳转。Each state transition logic triggers a jump of the state class according to a specific behavior in the corresponding state.
步骤120,当web app对象执行某个状态类时,在该状态类的状态中,执行所述状态的相关行为,并根据该状态类的状态转换逻辑,将web app对象从当前执行的状态类,跳转为执行与所述状态转换逻辑对应的另一状态类。Step 120: When the web app object executes a certain state class, in the state of the state class, the related behavior of the state is executed, and according to the state transition logic of the state class, the web app object is from the currently executed state class. The jump is to execute another state class corresponding to the state transition logic.
在实际应用中,web app启动后,可以创建一个web app对象,该web app对象可以理解为web app的实例。然后为该web app对象设置一个最开始的状态类,那么web app对象即可首先执行该初始被设置的状态类,然后执行该状态类的相关行为,在执行过程中,可根据该状态类的状态转换逻辑,将web app对象跳转为执行另一个状态类。那么跳转后,该web app对象执行该另一个状态类的相关行为,在执行过程中根据该状态类的状态转换逻辑再跳转为执行下一个状态类。其他情况以此类推。In a practical application, after the web app is launched, a web app object can be created, which can be understood as an instance of the web app. Then set a start state class for the web app object, then the web app object can first execute the initial set state class, and then execute the state class related behavior, in the execution process, according to the state class State transition logic that jumps the web app object to execute another state class. Then, after the jump, the web app object executes the related behavior of the other state class, and jumps to execute the next state class according to the state transition logic of the state class during execution. Other cases and so on.
在实际应用中,步骤110可离线进行预置,而步骤120在浏览器中执行。In an actual application, step 110 may be preset offline, and step 120 is performed in a browser.
本申请实施例预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑,各个状态类之
间是平行的,相互独立的,在web app执行时,web app对象的每个状态类独立执行,不和其他的状态存在交叉。因此,本申请实施例对于web app,能以完全状态模式进行运行,其代码中条件判断块小,即条件判断语句的数量少,分散到具体的状态类中,耦合性低。The embodiment of the present application divides the web app into states according to the attributes that determine the behavior change of the web app, and sets corresponding state classes for each state, each state class includes related behaviors of the corresponding states, and is used for state class jumps. State transition logic, each state class
The two are parallel and independent of each other. When the web app is executed, each state class of the web app object is executed independently and does not intersect with other states. Therefore, the embodiment of the present application can run in a full state mode for the web app, and the conditional judgment block in the code is small, that is, the number of conditional judgment statements is small, dispersed into a specific state class, and the coupling is low.
比如对web app的编辑和保存,分别设置编辑状态类和保存状态类,在编辑状态类中,直接启用其需要的键盘事件和鼠标事件、禁用其不需要的键盘事件和鼠标事件,然后进入保存状态类后,在保存状态类中直接启用其需要的键盘事件和鼠标事件、禁用其不需要的键盘事件和鼠标事件。由于两个状态是独立的,如此web app的保存状态和编辑状态之间对于键盘事件和鼠标事件的逻辑的就解耦了,也不存在大块化的条件判断语句,将大块化的条件判断语句分支化到各个状态类中。For example, to edit and save the web app, set the edit state class and the save state class respectively. In the edit state class, directly enable the keyboard events and mouse events it needs, disable its unwanted keyboard events and mouse events, and then enter the save. After the status class, enable the required keyboard events and mouse events, disable their unwanted keyboard events, and mouse events directly in the save state class. Since the two states are independent, the logic between the save state and the edit state of the web app for the keyboard event and the mouse event is decoupled, and there is no large conditional judgment statement, and the condition of the chunking is The judgment statement is branched into each state class.
在图1实施例的基础上,参照图2,本申请实施例将状态类划分为了至少下面几个状态类:初始状态类、加载状态类、编辑状态类、保存状态类,以执行本申请实施例的过程。On the basis of the embodiment of FIG. 1 , referring to FIG. 2 , the embodiment of the present application divides the state class into at least the following state classes: an initial state class, a load state class, an edit state class, and a save state class to perform the implementation of the present application. The process of the example.
参照图2,示出了本申请的一种执行完全状态模式的web app的方法实施例的步骤流程图,具体可以包括如下步骤:Referring to FIG. 2, a flow chart of steps of a method for performing a full-state mode web app of the present application is shown. Specifically, the method may include the following steps:
步骤210,预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类;所述状态类包括:初始状态类、加载状态类、编辑状态类、保存状态类;其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑;Step 210: Pre-determine the web app into states according to the attributes that determine the behavior change of the web app, and set a corresponding state class for each state; the state class includes: an initial state class, a loading state class, an editing state class, and a save. a state class; wherein each state class includes a related behavior of the corresponding state, and state transition logic for the state class jump;
所述状态,指web app对象实例的属性的属性值,所述行为,指web对象的功能,该行为可以理解为方法。比如方法function activateKeyboard(),为启用键盘事件的行为。The state refers to an attribute value of an attribute of a web app object instance, and the behavior refers to a function of a web object, and the behavior can be understood as a method. For example, the method function activateKeyboard() is the behavior of enabling keyboard events.
在本申请实施例中,对于一个web app,可以根据其逻辑将其分为多个状态类,如初始状态类、加载状态类、编辑状态类、保存状态类,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑。In the embodiment of the present application, for a web app, it may be divided into multiple state classes according to its logic, such as an initial state class, a load state class, an edit state class, a save state class, and each state class includes a corresponding state. Related behavior, as well as state transition logic for state class jumps.
其中,每个状态转换逻辑根据相应状态下的一个具体行为触发状态类的
跳转。Wherein each state transition logic triggers a state class according to a specific behavior in the corresponding state
Jump.
比如上述初始化状态类的相关行为可包括:为web app的各种变量分配空间、为各种变量赋予初始值、初始化鼠标,键盘,网络,以及其他异步处理事件,初始化界面等,其第一状态转换逻辑可包括,在为所有变量赋予初始值之后,跳转至执行加载状态类。For example, the related behavior of the initialization state class may include: allocating space for various variables of the web app, assigning initial values to various variables, initializing a mouse, a keyboard, a network, and other asynchronous processing events, initializing an interface, etc., the first state thereof The conversion logic can include jumping to the execution load state class after assigning an initial value to all variables.
上述加载状态类的相关行为可包括:载入各种信息,渲染web app的主界面、获取从上一状态传来的上下文数据、等,其第二状态转换逻辑可包括:在web app的主界面渲染完毕之后跳转至执行编辑状态类。The related behavior of the loading state class may include: loading various information, rendering a main interface of the web app, obtaining context data transmitted from the previous state, and the like, and the second state transition logic may include: a master in the web app After the interface is rendered, jump to the execution edit state class.
上述编辑状态类的相关行为可包括:启用键盘事件、启用鼠标事件、接收点击保存按钮的事件、获取从上一状态传来的上下文数据、web app关闭等各种业务逻辑等,其第三状态转换逻辑可包括:接收到对保存按钮的点击事件后,跳转至执行保存状态类。The related behaviors of the editing state class may include: enabling a keyboard event, enabling a mouse event, receiving an event of clicking a save button, obtaining context data transmitted from a previous state, closing a web app, and the like, and the third state thereof. The conversion logic may include jumping to the execution save state class after receiving a click event on the save button.
上述保存状态类的相关行为可包括:保存当前web app中的内容至存储区域,取消保存操作(如,接收到esc事件)、获取从上一状态传来的上下文数据等,其第四状态转换逻辑可包括:在保存完毕之后或者接收到取消保存操作后,跳转至执行编辑状态类。The related behavior of saving the state class may include: saving the content in the current web app to the storage area, canceling the save operation (eg, receiving the esc event), acquiring the context data transmitted from the previous state, and the fourth state transition. The logic may include jumping to the execution edit state class after the save is completed or after receiving the cancel save operation.
在实际应用中,本申请实施例可以如图2A设置:In practical applications, the embodiment of the present application can be set as shown in FIG. 2A:
环境类(Context):定义业务逻辑的接口,如图2A的Request()。维护一个状态类的实例,该环境类生成一个web app对象。Context: An interface that defines business logic, such as Request() in Figure 2A. Maintain an instance of a state class that generates a web app object.
基类(State):定义一个接口如图2A的Handle(),以封装与Context的一个状态类相关的行为。State: Defines an interface such as Handle() in Figure 2A to encapsulate the behavior associated with a state class of the Context.
各种状态类(ConcreteState),如图2A的ConcreteStateA、ConcreteStateB等,每个状态类继承上述基类,也即各个状态类为该基类的子类,每个状态类实现一个与Context的一个状态相关的行为。该状态类包括初始状态类、加载状态类、编辑状态类、保存状态类。Various state classes (ConcreteState), such as ConcreteStateA, ConcreteStateB, etc., each state class inherits the above base class, that is, each state class is a subclass of the base class, and each state class implements a state with the Context. Related behavior. The state class includes an initial state class, a load state class, an edit state class, and a save state class.
步骤220,根据所述初始状态类将所述web app对象设置为初始化状态,在初始化状态的web app对象中执行初始化状态的相关行为,并根据第一状态转换逻辑将web app对象跳转为执行加载状态类;
Step 220: Set the web app object to an initialization state according to the initial state class, perform an initialization state related behavior in a web app object in an initialization state, and jump the web app object to execution according to the first state transition logic. Load state class;
在本申请实施例中,浏览器获从服务器侧获取到网页文档后,如htlm(Hyper text Markup Language,超文本标记语言)文档后,执行所述文档,则生成的web app对象执行初始状态类,此时web app的属性为初始状态。In the embodiment of the present application, after the browser obtains the webpage document from the server side, such as a htlm (Hyper Text Markup Language) document, and executes the document, the generated web app object executes the initial state class. At this time, the properties of the web app are in the initial state.
在该初始状态的web app对象中,执行初始状态类里封装的各种初始状态的相关行为,如前述为web app的各种变量分配空间、为各种变量赋予初始值等。并且在执行到某个具体行为后,跳转至执行加载状态类,如前述在为所有变量赋予初始值之后,跳转至执行加载状态类。In the web app object of the initial state, the related behaviors of various initial states encapsulated in the initial state class are executed, such as allocating space for various variables of the web app, assigning initial values to various variables, and the like. And after executing a specific behavior, jump to the execution load state class, as described above, after assigning an initial value to all variables, jump to the execution load state class.
结合图2B,其介绍了本申请实施例的状态转换过程。2B, the state transition process of the embodiment of the present application is introduced.
然后,web app对象的属性更改为加载状态。Then, the properties of the web app object are changed to the loaded state.
步骤230,在加载状态的web app对象中,执行加载状态的相关行为,并根据第二状态转换逻辑将web app对象跳转为执行编辑状态类;Step 230: Perform a related behavior of the loading state in the web app object in the loading state, and jump the web app object to the execution editing state class according to the second state transition logic;
在web app的属性变更为加载状态之后,则执行加载状态类里封装的加载状态的相关行为。如前述载入各种信息,渲染web app的主界面等。并且在执行到某个具体行为后,跳转至执行编辑状态类,如前述在web app的主界面渲染完毕之后跳转至执行编辑状态类。After the property of the web app is changed to the loaded state, the related behavior of the loaded state encapsulated in the loaded state class is executed. Load various information as described above, render the main interface of the web app, and so on. And after executing a specific behavior, jump to the execution edit state class, as described above, after the main interface of the web app is rendered, jump to the execution edit state class.
然后,web app对象的属性更改为编辑状态。Then, the properties of the web app object are changed to the edit state.
步骤240,在编辑状态的web app对象中,执行编辑状态的相关行为,并根据第三状态转换逻辑将web app对象跳转为执行保存状态类; Step 240, in the edit state of the web app object, perform the relevant behavior of the edit state, and jump the web app object to the execution save state class according to the third state transition logic;
在web app对象的属性变更为编辑状态之后,则执行加载状态类里封装的编辑状态的相关行为。如前述启用键盘事件、启用鼠标事件、接收点击保存按钮的事件、web app关闭等各种业务逻辑等。并且在执行到某个具体行为后,跳转至执行保存状态类,如接收到对保存按钮的点击事件后,跳转至执行保存状态类。After the property of the web app object is changed to the edit state, the related behavior of the edit state encapsulated in the load state class is executed. Such as the aforementioned enable keyboard events, enable mouse events, receive events that click the save button, web application shutdown and other business logic. And after executing a specific behavior, jump to the execution save state class, for example, after receiving the click event on the save button, jump to the execution save state class.
然后,web app对象的属性更改为保存状态。Then, the properties of the web app object are changed to the save state.
可以理解,在本申请实施例中,编辑状态类里可以封装各种与外界交互的行为,该行为可以根据实际需要封装,本申请不对其加以限制。It can be understood that, in the embodiment of the present application, the editing status class can encapsulate various interactions with the outside world, and the behavior can be encapsulated according to actual needs, which is not limited in this application.
步骤250,在保存状态的web app对象中,执行保存状态的相关行为,并根据第四状态转换逻辑将web app对象跳转为执行编辑状态类。
Step 250: Perform a related behavior of saving the state in the web app object in the saved state, and jump the web app object to the execution editing state class according to the fourth state transition logic.
在web app的属性变更为保存状态之后,则执行保存状态类里封装的保存状态的相关行为。如前述保存当前web app中的内容至存储区域,取消保存操作(如,接收到esc事件)等等。并且在执行到某个具体行为后,跳转至执行保存状态类,如接在保存完毕之后或者接收到取消保存操作后,跳转至执行编辑状态类。After the property of the web app is changed to the save state, the related behavior of saving the state of the package encapsulated in the state class is executed. Save the contents of the current web app to the storage area as described above, cancel the save operation (eg, receive the esc event), and so on. And after executing a specific behavior, jump to the execution save state class, such as after the save is completed or after receiving the cancel save operation, jump to the execution edit state class.
在状态类模式中,当web app一个状态调整至另外一个状态之后,前一个状态的信息则会被清除,如此后一个状态则不会与前一个状态产生交叉,不存在耦合。In the state class mode, when the state of the web app is adjusted to another state, the information of the previous state is cleared, so that the latter state does not intersect with the previous state, and there is no coupling.
在实际应用中,步骤210可离线进行预置,而步骤220-250在浏览器中执行。In an actual application, step 210 can be preset offline, while steps 220-250 are performed in the browser.
本申请实施例预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类,即初始化状态类、加载状态类、编辑状态类、保存状态类,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑,各个状态类之间是平行的,相互独立的,在web app执行时,web app对象的每个状态类独立执行,不和其他的状态存在交叉。因此,本申请实施例对于web app,能以完全状态模式进行运行,其代码中条件判断块小,分散到具体的状态类中,耦合性低。In the embodiment of the present application, the web app is divided into states according to attributes that determine the behavior change of the web app, and corresponding state classes are set for each state, that is, an initialization state class, a load state class, an edit state class, and a save state class. The state class includes the related behavior of the corresponding state, and the state transition logic for the state class jump. Each state class is parallel and independent of each other. When the web app is executed, each state class of the web app object is independent. Execution does not intersect with other states. Therefore, the embodiment of the present application can run in the full state mode for the web app, and the condition judgment block in the code is small, dispersed into a specific state class, and the coupling is low.
在图2所示实施例的基础上,本申请还提供了一个优选的实施例:Based on the embodiment shown in FIG. 2, the present application also provides a preferred embodiment:
参照图3,示出了本申请的另一种执行完全状态模式的web app的方法实施例的步骤流程图,具体可以包括如下步骤:Referring to FIG. 3, a flow chart of steps of a method for performing a full-state mode web app of the present application is shown. Specifically, the method may include the following steps:
步骤310,预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类;所述状态类包括:初始状态类、加载状态类、编辑状态类、保存状态类,至少一个弹出窗口状态类;其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑;Step 310: pre-determine the web app into states according to the attributes that determine the behavior change of the web app, and set a corresponding state class for each state; the state class includes: an initial state class, a loading state class, an editing state class, and a save. a state class, at least one pop-up window state class; wherein each state class includes a related behavior of the corresponding state, and state transition logic for the state class jump;
在通常情况下,所有与外部交互的行为或者说业务逻辑,都被封装在编
辑状态类中,但实际上,这些行为之间从整体层面上很可能还是具备平行性,所谓平行性指的是各个状态的行为所处的层次是一样的,相互独立的、没有关联的,是可以根据不同的状态来决定到底走平行线的哪一条。那么本申请实施例,则可以根据行为之间的平行性,将与外部交互的行为拆分为多个状态类,比如,将在web app主页面本身中与外部交互的行为保留在编辑状态类中,将需要从web app主页面弹出的窗口中与外部交互的行为单独设置一个弹出窗口状态类,独立于该编辑状态类执行。Under normal circumstances, all external interactions or business logic are encapsulated in the editor.
In the state class, but in fact, these behaviors are likely to have parallelism on the whole level. The so-called parallelism means that the behaviors of each state are at the same level, independent and unrelated. It is possible to decide which one of the parallel lines to go according to different states. Then, in the embodiment of the present application, the behavior of interacting with the outside can be split into multiple state classes according to the parallelism between the behaviors, for example, the behavior of interacting with the outside in the web app main page itself is retained in the editing state class. In the window popping up from the main page of the web app, a pop-up window state class is set separately from the behavior of the external interaction, and is executed independently of the edit state class.
而由于可能从web app主页面中弹出的窗口有多个,本申请则可以对每个弹出窗口单独设置一个弹出窗口状态类。Since there may be multiple windows popping up from the main page of the web app, the present application can separately set a pop-up window state class for each pop-up window.
相应的,在编辑状态类中,针对每个弹出窗口状态类,设置了相应的第五状态转换逻辑,其在主页面中接收到相应的操作之后,则将web app对象跳转至执行相应的弹出窗口状态类。Correspondingly, in the edit state class, for each popup window state class, a corresponding fifth state transition logic is set, and after receiving the corresponding operation in the main page, the web app object is jumped to execute the corresponding Popup window status class.
在本申请实施例的一种优选实施例中,本申请实施例还包括:In a preferred embodiment of the embodiment of the present application, the embodiment of the present application further includes:
步骤302,在编辑状态类中加入sticky属性,所述sitcky属性用于web app对象的编辑状态类跳转为执行其他状态类时,保留编辑状态所对应的界面元素。Step 302: Add a sticky attribute to the edit state class, and the sitcky attribute is used to edit the interface state corresponding to the edit state when the edit state class of the web app object is jumped to execute other state classes.
在实际应用中,因为一个状态转换到另外一个状态之后,前一个状态会清理,那么如果编辑状态转换到弹出窗口状态之后,编辑状态则会清理,则其主页面就不存在了,该种情况可能会误导用户该web app出现了问题,并且影响界面的可视度,不方便用户观看主页面上弹窗覆盖部分之外的信息。那么本申请则添加了sticky属性,该属性可以保证编辑状态跳转至其他状态类之后,主界面的UI界面还在显示。In practical applications, because the previous state is cleared after one state transitions to another state, if the edit state is cleared after the edit state transitions to the popup state, the main page does not exist. It may mislead the user that the web app has a problem and affect the visibility of the interface. It is not convenient for the user to view information other than the pop-up portion of the main page. Then the application adds a sticky attribute, which ensures that the editing state jumps to other state classes, and the UI interface of the main interface is still displayed.
需要说明的是,该stickey属性通过基类的接口实现,如果某个状态类为该sticky属性的值设置为1,则不对该状态类进行清理,保留编辑状态所对应的界面元素,如保留图3B中web app的弹出窗口“新建bucket”后的web app主页面。在本申请实施例中,对编辑状态类执行时将sticky属性设置为1,其他状态类可将其值设置为null。
It should be noted that the stickey attribute is implemented through the interface of the base class. If a state class has the value of the sticky attribute set to 1, the status class is not cleaned, and the interface element corresponding to the edit state is retained, such as a reserved map. 3B web app's pop-up window "new bucket" after the web app main page. In the embodiment of the present application, the sticky attribute is set to 1 when the editing state class is executed, and other state classes can set the value to null.
当然,在本申请实施例中,也会定义前述环境类(Context)、基类(State)、以及各个状态类(ConcreteState)继承基类。Of course, in the embodiment of the present application, the foregoing environment class (Context), base class (State), and each state class (ConcreteState) inheritance base class are also defined.
基类比如:The base class is as follows:
当然本申请实施例中,根据实际的业务逻辑,还可以设置其他状态类,比如预览状态栏等,本申请实施例不对其加以限制。Of course, in the embodiment of the present application, other state classes, such as a preview status bar, may be set according to the actual business logic, which is not limited in the embodiment of the present application.
步骤320,根据所述初始状态类将所述web app对象设置为初始化状态,在初始化状态的web app对象中执行初始化状态的相关行为,并根据第一状态转换逻辑将web app对象跳转为执行加载状态类;Step 320: Set the web app object to an initialization state according to the initial state class, perform an initialization state related behavior in a web app object in an initialization state, and jump the web app object to execute according to the first state transition logic. Load state class;
本申请实施例结合图3A进行描述。
The embodiment of the present application is described in conjunction with FIG. 3A.
本步骤与图2实施例的步骤220类似,在此不再赘叙。This step is similar to step 220 of the embodiment of FIG. 2 and will not be described here.
步骤330,在加载状态的web app对象中,执行加载状态的相关行为,并根据第二状态转换逻辑将web app对象跳转为执行编辑状态类;Step 330: Perform a related behavior of the loading state in the web app object in the loading state, and jump the web app object to the execution editing state class according to the second state transition logic;
本步骤与图2实施例的步骤330类似,在此不再赘叙。This step is similar to step 330 of the embodiment of FIG. 2 and will not be described here.
步骤340,在编辑状态的web app对象中,执行编辑状态的相关行为,并根据各第五状态转换逻辑将web app对象跳转为执行相应的弹出窗口状态,根据第三状态转换逻辑将web app对象跳转为执行保存状态类; Step 340, in the edit state of the web app object, perform the relevant behavior of the edit state, and jump the web app object to execute the corresponding pop-up window state according to each fifth state transition logic, and the web app according to the third state transition logic The object jumps to the execution save state class;
如前述例子有在编辑状态之后有两个弹出窗口状态,即windowPopup1State和windowPopup1State。As in the previous example, there are two pop-up window states after the edit state, namely windowPopup1State and windowPopup1State.
对于windowPopup1State,如图3B,假使其对应bucket管理栏,其第五状态转换逻辑可以为:当接收到用户对bucket管理栏的点击操作,则弹出新建bucket窗口,web app对象的属性变为弹出窗口状态windowPopup1State。假使其对应资源监控报表栏,其第五状态转换逻辑可以为:当接收到用户对资源监控报表栏的点击操作,则弹出资源监控报表窗口web app对象的属性变为弹出窗口状态windowPopup1State。For windowPopup1State, as shown in FIG. 3B, if it corresponds to the bucket management column, the fifth state transition logic may be: when receiving the user's click operation on the bucket management bar, a new bucket window pops up, and the property of the web app object becomes a popup window. The state windowPopup1State. If it is corresponding to the resource monitoring report column, the fifth state transition logic may be: when the user clicks on the resource monitoring report column, the property of the web app object of the resource monitoring report window is changed to the popup window state windowPopup1State.
当然,在前述在编辑状态类中加入sticky属性的情况下,步骤340还包括:Of course, in the case that the sticky attribute is added to the edit status class, the step 340 further includes:
在web app对象的状态跳转到其他状态之后,保留编辑状态类对应的界面元素。After the state of the web app object jumps to other states, the interface element corresponding to the edit state class is retained.
该界面元素可以理解为web app的主页面。This interface element can be understood as the main page of the web app.
在本申请实施例的一种优选实施例中,本申请实施例还包括:In a preferred embodiment of the embodiment of the present application, the embodiment of the present application further includes:
步骤342在编辑状态类中,判断是否将web app对象由编辑状态类跳转至弹出窗口状态类;如果是跳转至弹出窗口状态,则保留编辑状态所对应的界面元素。In step 342, in the edit state class, it is determined whether the web app object is jumped from the edit state class to the popup window state class; if it is jumped to the popup window state, the interface element corresponding to the edit state is retained.
在本申请实施例中,还可以在编辑状态类中在跳转到其他状态时,还可以判断跳转的对象,如果跳转的对象不是弹出窗口状态,则对编辑状态进行清理。比如判断跳转的对象是保存状态,则将sticky设置为null,那么web app的状态变为保存状态后,则该编辑状态被清理。
In the embodiment of the present application, when jumping to other states in the editing state class, the object of the jump may also be determined. If the object to be jumped is not the state of the popup window, the editing state is cleared. For example, if the object to be jumped is saved, the sticky is set to null, and then the state of the web app is changed to the saved state, and the edit state is cleared.
如果跳转的对象是弹出窗口状态,则保留编辑状态所对应的界面元素。比如判断跳转的对象是保存状态,则将sticky设置为1,那么web app的状态变为保存状态后,则该编辑状态不会被完全清理,会保留web app的主页面。If the jumped object is in the popup state, the interface element corresponding to the edit state is retained. For example, if the object of the jump is saved, the sticky is set to 1, and then the state of the web app is changed to the saved state, the edit state will not be completely cleaned, and the main page of the web app will be retained.
步骤350在弹出窗口状态类中,执行弹出窗口状态类的相关行为,并根据第七状态转换逻辑将web app对象跳转为执行编辑状态类。 Step 350, in the pop-up window state class, performs a related behavior of the pop-up window state class, and jumps the web app object to the execution edit state class according to the seventh state transition logic.
在web app对象的属性变更为弹出窗口状态之后,则执行弹出窗口状态类里封装的弹出窗口状态的相关行为,如前图3B的windowPopup1State extends State下,使用蒙板将底部进行遮盖、不允许用户进行操作的行为,允许用户进行输入、提交、取消等行为。After the property of the web app object is changed to the state of the popup window, the related behavior of the popup window state encapsulated in the popup window state class is executed. As in the windowPopup1State extends State of FIG. 3B, the mask is covered by the mask, and the user is not allowed. The act of performing an action that allows the user to perform actions such as inputting, submitting, canceling, and the like.
当然,在弹出窗口状态类中,还设置第七状态转换逻辑,用于将web app对象的状态从弹出窗口状态跳转为编辑状态,以执行编辑状态类的各种操作。如图3B中的弹出窗口状态windowPopup1State extends State,该第七逻辑可以为,当接收到对提交按钮的点击操作或者接收到对取消按钮的点击操作,则将web app对象跳转为执行编辑状态类。Of course, in the pop-up window state class, a seventh state transition logic is also provided for jumping the state of the web app object from the pop-up window state to the edit state to perform various operations of the edit state class. As shown in FIG. 3B, the popup window state windowPopup1State extends State, the seventh logic may be that when a click operation on the submit button is received or a click operation on the cancel button is received, the web app object is jumped to the execution edit state class. .
步骤360,在保存状态的web app对象中,执行保存状态的相关行为,并根据第四状态转换逻辑将web app对象跳转为执行编辑状态类。Step 360: Perform a related behavior of saving the state in the web app object in the saved state, and jump the web app object to the execution editing state class according to the fourth state transition logic.
本步骤与图2实施例的步骤250类似,在此不再赘叙。This step is similar to step 250 of the embodiment of FIG. 2 and will not be described here.
在实际应用中,步骤310可离线进行预置,而不在320-360在浏览器中执行。In a practical application, step 310 can be preset offline without being executed in the browser at 320-360.
本申请实施例预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑,各个状态类之间是平行的,相互独立的,在web app执行时,web app对象的每个状态类独立执行,不和其他的状态存在交叉。因此,本申请实施例对于web app,能以完全状态模式进行运行,其代码中条件判断块小,分散到具体的状态类中,耦合性低。比如对web app的编辑和保存,分别设置编辑状态类和保存状态类,在编辑状态类中,直接启用其需要的键盘事件和鼠
标事件、禁用其不需要的键盘事件和鼠标事件,然后进入保存状态类后,在保存状态类中直接启用其需要的键盘事件和鼠标事件、禁用其不需要的键盘事件和鼠标事件。由于两个状态是独立的,如此web app的保存状态和编辑状态之间对于键盘事件和鼠标事件的逻辑的就解耦了,也不存在大块化的条件判断语句,将大块化的条件判断语句分支化到各个状态类中。The embodiment of the present application divides the web app into states according to the attributes that determine the behavior change of the web app, and sets corresponding state classes for each state, each state class includes related behaviors of the corresponding states, and is used for state class jumps. The state transition logic, each state class is parallel and independent of each other. When the web app is executed, each state class of the web app object is executed independently, and does not intersect with other states. Therefore, the embodiment of the present application can run in the full state mode for the web app, and the condition judgment block in the code is small, dispersed into a specific state class, and the coupling is low. For example, for the editing and saving of the web app, set the editing state class and the saving state class respectively, and directly enable the keyboard events and rats needed in the editing state class.
Mark events, disable their unwanted keyboard events and mouse events, and then enter the save state class, enable their required keyboard and mouse events directly in the save state class, disable their unwanted keyboard events and mouse events. Since the two states are independent, the logic between the save state and the edit state of the web app for the keyboard event and the mouse event is decoupled, and there is no large conditional judgment statement, and the condition of the chunking is The judgment statement is branched into each state class.
尤其是,本申请实施例将弹出窗口状态从编辑状态中独立出来,进一步对web app进行了解耦,下面以一个为代码示例对该提取出的弹出窗口状态能够进一步解耦的原理进行论述:In particular, the embodiment of the present application separates the pop-up window state from the edit state, and further decouples the web app. The following is a code example to discuss the principle that the extracted pop-up window state can be further decoupled:
1、将各个弹出窗口的行为都放在一个编辑状态类中的伪代码如下:1. The pseudo code that puts the behavior of each popup in an edit state class is as follows:
在通常情况下,将弹出窗口和其他业务逻辑一起放在编辑状态中,会使用蒙版将底部的内容区域遮盖,不允许用户操作(如图3B中2所述),但实际上用户可以通过tab导航快捷键的方式进行操作,此时Web app无法区分出这种操作是否合法。并且如上述示例,有两个弹出窗口,而两个窗口都要要禁用某些键盘和鼠标事件,然后再启用某些键盘和鼠标事件,两者和外部代码之间就产生了耦合。特别是,窗口中需要处理的一般都是异步操作,那么代码中将会出现大量异步处理的代码,增大了代码耦合性,增加了开发难度。Under normal circumstances, the pop-up window and other business logic are placed together in the edit state, the mask will be used to cover the content area at the bottom, and the user is not allowed to operate (as described in 2 of Figure 3B), but the user can actually pass The tab navigation shortcuts operate, and the web app cannot distinguish whether the operation is legal. And as in the example above, there are two pop-up windows, and both windows have to disable certain keyboard and mouse events, and then enable some keyboard and mouse events, and there is a coupling between the two and the external code. In particular, the window needs to be processed asynchronously, so there will be a lot of asynchronous processing code in the code, which increases the code coupling and increases the development difficulty.
而本申请实施例,对应上述伪代码,其将各个弹出窗口独立为弹出窗口状态类,其编辑状态类、弹出窗口状态类1和弹出窗口状态类2的伪代码如下:
In the embodiment of the present application, corresponding to the pseudo code, each pop-up window is independently a pop-up window state class, and the pseudo-codes of the edit state class, the pop-up window state class 1 and the pop-up window state class 2 are as follows:
在(1)的编辑状态类中,其处理弹出窗口windowPopup1的方法中,仅仅是将wep app对象的状态切换到(2)的弹出窗口状态1;其处理弹出窗口windowPopup2的方法中,仅仅是将wep app对象的状态切换到(3)的弹出
窗口状态2中。在编辑状态中,并不执行弹出窗口的具体行为。In the edit state class of (1), in the method of processing the popup window windowPopup1, only the state of the wep app object is switched to the popup window state 1 of (2); in the method of processing the popup window windowPopup2, only The state of the wep app object switches to the popup of (3)
Window state 2. In the edit state, the specific behavior of the popup window is not executed.
由于各个状态之间,因此可以很容易的屏蔽用户对底部内容区域的操作。并且,弹出窗口状态类(2)和弹出窗口状态类(3)与编辑状态类(1)之间的逻辑就解耦了,对鼠标和键盘事件的代码也解耦了,大大降低了开发难度。Due to the various states, it is easy to shield the user from the operation of the bottom content area. Moreover, the logic between the pop-up window state class (2) and the pop-up window state class (3) and the edit state class (1) is decoupled, and the code for the mouse and keyboard events is also decoupled, which greatly reduces the development difficulty. .
需要说明的是,对于方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请实施例并不受所描述的动作顺序的限制,因为依据本申请实施例,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作并不一定是本申请实施例所必须的。It should be noted that, for the method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should understand that the embodiments of the present application are not limited by the described action sequence, because In accordance with embodiments of the present application, certain steps may be performed in other sequences or concurrently. In the following, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required in the embodiments of the present application.
参照图4,示出了本申请的一种执行完全状态模式的web app的装置实施例的结构框图,具体可以包括如下模块:Referring to FIG. 4, a structural block diagram of an apparatus embodiment of a web app executing a full state mode of the present application is shown, which may specifically include the following modules:
预置模块410,用于预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类;其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑;The preset module 410 is configured to divide the web app into states according to the attributes that determine the behavior change of the web app, and set corresponding state classes for each state; wherein each state class includes related behaviors of the corresponding states, and State transition logic for state class jumps;
状态执行模块420,适于当web app对象执行某个状态类时,在该状态类的状态中,执行所述状态的相关行为,并根据该状态类的状态转换逻辑,将web app对象从当前执行的状态类,跳转为执行与所述状态转换逻辑对应的另一状态类。The state execution module 420 is adapted to perform a related behavior of the state in a state of the state class when the web app object executes a certain state class, and according to the state transition logic of the state class, the web app object is from the current state The executed state class jumps to execute another state class corresponding to the state transition logic.
本申请实施例预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑,各个状态类之间是平行的,相互独立的,在web app执行时,web app对象的每个状态类独立执行,不和其他的状态存在交叉。因此,本申请实施例对于web app,能以完全状态模式进行运行,其代码中条件判断块小,即条件判断语句的数量少,分散到具体的状态类中,耦合性低。The embodiment of the present application divides the web app into states according to the attributes that determine the behavior change of the web app, and sets corresponding state classes for each state, each state class includes related behaviors of the corresponding states, and is used for state class jumps. The state transition logic, each state class is parallel and independent of each other. When the web app is executed, each state class of the web app object is executed independently, and does not intersect with other states. Therefore, the embodiment of the present application can run in a full state mode for the web app, and the conditional judgment block in the code is small, that is, the number of conditional judgment statements is small, dispersed into a specific state class, and the coupling is low.
参照图5,示出了本申请的一种执行完全状态模式的web app的装置实
施例的结构框图,具体可以包括如下模块:Referring to FIG. 5, there is shown a device for executing a full state mode web app of the present application.
The structural block diagram of the embodiment may specifically include the following modules:
预置模块510,用于预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类;所述状态类包括:初始状态类、加载状态类、编辑状态类、保存状态类;其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑;The preset module 510 is configured to divide the web app into states according to the attributes that determine the behavior change of the web app, and set a corresponding state class for each state; the state class includes: an initial state class, a loading state class, and an editing State class, save state class; wherein each state class includes related behaviors of the corresponding state, and state transition logic for state class jumps;
状态执行模块520,具体包括:The state execution module 520 specifically includes:
初始化状态模块521,用于根据所述初始状态类将所述web app对象设置为初始化状态,在初始化状态的web app对象中执行初始化状态的相关行为,并根据第一状态转换逻辑将web app对象跳转为执行加载状态类;An initialization state module 521, configured to set the web app object to an initialization state according to the initial state class, perform an initialization state related behavior in a web app object in an initialization state, and convert the web app object according to the first state transition logic Jump to execute the load state class;
加载状态模块522,用于在加载状态的web app对象中,执行加载状态的相关行为,并根据第二状态转换逻辑将web app对象跳转为执行编辑状态类;The loading status module 522 is configured to execute a related behavior of the loading state in the web app object in the loading state, and jump the web app object to the execution editing state class according to the second state transition logic;
编辑状态模块523,用于在编辑状态的web app对象中,执行编辑状态的相关行为,并根据第三状态转换逻辑将web app对象跳转为执行保存状态类;The editing state module 523 is configured to execute a related behavior of the editing state in the web app object in the editing state, and jump the web app object to the execution saving state class according to the third state transition logic;
保存状态模块524,用于在保存状态的web app对象中,执行保存状态的相关行为,并根据第四状态转换逻辑将web app对象跳转为执行编辑状态类。The save state module 524 is configured to execute a related behavior of saving the state in the web app object in the saved state, and jump the web app object to execute the edit state class according to the fourth state transition logic.
本申请实施例预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类,即初始化状态类、加载状态类、编辑状态类、保存状态类,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑,各个状态类之间是平行的,相互独立的,在web app执行时,web app对象的每个状态类独立执行,不和其他的状态存在交叉。因此,本申请实施例对于web app,能以完全状态模式进行运行,其代码中条件判断块小,分散到具体的状态类中,耦合性低。In the embodiment of the present application, the web app is divided into states according to attributes that determine the behavior change of the web app, and corresponding state classes are set for each state, that is, an initialization state class, a load state class, an edit state class, and a save state class. The state class includes the related behavior of the corresponding state, and the state transition logic for the state class jump. Each state class is parallel and independent of each other. When the web app is executed, each state class of the web app object is independent. Execution does not intersect with other states. Therefore, the embodiment of the present application can run in the full state mode for the web app, and the condition judgment block in the code is small, dispersed into a specific state class, and the coupling is low.
参照图6,示出了本申请的另一种执行完全状态模式的web app的装置
实施例的结构框图,具体可以包括如下模块:Referring to FIG. 6, there is shown another apparatus for executing a full state mode web app of the present application.
The structural block diagram of the embodiment may specifically include the following modules:
预置模块610,用于预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类;所述状态类包括:初始状态类、加载状态类、编辑状态类、保存状态类、至少一个弹出窗口状态类;其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑;The preset module 610 is configured to divide the web app into states according to the attributes that determine the behavior change of the web app, and set a corresponding state class for each state; the state class includes: an initial state class, a loading state class, and an editing a state class, a save state class, and at least one popup window state class; wherein each state class includes a related behavior of the corresponding state, and state transition logic for the state class jump;
在本申请的另外一个优选实施例中,所述预置模块410还用于:在编辑状态类中加入sticky属性,所述sitcky属性用于web app对象的编辑状态类跳转为执行其他状态类时,保留编辑状态所对应的界面元素。In another preferred embodiment of the present application, the preset module 410 is further configured to: add a sticky attribute to the edit state class, where the sitcky attribute is used to edit the state of the web app object to perform other state classes. When you save the interface element corresponding to the editing state.
其中,每个所述状态转换逻辑根据相应状态下的一个或多个具体行为触发状态类的跳转。The state transition logic triggers a jump of the state class according to one or more specific behaviors in the corresponding state.
状态执行模块620,具体包括:The status execution module 620 specifically includes:
初始化状态模块621,用于根据所述初始状态类将所述web app对象设置为初始化状态,在初始化状态的web app对象中执行初始化状态的相关行为,并根据第一状态转换逻辑将web app对象跳转为执行加载状态类;An initialization state module 621, configured to set the web app object to an initialization state according to the initial state class, perform an initialization state related behavior in a web app object in an initialization state, and convert the web app object according to the first state transition logic Jump to execute the load state class;
加载状态模块622,用于在加载状态的web app对象中,执行加载状态的相关行为,并根据各第五状态转换逻辑将web app对象跳转为执行相应的弹出窗口状态,根据第二状态转换逻辑将web app对象跳转为执行编辑状态类;The loading status module 622 is configured to execute a related behavior of the loading state in the web app object in the loading state, and jump the web app object to perform a corresponding pop-up window state according to each fifth state transition logic, and convert according to the second state Logic jumps the web app object to execute the edit state class;
编辑状态模块623,用于在编辑状态的web app对象中,执行编辑状态的相关行为,并根据第三状态转换逻辑将web app对象跳转为执行保存状态类;The editing status module 623 is configured to execute a related behavior of the editing state in the web app object in the editing state, and jump the web app object to the execution saving state class according to the third state transition logic;
在本申请的另外一个优选实施例中,所述编辑状态模块440还用于:In another preferred embodiment of the present application, the edit status module 440 is further configured to:
判断是否将web app对象由编辑状态类跳转至弹出窗口状态类;如果是跳转至弹出窗口状态,则保留编辑状态所对应的界面元素;Determining whether the web app object is jumped from the edit state class to the popup window state class; if it is jumping to the popup window state, the interface element corresponding to the edit state is retained;
如果不是,则清理编辑状态类。If not, clean up the edit state class.
弹出窗口状态模块624,用于在弹出窗口状态类中,执行弹出窗口状态类的相关行为,并根据第七状态转换逻辑将web app对象跳转为执行编辑状
态类。a pop-up window status module 624, configured to execute a related behavior of the pop-up window state class in the pop-up window state class, and jump the web app object to execute the edit state according to the seventh state transition logic
State class.
保存状态模块625,用于在保存状态的web app对象中,执行保存状态的相关行为,并根据第四状态转换逻辑将web app对象跳转为执行编辑状态类。The save state module 625 is configured to execute a related behavior of saving the state in the web app object in the saved state, and jump the web app object to execute the edit state class according to the fourth state transition logic.
本申请实施例预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑,各个状态类之间是平行的,相互独立的,在web app执行时,web app对象的每个状态类独立执行,不和其他的状态存在交叉。因此,本申请实施例对于web app,能以完全状态模式进行运行,其代码中条件判断块小,分散到具体的状态类中,耦合性低。The embodiment of the present application divides the web app into states according to the attributes that determine the behavior change of the web app, and sets corresponding state classes for each state, each state class includes related behaviors of the corresponding states, and is used for state class jumps. The state transition logic, each state class is parallel and independent of each other. When the web app is executed, each state class of the web app object is executed independently, and does not intersect with other states. Therefore, the embodiment of the present application can run in the full state mode for the web app, and the condition judgment block in the code is small, dispersed into a specific state class, and the coupling is low.
尤其是,本申请实施例将各弹出窗口状态从编辑状态中独立出来,进一步对web app进行了解耦,在弹出窗口状态下可以很容易的屏蔽用户对底部内容区域的操作,大大降低了开发难度。In particular, the embodiment of the present application separates the state of each pop-up window from the editing state, further decouples the web app, and can easily shield the user from operating on the bottom content area in the pop-up window state, thereby greatly reducing development. Difficulty.
参照图7,示出了本申请的一种完全状态模式web app的实施例的结构框图,具体可以包括如下模块:Referring to FIG. 7, a structural block diagram of an embodiment of a full state mode web app of the present application is shown, which may specifically include the following modules:
状态执行模块710,适于当web app对象执行某个状态类时,在该状态类的状态中,执行所述状态的相关行为,并根据该状态类的状态转换逻辑,将web app对象从当前执行的状态类,跳转为执行与所述状态转换逻辑对应的另一状态类;其中所述各个状态类根据web app的状态设置,所述web app的状态根据决定web app行为变化的属性进行划分;其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑。The state execution module 710 is adapted to perform a related behavior of the state in a state of the state class when the web app object executes a certain state class, and according to the state transition logic of the state class, the web app object is from the current state Executing a state class, jumping to perform another state class corresponding to the state transition logic; wherein each state class is set according to a state of the web app, and the state of the web app is performed according to an attribute determining a behavior change of the web app Division; where each state class includes the associated behavior of the corresponding state, and state transition logic for state class jumps.
当然,在本发明实施例中,可以预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类,其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑,从而可以构建一个web app。然后即可得到状态执行模块710。Of course, in the embodiment of the present invention, the web app may be divided into states according to attributes that determine the behavior change of the web app, and corresponding state classes are set for each state, where each state class includes related behaviors of the corresponding states. And state transition logic for state class jumps so that you can build a web app. The state execution module 710 can then be obtained.
当然在状态执行模块710,还可包括web app对象创建模块,用于在启
动web app时,创建web app对象。Of course, in the state execution module 710, a web app object creation module may also be included for
Create a web app object when you move the web app.
还可包括起始状态赋予模块,用于为创建的web app对象赋予一个最开始的状态类。A start state assignment module can also be included for assigning a web application object to the initial state class.
其中,每个所述状态转换逻辑根据相应状态下的一个或多个具体行为触发状态类的跳转。The state transition logic triggers a jump of the state class according to one or more specific behaviors in the corresponding state.
在本申请另外一个优选的实施例中,所述状态类包括:初始状态类、加载状态类、编辑状态类、保存状态类;In another preferred embodiment of the present application, the state class includes: an initial state class, a load state class, an edit state class, and a save state class;
所述状态执行模块710包括:The state execution module 710 includes:
初始化状态模块,用于根据所述初始状态类将所述web app对象设置为初始化状态,在初始化状态的web app对象中执行初始化状态的相关行为,并根据第一状态转换逻辑将web app对象跳转为执行加载状态类;An initialization state module, configured to set the web app object to an initialization state according to the initial state class, perform an initialization state related behavior in a web app object in an initialization state, and jump the web app object according to the first state transition logic Go to the execution load state class;
加载状态模块,用于在加载状态的web app对象中,执行加载状态的相关行为,并根据第二状态转换逻辑将web app对象跳转为执行编辑状态类;a loading state module, configured to execute a related behavior of the loading state in the web app object in the loading state, and jump the web app object to an execution editing state class according to the second state transition logic;
编辑状态模块,用于在编辑状态的web app对象中,执行编辑状态的相关行为,并根据第三状态转换逻辑将web app对象跳转为执行保存状态类;Editing a state module, configured to perform an edit state related behavior in a web app object in an edit state, and jump the web app object to an execution save state class according to the third state transition logic;
保存状态模块,用于在保存状态的web app对象中,执行保存状态的相关行为,并根据第四状态转换逻辑将web app对象跳转为执行编辑状态类。The save state module is configured to execute a related behavior of saving the state in the web app object in the saved state, and jump the web app object to execute the edit state class according to the fourth state transition logic.
在本申请另外一个优选的实施例中,所述状态类还包括:至少一个弹出窗口状态类;In another preferred embodiment of the present application, the status class further includes: at least one popup window status class;
所述编辑状态模块,还用于:The edit status module is further configured to:
根据各第五状态转换逻辑将web app对象跳转为执行相应的弹出窗口状态。The web app object is jumped to execute the corresponding popup state according to each fifth state transition logic.
在本申请另外一个优选的实施例中,还包括:In another preferred embodiment of the present application, the method further includes:
弹出窗口状态模块,用于在弹出窗口状态类中,执行弹出窗口状态类的相关行为,并根据第七状态转换逻辑将web app对象跳转为执行编辑状态类。A pop-up window status module is configured to execute a related behavior of the pop-up window state class in the pop-up window state class, and jump the web app object to an execution edit state class according to the seventh state transition logic.
在本申请另外一个优选的实施例中,在所述编辑状态类中还包括sticky属性,所述sitcky属性用于web app对象的编辑状态类跳转为执行其他状态类时,保留编辑状态所对应的界面元素。
In another preferred embodiment of the present application, the edit state class further includes a sticky attribute, and the sitcky attribute is used to edit the edit state class of the web app object to retain the edit state when executing other state classes. Interface elements.
在本申请另外一个优选的实施例中,所述编辑状态模块还用于:In another preferred embodiment of the present application, the edit status module is further configured to:
判断是否将web app对象由编辑状态类跳转至弹出窗口状态类;如果是跳转至弹出窗口状态,则保留编辑状态所对应的界面元素;Determining whether the web app object is jumped from the edit state class to the popup window state class; if it is jumping to the popup window state, the interface element corresponding to the edit state is retained;
如果不是,则清理编辑状态类。If not, clean up the edit state class.
本申请实施例预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑,各个状态类之间是平行的,相互独立的,在web app执行时,web app对象的每个状态类独立执行,不和其他的状态存在交叉。因此,本申请实施例对于web app,能以完全状态模式进行运行,其代码中条件判断块小,即条件判断语句的数量少,分散到具体的状态类中,耦合性低。The embodiment of the present application divides the web app into states according to the attributes that determine the behavior change of the web app, and sets corresponding state classes for each state, each state class includes related behaviors of the corresponding states, and is used for state class jumps. The state transition logic, each state class is parallel and independent of each other. When the web app is executed, each state class of the web app object is executed independently, and does not intersect with other states. Therefore, the embodiment of the present application can run in a full state mode for the web app, and the conditional judgment block in the code is small, that is, the number of conditional judgment statements is small, dispersed into a specific state class, and the coupling is low.
比如对web app的编辑和保存,分别设置编辑状态类和保存状态类,在编辑状态类中,直接启用其需要的键盘事件和鼠标事件、禁用其不需要的键盘事件和鼠标事件,然后进入保存状态类后,在保存状态类中直接启用其需要的键盘事件和鼠标事件、禁用其不需要的键盘事件和鼠标事件。由于两个状态是独立的,如此web app的保存状态和编辑状态之间对于键盘事件和鼠标事件的逻辑的就解耦了,也不存在大块化的条件判断语句,将大块化的条件判断语句分支化到各个状态类中。For example, to edit and save the web app, set the edit state class and the save state class respectively. In the edit state class, directly enable the keyboard events and mouse events it needs, disable its unwanted keyboard events and mouse events, and then enter the save. After the status class, enable the required keyboard events and mouse events, disable their unwanted keyboard events, and mouse events directly in the save state class. Since the two states are independent, the logic between the save state and the edit state of the web app for the keyboard event and the mouse event is decoupled, and there is no large conditional judgment statement, and the condition of the chunking is The judgment statement is branched into each state class.
对于装置实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.
本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。The various embodiments in the present specification are described in a progressive manner, and each embodiment focuses on differences from other embodiments, and the same similar parts between the various embodiments can be referred to each other.
本领域内的技术人员应明白,本申请实施例的实施例可提供为方法、装置、或计算机程序产品。因此,本申请实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介
质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the embodiments of the present application can be provided as a method, apparatus, or computer program product. Therefore, the embodiments of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Moreover, embodiments of the present application may employ computer usable storage media in one or more of the computer usable program code embodied therein.
A form of computer program product implemented on a quality (including but not limited to disk storage, CD-ROM, optical storage, etc.).
在一个典型的配置中,所述计算机设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括非持续性的电脑可读媒体(transitory media),如调制的数据信号和载波。In a typical configuration, the computer device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory. The memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory. Memory is an example of a computer readable medium. Computer readable media includes both permanent and non-persistent, removable and non-removable media. Information storage can be implemented by any method or technology. The information can be computer readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory. (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disk read only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transportable media can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-persistent computer readable media, such as modulated data signals and carrier waves.
本申请实施例是参照根据本申请实施例的方法、终端设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理终端设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理终端设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。Embodiments of the present application are described with reference to flowcharts and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing terminal device to produce a machine such that instructions are executed by a processor of a computer or other programmable data processing terminal device Means are provided for implementing the functions specified in one or more of the flow or in one or more blocks of the flow chart.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理终端设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个
流程或多个流程和/或方框图一个方框或多个方框中指定的功能。The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. Instruction device implemented in a flowchart
A function specified in a block or blocks of a process or multiple processes and/or block diagrams.
这些计算机程序指令也可装载到计算机或其他可编程数据处理终端设备上,使得在计算机或其他可编程终端设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程终端设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device such that a series of operational steps are performed on the computer or other programmable terminal device to produce computer-implemented processing, such that the computer or other programmable terminal device The instructions executed above provide steps for implementing the functions specified in one or more blocks of the flowchart or in a block or blocks of the flowchart.
尽管已描述了本申请实施例的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例做出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请实施例范围的所有变更和修改。While a preferred embodiment of the embodiments of the present application has been described, those skilled in the art can make further changes and modifications to the embodiments once they are aware of the basic inventive concept. Therefore, the appended claims are intended to be interpreted as including all the modifications and the modifications
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者终端设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者终端设备中还存在另外的相同要素。Finally, it should also be noted that in this context, relational terms such as first and second are used merely to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these entities. There is any such actual relationship or order between operations. Furthermore, the terms "comprises" or "comprising" or "comprising" or any other variations are intended to encompass a non-exclusive inclusion, such that a process, method, article, or terminal device that includes a plurality of elements includes not only those elements but also Other elements that are included, or include elements inherent to such a process, method, article, or terminal device. An element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that comprises the element, without further limitation.
以上对本申请所提供的执行完全状态模式的web app的方法、执行完全状态模式的web app的装置、一种完全状态模式APP,进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。
The method for executing the full-state mode web app provided by the present application, the device for executing the full state mode web app, and the full state mode APP are described in detail. In this paper, the specific examples are applied to the principle of the present application. The embodiments are described, and the description of the above embodiments is only for helping to understand the method of the present application and its core ideas; at the same time, for those skilled in the art, according to the idea of the present application, in the specific embodiments and application scopes In the above, the contents of this specification should not be construed as limiting the present application.
Claims (15)
- 一种执行完全状态模式的web app的方法,其特征在于,包括:A method for executing a full state mode web app, comprising:预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类;其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑;The web app is divided into states according to the attributes that determine the behavior change of the web app, and corresponding state classes are set for each state; wherein each state class includes related behaviors of the corresponding states, and states for state class jumps. Conversion logic当web app对象执行某个状态类时,在该状态类的状态中,执行所述状态的相关行为,并根据该状态类的状态转换逻辑,将web app对象从当前执行的状态类,跳转为执行与所述状态转换逻辑对应的另一状态类。When the web app object executes a state class, in the state of the state class, the related behavior of the state is executed, and according to the state transition logic of the state class, the web app object is jumped from the currently executed state class. Another state class corresponding to the state transition logic is executed.
- 根据权利要求1所述的方法,其特征在于,所述状态类包括:初始状态类、加载状态类、编辑状态类、保存状态类;The method according to claim 1, wherein the state class comprises: an initial state class, a load state class, an edit state class, and a save state class;所述当web app对象执行某个状态类时,在该状态类的状态中,执行所述状态的相关行为,并根据该状态类的状态转换逻辑,将web app对象从当前执行的状态类,跳转为执行与所述状态转换逻辑对应的另一状态类的步骤包括:When the web app object executes a certain state class, in the state of the state class, the related behavior of the state is executed, and according to the state transition logic of the state class, the web app object is from the currently executed state class, The step of jumping to another state class corresponding to the state transition logic includes:根据所述初始状态类将所述web app对象设置为初始化状态,在初始化状态的web app对象中执行初始化状态的相关行为,并根据第一状态转换逻辑将web app对象跳转为执行加载状态类;Setting the web app object to an initialization state according to the initial state class, performing an initialization state related behavior in a web app object in an initialization state, and jumping the web app object to an execution loading state class according to the first state transition logic ;在加载状态的web app对象中,执行加载状态的相关行为,并根据第二状态转换逻辑将web app对象跳转为执行编辑状态类;In the loaded state web app object, performing a related behavior of the loading state, and jumping the web app object to an execution editing state class according to the second state transition logic;在编辑状态的web app对象中,执行编辑状态的相关行为,并根据第三状态转换逻辑将web app对象跳转为执行保存状态类;In the edited state web app object, executing the relevant behavior of the edit state, and jumping the web app object to the execution save state class according to the third state transition logic;在保存状态的web app对象中,执行保存状态的相关行为,并根据第四状态转换逻辑将web app对象跳转为执行编辑状态类。In the saved web app object, the related behavior of saving the state is executed, and the web app object is jumped to the execution editing state class according to the fourth state transition logic.
- 根据权利要求2所述的方法,其特征在于,The method of claim 2 wherein:所述状态类还包括:至少一个弹出窗口状态类;The state class further includes: at least one popup window state class;在编辑状态的web app对象中,还包括:In the edit state of the web app object, it also includes:根据各第五状态转换逻辑将web app对象跳转为执行相应的弹出窗口状态。 The web app object is jumped to execute the corresponding popup state according to each fifth state transition logic.
- 根据权利要求3所述的方法,其特征在于,还包括:The method of claim 3, further comprising:在弹出窗口状态类中,执行弹出窗口状态类的相关行为,并根据第七状态转换逻辑将web app对象跳转为执行编辑状态类。In the pop-up window state class, the related behavior of the pop-up window state class is executed, and the web app object is jumped to the execution edit state class according to the seventh state transition logic.
- 根据权利要求3或4所述的方法,其特征在于,还包括:The method according to claim 3 or 4, further comprising:在编辑状态类中加入sticky属性,所述sitcky属性用于web app对象的编辑状态类跳转为执行其他状态类时,保留编辑状态所对应的界面元素。The sticky attribute is added to the edit state class, and the sitcky attribute is used to edit the edit state of the web app object to retain the interface element corresponding to the edit state when executing other state classes.
- 根据权利要求4所述的方法,其特征在于,在编辑状态中,还包括:The method according to claim 4, wherein in the editing state, the method further comprises:判断是否将web app对象由编辑状态类跳转至弹出窗口状态类;如果是跳转至弹出窗口状态,则保留编辑状态所对应的界面元素;Determining whether the web app object is jumped from the edit state class to the popup window state class; if it is jumping to the popup window state, the interface element corresponding to the edit state is retained;如果不是,则清理编辑状态类。If not, clean up the edit state class.
- 根据权利要求1所述的方法,其特征在于,每个所述状态转换逻辑根据相应状态下的一个或多个具体行为触发状态类的跳转。The method of claim 1 wherein each of said state transition logic triggers a jump of a state class based on one or more specific behaviors in respective states.
- 一种执行完全状态模式的web app的装置,其特征在于,包括:An apparatus for executing a full state mode web app, comprising:预置模块,用于预先根据决定web app行为变化的属性,将web app划分为各个状态,并为各个状态设置对应的状态类;其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑;a preset module, configured to divide the web app into states according to attributes that determine changes in web app behavior, and set corresponding state classes for each state; wherein each state class includes related behaviors of corresponding states, and is used for State transition logic for state class jumps;状态执行模块,适于当web app对象执行某个状态类时,在该状态类的状态中,执行所述状态的相关行为,并根据该状态类的状态转换逻辑,将web app对象从当前执行的状态类,跳转为执行与所述状态转换逻辑对应的另一状态类。a state execution module, configured to: when a web app object executes a state class, perform a related behavior of the state in a state of the state class, and execute a web app object from the current state according to state transition logic of the state class The state class jumps to execute another state class corresponding to the state transition logic.
- 根据权利要求8所述的装置,其特征在于,所述状态类包括:初始状态类、加载状态类、编辑状态类、保存状态类;The apparatus according to claim 8, wherein the state class comprises: an initial state class, a load state class, an edit state class, and a save state class;所述状态执行模块包括:The state execution module includes:初始化状态模块,用于根据所述初始状态类将所述web app对象设置为初始化状态,在初始化状态的web app对象中执行初始化状态的相关行为,并根据第一状态转换逻辑将web app对象跳转为执行加载状态类;An initialization state module, configured to set the web app object to an initialization state according to the initial state class, perform an initialization state related behavior in a web app object in an initialization state, and jump the web app object according to the first state transition logic Go to the execution load state class;加载状态模块,用于在加载状态的web app对象中,执行加载状态的相关行为,并根据第二状态转换逻辑将web app对象跳转为执行编辑状态类; a loading state module, configured to execute a related behavior of the loading state in the web app object in the loading state, and jump the web app object to an execution editing state class according to the second state transition logic;编辑状态模块,用于在编辑状态的web app对象中,执行编辑状态的相关行为,并根据第三状态转换逻辑将web app对象跳转为执行保存状态类;Editing a state module, configured to perform an edit state related behavior in a web app object in an edit state, and jump the web app object to an execution save state class according to the third state transition logic;保存状态模块,用于在保存状态的web app对象中,执行保存状态的相关行为,并根据第四状态转换逻辑将web app对象跳转为执行编辑状态类。The save state module is configured to execute a related behavior of saving the state in the web app object in the saved state, and jump the web app object to execute the edit state class according to the fourth state transition logic.
- 根据权利要求8所述的装置,其特征在于,The device of claim 8 wherein:所述状态类还包括:至少一个弹出窗口状态类;The state class further includes: at least one popup window state class;所述编辑状态模块,还用于:The edit status module is further configured to:根据各第五状态转换逻辑将web app对象跳转为执行相应的弹出窗口状态。The web app object is jumped to execute the corresponding popup state according to each fifth state transition logic.
- 根据权利要求10所述的装置,其特征在于,所述状态执行模块还包括:The apparatus according to claim 10, wherein the state execution module further comprises:弹出窗口状态模块,用于在弹出窗口状态类中,执行弹出窗口状态类的相关行为,并根据第七状态转换逻辑将web app对象跳转为执行编辑状态类。A pop-up window status module is configured to execute a related behavior of the pop-up window state class in the pop-up window state class, and jump the web app object to an execution edit state class according to the seventh state transition logic.
- 根据权利要求10或11所述的装置,其特征在于,所述预置模块还用于:The device according to claim 10 or 11, wherein the preset module is further configured to:在编辑状态类中加入sticky属性,所述sitcky属性用于web app对象的编辑状态类跳转为执行其他状态类时,保留编辑状态所对应的界面元素。The sticky attribute is added to the edit state class, and the sitcky attribute is used to edit the edit state of the web app object to retain the interface element corresponding to the edit state when executing other state classes.
- 根据权利要求11所述的装置,其特征在于,所述编辑状态模块还用于:The apparatus according to claim 11, wherein the editing status module is further configured to:判断是否将web app对象由编辑状态类跳转至弹出窗口状态类;如果是跳转至弹出窗口状态,则保留编辑状态所对应的界面元素;Determining whether the web app object is jumped from the edit state class to the popup window state class; if it is jumping to the popup window state, the interface element corresponding to the edit state is retained;如果不是,则清理编辑状态类。If not, clean up the edit state class.
- 根据权利要求8所述的装置,其特征在于,每个所述状态转换逻辑根据相应状态下的一个或多个具体行为触发状态类的跳转。The apparatus of claim 8 wherein each of said state transition logic triggers a jump of a state class based on one or more specific behaviors in respective states.
- 一种完全状态模式web app,其特征在于,包括:A full state mode web app, comprising:状态执行模块,适于当web app对象执行某个状态类时,在该状态类的状态中,执行所述状态的相关行为,并根据该状态类的状态转换逻辑,将web app对象从当前执行的状态类,跳转为执行与所述状态转换逻辑对应的 另一状态类;其中所述各个状态类根据web app的状态设置,所述web app的状态根据决定web app行为变化的属性进行划分;其中,每个状态类包括相应状态的相关行为,以及用于状态类跳转的状态转换逻辑。 a state execution module, configured to: when a web app object executes a state class, perform a related behavior of the state in a state of the state class, and execute a web app object from the current state according to state transition logic of the state class State class, jumps to execute corresponding to the state transition logic Another state class; wherein the respective state classes are set according to a state of the web app, and the state of the web app is divided according to an attribute that determines a behavior change of the web app; wherein each state class includes a related behavior of the corresponding state, and State transition logic for state class jumps.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510604273.1 | 2015-09-21 | ||
CN201510604273.1A CN106547525A (en) | 2015-09-21 | 2015-09-21 | A kind of method and apparatus of the web app for performing complete state pattern |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2017050145A1 true WO2017050145A1 (en) | 2017-03-30 |
Family
ID=58364310
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2016/098813 WO2017050145A1 (en) | 2015-09-21 | 2016-09-13 | Method and device for executing web app under complete state mode |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN106547525A (en) |
WO (1) | WO2017050145A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110865865A (en) * | 2019-11-22 | 2020-03-06 | 科大讯飞股份有限公司 | Popup window position determining method, device, equipment and storage medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104216715A (en) * | 2014-09-02 | 2014-12-17 | 深圳前海诺德咨询服务有限公司 | Web App development framework and method |
CN104516738A (en) * | 2014-12-15 | 2015-04-15 | 北京金和软件股份有限公司 | Integrated implementing method for development and release of APP |
US20150234798A1 (en) * | 2012-06-01 | 2015-08-20 | Google Inc. | System and method for changing a web ui application appearance based on state through css selector cascading |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101527752B (en) * | 2009-04-07 | 2012-05-23 | 中兴通讯股份有限公司 | State transition method of mobile terminal and system thereof |
CN101957751B (en) * | 2010-06-04 | 2013-07-24 | 福建星网锐捷网络有限公司 | Method and device for realizing state machine |
CN103019695B (en) * | 2012-11-22 | 2016-07-06 | 用友网络科技股份有限公司 | Data object and state control logical separation system and method |
CN104133684A (en) * | 2014-08-04 | 2014-11-05 | 浪潮通用软件有限公司 | Graphical user interface state control method based on state machine |
CN104572029B (en) * | 2014-12-26 | 2017-06-30 | 中国科学院自动化研究所 | A kind of sliceable property of state machine and the regular decision method of splicing and device |
-
2015
- 2015-09-21 CN CN201510604273.1A patent/CN106547525A/en active Pending
-
2016
- 2016-09-13 WO PCT/CN2016/098813 patent/WO2017050145A1/en active Application Filing
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20150234798A1 (en) * | 2012-06-01 | 2015-08-20 | Google Inc. | System and method for changing a web ui application appearance based on state through css selector cascading |
CN104216715A (en) * | 2014-09-02 | 2014-12-17 | 深圳前海诺德咨询服务有限公司 | Web App development framework and method |
CN104516738A (en) * | 2014-12-15 | 2015-04-15 | 北京金和软件股份有限公司 | Integrated implementing method for development and release of APP |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110865865A (en) * | 2019-11-22 | 2020-03-06 | 科大讯飞股份有限公司 | Popup window position determining method, device, equipment and storage medium |
CN110865865B (en) * | 2019-11-22 | 2023-01-13 | 科大讯飞股份有限公司 | Popup window position determining method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN106547525A (en) | 2017-03-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10277582B2 (en) | Application service architecture | |
US8875098B2 (en) | Workflow engine for execution of web mashups | |
US10042834B2 (en) | Dynamic field extraction of data | |
RU2604431C2 (en) | Automated transformation of user interface object and code generation | |
US8862975B2 (en) | Web-based workflow service visualization and navigation | |
US8312425B2 (en) | Dynamic template instantiation | |
US8296721B2 (en) | Template-based software development | |
US11797273B2 (en) | System and method for enhancing component based development models with auto-wiring | |
US11635974B2 (en) | Providing a different configuration of added functionality for each of the stages of predeployment, deployment, and post deployment using a layer of abstraction | |
US9218100B2 (en) | Method and system for partitioning asset management plugins | |
US11321422B1 (en) | User-configurable aggregate web components | |
US12106077B2 (en) | Process flow builder for extensible web component sequences | |
US20170344363A1 (en) | Dependency management | |
US10409567B2 (en) | Trimming unused dependencies using package graph and module graph | |
US11797638B2 (en) | Aggregate component for parallel browser-initiated actions | |
US20220245206A1 (en) | Process flow builder for user-configurable web component sequences | |
US11604662B2 (en) | System and method for accelerating modernization of user interfaces in a computing environment | |
US10678561B2 (en) | Virtualizing extension code in an application | |
WO2017050145A1 (en) | Method and device for executing web app under complete state mode | |
US8990499B2 (en) | Caching of a site model in a hierarchical modeling system for network sites | |
US20240338302A1 (en) | Simulated software features in a simulated sandbox within a production environment | |
WO2024221415A1 (en) | Page rendering method and apparatus, device, and storage medium | |
US20140372862A1 (en) | System and method for automatic provisioning of companion resources in a web hosting environment | |
CN117608732A (en) | Web application dynamic rendering device, method, equipment and medium | |
Lamberti et al. | How to move your own applications into the cloud by exploiting interfaces automation and accessibility features |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 16848027 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 16848027 Country of ref document: EP Kind code of ref document: A1 |