Mini-program operation method, device, electronic device, storage medium, and program product

By loading scripts and rendering resources in parallel, and using the react framework and react-reconciler constructor to handle page operations, the white screen problem of the mini program is solved and the mobile interactive experience is improved.

CN114741126BActive Publication Date: 2024-10-29KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210255130.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-15
Publication Date
2024-10-29
Estimated Expiration
2042-03-15

AI Technical Summary

Technical Problem

There is a white screen problem when the mini program is opened for the first or second time, especially when the mobile device performance and network speed are limited, which is more obvious, affecting the interactive experience.

Method used

Load script resources by executing the Service layer and load rendering resources by the View layer in parallel, coordinate the Service layer and View layer through the Native layer after the resource loading is completed, send page initialization instructions to render the page, and use the react framework and react-reconciler constructor to process the page Operation to achieve rapid generation and rendering of page operation processing instructions.

Benefits of technology

It significantly solves the white screen problem, improves the smoothness of interactive display, reduces resource loading time and blocking, and improves the interactive experience of mobile web projects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114741126B_ABST
    Figure CN114741126B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a method, device, electronic device, storage medium and program product for running a small program, the method comprising: executing the Service layer to load script resources and the View layer to load rendering resources in parallel; the Service layer sends a page initialization instruction to the View layer, and the View layer parses the instruction and renders the page; in response to the View layer monitoring the page operation, the View layer feeds back the page operation to the Service layer; the Service layer generates a page operation processing instruction according to the page operation and passes it to the View layer; the View layer parses the page operation processing instruction and renders the page; the Service layer and the View layer communicate through the Native layer. The embodiment of the present invention coordinates the actions of the Service layer and the View layer by loading scripts and rendering resources in parallel, significantly solving the white screen problem and improving the fluency of interactive display.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of mini-program technology, and specifically to a mini-program running method, device, electronic device, storage medium and program product. Background Art

[0002] Mini programs are applications that can be used without downloading or installing. They realize the dream of "apps at your fingertips". Users can open apps by scanning or searching. They also embody the concept of "use it and go". Users don't have to worry about installing too many apps. Apps will be everywhere and available at any time, but there is no need to install or uninstall them.

[0003] As a web product, whether the interactive experience of mini programs is simple and smooth has attracted much attention. At present, mini programs have some common web problems in interactive connection. For example, when a web page is opened for the first time or the second time, there will be a white screen process. On the mobile side, due to the limitations of device performance and network speed, the appearance of the white screen is more obvious, especially for more complex web pages. Summary of the invention

[0004] An embodiment of the present invention provides a method for running a mini-program, comprising: executing in parallel loading of script resources in a Service layer and loading of rendering resources in a View layer; in response to completion of loading of the script resources and receipt of information that loading of the rendering resources is complete, using the Service layer to send a page initialization instruction to the View layer through a Native layer, and using the View layer to parse the page initialization instruction and render the page; in response to the View layer monitoring a page operation, using the View layer to feed back the page operation to the Service layer through the Native layer; in response to the Service layer receiving the page operation, using the Service layer to generate a page operation processing instruction according to the page operation, and passing the page operation processing instruction to the View layer through the Native layer; in response to the View layer receiving the page operation processing instruction, using the View layer to parse the page operation processing instruction, and rendering the page according to the page operation processing instruction.

[0005] According to an embodiment of the present invention, a mini-program running method is provided, which uses the Service layer to generate a page operation processing instruction according to the page operation, including: using the Service layer to pass the page operation to a corresponding page operation method according to the type of the page operation; converting the page operation into the corresponding page operation processing instruction through the page operation method.

[0006] According to a mini-program running method provided by an embodiment of the present invention, before using the Service layer to pass the page operation to a corresponding page operation method according to the type of the page operation, the method also includes: in the Service layer, installing the react framework, creating a new ReactElement element, and passing the web project source code as a child element of the ReactElement element; in the Service layer, installing the react-reconciler constructor, configuring the hostConfig protocol, and using the hostConfig protocol as the input of the react-reconciler constructor to obtain a constructor instance; wherein the configuration of the hostConfig protocol includes configuring the page operation method; passing the ReactElement element into the constructor instance, the startup entry of the constructor instance is the updateContainer method, and the ReactElement element is a parameter of the updateContainer method.

