Pop-up display method, device and storage medium
By using the combination method of pop-up queue and promise objects in the application, the asynchronous control problem during multiple pop-up displays is solved, and the simplicity of the code and efficient memory utilization are achieved.
Patent Information
- Application Number
- CN202411615114.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-04-01
AI Technical Summary
When handling multiple pop-up displays, it is difficult to achieve accurate asynchronous control, resulting in poor readability of code and prone to errors.
By using pop-up queues to manage the scheduling order of pop-up windows, take out pop-up objects from the head of the queue, determine the pop-up conditions based on their configuration information, and instantiate the promise object when the conditions are met to asynchronously control the display of pop-up windows.
It realizes asynchronously and accurately controls the display of multiple pop-up windows, avoids callback nesting, makes the code more concise and easy to read, and saves terminal memory usage.
Smart Images

Figure CN119739446A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a pop-up window display method, device and storage medium. Background Art
[0002] At present, many active projects in applications require multiple pop-up windows to be displayed. When the user clicks to enter the page, multiple pop-up windows pop up one by one in the display order. The commonly used processing method is to use a callback function to control the pop-up and closing of the pop-up window, and process the next callback in the pop-up window callback. The corresponding code of this processing method is poorly readable and difficult to understand and maintain. When it is necessary to control the display of multiple pop-up windows at the same time, errors are prone to occur. Summary of the invention
[0003] The embodiments of the present invention provide a pop-up window display method, device and storage medium, which are used to achieve accurate asynchronous control of the display of multiple pop-up windows.
[0004] In a first aspect, an embodiment of the present invention provides a pop-up window display method, the method comprising:
[0005] Take out a first pop-up window object from the head of the pop-up window queue, where the first pop-up window object encapsulates pop-up window configuration information of the corresponding pop-up window;
[0006] Determining a pop-up condition corresponding to the first pop-up window object according to the pop-up window configuration information;
[0007] If it is detected that the first pop-up window object satisfies the pop-up condition, the promise instance corresponding to the first pop-up window object is instantiated to display the pop-up window corresponding to the first pop-up window object.
[0008] In a second aspect, an embodiment of the present invention provides a pop-up window display device, the device comprising:
[0009] An extracting module, used for extracting a first pop-up window object from the head of the pop-up window queue, wherein the first pop-up window object encapsulates pop-up window configuration information of a corresponding pop-up window;
[0010] A determination module, used to determine a pop-up condition corresponding to the first pop-up window object according to the pop-up window configuration information;
[0011] The detection module is used to instantiate the promise instance corresponding to the first pop-up window object to display the pop-up window corresponding to the first pop-up window object if it is detected that the first pop-up window object meets the pop-up condition.
[0012] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the pop-up display method as described in the first aspect.
[0013] In a fourth aspect, an embodiment of the present invention provides a non-temporary machine-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor can at least implement the pop-up display method described in the first aspect.
[0014] In the pop-up window display solution provided by the embodiment of the present invention, first, the first pop-up window object is taken out from the head of the pop-up window queue, and the first pop-up window object encapsulates the pop-up window configuration information of the corresponding pop-up window. Then, according to the pop-up window configuration information, the pop-up condition corresponding to the first pop-up window object is determined. Next, it is detected whether the first pop-up window object meets the pop-up condition. If it is detected that the first pop-up window object meets the pop-up condition, the promise instance corresponding to the first pop-up window object is instantiated to display the pop-up window corresponding to the first pop-up window object.
[0015] In the above scheme, the scheduling order of pop-up windows is managed by using a pop-up queue, and the pop-up window objects corresponding to each pop-up window are taken out from the head of the pop-up queue in turn for scheduling, ensuring that each pop-up window pops up correctly in a predetermined order, and when the first pop-up window object meets the pop-up condition, the promise instance corresponding to the first pop-up window object is instantiated to display the pop-up window corresponding to the first pop-up window object, so as to realize the asynchronous and precise control of the display of multiple pop-up windows through the promise object, and to avoid callback nesting, making the code more concise and easy to read. In addition, the pop-up window object in the pop-up window queue only encapsulates the pop-up window configuration information, and only creates the promise instance when the pop-up window is actually displayed, which can save the terminal memory usage. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0017] Figure 1 A flowchart of a pop-up window display method provided by an embodiment of the present invention;
[0018] Figure 2 A flowchart of another pop-up window display method provided by an embodiment of the present invention;
[0019] Figure 3A schematic diagram of the life cycle state flow of a pop-up window object provided by an embodiment of the present invention;
[0020] Figure 4 A schematic diagram of the structure of a pop-up window display device provided by an embodiment of the present invention;
[0021] Figure 5 A schematic diagram of the structure of an electronic device provided in this embodiment. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. In addition, the step timing in the following method embodiments is only an example, not a strict limitation.
[0023] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0024] Definition of terms:
[0025] Promise object: An object that provides a unified API for asynchronous operations for further processing of asynchronous operations.
[0026] At present, many active projects in applications have the need to display multiple pop-up windows. When the user enters the page corresponding to the active project, multiple pop-up windows pop up one by one in the display order. In order to accurately and asynchronously control multiple pop-up windows to be displayed in a preset order, in an embodiment of the present invention, a queue data structure can be used to manage the scheduling order of multiple pop-up windows, and the pop-up window objects corresponding to the multiple pop-up windows are queued or dequeued as needed to ensure that the multiple pop-up windows pop up correctly in the predetermined order, and when the pop-up processing is actually performed on multiple pop-up windows, the promise instance corresponding to the pop-up window object is instantiated to display the pop-up window corresponding to the pop-up window object, wherein the promise object encapsulates an asynchronous display method to asynchronously control the display of the pop-up window by instantiating the promise instance corresponding to the pop-up window object. In addition, the pop-up window object in the pop-up window queue only includes necessary information such as the pop-up window configuration. When the display operation is actually performed, the promise instance corresponding to the pop-up window object is instantiated, which can save terminal memory overhead.
[0027] In the following, some embodiments of the present invention are described in detail in conjunction with the accompanying drawings. In the case where there is no conflict between the embodiments, the following embodiments and features in the embodiments can be combined with each other.
[0028] Figure 1 A flowchart of a pop-up window display method provided by an embodiment of the present invention, such as Figure 1 As shown, the execution subject of the method may be a pop-up display device, and it is understandable that the device may be implemented as software, or a combination of software and hardware. Specifically, the method may include:
[0029] 101. Take out a first pop-up window object from the head of the pop-up window queue, where the first pop-up window object encapsulates pop-up window configuration information of a corresponding pop-up window.
[0030] 102. Determine a pop-up condition corresponding to the first pop-up window object according to the pop-up window configuration information.
[0031] 103. If it is detected that the first pop-up window object satisfies the pop-up condition, instantiate a promise instance corresponding to the first pop-up window object to display the pop-up window corresponding to the first pop-up window object.
[0032] The pop-up window display solution provided by the embodiment of the present invention can be applied to various terminal devices installed with the target application to realize asynchronous control and display of multiple pop-up windows in the target application. Among them, the target application can be any type of application, for example, a recruitment APP, an information browsing APP, a video APP, etc. In addition, the pop-up window display solution provided by the embodiment of the present invention can also be applied to asynchronous control and display of multiple pop-up windows in a mini program or multiple pop-up windows in a web page.
[0033] In actual applications, an application usually promotes new features, advertisements, activities, etc. by displaying multiple pop-up windows during the startup process or during use. That is, the application may be associated with multiple pop-up windows to be displayed, and in order to better display these new features, advertisements, activities, etc. to be promoted, in practice, multiple pop-up windows to be displayed need to be displayed in sequence according to a predetermined order or trigger conditions.
[0034] Therefore, in an embodiment of the present invention, a queue data structure can be used to manage the scheduling of multiple pop-up windows so as to subsequently trigger and call multiple pop-up windows for display. Specifically, the pop-up window information corresponding to each of the multiple pop-up windows associated with the application can be added to the pop-up window queue in sequence according to a predetermined order.
[0035] In practice, multiple pop-up windows associated with applications are divided into non-interactive pop-up windows and interactive pop-up windows. Among them, non-interactive pop-up windows refer to pop-up windows that can be automatically popped up without user input. This type of pop-up window is generally used to display information notifications, warnings, or other types of information without interrupting the current operation process. Interactive pop-up windows refer to pop-up windows that require users to respond before they can be popped up. This type of pop-up window is often used in scenarios such as confirmation dialog boxes and warning prompts, requiring users to click OK, Cancel, or other buttons to indicate their intentions.
[0036] For example, in actual applications, when a user selects several files and clicks the delete button, the interactive pop-up window associated with the operation action will be triggered to pop up, and a confirmation dialog box will pop up in the application interface to ask the user whether to confirm the deletion of the selected file. When performing the pop-up operation, the interactive pop-up window needs to be scheduled out of the pop-up window queue first, and then the pop-up operation is performed. However, the pop-up window information corresponding to the multiple pop-ups in the pop-up window queue may be added in sequence in a predetermined order. When scheduling the pop-up window, each pop-up window can only be taken out from the pop-up window queue in sequence according to the order of addition. If the interactive pop-up window is not displayed in the predetermined order at this time, it is necessary to take out the multiple pop-ups in the pop-up window queue before the interactive pop-up window, and then perform the pop-up operation on the interactive pop-up window, and the user waits for a long time. In addition, after adding the multiple pop-ups before the interactive pop-up window to the pop-up window queue again, pop-up errors and other problems may occur, so that the multiple pop-ups cannot be normally popped up in the predetermined order.
[0037] That is to say, the interactive pop-up window associated with the application may be triggered to pop up suddenly instead of in the predetermined order. If all the pop-up windows associated with the application are directly added to the pop-up queue in the predetermined order, when scheduling the interactive pop-up windows, not only will the operation be complicated but pop-up errors may also occur.
[0038] Therefore, in order to flexibly use the queue data structure to schedule and manage multiple pop-up windows associated with the application, in an embodiment of the present invention, only the pop-up window information corresponding to the non-interactive pop-up window can be added to the pop-up window queue.
[0039] In a specific implementation, the pop-up window data of the multiple pop-up windows may be obtained first, the pop-up window data including the pop-up window configuration information. According to the pop-up window configuration information of the multiple pop-up windows, multiple first pop-up windows are screened out from the multiple pop-up windows, and the first pop-up windows are non-interactive pop-up windows. Then, a pop-up window object corresponding to each of the multiple first pop-up windows is created, and the pop-up window objects corresponding to each of the multiple first pop-up windows are added to the pop-up window queue in sequence according to the pop-up order of the multiple first pop-up windows.
[0040] Among them, the pop-up window information corresponding to each pop-up window usually includes pop-up window configuration information, pop-up window status, pop-up window display method and other information. If the pop-up window information corresponding to multiple pop-up windows is directly added to the pop-up window queue, this will occupy a large amount of memory space of the terminal device and affect the normal operation of the terminal device. Then, in an embodiment of the present invention, before registering multiple first pop-up windows to the pop-up window queue, a pop-up window object corresponding to each first pop-up window can be created first. The pop-up window object only encapsulates the necessary information such as the pop-up window configuration information and pop-up window status corresponding to the corresponding pop-up window. When the pop-up window display operation is actually executed, the promise object corresponding to the first pop-up window object is initialized to display the first pop-up window using the pop-up window display operation encapsulated in the promise object.
[0041] After adding each non-interactive first pop-up window to the pop-up window queue, when the pop-up window needs to be scheduled, the pop-up window object corresponding to each first pop-up window can be taken out from the head of the pop-up window queue in turn, so that each first pop-up window can be scheduled in an orderly manner to ensure that each first pop-up window can be normally popped up in a predetermined order. Among them, the pop-up window display process corresponding to each pop-up window is the same, and only the specific implementation process of displaying any first pop-up window is described here.
[0042] Specifically, the first pop-up window object is taken out from the head of the pop-up window queue, and the first pop-up window object encapsulates the pop-up window configuration information of the corresponding pop-up window, wherein the pop-up window configuration information includes configuration information such as trigger conditions, pop-up window icons, pop-up window styles, pop-up window positions, and pop-up window types.
[0043] Then, according to the pop-up window configuration information, the pop-up condition corresponding to the first pop-up window object is determined. When determining the pop-up condition of the first pop-up window object, the pop-up condition corresponding to the first pop-up window object can be determined in combination with the pop-up type and trigger condition of the first pop-up window object.
[0044] In an optional embodiment, the pop-up window triggering condition and the pop-up type corresponding to the first pop-up window object are determined according to the pop-up window configuration information. According to the pop-up window triggering condition and the pop-up type, the pop-up condition corresponding to the first pop-up window object is determined. For example, assuming that the pop-up type of the first pop-up window object is to pop up once a day, and the triggering condition is to display the first pop-up window corresponding to the first pop-up window object when the home page of the application is loaded, then the pop-up condition corresponding to the first pop-up window object determined is: the first pop-up window object has not popped up on the day, and the application is in the home page loading state.
[0045] After determining the pop-up condition corresponding to the first pop-up window object, it is detected whether the first pop-up window object meets the pop-up condition. Specifically, it can be checked whether the number of pop-ups of the first pop-up window object on the day meets the preset condition and whether the application is in a preset trigger state.
[0046] Among them, the pop-up record corresponding to the first pop-up object can be obtained from the server, and each pop-up operation can be reported to the server so that the server can record the pop-up information corresponding to each pop-up object in a timely and accurate manner, thereby ensuring that each pop-up window pops up according to the preset pop-up type.
[0047] When it is detected that the first pop-up window object meets the pop-up condition, the promise instance corresponding to the first pop-up window object is instantiated to display the pop-up window corresponding to the first pop-up window object. In actual applications, multiple pop-ups may need to be displayed at the same time. If the display of multiple pop-ups is controlled by synchronous control, then under synchronous control, the display of multiple pop-ups may block other operations of the user until all pop-ups are processed.
[0048] In order to avoid the display of multiple pop-up windows blocking other operations of the user, in an embodiment of the present invention, an asynchronous control method can be used to control the display of multiple pop-up windows. Among them, a promise object can be used to asynchronously control multiple pop-up windows, and the corresponding pop-up window display operation is encapsulated in the promise object. By managing the display and closing of pop-up windows through the promise object, callback nesting can also be avoided, making the code more concise and easy to read.
[0049] In order to reduce the memory usage of the terminal, you can first create corresponding promise objects for each pop-up window associated with the application. Each promise object encapsulates the pop-up display operation corresponding to the corresponding pop-up window. When it is detected that the first pop-up window object meets the pop-up condition, based on the Promise object corresponding to the first pop-up window object and the pop-up configuration information of the first pop-up window object, determine the Promise instance corresponding to the first pop-up window object, and then instantiate the promise instance corresponding to the first pop-up window object to display the pop-up window corresponding to the first pop-up window object.
[0050] From the above description, it can be seen that the first pop-up window object in the pop-up window queue does not include the Promise instances corresponding to each pop-up window. Only when the pop-up window display operation corresponding to each pop-up window object is actually executed, the Promise instance corresponding to each pop-up window object is instantiated to handle the pop-up window display operation, that is, creating Promise instances on demand, which can reduce the memory overhead of the mobile terminal.
[0051] In an embodiment of the present invention, a pop-up window queue is used to manage the scheduling order of pop-up windows, and the pop-up window objects corresponding to each pop-up window are taken out from the head of the pop-up window queue in sequence for scheduling, ensuring that each pop-up window pops up correctly in a predetermined order, and when the first pop-up window object meets the pop-up condition, the promise instance corresponding to the first pop-up window object is instantiated to display the pop-up window corresponding to the first pop-up window object, so as to realize the asynchronous and precise control of the display of multiple pop-up windows through the promise object, and to avoid callback nesting, making the code more concise and easy to read. In addition, the pop-up window object in the pop-up window queue only encapsulates the pop-up window configuration information, and only creates the promise instance when the pop-up window is actually executed and displayed, which can save the terminal memory usage.
[0052] Among them, when displaying and controlling multiple pop-up windows in a terminal application, if the network environment corresponding to the terminal may be unstable, a pop-up window may not be able to be popped up normally. In order to ensure that multiple pop-up windows are popped up normally, after instantiating the promise instance corresponding to each pop-up window object, it is also possible to detect whether the pop-up window object has been popped up. This process is described in detail in conjunction with the following embodiments.
[0053] Figure 2 A flowchart of another pop-up window display method provided by an embodiment of the present invention, such as Figure 2 As shown, based on the above embodiment, the method may further include the following steps:
[0054] 201. If it is detected that the pop-up window corresponding to the first pop-up window object is not popped up, obtain abnormal description information corresponding to the first pop-up window object.
[0055] 202. Determine an exception handling strategy corresponding to the first pop-up window object based on the exception description information and the pop-up window configuration information of the first pop-up window object.
[0056] 203. Perform exception handling on the first pop-up window object based on the exception handling strategy corresponding to the first pop-up window object.
[0057] After instantiating the promise instance corresponding to the first pop-up window object, it can be detected whether the pop-up window corresponding to the first pop-up window object is popped up. If it is detected that the pop-up window corresponding to the first pop-up window object is not popped up, the abnormal description information corresponding to the first pop-up window object is obtained.
[0058] As for the method of obtaining the exception description information of the first pop-up window object, the catch method in the promise instance can be used to capture the exception information of the first pop-up window object, and the exception information is published through the event bus to trigger the corresponding exception handling mechanism. When the pop-up window display device subscribes to the exception information, the exception description information corresponding to the first pop-up window object is determined according to the exception information.
[0059] After the exception description information corresponding to the first pop-up window object is obtained, the exception handling strategy corresponding to the first pop-up window object can be determined based on the exception description information and the pop-up window configuration information of the first pop-up window object, and the first pop-up window object is subjected to exception handling based on the exception handling strategy corresponding to the first pop-up window object.
[0060] Among them, the exception handling strategy can be to re-execute the pop-up operation or not to execute the pop-up operation. For more important pop-ups, the pop-up operation can be re-executed, and for less important pop-ups, the pop-up operation can be not executed, so as to avoid multiple pop-ups causing trouble to users.
[0061] The exception handling strategy may also include time information corresponding to re-executing the pop-up operation. For example, for some pop-up windows, when it is detected that the pop-up window has not popped up, the pop-up operation is performed on the pop-up window immediately, or the pop-up window object corresponding to the pop-up window is re-added to the end of the pop-up window queue and waits for the next scheduling before displaying the pop-up window.
[0062] In specific implementation, if the exception handling strategy is to immediately re-pop up the first pop-up object, the first pop-up object will be determined as the next pop-up object to be displayed, and inserted behind the pop-up object currently being displayed or in front of the first pop-up object that has been taken out of the pop-up queue and the pop-up display operation has not been executed, and the pop-up operation will be executed immediately; if the exception handling strategy is not to immediately re-pop up the first pop-up object, the first pop-up object will be added to the end of the pop-up queue.
[0063] In addition, you can also set the number of times each pop-up window pops up again, the retry interval, and whether to report the pop-up situation, so that you can flexibly handle abnormal pop-ups according to actual needs.
[0064] In an embodiment of the present invention, by detecting whether a pop-up window corresponding to a first pop-up window object has popped up, when it is detected that the pop-up window corresponding to the first pop-up window object has not popped up, exception handling can be performed on the first pop-up window object based on the exception handling strategy corresponding to the first pop-up window object. In this way, targeted exception handling can be performed on each pop-up window, abnormal pop-ups can be handled flexibly, and accurate delivery of the pop-up window corresponding to the first pop-up window object can be ensured.
[0065] The above embodiment describes the specific implementation process of performing pop-up window display on each pop-up window object in the pop-up window queue. However, in actual application, when performing the display operation on each pop-up window object in the pop-up window queue, if the user triggers the interactive pop-up window, the interactive pop-up window can be inserted behind the first pop-up window object currently being displayed as the next pop-up window object to be displayed.
[0066] In specific implementation, except for the first pop-up window, the other pop-up windows among the multiple pop-up windows associated with the application can be called second pop-up windows, and a corresponding second pop-up window object can be created in advance for each second pop-up window, and the pop-up window trigger condition and pop-up type corresponding to the second pop-up window object can be determined according to the pop-up window configuration information corresponding to the second pop-up window, and the pop-up condition corresponding to the second pop-up window object can be determined according to the pop-up window trigger condition and the pop-up type.
[0067] When performing a pop-up check operation on the first pop-up window object taken out, it is also possible to detect whether the second pop-up window object meets the corresponding pop-up condition. If it is detected that the second pop-up window object meets the corresponding pop-up condition, the second pop-up window object is determined as the next pop-up window object to be displayed. After closing the pop-up window corresponding to the first pop-up window object currently being displayed, instantiate the promise instance corresponding to the second pop-up window object to display the second pop-up window corresponding to the second pop-up window object. Among them, the second pop-up window object corresponds to the second pop-up window, and the second pop-up window is an interactive pop-up window among multiple pop-up windows.
[0068] In addition, in actual applications, if there is no first pop-up window being displayed at this time, and there is only the first pop-up window object taken out from the pop-up window queue, then if it is detected that the second pop-up window object meets the pop-up conditions, the promise instance corresponding to the second pop-up window object can be directly instantiated to display the second pop-up window corresponding to the second pop-up window object.
[0069] Among them, the display and hiding of each pop-up window may involve the resource scheduling of the terminal system (such as CPU, GPU, etc.). Effective management of the life cycle of each pop-up window can ensure that the terminal system resources are reasonably allocated and released. In addition, the display and hiding of each pop-up window can be accurately and asynchronously controlled through the life cycle status of each pop-up window.
[0070] In order to accurately control the display and hiding of each pop-up window, when performing pop-up window display operations on multiple pop-up windows, the pop-up of each pop-up window object can be controlled by combining the queue data structure and the life state of each pop-up window object. This can not only manage the pop-up windows in an orderly manner, optimize the user experience, and effectively utilize resources, but also make the code structure clearer. The implementation method is exemplarily described in conjunction with the following embodiments.
[0071] Each pop-up window object has multiple life cycle states from creation to deletion. Figure 3 The life cycle states corresponding to the pop-up window object shown include pending state, running state, completed state, failed state, retrying state, and canceled state.
[0072] The pending state refers to the initial state of each pop-up window object in the pop-up window queue, when the pop-up window object is waiting to be scheduled. The running state refers to the pop-up window being displayed. The completed state refers to the pop-up window popping up normally and being closed. The failed state refers to the pop-up window failing to pop up. The retrying state refers to the pop-up window entering the retry state after the pop-up window fails to pop up. The canceled state refers to the pop-up window being canceled and no longer popping up.
[0073] In specific implementation, the display and hiding of each pop-up window can be controlled in combination with the life cycle state corresponding to the pop-up window object. After the first pop-up window objects corresponding to each first pop-up window are added to the pop-up window queue in sequence, the life cycle state of the first pop-up window object can be set to the pending state, that is, the first pop-up window object is waiting for scheduling. At this time, the first pop-up window object can publish the corresponding life cycle state of the first pop-up window object at this time through the publish-subscribe method. In this way, the pop-up window display logic can be decoupled through the publish-subscribe mode, thereby improving the flexibility and maintainability of the pop-up window display.
[0074] Next, the first pop-up window object is taken out from the head of the pop-up window queue, and the promise instance corresponding to the first pop-up window object is instantiated. At this time, the life cycle state corresponding to the first pop-up window object can be set to the running state, and when the life cycle state corresponding to the first pop-up window object changes, the first pop-up window object can publish the life cycle state corresponding to the first pop-up window object at this time through the publish and subscribe method, so that the pop-up window display device can instantly obtain the execution stage of each pop-up window object, so as to further control the pop-up window display or pop-up window hiding.
[0075] Then, it can be detected whether the pop-up window corresponding to the first pop-up window object is displayed normally. If the first pop-up window object is displayed normally, the generation cycle state corresponding to the first pop-up window object can be set to the completed state. If the first pop-up window object is not displayed normally, the life cycle state corresponding to the first pop-up window object can be set to the failed state. In addition, the first pop-up window object can publish the life cycle state corresponding to the first pop-up window object at this time by publishing and subscribing.
[0076] When the life cycle state corresponding to the first pop-up window object subscribed to by the pop-up window display device is a failed state, an exception handling strategy corresponding to the first pop-up window object is determined to determine whether to re-execute the pop-up operation on the first pop-up window object.
[0077] Among them, it is possible to determine whether the pop-up window corresponding to the first pop-up window object has been popped up by subscribing to the life cycle status corresponding to each pop-up window object. Specifically, in an optional embodiment, the life cycle status corresponding to the first pop-up window object is subscribed, and the life cycle status is used to describe the stage of the first pop-up window object in the process from being created to being deleted. If the life cycle status is monitored as a pop-up window failure, it is determined that the pop-up window corresponding to the first pop-up window object has not been popped up.
[0078] If the pop-up operation does not need to be performed again on the first pop-up window object, the life cycle state corresponding to the first pop-up window object is set to the canceled state. If the pop-up operation needs to be performed again on the first pop-up window object, the life cycle state corresponding to the first pop-up window object is set to the retrying state, and the first pop-up window object can publish the life cycle state corresponding to the first pop-up window object at this time by publishing and subscribing. The pop-up display device subscribes to the life cycle state corresponding to the first pop-up window object as the retrying state, and can re-execute the pop-up process on the first pop-up window object.
[0079] When re-performing the pop-up processing on the first pop-up window object, first determine whether to re-perform the pop-up processing on the first pop-up window object immediately. If the pop-up processing needs to be performed on the first pop-up window object immediately, the first pop-up window object can be inserted after the pop-up window object being displayed as the next pop-up window object to be displayed. If the pop-up processing does not need to be performed on the first pop-up window object immediately, the first pop-up window object can be added to the end of the pop-up window queue to wait for scheduling.
[0080] Moreover, after each pop-up window pops up, the life cycle status corresponding to the first pop-up window object and the pop-up window display status can be reported to the server. Each time the pop-up window queue is initialized, the initialization operation can be performed according to the pop-up window data returned by the server. This can ensure the triggering history of the pop-up window and the life cycle status corresponding to the pop-up window object.
[0081] As can be seen from the above description, each pop-up window object can maintain its own state flow, and the pop-up window display device can subscribe to the life cycle state corresponding to the first pop-up window object to perform corresponding display processing according to the life cycle state corresponding to the first pop-up window object. In addition, the pop-up window display device can also process the next task in the pop-up window queue according to the life cycle state corresponding to each pop-up window object.
[0082] In addition, in actual applications, in order to better manage and track the life cycle states corresponding to each pop-up window object, the pop-up window display or hiding can be accurately controlled according to the life cycle states corresponding to each pop-up window object. At this time, the state manager can also be used to maintain the state flow of each pop-up window object to track the transformation of the life cycle states corresponding to these pop-up window objects and the exception handling.
[0083] When the pop-up window object performs the corresponding operation or is in different execution stages, the corresponding life cycle state of the pop-up window object will be automatically converted, and the current life cycle state of the pop-up window object will be published through the event bus, so that the state manager can track the corresponding life cycle state of each pop-up window object in time.
[0084] After the state manager tracks the life cycle state corresponding to the pop-up object, it can publish the life cycle state corresponding to the pop-up object through the event bus, so that the pop-up display device subscribes to the life cycle state corresponding to the pop-up object, and then controls the display and hiding of the pop-up object and further processes the next pop-up object to be displayed according to the pop-up life cycle state.
[0085] For example, when the pop-up display device subscribes to the failed state of the life cycle state corresponding to the first pop-up object, the pop-up configuration information corresponding to the first pop-up object and the exception description information corresponding to the first pop-up object can be obtained. The determined exception handling strategy corresponding to the first pop-up object is to immediately re-execute the pop-up operation. The first pop-up object can be inserted behind the currently displayed pop-up object as the next pop-up object to be displayed.
[0086] In order to facilitate the understanding of the above implementation process, the above pop-up display method is exemplified in combination with a specific application scenario. In specific application, it is assumed that the target application is a recruitment APP, and the recruitment APP is associated with 4 pop-ups. Among them, after the user starts the recruitment APP, the three associated message display pop-ups will automatically pop up, message display pop-up window 1, message display pop-up window 2, message display pop-up window 3, and these three message display pop-ups will pop up in sequence according to the pop-up window sequence number. When the user exits the session, the associated confirmation pop-up window 4 will pop up.
[0087] Before displaying the four pop-up windows in the recruitment APP, a pop-up window queue can be created first, and the four pop-up windows can be classified, and the pop-up window triggered automatically by the system can be determined as the first pop-up window, and the pop-up window triggered by the user's operation can be determined as the second pop-up window. In this way, message display pop-up window 1, message display pop-up window 2, and message display pop-up window 3 can be determined as the first pop-up window, and confirmation pop-up window 4 can be determined as the second pop-up window.
[0088] Next, according to the pop-up window configuration information of the multiple first pop-up windows, the pop-up window order corresponding to the multiple first pop-up windows is determined to be message display pop-up window 1, message display pop-up window 2, and message display pop-up window 3, and according to the pop-up window order, the first pop-up window objects corresponding to message display pop-up window 1, message display pop-up window 2, and message display pop-up window 3 are added to the pop-up window queue in sequence. Among them, each first pop-up window object encapsulates the pop-up window configuration information and initial state information of the corresponding first preset pop-up window, and the initial state information is waiting for scheduling.
[0089] Then, according to the pop-up configuration information of the multiple pop-up windows, the pop-up conditions corresponding to the multiple pop-up windows are determined. Message display pop-up window 1, message display pop-up window 2, and message display pop-up window 3 are extracted from the head of the pop-up window queue in sequence, and according to the pop-up window type corresponding to the first pop-up window and the trigger condition corresponding to the first pop-up window, it is detected whether the first pop-up window meets the pop-up condition. When the first pop-up window meets the corresponding pop-up condition, the promise instance corresponding to the first pop-up window is instantiated to display the first pop-up window in the recruitment APP. In addition, the status information of the pop-up window object corresponding to the first pop-up window is switched to the pop-up window being displayed.
[0090] At the same time, it is also possible to detect whether the first pop-up window has popped up in the application based on the status information of the pop-up window object corresponding to the first pop-up window. If it has popped up, the status information of the pop-up window object corresponding to the first pop-up window is switched to the pop-up window popping up and closing normally, and the status information of the pop-up window object is published through the event bus. If it has not popped up, determine whether to re-pop up the first pop-up window. If it pops up again, determine whether to re-pop up the first pop-up window immediately. If it is determined to retry immediately, the pop-up window object corresponding to the first pop-up window is inserted behind the pop-up window currently being displayed. After the pop-up window currently being displayed pops up and closes normally, the promise instance corresponding to the first pop-up window is instantiated to display the first pop-up window in the recruitment APP. If you do not retry immediately, the pop-up window object corresponding to the first pop-up window is inserted to the end of the pop-up queue and waits for scheduling.
[0091] In the process of performing pop-up window display processing on multiple first pop-up windows, if it is detected that a second pop-up window meets the pop-up condition, the second pop-up window is inserted behind the first pop-up window currently being displayed as the next pop-up window to be displayed.
[0092] In addition, the pop-up window display method provided in the embodiment of the present invention can not only be applied to various applications to display multiple pop-up windows corresponding to each application, but can also be applied to various application scenarios to display multiple pop-up windows.
[0093] In specific implementation, the pop-up display device can be easily embedded in mobile applications through cross-platform technologies such as React Native and Flutter. The publish-subscribe pattern allows the life cycle state changes of the pop-up window to interact well with other parts of the application (such as sharing state between native and Web components). In addition, lightweight state management and on-demand creation of Promise objects can reduce the memory overhead of mobile devices.
[0094] In addition, the pop-up display device can also adapt to the environment of the mini program, use the API provided by it to interact with the server, and use the state manager and queue mechanism to control the display logic of the pop-up window. Mini program users have high performance requirements. Queued scheduling can avoid frequent pop-ups and dynamically adjust the pop-up strategy according to user behavior and device conditions.
[0095] In addition, the pop-up display device can be used in mobile web pages, especially for pop-up scheduling of advertisements or notifications. The pop-up display device can ensure that the main thread of the web page will not be blocked through asynchronous processing, thereby improving the user experience. Moreover, when the network environment is unstable, the pop-up display device can also ensure the accuracy of delivery through a retry or error reporting mechanism.
[0096] The following will describe in detail one or more embodiments of the pop-up display device of the present invention. Those skilled in the art will appreciate that these devices can be configured using commercially available hardware components through the steps taught in this solution.
[0097] Figure 4 A schematic diagram of a pop-up window display device provided by an embodiment of the present invention is shown in FIG. Figure 4 As shown, the device includes: a taking-out module 11 , a determining module 12 , and a detecting module 13 .
[0098] The fetching module 11 is used to fetch a first pop-up window object from the head of the pop-up window queue, where the first pop-up window object encapsulates pop-up window configuration information of a corresponding pop-up window.
[0099] The determination module 12 is used to determine the pop-up condition corresponding to the first pop-up window object according to the pop-up window configuration information.
[0100] The detection module 13 is used to instantiate the promise instance corresponding to the first pop-up window object to display the pop-up window corresponding to the first pop-up window object if it is detected that the first pop-up window object meets the pop-up condition.
[0101] Optionally, the pop-up display device may further include an exception handling module, which may be specifically used to: if it is detected that the pop-up window corresponding to the first pop-up window object has not popped up, obtain exception description information corresponding to the first pop-up window object; determine the exception handling strategy corresponding to the first pop-up window object based on the exception description information and the pop-up window configuration information of the first pop-up window object; and perform exception handling on the first pop-up window object based on the exception handling strategy corresponding to the first pop-up window object.
[0102] Optionally, the exception handling module can also be used to: subscribe to the life cycle status corresponding to the first pop-up window object, the life cycle status is used to describe the stage of the first pop-up window object in the process from creation to deletion; if it is monitored that the life cycle status is a pop-up window failure, it is determined that the pop-up window corresponding to the first pop-up window object has not popped up.
[0103] Optionally, the exception handling module can also be used for: if the exception handling strategy is to immediately re-pop up the first pop-up window object, then the first pop-up window object is determined as the next pop-up window object to be displayed; if the exception handling strategy is not to immediately re-pop up the first pop-up window object, then the first pop-up window object is added to the end of the pop-up window queue.
[0104] Optionally, the pop-up display device may further include a configuration module, which may be specifically used to: obtain pop-up data of multiple pop-up windows, the pop-up data including pop-up configuration information; filter out multiple first pop-up windows from the multiple pop-up windows according to the pop-up configuration information of the multiple pop-up windows, the first pop-up windows being non-interactive pop-up windows; create a pop-up object corresponding to each of the multiple first pop-up windows; and add the pop-up objects corresponding to each of the multiple first pop-up windows to the pop-up queue in sequence according to the pop-up order of the multiple first pop-up windows.
[0105] Optionally, the configuration module can also be used for: if it is detected that the second pop-up window object meets the corresponding pop-up condition, the second pop-up window object is determined as the next pop-up window object to be displayed, the second pop-up window object corresponds to the second pop-up window, and the second pop-up window is an interactive pop-up window among the multiple pop-up windows; after closing the pop-up window corresponding to the first pop-up window object currently being displayed, instantiate the promise instance corresponding to the second pop-up window object to display the second pop-up window corresponding to the second pop-up window object.
[0106] Optionally, the determination module 12 can be specifically used to: determine the pop-up trigger condition and the pop-up type corresponding to the first pop-up object according to the pop-up configuration information; determine the pop-up condition corresponding to the first pop-up object according to the pop-up trigger condition and the pop-up type.
[0107] Optionally, the detection module 13 may also be used to: create a Promise object, the Promise object being used to encapsulate a pop-up window display operation; and determine a Promise instance corresponding to the first pop-up window object based on the Promise object and pop-up window configuration information of the first pop-up window object.
[0108] Figure 4The device shown can execute the steps in the pop-up display method in the aforementioned embodiment. The detailed execution process and technical effects can be found in the description in the aforementioned embodiment, which will not be repeated here.
[0109] The embodiment of the present invention also provides an electronic device, such as Figure 5 As shown, the electronic device may include: a processor 21, a memory 22, and a communication interface 23. The memory 22 stores executable codes, and when the executable codes are executed by the processor 21, the processor 21 implements the pop-up window display method in the above-mentioned embodiment.
[0110] In addition, an embodiment of the present invention provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the pop-up display method provided in the aforementioned embodiment.
[0111] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. Those of ordinary skill in the art may understand and implement the present invention without creative effort.
[0112] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and software. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a computer product, and the present invention can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0113] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A pop-up window display method, characterized in that: include: Take out a first pop-up window object from the head of the pop-up window queue, where the first pop-up window object encapsulates pop-up window configuration information of the corresponding pop-up window; Determining a pop-up condition corresponding to the first pop-up window object according to the pop-up window configuration information; If it is detected that the first pop-up window object satisfies the pop-up condition, the promise instance corresponding to the first pop-up window object is instantiated to display the pop-up window corresponding to the first pop-up window object.
2. The method according to claim 1, characterized in that The method further comprises: If it is detected that the pop-up window corresponding to the first pop-up window object is not popped up, obtaining abnormal description information corresponding to the first pop-up window object; Determine an exception handling strategy corresponding to the first pop-up window object based on the exception description information and the pop-up window configuration information of the first pop-up window object; Based on the exception handling strategy corresponding to the first pop-up window object, perform exception handling on the first pop-up window object.
3. The method according to claim 2, characterized in that The method further comprises: Subscribe to the life cycle state corresponding to the first pop-up window object, where the life cycle state is used to describe the stage of the process from creation to deletion of the first pop-up window object; If it is monitored that the life cycle state is a pop-up window failure, it is determined that the pop-up window corresponding to the first pop-up window object has not been popped up.
4. The method according to claim 2, characterized in that: The performing exception handling on the first pop-up window object based on the exception handling strategy includes: If the exception handling strategy is to immediately re-pop up the first pop-up window object, the first pop-up window object is determined as the next pop-up window object to be displayed; If the exception handling strategy is that the first pop-up window object does not need to be immediately re-popped up, the first pop-up window object is added to the end of the pop-up window queue.
5. The method according to claim 1, characterized in that The method further comprises: Obtain pop-up window data of multiple pop-up windows, wherein the pop-up window data includes pop-up window configuration information; Filtering a plurality of first pop-up windows from the plurality of pop-up windows according to the pop-up window configuration information of the plurality of pop-up windows, wherein the first pop-up windows are non-interactive pop-up windows; Creating a pop-up window object corresponding to each of the plurality of first pop-up windows; According to the pop-up order of the multiple first pop-up windows, the pop-up window objects corresponding to the multiple first pop-up windows are added to the pop-up window queue in sequence.
6. The method according to claim 5, characterized in that The method further comprises: If it is detected that the second pop-up window object meets the corresponding pop-up condition, the second pop-up window object is determined as the next pop-up window object to be displayed, the second pop-up window object corresponds to the second pop-up window, and the second pop-up window is an interactive pop-up window among the multiple pop-up windows; After closing the pop-up window corresponding to the first pop-up window object currently being displayed, instantiate the promise instance corresponding to the second pop-up window object to display the second pop-up window corresponding to the second pop-up window object.
7. The method according to claim 1, characterized in that The determining, according to the pop-up window configuration information, a pop-up condition corresponding to the first pop-up window object includes: Determine, according to the pop-up window configuration information, a pop-up window triggering condition and a pop-up type corresponding to the first pop-up window object; According to the pop-up window triggering condition and the pop-up type, a pop-up condition corresponding to the first pop-up window object is determined.
8. The method according to claim 1, characterized in that: Before instantiating the promi se instance corresponding to the first pop-up window object, the method further includes: Create a Promise object, which is used to encapsulate the pop-up window display operation; Based on the Promise object and the pop-up window configuration information of the first pop-up window object, determine the Promise instance corresponding to the first pop-up window object.
9. An electronic device, characterized in that: include: A memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the pop-up display method as described in any one of claims 1 to 8.
10. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor executes the pop-up display method as described in any one of claims 1 to 8.
Citation Information
Cited By
Cross-platform popup window display method and system, electronic equipment and storage medium
CN121300901A
A cross-platform pop-up display method and system, electronic equipment and storage medium
CN121300901B