Mini-program lifecycle management method, system, electronic device, and storage medium
By introducing a timing manager to uniformly manage the data acquisition of the mini-program lifecycle module, the problem of chaotic mini-program startup is solved, and effective timing control of the mini-program startup process and improved user experience are achieved.
Patent Information
- Application Number
- CN202210138718.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-15
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2042-02-15
AI Technical Summary
When the mini program is started, the lifecycle module cannot communicate with other modules, resulting in the inability to perceive asynchronous loading, which affects the user experience.
A timing manager is introduced to uniformly obtain pre-conditioning data for each life cycle module. By monitoring module startup and obtaining necessary pre-conditioning data from the server, the module is ensured to enter a waiting state before startup and to perform business processing only after data preparation is completed.
It effectively avoids the problem of confusion in mini-program startup, ensures that each module can obtain the required pre-data when executing business processing, realizes effective timing control of the mini-program startup process, and improves user experience.
Smart Images

Figure CN114489994B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of mini-programs, and in particular to a mini-program lifecycle management method, system, electronic device, and storage medium. Background Art
[0002] The mini-program's lifecycle module is the foundational module responsible for loading, displaying, and responding to other events. In related technologies, when a mini-program is launched, the lifecycle module autonomously and asynchronously loads pre-requisite data from the server. However, this module cannot communicate with other lifecycle modules and, therefore, cannot detect when other modules are performing asynchronous loading. This can easily lead to the mini-program launching without the necessary pre-requisite data, impacting the user experience. Summary of the Invention
[0003] The purpose of the present invention is to provide a method, system, electronic device and storage medium for mini-program lifecycle management, which can use a timing manager to uniformly obtain necessary pre-data for each lifecycle module, thereby effectively controlling the timing of the mini-program startup process and effectively avoiding the startup confusion problem of the mini-program.
[0004] To solve the above technical problems, the present invention provides a method for managing the lifecycle of a mini-program, comprising:
[0005] When the life cycle module is started, it enters the waiting state;
[0006] When detecting that the life cycle module has been started, the timing manager obtains the pre-data required by the life cycle module from the server and sends the pre-data to the life cycle module;
[0007] When receiving the preceding data, the life cycle module exits the waiting state and performs business processing on the preceding data.
[0008] Optionally, before entering the waiting state, the method further includes:
[0009] The lifecycle module sends a startup notification to the timing manager;
[0010] Accordingly, the timing manager detects that the lifecycle module has been started, including:
[0011] When receiving the startup notification, the timing manager determines that the lifecycle module has been started.
[0012] Optionally, obtaining the pre-conditional data required by the life cycle module from the server includes:
[0013] The timing manager asynchronously obtains the pre-conditioning data required by the life cycle module from the server.
[0014] Optionally, the pre-data includes application-level data and page-level data.
[0015] Optionally, the life cycle module includes an onload module and an onshow module.
[0016] Optionally, it also includes:
[0017] When the lifecycle module monitors that a preset event is triggered, it sends an event notification corresponding to the preset event to the timing manager and enters the waiting state;
[0018] When receiving the event notification, the timing manager executes the business logic corresponding to the event notification and sends the execution result of the business logic to the lifecycle module;
[0019] When receiving the execution result, the lifecycle module exits the waiting state and performs business processing using the execution result.
[0020] The present invention also provides a mini-program lifecycle management system, including: a lifecycle module and a timing manager, wherein:
[0021] The life cycle module is configured to enter a waiting state upon startup; upon receiving the pre-data sent by the timing management controller, exit the waiting state and perform business processing on the pre-data;
[0022] The timing manager is configured to obtain the pre-condition data required by the life cycle module from a server when detecting that the life cycle module has been started, and send the pre-condition data to the life cycle module.
[0023] Optionally, the lifecycle module is further configured to send a startup notification to the timing manager;
[0024] Correspondingly, the timing manager is further configured to determine that the lifecycle module has been started when receiving the start notification.
[0025] The present invention further provides an electronic device, comprising:
[0026] memory for storing computer programs;
[0027] A processor is used to implement the mini-program lifecycle management method as described above when executing the computer program.
[0028] The present invention also provides a storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are loaded and executed by a processor, the mini-program lifecycle management method as described above is implemented.
[0029] The present invention provides a method for mini-program lifecycle management and control, comprising: when the lifecycle module is started, it enters a waiting state; when the timing manager detects that the lifecycle module has been started, it obtains the pre-data required by the lifecycle module from the server and sends the pre-data to the lifecycle module; when the lifecycle module receives the pre-data, it exits the waiting state and performs business processing on the pre-data.
[0030] It can be seen that in the present invention, the life cycle module will automatically enter the waiting state after startup, and the newly added timing manager of the present invention will automatically obtain the pre-data required by the module from the server after detecting that the life cycle module has been started, and send the data to the module; and the life cycle module will automatically exit the waiting state after receiving the pre-data sent by the timing manager, and perform subsequent business processing. In other words, the present invention can use the timing manager to uniformly obtain the necessary pre-data for each life cycle module, which not only ensures that these modules can obtain the required pre-data when performing subsequent business processing, but also can perceive the situation of each life cycle module obtaining pre-data in real time, and can effectively control the timing of the startup process of the mini program, and can effectively avoid the startup confusion problem of the mini program. The present invention also provides a mini program life cycle management and control system, electronic equipment and storage medium, which have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0032] Figure 1 A flowchart of a method for managing the lifecycle of a mini-program provided by an embodiment of the present invention;
[0033] Figure 2 This is a structural block diagram of a mini-program lifecycle management system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0034] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only 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 making creative efforts shall fall within the scope of protection of the present invention.
[0035] In the related art, when the mini program is started, the life cycle module will autonomously and asynchronously load the pre-data with the server. However, this module cannot communicate with other life cycle modules, and thus cannot perceive the situation where other modules perform asynchronous loading, which can easily cause the mini program to start in the absence of necessary pre-data, affecting the user experience. In view of this, the present invention provides a mini program life cycle management method, which can use a timing manager to uniformly obtain the necessary pre-data for each life cycle module, thereby effectively controlling the timing of the mini program startup process and effectively avoiding the startup confusion of the mini program. Please refer to Figure 1 , Figure 1 A flowchart of a method for managing the lifecycle of a mini-program provided in an embodiment of the present invention may include:
[0036] S101. When the life cycle module is started, it enters a waiting state.
[0037] In an embodiment of the present invention, after the lifecycle module is started, it will not immediately execute any business logic operations that it originally needed to execute, but will first enter a waiting state, waiting for the required pre-condition data to be loaded before executing the corresponding business logic operations. The embodiment of the present invention does not limit the specific lifecycle module of the mini program, and reference may be made to the relevant technology of the mini program. Taking into account that the onload module and the onshow module are more important in the startup link of the mini program, the startup of these two modules should be given priority. Therefore, in an embodiment of the present invention, the lifecycle module may include the onload module and the onshow module. The embodiment of the present invention also does not limit the specific pre-condition data, which is related to the specific business scenario, such as user information, page configuration information, long QR code, etc., and can be selected according to actual application needs.
[0038] S102 : When the timing manager detects that the life cycle module has been started, it obtains the pre-data required by the life cycle module from the server and sends the pre-data to the life cycle module.
[0039] The embodiment of the present invention additionally adds a timing manager (Scheduler) to monitor the startup status of each life cycle module, and when a life cycle module is detected to be started, it obtains the corresponding pre-data from the server. This is because there is no notification mechanism between life cycle modules, and the life cycle module performs pre-data loading by itself, which will cause other modules to be unable to understand the data loading status of this module, and thus easily lead to loading confusion. The embodiment of the present invention adopts a timing manager to uniformly obtain pre-data for each life cycle module, which can clearly determine the data acquisition status of each module, and can effectively control the timing of the pre-data acquisition process, avoiding the loading confusion problem caused by the existing solution.
[0040] It should be noted that the embodiments of the present invention do not limit the specific process of detecting the startup of the lifecycle module. For reference, the relevant technology of the mini-program can be used. In one possible scenario, for ease of management, the lifecycle module can proactively send a startup notification to the timing manager to inform the manager that it has started. When the timing manager receives the startup notification, it will determine that the lifecycle module has started and load the corresponding pre-data.
[0041] In a possible case, before entering the waiting state, the following steps may also be included:
[0042] Step 11: The lifecycle module sends a startup notification to the timing manager;
[0043] Accordingly, the timing manager detects that the lifecycle module has been started, including:
[0044] Step 21: Upon receiving the startup notification, the timing manager determines that the lifecycle module has been started.
[0045] It should be noted that the embodiment of the present invention does not limit the specific form of the startup notification, and it can be set according to actual application requirements, as long as the notification can indicate that a certain life cycle module has been started.
[0046] Furthermore, embodiments of the present invention do not limit how the sequence manager obtains pre-processing data from the server; for example, synchronous or asynchronous acquisition may be used. To improve acquisition efficiency and prevent the impact of failed or slow loading of a particular piece of data on the overall efficiency of the data acquisition process, the sequence manager may use asynchronous loading to obtain pre-processing data from the server.
[0047] In one possible scenario, obtaining the prerequisite data required by the lifecycle module from the server may include:
[0048] Step 31: The timing manager asynchronously obtains the prerequisite data required by the lifecycle module from the server.
[0049] Furthermore, it should be pointed out that in the field of mini programs, business data is usually divided into application-level data and page-level data, where application-level data is data that can be accessed in all pages of the mini program, while page-level data is data that can only be accessed on a specific page. Since the onload module and onshow module belong to page-level modules, logically they can only obtain page-level data from the server, but cannot obtain application-level data. However, in actual application scenarios, the above two lifecycle modules may still use application-level data. Therefore, in an embodiment of the present invention, in addition to obtaining page-level data for the onload module and onshow module, the timing manager can also obtain application-level data for them, which can break through the original mini program limitations and improve the flexibility of mini program data loading.
[0050] In one possible case, the pre-data includes application-level data and page-level data.
[0051] S103 . When receiving the preceding data, the lifecycle module exits the waiting state and performs business processing on the preceding data.
[0052] It should be noted that the embodiments of the present invention do not limit the business processing content corresponding to each lifecycle module, and reference may be made to the relevant technologies of mini-programs.
[0053] Based on the above embodiment, in the present invention, the life cycle module will automatically enter the waiting state after startup, and the newly added timing manager of the present invention will automatically obtain the pre-condition data required by the module from the server after detecting that the life cycle module has been started, and send the data to the module; and after receiving the pre-condition data sent by the timing manager, the life cycle module will automatically exit the waiting state and perform subsequent business processing. In other words, the present invention can use the timing manager to uniformly obtain the necessary pre-condition data for each life cycle module, which can not only ensure that these modules can obtain the required pre-condition data when performing subsequent business processing, but also can perceive the situation of each life cycle module obtaining pre-condition data in real time, and can effectively control the timing of the startup process of the applet, and can effectively avoid the startup confusion problem of the applet.
[0054] Based on the above embodiment, since there is no notification mechanism between the existing life cycle modules, conflicts may occur between the life cycle modules when executing business processing, which may easily lead to business processing confusion. In an embodiment of the present invention, the timing manager can also manage the business processing of the life cycle module to avoid the above-mentioned processing confusion. In one possible scenario, the mini program life cycle management method may also include:
[0055] S201 : When a lifecycle module monitors that a preset event is triggered, it sends an event notification corresponding to the preset event to the timing manager and enters a waiting state.
[0056] Similar to the pre-data loading process, when a preset event occurs in the monitored application or page, the lifecycle module will send an event notification corresponding to the event to the timing manager to trigger the timing manager to execute the business logic corresponding to the event. At the same time, the lifecycle module will enter a waiting state to wait for the execution result returned by the timing manager. The advantage of this setting is that since the business logic of each lifecycle module can be uniformly processed by the timing manager, the manager can clearly understand the processing status of various business logics and perform unified timing control, which can effectively avoid the problem of chaotic business logic processing caused by the lack of a notification mechanism between lifecycle modules in existing solutions.
[0057] It should be noted that the embodiment of the present invention does not limit the specific form of the event notification, which can be set according to actual application requirements, as long as the notification can indicate that an event has been triggered.
[0058] S202. When receiving an event notification, the sequence manager executes the business logic corresponding to the event notification and sends the execution result of the business logic to the lifecycle module.
[0059] The embodiment of the present invention does not limit the specific business logic that the timing manager needs to execute, and it can be set according to actual application requirements.
[0060] S203. When receiving the execution result, the lifecycle module exits the waiting state and uses the execution result to perform business processing.
[0061] Based on the above embodiments, the present invention can also host the business processing process of each life cycle module by the timing manager, so as to clearly understand the processing status of various business logics and perform unified timing management, which can effectively avoid the problem of business logic processing confusion caused by the lack of notification mechanism between life cycle modules in the existing solution.
[0062] The following is an introduction to the mini-program lifecycle management system, electronic device and storage medium provided in an embodiment of the present invention. The mini-program lifecycle management system, electronic device and storage medium described below can be referenced to the mini-program lifecycle management method described above.
[0063] Please refer to Figure 2 , Figure 2 This is a structural block diagram of a mini-program lifecycle management system provided by an embodiment of the present invention. The system may include: a lifecycle module 201 and a timing manager 202, wherein:
[0064] The life cycle module 201 is configured to enter a waiting state upon startup; exit the waiting state upon receiving the preceding data sent by the timing management controller 202, and perform service processing on the preceding data.
[0065] The timing manager 202 is configured to obtain the pre-data required by the life cycle module from the server when detecting that the life cycle module 201 has been started, and send the pre-data to the life cycle module.
[0066] Optionally, the lifecycle module 201 is further configured to send a startup notification to the timing manager 202;
[0067] Correspondingly, the timing manager 202 is further configured to determine whether the lifecycle module 201 has been started upon receiving the start notification.
[0068] Optionally, the timing manager 202 may also be used to asynchronously obtain the pre-conditional data required by the lifecycle module from the server.
[0069] Optionally, the pre-data includes application-level data and page-level data.
[0070] Optionally, the lifecycle module 201 includes an onload module and an onshow module.
[0071] Optionally, the lifecycle module 201 can also be used to send an event notification corresponding to the preset event to the timing manager 202 when it monitors that a preset event is triggered, and enter a waiting state; when receiving the execution result returned by the timing manager 202, it exits the waiting state and uses the execution result to perform business processing.
[0072] The timing manager 202 may also be configured to execute the business logic corresponding to the event notification upon receiving the event notification, and send the execution result of the business logic to the lifecycle module 201 .
[0073] An embodiment of the present invention further provides an electronic device, including:
[0074] Memory for storing computer programs;
[0075] A processor is used to implement the steps of the mini-program lifecycle management method as described above when executing a computer program.
[0076] Since the embodiments of the electronic device part correspond to the embodiments of the mini-program lifecycle management method part, please refer to the description of the embodiments of the electronic device part for the embodiments of the mini-program lifecycle management method part, which will not be repeated here.
[0077] An embodiment of the present invention also provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the mini-program lifecycle management method of any of the above embodiments are implemented.
[0078] Since the embodiments of the storage medium part correspond to the embodiments of the mini-program lifecycle management method part, please refer to the description of the embodiments of the mini-program lifecycle management method part for the embodiments of the storage medium part, which will not be repeated here.
[0079] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.
[0080] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0081] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0082] The above is a detailed introduction to the mini-program lifecycle management method, system, electronic device and storage medium provided by the present invention. This article uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. A method for managing the lifecycle of a mini-program, characterized in that: include: When the life cycle module is started, it enters a waiting state; there are at least two life cycle modules; When detecting that the life cycle module has been started, the timing manager obtains the pre-data required by the life cycle module from the server and sends the pre-data to the life cycle module; The timing manager determines the situation of each life cycle module acquiring the preceding data and performs timing control on the acquisition process of the preceding data; When receiving the pre-data, the life cycle module exits the waiting state and performs business processing on the pre-data; When the lifecycle module monitors that a preset event is triggered, it sends an event notification corresponding to the preset event to the timing manager and enters the waiting state; When the timing manager receives the event notification, it executes the business logic corresponding to the event notification, determines the processing status of various business logics of each lifecycle module and performs unified timing management, and sends the execution results of the business logic to the lifecycle module; When receiving the execution result, the lifecycle module exits the waiting state and performs business processing using the execution result.
2. The mini program lifecycle management method according to claim 1, characterized in that: Before entering the waiting state, it also includes: The lifecycle module sends a startup notification to the timing manager; Accordingly, the timing manager detects that the lifecycle module has been started, including: When receiving the startup notification, the timing manager determines that the lifecycle module has been started.
3. The mini program lifecycle management method according to claim 1, characterized in that: The step of obtaining the pre-condition data required by the life cycle module from the server includes: The timing manager asynchronously obtains the pre-conditioning data required by the life cycle module from the server.
4. The mini program lifecycle management method according to claim 1, characterized in that: The pre-data includes application-level data and page-level data.
5. The mini program lifecycle management method according to claim 1, characterized in that: The life cycle module includes an onload module and an onshow module.
6. A mini-program lifecycle management system, characterized in that: It includes: a life cycle module and a timing manager, and there are at least two life cycle modules; wherein, The life cycle module is configured to enter a waiting state upon startup; upon receiving the preceding data sent by the timing manager, exit the waiting state and perform business processing on the preceding data; The timing manager is configured to, upon detecting that the lifecycle module has been started, obtain the pre-data required by the lifecycle module from the server and send the pre-data to the lifecycle module; determine the status of each lifecycle module in obtaining the pre-data and perform timing control on the pre-data obtaining process; The lifecycle module is further configured to, upon monitoring that a preset event is triggered, send an event notification corresponding to the preset event to the timing manager and enter the waiting state; upon receiving an execution result, exit the waiting state and perform business processing using the execution result; The timing manager is also used to execute the business logic corresponding to the event notification when receiving the event notification, determine the processing status of various business logics of each life cycle module and perform unified timing management, and send the execution results of the business logic to the life cycle module.
7. The mini program lifecycle management system according to claim 6, characterized in that: The lifecycle module is further configured to send a startup notification to the timing manager; Correspondingly, the timing manager is further configured to determine that the lifecycle module has been started when receiving the start notification.
8. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the mini-program lifecycle management method as described in any one of claims 1 to 5 when executing the computer program.
9. A storage medium, characterized in that: The storage medium stores computer-executable instructions, which, when loaded and executed by the processor, implement the mini-program lifecycle management method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for converting asynchronous call into synchronous call, equipment and storage medium
CN111506368A
Front-end micro-service implementation method and related parts
CN112416415A