[0007] According to a method for running a small program provided by an embodiment of the present invention, the page operation method includes a method for creating an element, a method for updating an element, and a method for deleting an element.

[0008] According to a mini-program running method provided by an embodiment of the present invention, rendering a page according to the page operation processing instruction includes: using a separate process to render the page according to the page operation processing instruction; the method also includes: after the page is closed, saving the page state to the background.

[0009] According to a mini-program running method provided by an embodiment of the present invention, rendering a page according to the page operation processing instruction includes: parsing the page operation instruction, processing a document object model element according to the page operation instruction, and completing page rendering.

[0010] An embodiment of the present invention also provides a mini-program running device, including: a resource loading module, used to: execute in parallel the loading of script resources in the Service layer and the loading of rendering resources in the View layer; a page initialization module, used to: in response to the completion of the loading of the script resources and the Service layer receiving the information that the loading of the rendering resources is completed, use the Service layer to send a page initialization instruction to the View layer through the Native layer, use the View layer to parse the page initialization instruction and render the page; a page monitoring module, used to: in response to the View layer monitoring the page operation, use the View layer to feedback the page operation to the Service layer through the Native layer; a page operation processing module, used to: in response to the Service layer receiving the page operation, use the Service layer to generate a page operation processing instruction according to the page operation, and pass the page operation processing instruction to the View layer through the Native layer; a page rendering module, used to: in response to the View layer receiving the page operation processing instruction, use the View layer to parse the page operation processing instruction, and render the page according to the page operation processing instruction.

[0011] An embodiment of the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-mentioned mini-program running methods are implemented.

[0012] An embodiment of the present invention further provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned mini-program running methods are implemented.

[0013] An embodiment of the present invention further provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned mini-program running methods when executed by a processor.

[0014] The mini-program running method, device, electronic device, storage medium and program product provided by the embodiments of the present invention significantly solve the white screen problem and improve the smoothness of interactive display by loading script resources and rendering resources in parallel in different execution environments and effectively coordinating the actions of the Service layer and the View layer. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0016] Figure 1 This is one of the flowcharts of a method for running a small program provided by an embodiment of the present invention;

[0017] Figure 2 It is a schematic diagram of the relationship model among the Service layer, the Native layer, and the View layer in the mini-program running method provided in an embodiment of the present invention;

[0018] Figure 3 This is the second flowchart of the method for running a small program provided by an embodiment of the present invention;

[0019] Figure 4 It is a communication architecture diagram of the mini-program running method provided by an embodiment of the present invention;

[0020] Figure 5 It is a schematic diagram of the process of generating Service layer instructions in the mini-program running method provided in an embodiment of the present invention;

[0021] Figure 6 It is a schematic diagram of the View layer implementation process in the mini-program running method provided in an embodiment of the present invention;

[0022] Figure 7 is a schematic diagram of the structure of a mini-program running device provided by an embodiment of the present invention;

[0023] Figure 8 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0025] Figure 1 This is one of the flowcharts of a method for running a small program provided by an embodiment of the present invention. Figure 1 As shown, the method includes:

[0026] Step 101: Loading script resources in the Service layer and loading rendering resources in the View layer are executed in parallel.

[0027] The existing script resources and rendering resources are loaded in the same environment, which belongs to the serial loading method. For example, after loading some rendering resources, some script resources are loaded according to the needs of page display, and then some rendering resources are loaded, and then some script resources are loaded again until the script resources and rendering resources are loaded. The serial loading method of script resources and rendering resources causes problems such as long resource loading time and resource blocking, resulting in a white screen problem when displaying the page.

