Mini-program startup method, device, computer equipment, and storage medium
By detecting and updating the cache information of the mini program and using user identification information to achieve hot start, the startup speed problem of the mini program when the host application user login state changes frequently is solved, and the startup efficiency is improved.
Patent Information
- Application Number
- CN202010162083.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-10
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2040-03-12
AI Technical Summary
When the user login status of the host application changes frequently, the mini program needs to be cold started every time it is started, which takes a long time and affects the startup speed.
By detecting user identification information, cache information is obtained and updated to achieve hot start, including the update of view cache, logic cache and login cache, and the user identification information is used to quickly start the applet.
Even if the user identification information is different each time the app is started, the hot start method can be used to speed up the startup of the mini program and improve the user experience.
Smart Images

Figure CN113448641B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and apparatus for starting a small program, a computer-readable storage medium, and a computer device. Background Art
[0002] Mini Programs are a new form of Internet application provided by the WeChat client. They focus on the "use it and go" user experience. Users do not need to worry about installing the application. They can start the mini program by simply "scanning" or "searching".
[0003] Mini Programs can be started in two ways: cold start and hot start. Before the basic environment (such as components and mini program packages) is initialized, the mini program can be started using the cold start method. If the mini program has been started before and the basic environment is cached, the mini program can be started using the hot start method. Hot start is faster than cold start.
[0004] However, mini programs must run within a host application, such as WeChat. WeChat provides a mini program runtime environment that maintains the user's login state. After a cold start, the mini program can be hot-started. However, mini programs are currently also used in other host applications, and the user login state of these host applications frequently changes. This means that the mini program must be cold-started every time it is launched, which takes a long time. Summary of the Invention
[0005] Based on this, it is necessary to provide a method, device, computer equipment and storage medium for starting a mini-program that can speed up the startup of the mini-program in order to address the above technical problems.
[0006] A method for starting a small program, comprising:
[0007] When a start instruction for a target applet is detected, user identification information corresponding to the start instruction is obtained, and whether cache information of the target applet exists;
[0008] When the target applet has cache information, the user identification startup information is obtained according to the user identification information;
[0009] Update cache information based on user identification startup information;
[0010] The target applet is controlled to start according to the updated cache information.
[0011] A device for starting a small program, comprising:
[0012] The detection module is used to obtain user identification information corresponding to the startup instruction when a startup instruction for the target applet is detected, and to detect whether there is cache information of the target applet;
[0013] An acquisition module, configured to acquire user identification startup information based on user identification information when cache information exists for the target applet;
[0014] An update module, configured to update cache information based on user identification startup information;
[0015] The control module is used to control the target applet to start according to the updated cache information.
[0016] In one embodiment, the start instruction is triggered by an input facial image; the acquisition module is further configured to determine user identification information corresponding to the start instruction based on the input facial image.
[0017] In one embodiment, the start instruction is triggered by an input graphic code; the acquisition module is further configured to determine user identification information corresponding to the start instruction based on the input graphic code.
[0018] In one embodiment, the cache information includes at least one of view cache information, logical cache information, and login cache information, and the user identification startup information includes at least one of user identification view information, user identification logical information, and user identification login information; the update module is further used to: update the view cache information according to the user identification view information; update the logical cache information according to the user identification logical information; and update the login cache information according to the user identification login information.
[0019] In one embodiment, the view cache information includes the code information of the view layer and at least one of the first code information of the basic library; the logic cache information includes the code information of the logic layer and at least one of the second code information of the basic library; the login cache information includes the code information of the system layer; the update module is also used to: update the code information of the system layer, the second code information and the first code information of the basic library, the code information of the logic layer and the code information of the view layer in sequence according to the user identification startup information.
[0020] In one embodiment, the startup device of the mini program also includes a detection module, which is used to detect whether the user identification information matches the login cache information in the cache information; in one embodiment, the startup device of the mini program also includes an execution module, which is used to execute the step of obtaining user identification startup information based on the user identification information when the user identification information does not match the login cache information in the cache information.
[0021] In one embodiment, the acquisition module is also used to: when there is no cache information for the target applet, obtain the execution information of each step to be loaded of the target applet, the execution information is used to characterize the loading method and loading order of each step to be loaded, and the loading method includes a parallel loading method and a sequential loading method; the execution module is also used to: execute each step to be loaded according to the execution information.
[0022] In one embodiment, the execution information is also used to characterize the loading status of each step to be loaded; the startup device of the applet also includes a determination module, which is used to: determine the pre-loading step based on the execution information; the execution module is also used to: execute the steps to be loaded except the pre-loading step in each step to be loaded according to the execution information.
[0023] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are performed:
[0024] When a start instruction for a target applet is detected, user identification information corresponding to the start instruction is obtained, and whether cache information of the target applet exists;
[0025] When the target applet has cache information, the user identification startup information is obtained according to the user identification information;
[0026] Update cache information based on user identification startup information;
[0027] The target applet is controlled to start according to the updated cache information.
[0028] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0029] When a start instruction for a target applet is detected, user identification information corresponding to the start instruction is obtained, and whether cache information of the target applet exists;
[0030] When the target applet has cache information, the user identification startup information is obtained according to the user identification information;
[0031] Update cache information based on user identification startup information;
[0032] The target applet is controlled to start according to the updated cache information.
[0033] The aforementioned mini-program startup method, apparatus, computer device, and storage medium, upon detecting a startup instruction for a target mini-program, obtains user identification information corresponding to the startup instruction and detects whether cached information exists for the target mini-program. If cached information exists for the target mini-program, the method obtains user identification startup information based on the user identification information, updates the cached information based on the user identification startup information, and controls the startup of the target mini-program based on the updated cached information. This allows the mini-program to be started using a hot start method, even if the user identification information obtained is different each time the mini-program is started, thereby accelerating the startup of the mini-program. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 This is a diagram of an application environment for a method for starting a mini-program in one embodiment;
[0035] Figure 2 1 is a flowchart of a method for starting a mini-program in one embodiment;
[0036] Figure 3 A structural block diagram of a mini-program in one embodiment;
[0037] Figure 4 A structural block diagram of a mini-program in another embodiment;
[0038] Figure 5 Schematic diagram of a flow chart of a method for starting a mini-program in another embodiment;
[0039] Figure 6 A schematic diagram of a method for starting a mini-program in one embodiment;
[0040] Figure 7 is a structural block diagram of a host application of a mini-program in one embodiment;
[0041] Figure 8 This is an application scenario diagram of a method for starting a mini-program in one embodiment;
[0042] Figure 9 is a structural block diagram of a device for starting a mini-program in one embodiment;
[0043] Figure 10 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0045] The method for starting a small program provided in this application can be applied to Figure 1In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. In one embodiment, when the terminal 102 detects a startup instruction for the target applet, the startup instruction is sent to the server 104, so that the server 104 obtains the user identification information corresponding to the startup instruction and sends the user identification information to the terminal 102; and the terminal 102 detects whether the target applet has cache information; then, when the terminal 102 detects that the target applet has cache information, it obtains the user identification startup information according to the user identification information; then, the terminal 102 updates the cache information according to the user identification startup information; then, the terminal 102 controls the startup of the target applet according to the updated cache information. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablets, portable wearable devices and various smart devices, etc. The smart device can be a smart payment device, a vending machine, a smart express locker, an automatic ticket vending machine, a shared charging device, etc. The server 104 can be implemented as an independent server or a server cluster consisting of multiple servers.
[0046] In one embodiment, the startup method of the mini program provided in this application can be applied to a smart payment device. A smart payment device is a cash register device that cooperates with mobile payment methods. Smart payment devices may include desktop cashier payment devices and self-service cashier payment devices. The desktop cashier payment device is a plug-and-play payment device for manual cashier counters. After connecting to a POS machine, it can replace the original barcode scanner gun or barcode scanner box for scan code payment. The self-service cashier payment device is a payment device for a self-service cashier counter. The smart payment device is installed with a payment application, and the mini program can use the payment application as a host application to realize functions such as information display and information push. The payment application can run without login in the default state. When necessary, the user can also log in to the payment application so that the payment application temporarily obtains the login state. Specifically, when the smart payment device detects a startup instruction for the target mini-program, it obtains user identification information corresponding to the startup instruction and detects whether there is cached information of the target mini-program; when the smart payment device detects that there is cached information of the target mini-program, it obtains user identification startup information based on the user identification information; the smart payment device updates the cache information based on the user identification startup information; and the smart payment device controls the startup of the target mini-program based on the updated cache information.
[0047] In one embodiment, Figure 2 As shown, a method for starting a small program is provided, which is applied to Figure 1 The following steps are used as an example to illustrate the terminal in the figure:
[0048] Step 202: When a start instruction for a target applet is detected, user identification information corresponding to the start instruction is obtained, and it is detected whether there is cache information of the target applet.
[0049] Among them, mini programs are an application form between traditional HTML (Hypertext Markup Language) pages and APP (Application). Mini programs need to rely on host applications to run. The traditional host application of mini programs is WeChat. Currently, mini programs can also rely on some non-WeChat host applications. These non-WeChat host applications can provide various functions, such as payment functions, communication functions, product purchase functions, express delivery functions, ticket sales and collection functions, rental functions, etc. Mini programs can provide a variety of functions, such as information display, information push, etc. Taking the payment function provided by the host application as an example, during the payment process, the mini program can display the user's membership information in the merchant (user name, avatar, membership points, coupons, common addresses, etc.), the user's order information (current order information, historical order information), etc. The mini program can also push the merchant's promotional information, etc. The target mini program refers to the mini program to be launched.
[0050] The launch instruction is used to instruct the mini program to start. In one embodiment, the launch of the target mini program can be triggered by an input launch instruction. The input launch instruction can be triggered by the input mini program code, or it can be triggered based on the mini program launch button. The mini program launch button can be a virtual button or a physical button. The launch of the target mini program can also be triggered by the host application. For example, when the host application runs a function or the host application completes a function, the launch instruction is automatically triggered.
[0051] User identification information is the account used by the user to log in to the target mini program and the user information associated with that account. The account used by the user to log in to the target mini program can be determined by the account used by the user to log in to the host application. Optionally, the target mini program can output a query message, which is used to ask the user whether to log in using the host application account, or to ask the user whether to log in using the mobile phone number bound to the host application. When asking the user whether to log in using the host application account, the user can be further asked whether to use the host application user information, such as username, avatar, region, and gender.
[0052] Cache information is used for hot-starting the mini-program. This cache information may include at least one of view cache information, logic cache information, and login cache information. View cache information is used to display the mini-program's application interface, logic cache information is used to run the mini-program's business logic, and login cache information is used to log in user identification information.
[0053] In one embodiment, when a terminal detects a launch instruction for a target mini-program, it obtains user identification information corresponding to the launch instruction and detects whether cached information for the target mini-program exists. The method for obtaining the user identification information corresponding to the launch instruction may be: the terminal sends the launch instruction to a server, so that the server obtains the user identification information corresponding to the launch instruction and sends the user identification information to the terminal.
[0054] Step 204: When cache information exists for the target applet, user identification startup information is obtained according to the user identification information.
[0055] Among them, the user identification startup information is startup information that carries user identification information, and the startup information is used to realize the startup of the mini program. In one embodiment, the user identification startup information may include at least one of user identification view information, user identification logic information, and user identification login information. The user identification view information is used to realize the display of the application interface related to the user identification information in the mini program, such as user name display, avatar display, member points display, coupon display, current order information display, etc. The user identification logic information is used to realize the operation of the business logic related to the user identification information in the mini program, such as detecting member points, detecting coupons, detecting current order information, etc.; the user identification login information is used to log in the current user identification information.
[0056] In one embodiment, when cache information exists for the target applet, the terminal obtains user identification startup information according to the user identification information.
[0057] Step 206: Update the cache information according to the user identification startup information.
[0058] Specifically, the view cache information may be updated according to the user identification view information, the logic cache information may be updated according to the user identification logic information, and the login cache information may be updated according to the user identification login information.
[0059] In one embodiment, the terminal starts updating the cache information according to the user identification information.
[0060] Step 208: Control the target applet to start according to the updated cache information.
[0061] Specifically, the updated cache information carries the current user identification information, so the started target applet can display the current user identification information and execute the business logic of the current user identification information.
[0062] In one embodiment, the terminal controls the target applet to start according to the updated cache information.
[0063] In the aforementioned mini-program startup method, when a startup instruction for a target mini-program is detected, the user identification information corresponding to the startup instruction is obtained, and the target mini-program cache information is checked. If cache information exists for the target mini-program, the user identification startup information is obtained based on the user identification information, the cache information is updated based on the user identification startup information, and the target mini-program is controlled to start based on the updated cache information. In this way, even if the user identification information obtained for each mini-program startup is different, a hot start method can be used to start the mini-program, which speeds up the startup of the mini-program.
[0064] In one embodiment, the start instruction is triggered by an input facial image; and a method of obtaining user identification information corresponding to the start instruction includes: determining the user identification information corresponding to the start instruction based on the input facial image.
[0065] A facial image refers to an image containing a human face. This facial image can be a color image or a depth image. Each pixel value in a color image is represented by the color components of the three channels: R (red), G (green), and B (blue). A depth image is an image in which the distance from the camera to each point in the user's scene is used as the pixel value.
[0066] In one embodiment, a facial image is captured by a terminal camera. The terminal camera may be a 3D camera. Compared to 2D cameras that can only capture color images, 3D cameras can capture both color and depth images. The 3D camera may include a color camera and a depth sensor. The color camera is used to capture color images, and the depth sensor is used to collect depth information to generate a depth image.
[0067] In one embodiment, an input facial image is obtained, and the input facial image is matched and identified with a pre-stored facial image. When there is a pre-stored facial image that matches the input facial image, the target mini program is started using the user identification information corresponding to the pre-stored facial image; when there is no pre-stored facial image that matches the input facial image, activation information is output, and the activation information is used to prompt the user to activate and register the target mini program.
[0068] In this embodiment, an input facial image is obtained, and a start instruction is triggered based on the input facial image, thereby achieving quick login of the mini program.
[0069] In one embodiment, the start instruction is triggered by an input graphic code; the method of obtaining the user identification information corresponding to the start instruction includes: determining the user identification information corresponding to the start instruction according to the input graphic code.
[0070] Among them, the graphic code is a black and white geometric figure distributed on a plane according to a certain pattern, which can carry user identification information, such as a QR code.
[0071] In one embodiment, an input graphic code is obtained, and the input graphic code is matched and identified with a pre-stored graphic code. When there is a pre-stored graphic code that matches the input graphic code, the target applet is started using the user identification information corresponding to the pre-stored graphic code; when there is no pre-stored graphic code that matches the input graphic code, activation information is output, and the activation information is used to prompt the user to activate and register the target applet.
[0072] In one embodiment, when a target object is detected in an area where the distance from the camera is less than a preset distance threshold, the camera is called to capture the target object to obtain a preview image. If the preview image includes a graphic code, it is determined based on the preview image whether the graphic code is within the recognition range of the recognition operation. If the graphic code exceeds the recognition range, a prompt message is output, which is used to prompt the graphic code to be adjusted to within the recognition range.
[0073] In this embodiment, the input graphic code is obtained, and a start instruction is triggered according to the input graphic code, thereby realizing quick login of the mini program.
[0074] In one embodiment, updating cache information according to user identification startup information includes: updating view cache information according to user identification view information; updating logic cache information according to user identification logic information; and updating login cache information according to user identification login information.
[0075] In one embodiment, the login cache information may be updated first according to the user identification login information, then the logic cache information may be updated according to the user identification logic information, and then the view cache information may be updated according to the user identification view information.
[0076] In this embodiment, the view cache information is updated according to the user identification view information, the logic cache information is updated according to the user identification logic information, and the login cache information is updated according to the user identification login information. In this way, during the hot start of the mini program, user information leakage is avoided and the security of user login is guaranteed.
[0077] In one embodiment, updating cache information according to user identification startup information includes: updating system layer code information, second code information and first code information of the basic library, logic layer code information and view layer code information in sequence according to the user identification startup information.
[0078] The view cache information may include at least one of the code information of the view layer and the first code information of the basic library; the logic cache information may include at least one of the code information of the logic layer and the second code information of the basic library; the login cache information may include the code information of the system layer. Figure 3As shown, the interface of the mini program is jointly implemented by the code information of the view layer, the code information of the logic layer, the code information of the basic library, and the code information of the system layer. In one embodiment, the code information of the view layer can be the mini program web page code, which is used to implement the UI interface of the mini program; the code information of the logic layer can be the mini program logic code, which is used to implement the business logic of the mini program. The first code information of the basic library is the code in the basic library used to inject the view layer; the second code information of the basic library is the code in the basic library used to inject the logic layer. The code information of the system layer is the specific implementation of the mini program framework at the system layer.
[0079] In one embodiment, Figure 4 As shown, the mini program may include a view layer, a logic layer, and a system layer. The view layer is responsible for the UI (User Interface) of the mini program, and is mainly responsible for rendering the page structure. The view layer may include the mini program web page code. The logic layer is responsible for the business logic of the mini program, and is mainly responsible for logic processing, data requests, interface calls, etc. The logic layer may include the mini program logic code. The system layer is provided by the host application, and is mainly responsible for responding to requests from the basic library. It is the ultimate implementer of business logic and page rendering. The system layer encapsulates logic layer components and view layer components. These components can call terminal hardware information through the interface provided by the host application. The logic layer and view layer can also call logic layer components and view layer components respectively. At the same time, the system layer contains the login information of the host application.
[0080] Mini programs run in host applications and terminals using a foundational library. This library encapsulates the capabilities of the host application and terminal and provides them to mini programs. Generally, the foundational library is pre-built into the host application. It can be injected into the view and logic layers for execution: in the view layer, it provides various components to assemble page elements; in the logic layer, it provides various APIs (Application Programming Interfaces) to manipulate these elements. The logic and view layers can be managed using separate threads. The view layer's interface can be rendered using WebView. Mini programs have multiple interfaces, so the view layer can have multiple WebView threads. The logic layer can use JSCore threads to run JavaScript scripts. For example, the foundational library might provide pageView.js to the view layer. This library's pageView.js and the mini program's webpage code run in the same JavaScript interpreter, jointly implementing the mini program's UI. Alternatively, the foundational library might provide waService.js to the logic layer. This library's waService.js and the mini program's logic code run in the same JavaScript interpreter, jointly implementing the mini program's business logic. The interpreter parses and executes code information, such as the code information of the mini program package and the foundational library.
[0081] The view layer and the logic layer can communicate through the system layer. Optionally, the system layer's JSBridage can be used as the communication medium between the view layer and the logic layer. The logic layer notifies the view layer of data changes, triggering page updates in the view layer. The view layer then notifies the triggered events to the logic layer, allowing the logic layer to perform business logic processing. Therefore, during the update process, updates must be made from the bottom layer upwards, that is, updating the code information of the system layer, the second code information and the first code information of the basic library, the code information of the logic layer, and the code information of the view layer in sequence.
[0082] In this embodiment, the code information of the system layer, the second code information and the first code information of the basic library, the code information of the logic layer and the code information of the view layer are updated in sequence according to the user identification startup information, so that the mini program is started in an orderly manner.
[0083] In one embodiment, before obtaining user identification startup information based on user identification information, it also includes: detecting whether the user identification information matches the login cache information in the cache information; when the user identification information does not match the login cache information in the cache information, executing the step of obtaining user identification startup information based on the user identification information.
[0084] In one embodiment, it is detected whether the user identification information matches the login cache information in the cache information. When the user identification information does not match the login cache information in the cache information, it means that the current user identification information is inconsistent with the user identification information in the cache, and the cache information needs to be updated to log in to the target applet according to the current user identification information.
[0085] In this embodiment, it is detected whether the user identification information matches the login cache information in the cache information. When the user identification information does not match the login cache information in the cache information, the step of obtaining the user identification startup information based on the user identification information is executed. In this way, in different startup scenarios, the fastest startup method is selected for the mini program.
[0086] In one embodiment, the method also includes: when there is no cache information for the target applet, obtaining the execution information of each step to be loaded of the target applet, the execution information is used to characterize the loading method and loading order of each step to be loaded, the loading method includes parallel loading method and sequential loading method; executing each step to be loaded according to the execution information.
[0087] Specifically, when there is no cache information for the target applet, the target applet is controlled to perform a cold start. When there is cache information for the target applet, the target applet can be controlled to perform a hot start based on the cache information. Cold start refers to the process of starting a applet when there is no running instance of the applet in the system memory; hot start refers to the process of triggering the applet to return to the foreground when there is a running instance of the applet in the system memory, but the applet is temporarily switched to the background. When the applet enters the background, the host application will maintain the running status of the applet within a preset time period (such as 5 minutes). If the preset time period is exceeded, the host application will actively destroy the applet; or, when at least two system memory alarms are received within a predetermined time period (such as 5 seconds), the host application will destroy the applet.
[0088] Among them, each step to be loaded is used to achieve a cold start of the target mini-program. Each step to be loaded may include: a mini-program package loading step, an interpreter loading step, a basic library loading step, a network view component loading step, a paging display control loading step, a mini-program package running step, and a page rendering step. The mini-program package loading step is to download the mini-program package from the server and read the mini-program package into the memory. The mini-program package may include the mini-program web page code and the mini-program logic code. The basic library loading step is used to load the basic library. The interpreter loading step is used to load the interpreter, which is used to parse and execute code information, such as the code information of the mini-program package and the code information of the basic library. The network view component loading step is used to initialize the network view component, which is used to display and render the mini-program page, such as WebView. The paging display control loading step is used to initialize the paging display control, which is used to implement the paging display of the mini-program interface, such as PageView. The page rendering step is used to render the mini-program page. The page rendering step can be implemented using the network view component and the paging display control.
[0089] Among them, the execution information can be used to characterize the loading method of each step to be loaded, and the loading method includes parallel loading method and sequential loading method. The parallel loading method is to use at least two threads for loading in the same time period, and the sequential loading method is to use one thread for loading in the same time period. After one step to be loaded is loaded, the next step to be loaded will be loaded. For example, the steps to be loaded are: step A and step B. If steps A and B are set to use parallel loading method, two threads are used for loading in the same time period, one thread loads step A, and the other thread loads step B; if steps A and B are set to use sequential loading method, and the loading order of step A is before the loading order of step B, one thread is used for loading in the same time period, and step B will be loaded only after step A is loaded.
[0090] The execution information can also be used to characterize the loading order of each pending step. The loading order characterizes the order in which each pending step is loaded. For example, if the pending steps are: Step A, Step B, and Step C, and the loading order of each pending step is set as: Step A before Step B, and Step B before Step C, then Step B will be loaded only after Step A is loaded, and Step C will be loaded only after Step B is loaded.
[0091] In one embodiment, a sequential loading method is first used to execute the mini-program package loading step and the interpreter loading step. When the mini-program package loading step is completed, the interpreter loading step is executed. When the mini-program package loading step and the interpreter loading step are completed, a parallel loading method is used to execute the first step set and the second step set. The first step set includes a basic library loading step and a mini-program package running step. The basic library loading step is executed first. When the basic library loading step is completed, the mini-program package running step is executed. The second step set includes a network view component loading step, a paging display control loading step, and a page rendering step. The network view component loading step is executed first. When the network view component loading step is completed, the paging display control loading step is executed. When the paging display control loading step is completed, the page rendering step is executed.
[0092] In one embodiment, the mini-program package is first downloaded from the server and read into memory. Next, the interpreter is loaded. Once the interpreter is loaded, two parallel threads are started for loading. One thread first loads the base library. Once the base library is loaded, the interpreter runs the code information of the mini-program package and the base library. The other thread first initializes the network view component. Once the network view component is initialized, the paging display control is initialized. Once the paging display control is initialized, the network view component and the paging display control are used to render the mini-program homepage. Once these two parallel loading threads are executed, the mini-program is started.
[0093] In this embodiment, the execution information of each step to be loaded of the target applet is obtained. The execution information is used to characterize the loading method and loading order of each step to be loaded. The loading method includes a parallel loading method and a sequential loading method. Each step to be loaded is executed according to the execution information. In this way, when the applet is cold started, the steps to be loaded are executed according to the parallel loading method, which speeds up the startup speed of the applet.
[0094] In one embodiment, before executing each step to be loaded according to the execution information, it also includes: determining a pre-loading step according to the execution information; executing each step to be loaded according to the execution information, including: executing each step to be loaded except the pre-loading step according to the execution information.
[0095] The execution information is also used to represent the loading status of each step to be loaded, which includes a loaded state and an unloaded state. When the loading status of a step to be loaded is loaded, it means that the step to be loaded has been loaded in advance and does not need to be loaded this time; when the loading status of a step to be loaded is unloaded, it means that the step to be loaded needs to be loaded this time.
[0096] In one embodiment, the preloading step may include at least one of: an interpreter loading step, a basic library loading step, and a network view component loading step. Specifically, when the interpreter loading step, the basic library loading step, and the network view component loading step are pre-executed, the mini-program package loading step is executed first. When the mini-program package loading step is executed, the mini-program package running step and a third step set are executed in parallel loading. The third step set includes a paging display control loading step and a page rendering step. The paging display control loading step is executed first. When the paging display control loading step is executed, the page rendering step is executed.
[0097] In this embodiment, the pre-loading steps are determined based on the execution information, and the steps to be loaded except the pre-loading steps are executed according to the execution information. In this way, some steps to be loaded are preheated in advance, which reduces the steps to be loaded during the cold start process of the mini program and improves the startup speed of the mini program.
[0098] In a specific embodiment, a method for starting a mini-program is provided, comprising:
[0099] Obtaining an input facial image, and determining user identification information based on the input facial image;
[0100] Next, detecting whether the target applet has cache information, the cache information including at least one of view cache information, logic cache information, and login cache information, the view cache information including at least one of code information of the view layer and first code information of the basic library, the logic cache information including at least one of code information of the logic layer and second code information of the basic library, and the login cache information including code information of the system layer;
[0101] Further, when cache information exists in the target applet, user identification startup information is obtained according to the user identification information, the user identification startup information including at least one of user identification view information, user identification logic information, and user identification login information;
[0102] Then, according to the user identification startup information, the code information of the system layer, the second code information and the first code information of the basic library, the code information of the logic layer and the code information of the view layer are updated in sequence, and the target applet is controlled to perform hot startup according to the updated cache information.
[0103] In this embodiment, even if the user identification information obtained each time the mini program is started is different, it can be started in a hot start manner, thereby speeding up the startup speed of the mini program.
[0104] In a specific embodiment, Figure 5 As shown, a method for starting a small program is provided, including:
[0105] When a start instruction for a target applet is detected, detecting whether the target applet is started for the first time;
[0106] Next, when the target applet is not started for the first time, detecting whether the target applet has cache information, the cache information including at least one of view cache information, logic cache information, and login cache information, the view cache information including at least one of code information of the view layer and first code information of the basic library, the logic cache information including at least one of code information of the logic layer and second code information of the basic library, and the login cache information including code information of the system layer;
[0107] Further, when cache information exists for the target applet, user identification information corresponding to the startup instruction is obtained, and user identification startup information is obtained according to the user identification information, where the user identification startup information includes at least one of user identification view information, user identification logic information, and user identification login information;
[0108] Then, according to the user identification startup information, the code information of the system layer, the second code information and the first code information of the basic library, the code information of the logic layer and the code information of the view layer are updated in sequence, and the target applet is controlled to perform hot startup according to the updated cache information.
[0109] like Figure 6 As shown, when the mini program is started for the first time, the mini program is first cold started. When the mini program enters the background and is started again, it is hot started using the method provided in this embodiment.
[0110] In this embodiment, in different startup scenarios, the fastest startup method is selected for the mini program; and the hot startup method provided by this embodiment avoids the leakage of user information and ensures the security of user login.
[0111] The present application also provides an application scenario, which applies the above-mentioned method for starting the mini program. The method for starting the mini program provided in the present application can be applied to smart payment devices. Smart payment devices are cash register devices that cooperate with mobile payment methods. Smart payment devices may include desktop cash register payment devices and self-service cash register payment devices. Desktop cash register payment devices are plug-and-play payment devices for manual cash registers. After connecting to a POS machine, they can replace the original barcode scanning gun or barcode scanning box for scanning payment. Self-service cash register payment devices are payment devices for self-service cash registers.
[0112] Smart payment devices have a payment app installed, and the mini-program can use this payment app as the host application. By default, the payment app can run without logging in. Users can use features such as facial recognition or QR code scanning to temporarily log in to the payment app.
[0113] In one embodiment, Figure 7 As shown, Figure 7 This is a software architecture diagram for a payment application in one embodiment. The payment application provides a facial recognition module that enables login and payment. The payment application also provides an application environment for mini-programs.
[0114] Specifically, if Figure 8 As shown in the figure, the application scenario is: click the face payment button to start the face payment function, obtain user identification information by face scanning, and control the target mini program to cold start according to the user identification information. After the target mini program is started, the target mini program can display the user's membership information in the merchant (user name, avatar, membership points, coupons, common addresses, etc.), the user's order information (current order information, historical order information), etc. The mini program can also push the merchant's promotional information, etc. The specific methods of starting the mini program include:
[0115] Obtaining an input facial image, and determining user identification information based on the input facial image;
[0116] Next, detecting whether the target applet has cache information, the cache information including at least one of view cache information, logic cache information, and login cache information, the view cache information including at least one of code information of the view layer and first code information of the basic library, the logic cache information including at least one of code information of the logic layer and second code information of the basic library, and the login cache information including code information of the system layer;
[0117] Further, when cache information exists in the target applet, user identification startup information is obtained according to the user identification information, the user identification startup information including at least one of user identification view information, user identification logic information, and user identification login information;
[0118] Then, according to the user identification startup information, the code information of the system layer, the second code information and the first code information of the basic library, the code information of the logic layer and the code information of the view layer are updated in sequence, and the target applet is controlled to perform hot startup according to the updated cache information.
[0119] In this embodiment, even if the user identification information obtained each time the mini program is started is different, it can be started in a hot start manner, thereby speeding up the startup speed of the mini program.
[0120] It should be understood that although Figure 2 、 Figure 5The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 2 、 Figure 5 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The order of execution of these steps or stages is not necessarily one by one, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0121] In one embodiment, Figure 9 As shown, a device for starting a small program is provided. The device can be a software module or a hardware module, or a combination of the two to form a part of a computer device. The device specifically includes: a detection module 902, an acquisition module 904, an update module 906 and a control module 908, wherein:
[0122] The detection module 902 is configured to, when a startup instruction for a target applet is detected, obtain user identification information corresponding to the startup instruction and detect whether cached information of the target applet exists;
[0123] An acquisition module 904 is configured to acquire user identification startup information based on user identification information when cache information exists for the target applet;
[0124] An updating module 906 is configured to update cache information according to user identification startup information;
[0125] The control module 908 is used to control the target applet to start according to the updated cache information.
[0126] In the aforementioned mini-program startup device, upon detecting a startup instruction for a target mini-program, the device obtains the user identification information corresponding to the startup instruction and detects whether cached information exists for the target mini-program. If cached information exists for the target mini-program, the device obtains user identification startup information based on the user identification information, updates the cached information based on the user identification startup information, and controls the startup of the target mini-program based on the updated cached information. In this way, even if the user identification information obtained for each mini-program startup is different, a hot startup method can be used to start the mini-program, thereby accelerating the startup of the mini-program.
[0127] In one embodiment, the start instruction is triggered by an input facial image; the acquisition module 904 is further configured to determine user identification information corresponding to the start instruction based on the input facial image.
[0128] In this embodiment, an input facial image is obtained, and a start instruction is triggered based on the input facial image, thereby achieving quick login of the mini program.
[0129] In one embodiment, the start instruction is triggered by an input graphic code; the acquisition module 904 is further configured to determine user identification information corresponding to the start instruction based on the input graphic code.
[0130] In this embodiment, the input graphic code is obtained, and a start instruction is triggered according to the input graphic code, thereby realizing quick login of the mini program.
[0131] In one embodiment, the cache information includes at least one of view cache information, logical cache information, and login cache information, and the user identification startup information includes at least one of user identification view information, user identification logical information, and user identification login information; the update module 906 is further used to: update the view cache information according to the user identification view information; update the logical cache information according to the user identification logical information; and update the login cache information according to the user identification login information.
[0132] In this embodiment, the view cache information is updated according to the user identification view information, the logic cache information is updated according to the user identification logic information, and the login cache information is updated according to the user identification login information. In this way, during the hot start of the mini program, user information leakage is avoided and the security of user login is guaranteed.
[0133] In one embodiment, the view cache information includes the code information of the view layer and at least one of the first code information of the basic library; the logic cache information includes the code information of the logic layer and at least one of the second code information of the basic library; the login cache information includes the code information of the system layer; the update module 906 is also used to: update the code information of the system layer, the second code information and the first code information of the basic library, the code information of the logic layer and the code information of the view layer in sequence according to the user identification startup information.
[0134] In this embodiment, the code information of the system layer, the second code information and the first code information of the basic library, the code information of the logic layer and the code information of the view layer are updated in sequence according to the user identification startup information, so that the mini program is started in an orderly manner.
[0135] In one embodiment, the startup device of the mini program also includes a detection module 902, which is used to detect whether the user identification information matches the login cache information in the cache information; in one embodiment, the startup device of the mini program also includes an execution module, which is used to execute the step of obtaining user identification startup information based on the user identification information when the user identification information does not match the login cache information in the cache information.
[0136] In this embodiment, it is detected whether the user identification information matches the login cache information in the cache information. When the user identification information does not match the login cache information in the cache information, the step of obtaining the user identification startup information based on the user identification information is executed. In this way, in different startup scenarios, the fastest startup method is selected for the mini program.
[0137] In one embodiment, the acquisition module 904 is also used to: when there is no cache information for the target applet, obtain the execution information of each step to be loaded of the target applet, the execution information is used to characterize the loading method and loading order of each step to be loaded, and the loading method includes a parallel loading method and a sequential loading method; the execution module is also used to: execute each step to be loaded according to the execution information.
[0138] In this embodiment, the execution information of each step to be loaded of the target applet is obtained. The execution information is used to characterize the loading method and loading order of each step to be loaded. The loading method includes a parallel loading method and a sequential loading method. Each step to be loaded is executed according to the execution information. In this way, when the applet is cold started, the steps to be loaded are executed according to the parallel loading method, which speeds up the startup speed of the applet.
[0139] In one embodiment, the execution information is also used to characterize the loading status of each step to be loaded; the startup device of the applet also includes a determination module, which is used to: determine the pre-loading step based on the execution information; the execution module is also used to: execute the steps to be loaded except the pre-loading step in each step to be loaded according to the execution information.
[0140] In this embodiment, the pre-loading steps are determined based on the execution information, and the steps to be loaded except the pre-loading steps are executed according to the execution information. In this way, some steps to be loaded are preheated in advance, which reduces the steps to be loaded during the cold start process of the mini program and improves the startup speed of the mini program.
[0141] For the specific definition of the mini-program startup device, please refer to the definition of the mini-program startup method above, which will not be repeated here. The various modules in the above-mentioned mini-program startup device can be implemented in whole or in part by software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0142] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 10As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for starting a small program is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse.
[0143] Those skilled in the art will understand that Figure 10 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0144] In one embodiment, a computer device is further provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.
[0145] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above-mentioned method embodiments when executed by a processor.
[0146] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0147] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0148] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A method for starting a mini-program, characterized in that: Applied to a smart payment device having a payment application installed thereon, the method includes: When the payment application runs the payment function, it triggers a start instruction for the target mini-program, and the target mini-program uses the payment application as the host application; When a start instruction for a target applet is detected, user identification information corresponding to the start instruction is obtained, and cache information of the target applet is detected, the cache information including view cache information, logic cache information, and login cache information, wherein the view cache information is used to display the application interface of the applet, the logic cache information is used to run the business logic of the applet, and the login cache information is used to log in the user identification information; When the cache information exists in the target applet, detecting whether the user identification information matches the login cache information; when the user identification information does not match the login cache information, obtaining user identification startup information according to the user identification information, the user identification startup information including user identification view information, user identification logic information and user identification login information; the user identification view information is used to implement the display of the application interface related to the user identification information in the target applet, the user identification logic information is used to implement the operation of the business logic related to the user identification information in the target applet, and the user identification login information is used to implement the login of the user identification information; updating the view cache information according to the user identification view information, updating the logic cache information according to the user identification logic information, and updating the login cache information according to the user identification login information, wherein the updated cache information carries the user identification information; The target applet is controlled to start according to the updated cache information; the started target applet is used to display the payment order information corresponding to the user identifier in the user identifier startup information.
2. The method according to claim 1, characterized in that The start instruction is also triggered by an input face image; The method of obtaining the user identification information corresponding to the start instruction includes: The user identification information corresponding to the start instruction is determined according to the input facial image.
3. The method according to claim 1, characterized in that The start instruction is also triggered by an input graphic code; The method of obtaining the user identification information corresponding to the start instruction includes: The user identification information corresponding to the start instruction is determined according to the input graphic code.
4. The method according to claim 3, characterized in that The view cache information includes at least one of code information of the view layer and first code information of the basic library; the logic cache information includes at least one of code information of the logic layer and second code information of the basic library; The login cache information includes code information of the system layer; The updating of the cache information according to the user identification startup information includes: The code information of the system layer, the second code information and the first code information of the basic library, the code information of the logic layer, and the code information of the view layer are updated in sequence according to the user identification startup information.
5. The method according to claim 1, wherein The method further comprises: When the target applet does not have the cache information, obtaining execution information of each to-be-loaded step of the target applet, the execution information being used to characterize a loading method and a loading order of each to-be-loaded step, wherein the loading method includes a parallel loading method and a sequential loading method; Execute the steps to be loaded according to the execution information.
6. The method according to claim 5, characterized in that The execution information is also used to represent the loading status of each step to be loaded; Before executing the steps to be loaded according to the execution information, the method further includes: determining a preloading step according to the execution information; The executing each of the steps to be loaded according to the execution information includes: The steps to be loaded except the pre-loading step in the steps to be loaded are executed according to the execution information.
7. A device for starting a small program, characterized in that: Applied to a smart payment device, wherein a payment application is installed on the smart payment device, the apparatus comprises: A module for triggering a start instruction for a target mini-program when the payment application runs a payment function; the target mini-program uses the payment application as a host application; a detection module configured to, upon detecting a startup instruction for a target mini-program, obtain user identification information corresponding to the startup instruction and detect whether cache information exists for the target mini-program, the cache information including view cache information, logic cache information, and login cache information, wherein the view cache information is used to display the application interface of the mini-program, the logic cache information is used to run the business logic of the mini-program, and the login cache information is used to log in user identification information; an acquisition module, configured to detect, when the cache information exists in the target applet, whether the user identification information matches the login cache information; and, when the user identification information does not match the login cache information, acquire user identification startup information based on the user identification information, wherein the user identification startup information includes user identification view information, user identification logic information, and user identification login information; the user identification view information is used to display an application interface related to the user identification information in the target applet; the user identification logic information is used to execute a business logic related to the user identification information in the target applet; and the user identification login information is used to log in the user identification information; an updating module, configured to update the view cache information according to the user identification view information, update the logic cache information according to the user identification logic information, and update the login cache information according to the user identification login information, wherein the updated cache information carries the user identification information; The control module is used to control the target applet to start according to the updated cache information; the started target applet is used to display the payment order information corresponding to the user identifier in the user identifier startup information.
8. The device according to claim 7, characterized in that The start instruction is also triggered by an input face image; The acquisition module is further configured to determine user identification information corresponding to the start instruction based on the input facial image.
9. The device according to claim 7, characterized in that The start instruction is also triggered by an input graphic code; The acquisition module is further configured to determine user identification information corresponding to the start instruction based on the input graphic code.
10. The device according to claim 7, characterized in that The view cache information includes at least one of the code information of the view layer and the first code information of the basic library; the logic cache information includes at least one of the code information of the logic layer and the second code information of the basic library; the login cache information includes the code information of the system layer; The update module is further configured to sequentially update the code information of the system layer, the second code information and the first code information of the basic library, the code information of the logic layer, and the code information of the view layer according to the user identification startup information.
11. The device according to claim 7, characterized in that The acquisition module is further configured to, when the cache information does not exist for the target applet, acquire execution information of each to-be-loaded step of the target applet, wherein the execution information is used to characterize a loading method and a loading order of each to-be-loaded step, wherein the loading method includes a parallel loading method and a sequential loading method; Execute the steps to be loaded according to the execution information.
12. The device according to claim 11, characterized in that The execution information is also used to represent the loading status of each step to be loaded; The device further comprises: a determination module, configured to determine a preloading step according to the execution information; The execution module is further configured to execute the steps to be loaded except the pre-loading step in the steps to be loaded according to the execution information.
13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
14. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Method for starting application program based on mobile terminal and mobile terminal
CN105760731A
Processing method and device of App (application) starting events and equipment
CN107766101A
Personalized page preloading method and system based on user behaviors
CN109918150A