Dialog box display method and device, electronic equipment and readable storage medium
By using a unified preset object to manage dialog box lifecycles via JavaScript promises, the method addresses code redundancy issues in dialog box management, enhancing development efficiency and maintainability.
Patent Information
- Application Number
- CN202411175240.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-17
AI Technical Summary
The proliferation of dialog boxes in web or application pages leads to increased code redundancy due to the need for numerous state variables to manage their states, complicating the development and maintenance process.
A method and device for displaying dialog boxes that utilize a single preset object to manage asynchronous operations, allowing dialog box instances to be created and closed without individual state variables, leveraging JavaScript promises to encapsulate and control the lifecycle of each dialog box.
Reduces code redundancy, improves maintainability, simplifies state management, and decreases developer burden by allowing dialog boxes to be controlled through a unified object, ensuring efficient and error-free development.
Smart Images

Figure CN119149154A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for displaying a dialog box, an electronic device and a readable storage medium. Background Art
[0002] At present, when a web page or an application page receives certain events, a dialog box will be displayed in the page. For example, when a user clicks the purchase button of a certain product in the page, a purchase confirmation dialog box may pop up to remind the user to confirm whether to purchase the product, and then confirm whether the user purchases the product based on the interaction between the user and the dialog box. In the case of confirming the purchase, subsequent processing can be performed based on the purchase confirmation information, and the dialog box can be closed at the same time; in the case of confirming not to purchase, the dialog box can be directly closed without performing other subsequent operations.
[0003] In the related art, for each dialog box that may be displayed in the page, a state variable needs to be set respectively to manage the state of the dialog box, so that when the state variable indicates an open state, the corresponding dialog box is displayed, and when the state variable indicates a closed state, the corresponding dialog box is closed. It can be seen that when the number of dialog boxes is large, the number of state variables will also increase, which aggravates the problem of code redundancy in the page development process. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a method, device, electronic device and readable storage medium for displaying a dialog box, so as to reduce code redundancy in the process of page development. The specific technical solution is as follows:
[0005] In one aspect of the present invention, a method for displaying a dialog box is first provided, the method comprising:
[0006] When a dialog box opening event of a target page is detected, a dialog box identifier corresponding to the dialog box opening event is obtained as a target identifier;
[0007] Creating a dialog box instance corresponding to the target identifier to display the corresponding dialog box; wherein each dialog box instance includes a first function for destroying the dialog box instance;
[0008] Creating a preset object for processing an asynchronous operation task; wherein the preset object comprises: a second function for executing when the preset object is in an end state; the second function is bound to the first function;
[0009] Injecting a third function for changing the object state in the preset object into the dialog box instance corresponding to the target identifier;
[0010] When a closing operation on the displayed dialog box is detected, the third function is called to change the state of the preset object to an end state, so as to trigger the second function to call the first function to close the displayed dialog box.
[0011] Optionally, the end state includes: a success state indicating that the asynchronous operation task is executed successfully, and a failure state indicating that the asynchronous operation task is executed unsuccessfully; the third function includes: a fourth function for changing the state of the preset object to a success state and obtaining the execution result of the asynchronous operation task;
[0012] When a closing operation on the displayed dialog box is detected, calling the third function to change the state of the preset object to an end state includes:
[0013] When a close operation is detected for the displayed dialog box, if the close operation indicates that the user needs to pass information through the dialog box, the fourth function is called to obtain the information passed by the close operation as the asynchronous operation task execution result, and the state of the preset object is changed to the end state.
[0014] Optionally, the end state includes: a success state indicating that the asynchronous operation task is executed successfully, and a failure state indicating that the asynchronous operation task is executed unsuccessfully; the third function includes: a fifth function for changing the state of the preset object to a failure state; when a close operation on the displayed dialog box is detected, calling the third function to change the state of the preset object to the end state includes:
[0015] When a closing operation on the displayed dialog box is detected, if the closing operation indicates that the user does not need to transmit information through the dialog box, the fifth function is called to change the state of the preset object to an execution failure state.
[0016] Optionally, the creating a dialog box instance corresponding to the target identifier to display the corresponding dialog box includes:
[0017] Create a dialog box instance corresponding to the target identifier;
[0018] Injecting a sixth function for obtaining parameters passed by a dialog box opening event into the dialog box instance corresponding to the target identifier;
[0019] The sixth function is called to obtain the parameters passed by the dialog box opening event, so as to display a dialog box containing the obtained parameters.
[0020] Optionally, the method further comprises:
[0021] When the dialog box corresponding to the target identifier is in a display state, calling a preset page sliding prohibition function to stop the page sliding function of the target page;
[0022] When the dialog box corresponding to the target identifier is closed, a preset page sliding recovery function is called to restore the page sliding function of the target page.
[0023] In another aspect of the present invention, a device for displaying a dialog box is provided, the device comprising:
[0024] An identifier acquisition module, used for acquiring a dialog box identifier corresponding to the dialog box opening event as a target identifier when a dialog box opening event of a target page is detected;
[0025] A dialog creation module, used for creating a dialog instance corresponding to the target identifier to display the corresponding dialog; wherein each dialog instance includes a first function for destroying the dialog instance;
[0026] An object creation module, used for creating a preset object for processing an asynchronous operation task; wherein the preset object comprises: a second function for executing when the preset object is in an end state; the second function is bound to the first function;
[0027] An injection module, used for injecting a third function for changing the object state in the preset object into the dialog instance corresponding to the target identifier;
[0028] The closing module is used to call the third function to change the state of the preset object to the end state when a closing operation on the displayed dialog box is detected, so as to trigger the second function to call the first function to close the displayed dialog box.
[0029] Optionally, the end state includes: a success state indicating that the asynchronous operation task is executed successfully, and a failure state indicating that the asynchronous operation task is executed unsuccessfully; the third function includes: a fourth function for changing the state of the preset object to a success state and obtaining the execution result of the asynchronous operation task;
[0030] The closing module is specifically used for:
[0031] When a close operation is detected for the displayed dialog box, if the close operation indicates that the user needs to pass information through the dialog box, the fourth function is called to obtain the information passed by the close operation as the asynchronous operation task execution result, and the state of the preset object is changed to the end state.
[0032] In another aspect of the present invention, there is provided an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0033] Memory, used to store computer programs;
[0034] The processor is used to implement any of the above-mentioned dialog box display methods when executing the program stored in the memory.
[0035] In another aspect of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method for displaying any of the above-mentioned dialog boxes is implemented.
[0036] In another aspect of the present invention, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute any of the above-mentioned methods for displaying a dialog box.
[0037] The dialog box display method provided by the embodiment of the present invention, when the dialog box opening event of the target page is detected, the dialog box identification corresponding to the dialog box opening event is obtained as the target identification, and the corresponding dialog box instance is created to realize the display of the dialog box; then a preset object for processing asynchronous operation tasks is created, and the preset object will execute a second function when it is in the end state, and the second function is bound to the first function for destroying the dialog box instance; on this basis, the third function for changing the object state in the preset object is injected into the dialog box instance, so that when the closing operation for the displayed dialog box is detected, the state of the preset object can be changed to the end state by calling the third function, so as to trigger the second function to call the bound first function, and the created dialog box instance is destroyed to realize the closing of the displayed dialog box. It can be seen that in this scheme, for any dialog box that needs to be opened on the page, the display of the dialog box can be realized by creating a corresponding dialog box instance, and then, the closing of the dialog box can be controlled by the same preset object for processing asynchronous operation tasks, without setting state variables for each dialog box to control the display and closing of the dialog box, so that the code redundancy in the page development process can be reduced by this scheme. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0039] Figure 1 Schematic diagram of a flow chart of a method for displaying a dialog box in an embodiment of the present invention;
[0040] Figure 2 is a schematic diagram of a page in an embodiment of the present invention;
[0041] Figure 3 is a schematic diagram of a dialog box in an embodiment of the present invention;
[0042] Figure 4 Another schematic diagram of the flow of the method for displaying a dialog box in an embodiment of the present invention;
[0043] Figure 5 is a schematic diagram of the structure of a display device for a dialog box in an embodiment of the present invention;
[0044] Figure 6 FIG. 4 is a schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0045] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0046] In order to reduce code redundancy in the page development process, an embodiment of the present invention provides a method, device, electronic device and readable storage medium for displaying a dialog box. The method for displaying a dialog box can be applied to an electronic device with data processing capabilities. Specifically, the method can be executed by a program pre-developed and installed in the electronic device. The method can include the following steps:
[0047] When a dialog box opening event of the target page is detected, a dialog box identifier corresponding to the dialog box opening event is obtained as a target identifier;
[0048] Creating a dialog box instance corresponding to the target identifier to display the corresponding dialog box; wherein each dialog box instance includes a first function for destroying the dialog box instance;
[0049] Creating a preset object for processing an asynchronous operation task; wherein the preset object includes: a second function for executing when the preset object is in an end state; the second function is bound to the first function;
[0050] Inject the third function for changing the object state in the preset object into the dialog box instance corresponding to the target identifier;
[0051] When a closing operation on the displayed dialog box is detected, the third function is called to change the state of the preset object to the end state, so as to trigger the second function to call the first function to close the displayed dialog box.
[0052] In this embodiment, for any dialog box that needs to be opened on the page, the display of the dialog box can be achieved by creating a corresponding dialog box instance. Afterwards, the closing of the dialog box can be controlled by the same preset object for processing asynchronous operation tasks, without having to set state variables for each dialog box to control the display and closing of the dialog box. Therefore, this solution can reduce code redundancy in the page development process.
[0053] The following is an exemplary description of the embodiments of the present invention in conjunction with the accompanying drawings. Figure 1 As shown, the method may include the following steps:
[0054] S101, when a dialog box opening event of a target page is detected, a dialog box identifier corresponding to the dialog box opening event is obtained as a target identifier;
[0055] A dialog box is a special window that can be a pop-up window or a floating window. It is used to display information to the user on the page, or to request user input, or both.
[0056] For a page, you can pre-configure multiple dialog boxes that may need to be opened, and set corresponding dialog box identifiers for events that require opening a dialog box. The dialog box identifier can be the name of the dialog box, so that when an event that requires opening a dialog box is detected, the dialog box identifier corresponding to the event can be obtained to determine the dialog box that needs to be displayed.
[0057] For example, Figure 2 As shown, in Figure 2 In the page shown, the events that require opening a dialog box may include: the event of clicking "view details", in response to which a dialog box for displaying the history of points acquisition and consumption may pop up; the events that require opening a dialog box may also include: the event of clicking any prize, in response to which a dialog box for reminding the user whether to confirm the redemption may pop up. In the development stage of the program, the corresponding relationship between these events and the dialog box identifier can be set respectively, so that when any event that requires opening a dialog box is detected, the corresponding dialog box identifier is obtained to execute the subsequent steps of displaying the dialog box.
[0058] S102, creating a dialog box instance corresponding to the target identifier to display the corresponding dialog box; wherein each dialog box instance includes a first function for destroying the dialog box instance;
[0059] In this embodiment, a dialog box component can be developed for a page based on a Vue (a JavaScript framework for building a user interface) framework in a JavaScript (a programming language) language. For each dialog box, the corresponding program logic can be pre-set for it according to the functional requirements, and a display function of the dialog box can be set to display the dialog box, and an instance destruction function can be set to destroy the dialog box instance to close the dialog box.
[0060] S103, creating a preset object for processing an asynchronous operation task; wherein the preset object includes: a second function for executing when the preset object is in an end state; the second function is bound to the first function;
[0061] In this embodiment, the end state of the preset object for processing the asynchronous operation task may include: a success state indicating that the asynchronous operation task is executed successfully, and a failure state indicating that the asynchronous operation task is executed unsuccessfully.
[0062] In one implementation, the preset object may be a promise object in the JavaScript language, and the promise object may encapsulate an asynchronous operation task. In this embodiment, each dialog box that needs to be opened on the target page may be treated as an asynchronous operation task, and thus encapsulated by a promise object. In this way, after a promise object is created, a new promise object may not be created until the encapsulated asynchronous operation task is completed. Based on this property, it can also ensure that at most only one dialog box is displayed at the same time, avoiding the problem of dialog box stacking.
[0063] The second function can be the finally (result) function of the promise object. The promise object can be created when executing an abnormal operation task. The initial state of the promise object after being created is pending. When the asynchronous operation task it handles is completed, its state can be changed to the end state by calling the resolve function or the reject function. Specifically, when the resolve function is called, the state of the promise object will change to the fulfilled state, which means that the asynchronous operation task is successfully completed; when the reject function is called, the state of the promise object will change to the rejected state, which means that the asynchronous operation task is successfully completed. Both states indicate that the execution of the asynchronous operation task is completed, after which the instance of the promise object will be automatically destroyed and the execution of the finally function will be triggered. The finally function can set the corresponding program logic as needed.
[0064] Based on the above principle, in this embodiment, the finally function can be bound to the first function that destroys the dialog instance, that is, when the finally function is called, the function that destroys the dialog instance will be called at the same time to finally close the dialog box.
[0065] S104, injecting a third function for changing the object state in the preset object into the dialog box instance corresponding to the target identifier;
[0066] In the case where the end state can be: a success state indicating that the asynchronous operation task is executed successfully and a failure state indicating that the asynchronous operation task is executed unsuccessfully; the third function includes: a function for changing the state of a preset object to a success state, and / or a function for changing the state of the preset object to a failure state. The third function may include the resolve function and / or the reject function in the above-mentioned promise object. In this step, the third function may be injected into the dialog instance by calling the mixin (injection) function, so that the dialog instance can call the third function at runtime.
[0067] S105, when a closing operation on the displayed dialog box is detected, calling a third function to change the state of the preset object to an end state, so as to trigger the second function to call the first function, thereby closing the displayed dialog box.
[0068] The dialog box can be closed by the user through interaction with the dialog box, for example, Figure 3 As shown, the user can click the "Confirm" button or the "Cancel" button in the dialog box to generate a closing operation. When a closing operation on the displayed dialog box is detected, the third function can be called to change the state of the preset object to the end state, thereby triggering the second function to call the first function to close the displayed dialog box. Afterwards, the target page can continue to respond to other dialog box opening events to display dialog boxes.
[0069] Specifically, the state of the promise object can be changed to the fulfilled state by calling the above-mentioned resolve function, or the state of the promise object can be changed to the rejected state by calling the reject function, which will trigger the call of the finally function. Since the finally function is pre-set to be bound to the function that destroys the dialog instance, the function that destroys the dialog instance will also be called when the finally function is called, thereby automatically destroying the dialog instance to achieve the purpose of closing the dialog box. In this embodiment, by encapsulating the dialog box with the promise object, the state management of the dialog box is abstracted into the life cycle management of the promise object, so that there is no need to set variables for managing the state for each dialog box separately.
[0070] In this embodiment, when a dialog box opening event of a target page is detected, a dialog box identifier corresponding to the dialog box opening event is obtained as the target identifier, and a corresponding dialog box instance is created to realize the display of the dialog box; then a preset object for processing asynchronous operation tasks is created, and a second function is executed when the preset object is in an end state, and the second function is bound to a first function for destroying the dialog box instance; on this basis, a third function for changing the object state in the preset object is injected into the dialog box instance, so that when a closing operation for the displayed dialog box is detected, the state of the preset object can be changed to the end state by calling the third function, so as to trigger the second function to call the bound first function, and the created dialog box instance is destroyed to realize the closing of the displayed dialog box.
[0071] It can be seen that in this solution, for any dialog box that needs to be opened on the page, the display of the dialog box can be realized by creating a corresponding dialog box instance. After that, the closing of the dialog box can be controlled by the same preset object for processing asynchronous operation tasks, without having to set state variables for each dialog box to control the display and closing of the dialog box. Therefore, this solution can reduce code redundancy in the page development process, improve code maintainability, simplify the logic of state management, reduce code errors in the development process, and thus reduce the burden on developers, allowing developers to focus more on the core function development of the application.
[0072] In one embodiment of the present invention, the third function may include: a fourth function for changing the state of the preset object to a success state and obtaining the execution result of the asynchronous operation task; when a close operation for the displayed dialog box is detected, calling the third function to change the state of the preset object to an end state, including:
[0073] When a close operation is detected for the displayed dialog box, if the close operation indicates that the user needs to pass information through the dialog box, the fourth function is called to obtain the information passed by the close operation as the asynchronous operation task execution result, and the state of the preset object is changed to the end state.
[0074] The creation and closing of the dialog instance in this embodiment can be regarded as an asynchronous operation task of the page. The fourth function can be the above-mentioned resolve function. When the asynchronous operation task ends, the resolve function can trigger the finally function and obtain the execution result of the asynchronous operation task. Subsequently, the then function in the promise object can be called to obtain the execution result for subsequent task processing.
[0075] Still Figure 3For example, when developing the dialog box, you can bind the "Confirm" button to the resolve function. In this way, when the user clicks the "Confirm" button, it means that the user agrees to consume 10 points to redeem the prize. Then, you can pass the "10 points" as the execution result of the asynchronous operation task to the resolve function. After that, the main program of the page can obtain the 10 points to perform subsequent points deduction tasks and subtract 10 from the user's remaining points.
[0076] The third function may further include: a fifth function for changing the state of the preset object to a failed state; when a closing operation on the displayed dialog box is detected, calling the third function to change the state of the preset object to an ending state, including:
[0077] When a close operation on the displayed dialog box is detected, if the close operation indicates that the user does not need to transmit information through the dialog box, the fifth function is called to change the state of the preset object to an execution failure state.
[0078] Accordingly, the fifth function may be the reject function, and when the asynchronous operation task ends, the finally function may be directly triggered by calling the reject function. Based on this, when the closing operation indicates that the user does not need to pass information through the dialog box, the purpose of closing the dialog box can be achieved by calling the reject function.
[0079] Still Figure 3 For example, when developing the dialog box, you can bind the "Cancel" button to the reject function. In this way, when the user clicks the "Cancel" button, it means that the user does not agree to consume 10 points to redeem the prize. At this time, there is no need to perform subsequent points deduction tasks. In this case, it can be regarded that the user does not need to pass information through the dialog box. The finally function can be triggered by calling the reject function to directly close the dialog box.
[0080] It can be seen that two modes of interaction can be achieved by respectively utilizing the resolve function and the reject function in the promise object.
[0081] In this embodiment, when the closing operation indicates that the user needs to pass information through a dialog box, the information passed by the closing operation is obtained by calling the fourth function used to obtain the execution result of the asynchronous operation task. While closing the dialog box, the purpose of obtaining the information passed by the user through the dialog box is also achieved.
[0082] In one embodiment of the present invention, creating a dialog box instance corresponding to a target identifier to display a corresponding dialog box includes:
[0083] Step A1, creating a dialog box instance corresponding to the target identifier;
[0084] Step A2, injecting a sixth function for obtaining parameters passed by a dialog box opening event into a dialog box instance corresponding to the target identifier;
[0085] This step can be performed together with the above step S104 of injecting the third function for changing the object state, that is, the third function and the sixth function can be injected into the dialog instance at the same time by calling the mixin function.
[0086] Step A3, calling the sixth function to obtain the parameters passed by the dialog box opening event, so as to display a dialog box containing the obtained parameters.
[0087] Understandably, the information displayed in some dialog boxes is not fixed, for example Figure 2-Figure 3 , when the user clicks "Prize 1", "Prize 2", "Prize 3", and "Prize 4" respectively, the same dialog box instance can be used to display the dialog box, but the information to be displayed is different. Therefore, in this embodiment, the sixth function for obtaining the parameters passed by the dialog box opening event can be injected into the currently created dialog box instance, so that the dialog box instance can obtain the parameters passed by the dialog box opening event during operation and display the dialog box. For example, when the user clicks "Prize 1", "10 points" can be obtained, and when the user clicks "Prize 2", "20 points" can be obtained.
[0088] In this embodiment, the sixth function used to obtain the parameters passed by the dialog box open event is injected into the dialog box instance corresponding to the target identifier, so that the dialog box instance can obtain the parameters passed by the dialog box open event at runtime to display the dialog box, thereby achieving the purpose of passing external information to the dialog box.
[0089] In one embodiment of the present invention, the method for displaying the dialog box further includes:
[0090] When the dialog box corresponding to the target identifier is in the display state, a preset page sliding prohibition function is called to stop the page sliding function of the target page;
[0091] This step may be performed after the above step S102 or step A3. The page sliding prohibition function may be provided by an external SDK (Software Development Kit), such as the page sliding recovery function being a preventMove (prohibit sliding) function.
[0092] When the dialog box corresponding to the target identifier is closed, a preset page sliding recovery function is called to restore the page sliding function of the target page.
[0093] This step may be performed after the above step S105. The page sliding recovery function may be provided by an external SDK, such as the page sliding recovery function being a recoverMove (recover sliding) function.
[0094] In this embodiment, by calling a preset page sliding prohibition function to stop the page sliding function of the target page when the dialog box is in the display state, the correct display of the dialog box can be ensured, allowing the user to focus on the interaction with the dialog box, thereby enhancing the user experience of the dialog box.
[0095] like Figure 4 As shown, by integrating the steps in the above embodiment, the method for displaying a dialog box provided by the present invention may include the following steps:
[0096] S401, when a dialog box opening event of a target page is detected, a dialog box identifier corresponding to the dialog box opening event is obtained as a target identifier;
[0097] S402, creating a dialog box instance corresponding to the target identifier and a preset object for processing an asynchronous operation task;
[0098] S403, injecting a third function for changing the state of a preset object and a sixth function for obtaining parameters passed by a dialog box opening event into a dialog box instance corresponding to the target identifier;
[0099] S404, calling the sixth function to obtain the parameters passed by the dialog box opening event, so as to display a dialog box containing the obtained parameters; and calling a preset page sliding prohibition function to stop the page sliding function of the target page;
[0100] S405, when a closing operation on the displayed dialog box is detected, the third function is called to change the state of the preset object to the end state, so as to trigger the second function to call the first function to close the displayed dialog box; and the preset page sliding recovery function is called to restore the page sliding function of the target page.
[0101] The above steps have been introduced in the previous article and will not be repeated here.
[0102] It should be noted that, in the specific implementation process, the above step S402 can be customized as a function (hereinafter referred to as the openDialog function). In this way, when it is necessary to display a dialog box, the openDialog function can be called, and the target identifier of the dialog box to be opened, the parameters passed by the dialog box opening event, and the preset configuration information are passed to the openDialog function, and a promise instance and a dialog box instance corresponding to the target identifier can be automatically created. The above configuration information may include: information indicating whether page sliding is disabled. If the configuration information indicates that page sliding is disabled, the preset page sliding prohibition function can be called in subsequent steps to stop the page sliding function of the target page; if the configuration information indicates that page sliding is not disabled, the page sliding prohibition function will not be called subsequently.
[0103] In this embodiment, for any dialog box that needs to be opened on the page, the display of the dialog box can be achieved by creating a dialog box instance. Afterwards, the closing of the dialog box can be controlled by the same preset object for processing asynchronous operation tasks, without having to set state variables for each dialog box separately. Therefore, this solution can reduce code redundancy in the page development process.
[0104] Based on the same inventive concept, an embodiment of the present invention further provides a dialog box display device, such as Figure 5 As shown, the device comprises:
[0105] The identifier acquisition module 501 is used to acquire the dialog box identifier corresponding to the dialog box opening event as the target identifier when a dialog box opening event of the target page is detected;
[0106] The dialog creation module 502 is used to create a dialog instance corresponding to the target identifier to display the corresponding dialog; wherein each dialog instance includes a first function for destroying the dialog instance;
[0107] The object creation module 503 is used to create a preset object for processing an asynchronous operation task; wherein the preset object includes: a second function for executing when the preset object is in an end state; the second function is bound to the first function;
[0108] An injection module 504 is used to inject a third function for changing the object state in the preset object into the dialog box instance corresponding to the target identifier;
[0109] The closing module 505 is used to call the third function to change the state of the preset object to the end state when a closing operation on the displayed dialog box is detected, so as to trigger the second function to call the first function to close the displayed dialog box.
[0110] Optionally, the end state includes: a success state indicating that the asynchronous operation task is executed successfully, and a failure state indicating that the asynchronous operation task is executed unsuccessfully; the third function includes: a fourth function for changing the state of the preset object to a success state and obtaining the execution result of the asynchronous operation task;
[0111] The closing module 505 is specifically used for:
[0112] When a close operation is detected for the displayed dialog box, if the close operation indicates that the user needs to pass information through the dialog box, the fourth function is called to obtain the information passed by the close operation as the asynchronous operation task execution result, and the state of the preset object is changed to the end state.
[0113] Optionally, the third function includes: a fifth function for changing the state of the preset object to a failed state; a closing module 505, specifically for:
[0114] When a closing operation on the displayed dialog box is detected, if the closing operation indicates that the user does not need to transmit information through the dialog box, the fifth function is called to change the state of the preset object to an execution failure state.
[0115] Optionally, the dialog creation module 502 is specifically used for:
[0116] Create a dialog box instance corresponding to the target identifier;
[0117] Injecting a sixth function for obtaining parameters passed by a dialog box opening event into the dialog box instance corresponding to the target identifier;
[0118] The sixth function is called to obtain the parameters passed by the dialog box opening event, so as to display a dialog box containing the obtained parameters.
[0119] Optionally, the device further comprises:
[0120] A sliding prohibition module, used to call a preset page sliding prohibition function to stop the page sliding function of the target page when the dialog box corresponding to the target identifier is in a display state;
[0121] The sliding recovery module is used to call a preset page sliding recovery function to restore the page sliding function of the target page when the dialog box corresponding to the target identifier is closed.
[0122] The embodiment of the present invention further provides an electronic device, such as Figure 6As shown, it includes a processor 601, a communication interface 602, a memory 603 and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604.
[0123] Memory 603, used for storing computer programs;
[0124] The processor 601 is used to implement any of the above-mentioned dialog box display methods when executing the program stored in the memory 603.
[0125] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0126] The communication interface is used for communication between the above terminal and other devices.
[0127] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0128] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0129] In another embodiment of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method for displaying a dialog box described in any of the above embodiments is implemented.
[0130] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the method for displaying a dialog box described in any one of the above embodiments.
[0131] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0132] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0133] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, and computer-readable storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0134] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A method for displaying a dialog box, characterized in that: The method comprises: When a dialog box opening event of the target page is detected, a dialog box identifier corresponding to the dialog box opening event is obtained as a target identifier; Creating a dialog box instance corresponding to the target identifier to display the corresponding dialog box; wherein each dialog box instance includes a first function for destroying the dialog box instance; Creating a preset object for processing an asynchronous operation task; wherein the preset object comprises: a second function for executing when the preset object is in an end state; the second function is bound to the first function; Injecting a third function for changing the object state in the preset object into the dialog box instance corresponding to the target identifier; When a closing operation on the displayed dialog box is detected, the third function is called to change the state of the preset object to an end state, so as to trigger the second function to call the first function to close the displayed dialog box.
2. The method according to claim 1, characterized in that The end state includes: a success state indicating that the asynchronous operation task is executed successfully, and a failure state indicating that the asynchronous operation task is executed unsuccessfully; the third function includes: a fourth function for changing the state of the preset object to a success state and obtaining the execution result of the asynchronous operation task; When a closing operation on the displayed dialog box is detected, calling the third function to change the state of the preset object to an end state includes: When a close operation is detected for the displayed dialog box, if the close operation indicates that the user needs to pass information through the dialog box, the fourth function is called to obtain the information passed by the close operation as the asynchronous operation task execution result, and the state of the preset object is changed to the end state.
3. The method according to claim 1, characterized in that The end state includes: a success state indicating that the asynchronous operation task is executed successfully, and a failure state indicating that the asynchronous operation task is executed unsuccessfully; the third function includes: a fifth function for changing the state of the preset object to a failure state; when a close operation for the displayed dialog box is detected, calling the third function to change the state of the preset object to the end state includes: When a closing operation on the displayed dialog box is detected, if the closing operation indicates that the user does not need to transmit information through the dialog box, the fifth function is called to change the state of the preset object to an execution failure state.
4. The method according to claim 1, characterized in that The step of creating a dialog box instance corresponding to the target identifier to display the corresponding dialog box includes: Create a dialog box instance corresponding to the target identifier; Injecting a sixth function for obtaining parameters passed by a dialog box opening event into the dialog box instance corresponding to the target identifier; The sixth function is called to obtain the parameters passed by the dialog box opening event, so as to display a dialog box containing the obtained parameters.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: When the dialog box corresponding to the target identifier is in a display state, calling a preset page sliding prohibition function to stop the page sliding function of the target page; When the dialog box corresponding to the target identifier is closed, a preset page sliding recovery function is called to restore the page sliding function of the target page.
6. A dialog box display device, characterized in that: The device comprises: An identifier acquisition module, used for acquiring a dialog box identifier corresponding to the dialog box opening event as a target identifier when a dialog box opening event of a target page is detected; A dialog creation module, used for creating a dialog instance corresponding to the target identifier to display the corresponding dialog; wherein each dialog instance includes a first function for destroying the dialog instance; An object creation module, used for creating a preset object for processing an asynchronous operation task; wherein the preset object comprises: a second function for executing when the preset object is in an end state; the second function is bound to the first function; An injection module, used for injecting a third function for changing the object state in the preset object into the dialog instance corresponding to the target identifier; The closing module is used to call the third function to change the state of the preset object to the end state when a closing operation on the displayed dialog box is detected, so as to trigger the second function to call the first function to close the displayed dialog box.
7. The device according to claim 6, characterized in that The end state includes: a success state indicating that the asynchronous operation task is executed successfully, and a failure state indicating that the asynchronous operation task is executed unsuccessfully; the third function includes: a fourth function for changing the state of the preset object to a success state and obtaining the execution result of the asynchronous operation task; The closing module is specifically used for: When a close operation is detected for the displayed dialog box, if the close operation indicates that the user needs to pass information through the dialog box, the fourth function is called to obtain the information passed by the close operation as the asynchronous operation task execution result, and the state of the preset object is changed to the end state.
8. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 5 when executing a program stored in a memory.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 5 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is run on a computer, the computer is enabled to implement the method according to any one of claims 1 to 5.