[0028] The embodiment of the present invention loads script resources and rendering resources in parallel in different execution environments. The script resources are loaded in the Service layer, and the rendering resources are loaded in the View layer, and the two are executed in parallel. Since resources are loaded in parallel, resource loading will not be blocked, thus avoiding or reducing the white screen problem caused by long resource loading time, resource blocking, etc.

[0029] Step 102, in response to the completion of loading the script resource and the Service layer receiving the information that the loading of the rendering resource is complete, the Service layer sends a page initialization instruction to the View layer through the Native layer, and the View layer parses the page initialization instruction and renders the page.

[0030] Figure 2 Schematic diagram of the relationship model among the Service layer, Native layer and View layer in the mini-program running method provided in the embodiment of the present invention. Figure 2 As shown in the figure, the Service layer is where data and instructions are generated. For the Android operating system, the Service layer can use V8; for the IOS operating system, the Service layer can use JavascriptCore (JSCore for short). V8 and JavascriptCore are both Javascript engines. The View layer is mainly used to parse instructions, render data to the interface, and monitor user operations on the interface, and then feed back to the Service layer for processing. For both the Android operating system and the IOS operating system, the View layer can use the system's built-in WebView (a visual component).

[0031] The Service layer and the View layer do not communicate directly, but communicate through the Native layer. The Native layer serves as the communication layer between the Service layer and the View layer, and provides more Native capabilities (native capabilities of the APP, and developing mini-programs based on the APP).

[0032] In order to improve the smoothness of interaction, it is necessary to set the interaction order of the communicating parties to avoid waiting and conflicts. Instructions will be sent to the View layer for rendering only after the script resources and rendering resources are loaded. The Service layer is used to load script resources and can know the progress of script resource loading. The View layer is used to load rendering resources. In order to enable the Service layer to obtain the information that the rendering resource loading is completed in time and send the page initialization instruction in time, after the View layer in the embodiment of the present invention completes loading the rendering resources, it sends the information that the rendering resource loading is completed to the Service layer through the Native layer, so as to notify the Service layer in time after the rendering resource loading is completed. After the script resource is loaded and the rendering resource loading is completed, the Service layer sends the page initialization instruction to the View layer through the Native layer, and the View layer parses the page initialization instruction and renders the page.

[0033] Step 103: In response to the View layer monitoring the page operation, the View layer is used to feed back the page operation to the Service layer through the Native layer.

[0034] After the page is initialized, the View layer monitors page operations in real time. If a page operation is detected, the View layer will promptly feed back the page operation to the Service layer through the Native layer.

[0035] Step 104 , in response to the Service layer receiving the page operation, using the Service layer to generate a page operation processing instruction according to the page operation, and passing the page operation processing instruction to the View layer through the Native layer.

[0036] After the Service layer receives the page operation sent by the View layer through the Native layer, it generates a page operation processing instruction based on the page operation and passes the page operation processing instruction to the View layer through the Native layer.

[0037] Step 105: In response to the View layer receiving the page operation processing instruction, the View layer is used to parse the page operation processing instruction, and the page is rendered according to the page operation processing instruction.

[0038] After the View layer receives the page operation processing instruction, it parses the page operation processing instruction and renders the page according to the page operation processing instruction.

[0039] Through the above steps 103 to 105, timely processing of page operations after page initialization is further achieved.

[0040] Figure 3This is the second flow chart of the mini-program operation method provided by the embodiment of the present invention. Figure 3 As shown, the method includes:

[0041] Download the mini program compressed package from the mini program server and decompress it to obtain rendering resources and script resources;

[0042] Initialize the Service layer (V8 or JavascriptCore) and View layer (WebView) respectively;

[0043] The Service layer loads script resources and generates the first instruction (page initialization instruction); waits for the rendering resources to be loaded;

[0044] The View layer loads rendering resources (in parallel with the Service layer loading script resources), and after loading is complete, notifies the Service layer of the completion of rendering resource loading through the Native layer; waits for the first instruction;

[0045] The Service layer receives the information that the rendering resource loading is complete. If the script resource has been loaded at this time, it sends the first instruction generated to the View layer through the Native layer and waits for the page operation to be processed;

[0046] The View layer parses the first instruction and renders the page;

[0047] The View layer monitors page operations, and after monitoring page operations, it feeds back page operations to the Service layer through the Native layer; waiting for the second instruction;

[0048] The Service layer receives the page operation, processes the page operation, generates a second instruction (page operation processing instruction), and sends the second instruction to the View layer through the Native layer; waits for the page operation to be processed;

[0049] The View layer parses the second instruction and updates the page;

[0050] The View layer monitors page operations, and after monitoring page operations, it feeds back page operations to the Service layer through the Native layer; waits for the third instruction;

[0051] The Service layer receives the page operation, processes the page operation, generates a third instruction (page operation processing instruction), and sends the third instruction to the View layer through the Native layer;

[0052] …

[0053] According to the above process, the subsequent page operations are processed and rendered step by step.

[0054] Figure 4 : is a communication architecture diagram of the mini-program operation method provided by an embodiment of the present invention. Figure 4 As shown in the figure, it is necessary to set up a message sending and receiving mechanism in the Service layer and the View layer for sending and receiving messages. As a bridge between the Service layer and the View layer, the Native layer needs to construct a unified method to receive and forward data transmitted by the Service layer and the View layer, while also taking into account the asynchrony of the messages to ensure the correct execution of sending and receiving messages.

[0055] The mini-program running method provided by the embodiment of the present invention significantly solves the white screen problem and improves the fluency of interactive display by loading script resources and rendering resources in parallel in different execution environments and effectively coordinating the actions of the Service layer and the View layer.

[0056] According to an embodiment of the present invention, a mini-program running method is provided, which uses the Service layer to generate a page operation processing instruction according to the page operation, including: using the Service layer to pass the page operation to a corresponding page operation method according to the type of the page operation; converting the page operation into the corresponding page operation processing instruction through the page operation method.

[0057] According to the processing needs of page operations, the Service layer sets a variety of page operation methods. After receiving the page operation, the corresponding page operation method will receive the result of the corresponding operation, and the corresponding page operation method will convert the page operation into the corresponding page operation processing instruction. The relevant content of the page operation instruction can be pre-written in the page operation method.

[0058] The mini-program running method provided by the embodiment of the present invention realizes the rapid generation of page operation instructions by passing the page operation to the corresponding page operation method according to the type of page operation by utilizing the Service layer, and converting the page operation into the corresponding page operation processing instruction through the page operation method.

[0059] According to a mini-program running method provided by an embodiment of the present invention, before using the Service layer to pass the page operation to a corresponding page operation method according to the type of the page operation, the method also includes: in the Service layer, installing the react framework, creating a new ReactElement element, and passing the web project source code as a child element of the ReactElement element; in the Service layer, installing the react-reconciler constructor, configuring the hostConfig protocol, and using the hostConfig protocol as the input of the react-reconciler constructor to obtain a constructor instance; wherein the configuration of the hostConfig protocol includes configuring the page operation method; passing the ReactElement element into the constructor instance, the startup entry of the constructor instance is the updateContainer method, and the ReactElement element is a parameter of the updateContainer method.

[0060] WeChat applet has its own set of frameworks, and the syntax of its framework is quite different from that of the react framework. Therefore, the framework of WeChat applet cannot be directly reused in the development of applet of APP based on the react framework. The development of applet under the react framework based on the framework of WeChat applet has too high cost in both learning and project migration. To solve this problem, an embodiment of the present invention provides a method for developing applet using the react framework. In this method, a web project built with react can be seamlessly migrated to an applet project, which can use more client capabilities and have a more friendly interactive experience.

[0061] Figure 5 FIG. 1 is a schematic diagram of the process of generating a Service layer instruction in the mini-program operation method provided in an embodiment of the present invention. Figure 5 As shown, the Service layer instruction generation process includes:

[0062] (1) In the Service layer, install the react framework, create a ReactElement element, and pass the web project source code as a child element of the ReactElement element; the web project source code is the web project code based on the react framework to be converted into a mini program, such as the react project code generated with one click. Figure 5 In <app / > For code examples.

[0063] (2) In the Service layer, install the react-reconciler constructor, configure the hostConfig protocol, and use the hostConfig protocol as the input of the react-reconciler constructor to obtain a constructor instance. Configuring the hostConfig protocol includes configuring the page operation method.

[0064] (3) The obtained ReactElement element is passed into the constructor instance. The startup entry of the constructor instance is the updateContainer method, and the ReactElement element is the parameter of the updateContainer method.

[0065] (4) The page operation methods configured in the hostConfig protocol, such as creating elements, deleting elements, and updating elements, need to be implemented according to the needs. This method will receive the results of the corresponding page operation.

[0066] (5) After receiving the page operation, the page operation method converts the results into instructions and passes them to the Native layer through the message sending and receiving mechanism. The Native layer then forwards the instructions to the View layer for page rendering.

[0067] The mini-program running method provided by the embodiment of the present invention realizes the running of the mini-program based on the react framework by installing the react framework in the Service layer, creating a new ReactElement element, passing the web project source code as a child element of the ReactElement element, installing the react-reconciler constructor in the Service layer, configuring the hostConfig protocol, using the hostConfig protocol as the input of the react-reconciler constructor, obtaining a constructor instance, and passing the ReactElement element into the constructor instance, thereby realizing the running of the mini-program based on the react framework and supporting developers to use the react framework to implement mini-program applications.

[0068] According to a method for running a small program provided by an embodiment of the present invention, the page operation method includes a method for creating an element, a method for updating an element, and a method for deleting an element.

[0069] The page operation method can be set as needed, for example, it can include commonly used methods of creating elements, updating elements and deleting elements. The specific method of the method of updating elements can be further flexibly set as needed.

[0070] The mini-program running method provided in the embodiment of the present invention provides basic guarantee for page interaction by setting page operation methods including creating element method, updating element method and deleting element method.

[0071] According to a mini-program running method provided by an embodiment of the present invention, rendering a page according to the page operation processing instruction includes: using a separate process to render the page according to the page operation processing instruction; the method also includes: after the page is closed, saving the page state to the background.

[0072] For a web page loaded on a mobile terminal, once it is closed, all states of user operations will be lost, increasing the user's secondary interaction cost. When rendering a page according to a page operation processing instruction, an embodiment of the present invention uses a separate process to render the page according to the page operation processing instruction.

[0073] Each time a page is rendered, Android needs to use a separate process to load WebView for page rendering, and this process is managed by the main process. IOS uses a Native page to load a WebView for page rendering. The above methods all use a separate process to render the page according to the page operation processing instructions, that is, extracting the rendering process into a separate process.

[0074] By using a separate process to render the page according to the page operation processing instructions, the page state can be saved to the background after the page is closed. In this way, when the page is opened again, the previous page state can be maintained to avoid repeated operations. In iOS, the effect of maintaining the page state is simulated based on whether the context of the WebView in the memory is destroyed.

[0075] An embodiment of the present invention provides a method for running a mini-program, which uses a separate process to render a page according to page operation processing instructions. After the page is closed, the page status is saved to the background. By establishing the concept of multi-process of the page, the user's usage status is retained, making the interactive experience more friendly.

[0076] According to a mini-program running method provided by an embodiment of the present invention, rendering a page according to the page operation processing instruction includes: parsing the page operation instruction, processing a document object model element according to the page operation instruction, and completing page rendering.

[0077] Figure 6 1 is a schematic diagram of the View layer implementation process in the mini-program running method provided in an embodiment of the present invention. Figure 6 As shown, in the View layer, the following functions need to be implemented:

[0078] (1) Implement the mechanism for sending and receiving messages.

[0079] (2) Implement the method of rendering the instructions from the Service layer to the WebView, including creating Document Object Model (DOM) elements, updating Document Object Model elements, deleting Document Object Model elements, etc. After receiving the instructions from the Service layer, parse the instructions, trigger the corresponding methods to process the page elements according to the content of the instructions, and complete the interface rendering (page rendering).

[0080] (3) Monitor each rendered element. If any interactive operation occurs on the page, a feedback operation needs to be triggered immediately, and the page operation is notified to the Service layer through the Native layer for processing.

[0081] The mini-program running method provided by the embodiment of the present invention parses the page operation instruction, processes the document object model element according to the page operation instruction, completes the page rendering, and realizes the response of the page operation.

[0082] The mini-program running method provided in the embodiment of the present invention can solve the white screen problem and the problem of losing user operation status when interacting with the mobile terminal, and improve the interactive experience of the mobile terminal web project; it can solve the problems of high learning cost of the new framework and difficulty in project migration, improve the reuse of mobile terminal capabilities, and reduce the cost of web developers to develop mini-programs.

[0083] The following is a description of a mini-program running device provided in an embodiment of the present invention. The mini-program running device described below and the mini-program running method described above can be referenced to each other.

[0084] Figure 7 Schematic diagram of the structure of the mini-program running device provided by the embodiment of the present invention. Figure 7As shown, the device includes a resource loading module 10, a page initialization module 20, a page monitoring module 30, a page operation processing module 40 and a page rendering module 50, wherein: the resource loading module 10 is used to: execute in parallel the loading of script resources in the Service layer and the loading of rendering resources in the View layer; the page initialization module 20 is used to: in response to the completion of the loading of the script resources and the Service layer receiving the information that the loading of the rendering resources is completed, use the Service layer to send a page initialization instruction to the View layer through the Native layer, use the View layer to parse the page initialization instruction and render the page; the page monitoring module 30 is used to: in response to the View layer monitoring the page operation, use the View layer to feedback the page operation to the Service layer through the Native layer; the page operation processing module 40 is used to: in response to the Service layer receiving the page operation, use the Service layer to generate a page operation processing instruction according to the page operation, and pass the page operation processing instruction to the View layer through the Native layer; the page rendering module 50 is used to: in response to the View layer receiving the page operation processing instruction, use the View layer to parse the page operation processing instruction, and render the page according to the page operation processing instruction.

[0085] The mini-program running device provided in the embodiment of the present invention significantly solves the white screen problem and improves the smoothness of interactive display by loading script resources and rendering resources in parallel in different execution environments and effectively coordinating the actions of the Service layer and the View layer.

[0086] According to a mini-program running device provided by an embodiment of the present invention, when the page operation processing module 40 uses the Service layer to generate a page operation processing instruction according to the page operation, it is specifically used to: use the Service layer to pass the page operation to a corresponding page operation method according to the type of the page operation; and convert the page operation into the corresponding page operation processing instruction through the page operation method.

[0087] The mini-program running device provided by the embodiment of the present invention realizes the rapid generation of page operation instructions by passing the page operation to the corresponding page operation method according to the type of page operation by utilizing the Service layer, and converting the page operation into the corresponding page operation processing instruction through the page operation method.

[0088] According to a mini-program running device provided by an embodiment of the present invention, the page operation processing module 40 is also used for: installing the react framework in the Service layer, creating a new ReactElement element, and passing the web project source code as a child element of the ReactElement element; installing the react-reconciler constructor in the Service layer, configuring the hostConfig protocol, and using the hostConfig protocol as the input of the react-reconciler constructor to obtain a constructor instance; wherein the configuration of the hostConfig protocol includes configuring the page operation method; passing the ReactElement element into the constructor instance, the startup entry of the constructor instance is the updateContainer method, and the ReactElement element is a parameter of the updateContainer method.

[0089] The mini-program running device provided by the embodiment of the present invention installs the react framework in the Service layer, creates a new ReactElement element, passes the web project source code as a child element of the ReactElement element, installs the react-reconciler constructor in the Service layer, configures the hostConfig protocol, uses the hostConfig protocol as the input of the react-reconciler constructor, obtains a constructor instance, passes the ReactElement element into the constructor instance, thereby realizing the running of the mini-program based on the react framework and supporting developers to use the react framework to implement mini-program applications.

[0090] According to a mini-program running device provided by an embodiment of the present invention, the page operation method includes a method for creating an element, a method for updating an element, and a method for deleting an element.

[0091] The mini-program running device provided in the embodiment of the present invention provides basic guarantee for page interaction by setting page operation methods including creating element methods, updating element methods and deleting element methods.

[0092] According to a mini-program running device provided by an embodiment of the present invention, the page rendering module 50, when used to render a page according to the page operation processing instruction, is specifically used to: use a separate process to render the page according to the page operation processing instruction; the page rendering module 50 is also used to: after the page is closed, save the page status to the background.

[0093] An embodiment of the present invention provides a mini-program running device, which uses a separate process to render a page according to a page operation processing instruction. After the page is closed, the page status is saved to the background. By establishing the concept of multi-process of the page, the user's usage status is retained, making the interactive experience more friendly.

[0094] According to a mini-program running device provided by an embodiment of the present invention, when the page rendering module 50 is used to render a page according to the page operation processing instruction, it is specifically used to: parse the page operation instruction, process the document object model element according to the page operation instruction, and complete the page rendering.

[0095] The mini-program running device provided in the embodiment of the present invention parses the page operation instruction, processes the document object model element according to the page operation instruction, completes page rendering, and realizes the response of the page operation.

[0096] Figure 8 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 8 As shown, the electronic device may include: a processor (processor) 810, a communication interface (Communications Interface) 820, a memory (memory) 830 and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 can call the logic instructions in the memory 830 to execute the applet running method, which includes: executing in parallel the loading of script resources in the Service layer and the loading of rendering resources in the View layer; in response to the completion of the loading of the script resources and the Service layer receiving the information that the loading of the rendering resources is complete, using the Service layer to send a page initialization instruction to the View layer through the Native layer, and using the View layer to parse the page initialization instruction and render the page; in response to the View layer monitoring the page operation, using the View layer to feedback the page operation to the Service layer through the Native layer; in response to the Service layer receiving the page operation, using the Service layer to generate a page operation processing instruction according to the page operation, and passing the page operation processing instruction to the View layer through the Native layer; in response to the View layer receiving the page operation processing instruction, using the View layer to parse the page operation processing instruction, and rendering the page according to the page operation processing instruction.

[0097] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Ran Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0098] On the other hand, an embodiment of the present invention further provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the applet running method provided by the above methods, which includes: executing in parallel loading script resources in the Service layer and loading rendering resources in the View layer; in response to the completion of loading of the script resources and the Service layer receiving information that the loading of the rendering resources is complete, using the Service layer to send a page initialization instruction to the View layer through the Native layer, and using the View layer to parse the page initialization instruction and render the page; in response to the View layer monitoring the page operation, using the View layer to feedback the page operation to the Service layer through the Native layer; in response to the Service layer receiving the page operation, using the Service layer to generate a page operation processing instruction according to the page operation, and passing the page operation processing instruction to the View layer through the Native layer; in response to the View layer receiving the page operation processing instruction, using the View layer to parse the page operation processing instruction, and rendering the page according to the page operation processing instruction.

[0099] On the other hand, an embodiment of the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the mini-program running method provided by the above-mentioned methods, the method comprising: executing in parallel loading of script resources in the Service layer and loading of rendering resources in the View layer; in response to the completion of loading of the script resources and the Service layer receiving information that the loading of the rendering resources is complete, using the Service layer to send a page initialization instruction to the View layer through the Native layer, and using the View layer to parse the page initialization instruction and render the page; in response to the View layer monitoring a page operation, using the View layer to feed back the page operation to the Service layer through the Native layer; in response to the Service layer receiving the page operation, using the Service layer to generate a page operation processing instruction according to the page operation, and passing the page operation processing instruction to the View layer through the Native layer; in response to the View layer receiving the page operation processing instruction, using the View layer to parse the page operation processing instruction, and rendering the page according to the page operation processing instruction.

[0100] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0101] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for running a small program, It is characterized in that include: Parallel execution of loading script resources in the Service layer and loading rendering resources in the View layer; In response to the completion of loading of the script resource and the Service layer receiving the information that the loading of the rendering resource is completed, using the Service layer to send a page initialization instruction to the View layer through the Native layer, and using the View layer to parse the page initialization instruction and render the page; In response to the View layer monitoring the page operation, using the View layer to feed back the page operation to the Service layer through the Native layer; In response to the Service layer receiving the page operation, generating a page operation processing instruction according to the page operation by using the Service layer, and passing the page operation processing instruction to the View layer through the Native layer; In response to the View layer receiving the page operation processing instruction, parsing the page operation processing instruction using the View layer, and rendering the page according to the page operation processing instruction; The generating a page operation processing instruction according to the page operation by using the Service layer includes: Using the Service layer to pass the page operation to a corresponding page operation method according to the type of the page operation; Converting the page operation into the corresponding page operation processing instruction through the page operation method; Before using the Service layer to pass the page operation to a corresponding page operation method according to the type of the page operation, the method further includes: In the Service layer, install the react framework, create a new ReactElement element, and pass the web project source code as a child element of the ReactElement element; In the Service layer, the react-reconciler constructor is installed, the hostConfig protocol is configured, and the hostConfig protocol is used as the input of the react-reconciler constructor to obtain a constructor instance; wherein the configuration of the hostConfig protocol includes a configuration page operation method; The ReactElement element is passed into the constructor instance, the startup entry of the constructor instance is the updateContainer method, and the ReactElement element is a parameter of the updateContainer method.

2. The applet running method according to claim 1, It is characterized in that The page operation method includes a method for creating an element, a method for updating an element, and a method for deleting an element.

3. The applet running method according to claim 1, It is characterized in that The rendering of the page according to the page operation processing instruction comprises: using a separate process to render the page according to the page operation processing instruction; The method further includes: after the page is closed, saving the page state to the background.

4. The applet running method according to claim 1, It is characterized in that The rendering of the page according to the page operation processing instruction includes: The page operation instruction is parsed, and the document object model element is processed according to the page operation instruction to complete page rendering.

5. A small program running device, It is characterized in that include: Resource loading module, used to: load script resources in the Service layer and load rendering resources in the View layer in parallel; A page initialization module, configured to: in response to the completion of loading of the script resource and the Service layer receiving the information that the loading of the rendering resource is completed, use the Service layer to send a page initialization instruction to the View layer through the Native layer, and use the View layer to parse the page initialization instruction and render the page; A page monitoring module, used to: in response to the View layer monitoring a page operation, use the View layer to feed back the page operation to the Service layer through the Native layer; A page operation processing module, configured to: in response to the Service layer receiving the page operation, generate a page operation processing instruction according to the page operation using the Service layer, and pass the page operation processing instruction to the View layer through the Native layer; A page rendering module, configured to: in response to the View layer receiving the page operation processing instruction, parse the page operation processing instruction using the View layer, and render the page according to the page operation processing instruction; When the page operation processing module generates a page operation processing instruction according to the page operation by using the Service layer, the page operation processing module is specifically used to: transmit the page operation to a corresponding page operation method according to the type of the page operation by using the Service layer; Converting the page operation into the corresponding page operation processing instruction through the page operation method; Before the page operation processing module is used to pass the page operation to the corresponding page operation method according to the type of the page operation by using the Service layer, it is also used to: install the react framework in the Service layer, create a new ReactElement element, and pass the web project source code as a child element of the ReactElement element; install the react-reconciler constructor in the Service layer, configure the hostConfig protocol, and use the hostConfig protocol as the input of the react-reconciler constructor to obtain a constructor instance; wherein the configuration of the hostConfig protocol includes configuring the page operation method; pass the ReactElement element into the constructor instance, the startup entry of the constructor instance is the updateContainer method, and the ReactElement element is a parameter of the updateContainer method.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps of the applet running method as described in any one of claims 1 to 4 are implemented.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the applet running method as claimed in any one of claims 1 to 4 are implemented.

8. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the applet running method as claimed in any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Quick display method and device of webpage

    CN106294658A