Mini-program preview method, related device and computer program product

By extracting the compiled code of the applet and converting it into an intermediate file in large-capacity binary object format, combined with the running environment of the local browser, local compilation and preview of the applet is realized, solving the problem of compilation adaptation difficulties and improving the response speed and concurrency capabilities.

CN113050940BActive Publication Date: 2025-02-21BAIDU ONLINE NETWORK TECH (BEIJIBG) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110317024.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-24
Publication Date
2025-02-21
Estimated Expiration
2041-03-24

AI Technical Summary

Technical Problem

In the prior art, the compilation architecture and environment used by different applets lead to difficulty in compilation adaptation, and usually requires relying on cloud configuration development environments.

Method used

A preview method for applets is proposed. By responding to the test request of the target applet, the compilation code is extracted and converted into an intermediate file in large-capacity binary object format, and the intermediate file is converted into a file to be previewed based on the local browser's running environment. , and finally use a local browser to browse the visual interface of the files to be previewed.

Benefits of technology

It realizes local compilation and preview of applets, saves development resources, improves the concurrency ability of compilation work, improves the user's compile-time response speed, and avoids the delay and overhead of network communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113050940B_ABST
    Figure CN113050940B_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose a method, device, electronic device, computer-readable storage medium and computer program product for previewing a mini-program, and relate to the fields of computer technology such as mini-program compilation, preview and deployment technology. A specific implementation of the method includes: in response to receiving a test request for a target mini-program, extracting a compiled code from the test request, and converting the compiled code into an intermediate file in a large-capacity binary object format, further converting the intermediate file into a file to be previewed based on the operating environment of the local browser, and finally using the local browser to browse the visual interface of the file to be previewed. This implementation provides a method for completing mini-program compilation and preview based on a local browser, so that the compilation and file loading of the mini-program are completed in the local browser, reducing the consumption of server and network resources, and improving the response speed of mini-program compilation and real-time preview.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, specifically to the field of mini-program compilation, preview and deployment technology, and in particular to a mini-program preview method, device, electronic device, computer-readable storage medium and computer program product. Background Art

[0002] As we all know, with the development of electronic technology, more and more mini-programs can be installed in mobile terminals. Mini-programs are terminal small programs that can be used without downloading and installing. Usually, you only need to scan a QR code or search to use them immediately. Mini-programs are usually hosted in a host program and rely on the operating environment configured by the host program to work. When there is a host program in the terminal device, there is usually no need to download and install the mini-program additionally. You can use it directly anytime and anywhere without worrying about traffic downloads and insufficient mobile phone memory. In order to give the mini-program more functions and fix existing vulnerabilities in the mini-program, it is often necessary to compile and debug the mini-program accordingly.

[0003] In the prior art, since different applets use different compilation frameworks and require different compilation environments, in order to achieve compilation adaptation of each applet as much as possible, it is often necessary to rely on the cloud to configure the development environment, such as completing the configuration of the nodeJavaScript development environment based on the cloud. Summary of the invention

[0004] The embodiments of the present application provide a method, device, electronic device, computer-readable storage medium, and computer program product for previewing a mini-program.

[0005] In the first aspect, an embodiment of the present application proposes a preview method for a mini-program, comprising: in response to receiving a test request for a target mini-program, extracting compiled code from the test request; converting the compiled code into an intermediate file in a large-capacity binary object format, and converting the intermediate file into a file to be previewed based on the operating environment of a local browser; and using the local browser to browse a visual interface of the file to be previewed.

[0006] In the second aspect, an embodiment of the present application proposes a preview device for a mini-program, comprising: a compiled code extraction unit, configured to extract compiled code from a test request in response to receiving a test request for a target mini-program; a file to be previewed generation unit, configured to convert the compiled code into an intermediate file in a large-capacity binary object format, and convert the intermediate file into a file to be previewed based on the operating environment of a local browser; and a visual interface generation unit, configured to use the local browser to browse a visual interface of the file to be previewed.

[0007] In a third aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that when the at least one processor executes, it is able to implement the preview method of the mini-program described in any implementation method in the first aspect.

[0008] In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium storing computer instructions, which are used to enable a computer to implement a preview method for a mini-program as described in any implementation method in the first aspect when executed.

[0009] In a fifth aspect, an embodiment of the present application provides a computer program product comprising a computer program, which, when executed by a processor, can implement the preview method of the mini-program as described in any implementation method in the first aspect.

[0010] The mini-program preview method, device, electronic device, computer-readable storage medium and computer program product provided in the embodiments of the present application, in response to receiving a test request for a target mini-program, extracts compiled code from the test request, and converts the compiled code into an intermediate file in a large-capacity binary object format, further converts the intermediate file into a file to be previewed based on the operating environment of the local browser, and finally uses the local browser to browse the visual interface of the file to be previewed.

[0011] The present application unifies the encoding code by integrating the compiled code into an intermediate file in a large-capacity binary object format, so that the intermediate file can be converted into a file to be previewed through a local browser, and finally the local browser is used to directly generate a corresponding visual interface based on the file to be previewed to realize the preview of the mini-program, so as to completely rely on the local browser to realize the compilation and preview of the mini-program, save development resources, improve the concurrency of compilation work, and improve the response speed of users during compilation. Furthermore, considering that the common method of sequentially generating intermediate files and files to be previewed through the same process is not convenient for presenting the preview results of the compiled code after real-time modification, the operations of generating intermediate files and files to be previewed can also be placed in two isolated processes for execution, so that the real-time modification of the compiled code does not affect the normal preview effect of the file to be previewed when it is converted into a new intermediate file, and the potential risk of data conflicts is also eliminated.

[0012] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

[0014] Figure 1 is an exemplary system architecture in which the present application may be applied;

[0015] Figure 2 A flowchart of a method for previewing a mini-program provided in an embodiment of the present application;

[0016] Figure 3 A flowchart of another mini-program preview method provided in an embodiment of the present application;

[0017] Figure 4 A flowchart of a method for previewing a mini-program in a mini-program scenario provided in an embodiment of the present application;

[0018] Figure 5 A structural block diagram of a preview device for a small program provided in an embodiment of the present application;

[0019] Figure 6 A schematic diagram of the structure of an electronic device suitable for executing a preview method of a mini-program provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be appreciated by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description. It should be noted that, in the absence of conflict, the embodiments in the present application and the features in the embodiments may be combined with each other.

[0021] Figure 1 An exemplary system architecture 100 of an embodiment of a method, apparatus, electronic device, and computer-readable storage medium for previewing a small program of the present application is shown.

[0022] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0023] The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. The terminal devices 101, 102, 103 and the server 105 can be installed with various applications for realizing information communication between the two, such as small program publishing applications, remote debugging applications, instant messaging applications, etc.

[0024] Terminal devices 101, 102, 103 and server 105 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices with display screens, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, etc.; when terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above, which can be implemented as multiple software or software modules, or as a single software or software module, and no specific limitation is made here. When server 105 is hardware, it can be implemented as a distributed server cluster composed of multiple servers, or as a single server; when the server is software, it can be implemented as multiple software or software modules, or as a single software or software module, and no specific limitation is made here.

[0025] The terminal devices 101, 102, and 103 can provide various services through built-in applications. Taking the provision of small program publishing applications as an example, the terminal devices 101, 102, and 103 can achieve the following effects when running the small program publishing applications: in response to receiving a test request for the target small program, extract the compiled code from the test request, and convert the compiled code into an intermediate file in a large-capacity binary object format, further convert the intermediate file into a file to be previewed based on the operating environment of the local browser, and finally use the local browser to browse the visual interface of the file to be previewed.

[0026] Furthermore, after browsing the visual interface presented by the above-mentioned terminal devices 101, 102, and 103, the user can determine whether the mini program needs to be adjusted again based on the content in the visual interface. After completing the mini program preview and determining that the mini program does not need to be adjusted, the user can communicate with the server 105 through the network 104 to realize the purpose of the mini program and publish the mini program.

[0027] It should be noted that the compiled code included in the test request can be obtained based on the direct input of the user using the terminal device 101, 102, 103, and can also be obtained from the terminal device used by the user such as the server 105 through the network 104, or can be pre-stored in the server terminal device 101, 102, 103 in various ways. Therefore, when the terminal device 101, 102, 103 detects that the data has been stored locally (for example, the compiled code retained before the start of processing), it can choose to directly obtain the data locally. In this case, if there is no purpose of transmitting the preview result to the server 105 for storage, publishing, etc., the exemplary system architecture 100 may also not include the server 105 and the network 104.

[0028] Since the preview method of the applet needs to generate a large amount of computing data and occupy more computing resources, a large amount of data needs to be transmitted over the network when it is executed across terminals. Therefore, in order to better meet the purpose of this application and take into account the convenience of users compiling and previewing applet, the preview method of the applet provided in the subsequent embodiments of this application is generally provided by the terminal devices 101, 102, 103 used by the user, and accordingly, the preview device of the applet is generally also provided in the terminal devices 101, 102, 103. However, it should also be pointed out that, in specific demand occasions, the server 105 can also complete the various operations entrusted to the terminal devices 101, 102, 103 through the remote debugging applet installed thereon, and then output the same results as the terminal devices 101, 102, 103. In particular, when there are multiple terminal devices with different computing capabilities, when the mini-program publishing application or remote debugging application determines that the resources required to implement the mini-program preview method based on the server or the server and the terminal in collaboration are less, and the response speed to the user is better than using the terminal device alone, the server can be used alone or in combination to perform collaborative computing between the server and the terminal, thereby providing users with a better processing solution. Accordingly, the mini-program preview device can also be completely or partially set in the server 105. In this case, according to actual usage, the exemplary system architecture 100 may not include the terminal devices 101, 102, 103 and the network 104.

[0029] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0030] Please refer to Figure 2 , Figure 2 A flowchart of a method for previewing a mini-program provided in an embodiment of the present application, wherein process 200 includes the following steps:

[0031] Step 201 , in response to receiving a test request of a target applet, extracting compiled code from the test request.

[0032] In this embodiment, the execution body of the preview method of the mini program (for example Figure 1 The terminal devices 101, 102, 103 shown in the figure, upon receiving a test request for a target applet, extract the compiled code from the test request.

[0033] The target applet may be a applet pre-set by the user locally on the execution subject, or may be a target applet pre-transferred by the user or transmitted along with the test request.

[0034] In some optional embodiments of the present application, when the above-mentioned target applet is missing locally, the above-mentioned execution entity can, after receiving a test request, obtain the target applet or the source code of the target applet from a server or other terminal device communicating with the above-mentioned execution entity, so as to facilitate the subsequent compilation and preview of the target applet based on the obtained target applet or the source code of the target applet according to the obtained compiled code.

[0035] Furthermore, the compilation code included in the test request can be clear and specific compilation code content or a directional link. The above-mentioned execution subject obtains the corresponding compilation code according to the content pointed to by the directional link. For example, after obtaining the test request, the test request contains instructions for the above-mentioned execution subject to obtain the compilation code of the corresponding target applet from the server or other terminal device communicating with the above-mentioned execution subject.

[0036] It should be noted that the target applet and the compiled code can be obtained by the above-mentioned execution subject directly from a local storage device, or from a non-local storage device (such as Figure 1 The local storage device may be a data storage module provided in the above-mentioned execution subject, such as a server hard disk. In this case, the target applet and the compiled code may be quickly read locally; the non-local storage device may also be any other electronic device provided for storing data, such as some user terminals, etc. In this case, the above-mentioned execution subject may obtain the required compiled code by sending a obtain command to the electronic device.

[0037] Step 202: convert the compiled code into an intermediate file in a large-capacity binary object format, and convert the intermediate file into a file to be previewed based on the operating environment of the local browser.

[0038] In this embodiment, after obtaining the compiled code, the code is converted into an intermediate file in a large-capacity binary object format, and based on the operating environment of the local browser, the intermediate file is converted into a file to be previewed that can be previewed by the local browser, and then the file to be previewed is stored in the local browser.

[0039] Among them, the large capacity binary object format, also known as BLOB (Binary Large Object, BLOB for short), is a container that can store binary files. A BLOB represents an immutable, raw data-like file object. The data represented by a BLOB is not necessarily a JavaScript native format. The BLOB object is essentially an object in JavaScript that can store a large amount of data in binary encoding format.

[0040] Furthermore, after the files to be previewed are generated, a list of files to be previewed may be generated based on the relationship between the target applet, the intermediate files and the files to be previewed, so that subsequent users may request the files to be previewed corresponding to the target applet based on the list of files to be previewed.

[0041] Exemplarily, the swan template is parsed into the mini-program kernel san framework executable template, and the executable context is added to the mini-program js file, and the dependencies between js files are processed. Next, the custom components are processed, and the custom components are packaged into the allCusomComponents.swan.js file, the sjs file is processed, and the allRegisteredSJS.js file is packaged. Finally, the app.json file is processed, and the static resource file path is changed from the standard Uniform Resource Locator (URL) to the BLOB URL, so as to realize the parsing and processing of the extracted compiled code through the Abstract Syntax Tree (AST) static code analysis to obtain the corresponding intermediate file.

[0042] Step 203: Use a local browser to browse the visual interface of the file to be previewed.

[0043] In this embodiment, after the file to be previewed is generated in the above step 202, the local browser is called to preview the file to be previewed, and a corresponding visual interface is generated, wherein the visual interface generally may include: the compiled code of the target applet, the execution process of the compiled code, and the final preview result of the file to be previewed, so that the user can understand the information corresponding to the above content according to the content in the visual interface.

[0044] The preview method of the mini-program provided in the embodiment of the present application unifies the encoding code by integrating the compiled code into an intermediate file in a large-capacity binary object format, so that the intermediate file can be converted into a file to be previewed through a local browser, and finally the local browser is used to directly generate a corresponding visual interface based on the file to be previewed to realize the preview of the mini-program, so that the compilation and preview of the mini-program can be realized completely by relying on the local browser, saving development resources, improving the concurrency of the compilation work, and improving the response speed of the user during compilation. Furthermore, considering that the common method of sequentially generating intermediate files and files to be previewed through the same process is not convenient for presenting the preview results of the compiled code after real-time modification, the operations of generating intermediate files and files to be previewed can also be placed in two isolated processes for execution, so that the real-time modification of the compiled code does not affect the normal preview effect of the file to be previewed when it is converted into a new intermediate file, and the potential risk of data conflicts is eliminated.

[0045] In some optional implementations of this embodiment, the file to be previewed includes: a file mapping file, and a visual interface for browsing the file to be previewed using a local browser, including: in response to receiving a preview request, determining a file mapping file corresponding to the preview request based on a large-capacity binary object resource location standard; and browsing the visual interface of the file mapping file using the local browser.

[0046] Specifically, in order to further save hard disk resource usage, based on the compilation mechanism of the JavaScript runtime environment in the local browser, static resources are used to process the intermediate file in the large-capacity binary object format to convert it into a file mapping file, wherein the file mapping file exists in the content of the local browser. After the file mapping file is generated, in response to receiving a preview request, the file mapping file corresponding to the preview request can be determined based on the large-capacity binary object resource positioning standard, and the local browser can be used to browse the visual interface of the file mapping file.

[0047] In this implementation, the conversion and processing of intermediate files are completed only through the memory of the local browser, and the subsequent preview of the applet is directly implemented based on the browser memory. Compared with the compilation method in the prior art, it is free from the limitations of the nodeJavaScript operating environment. Compared with the centralized compilation provided based on the nodeJavaScript operating environment, it can save resource consumption to the maximum extent and improve compilation efficiency. In addition, since the loading of large-capacity binary objects is completed in the local browser memory, no additional network communication is required, which avoids the delay and overhead of network communication, thereby achieving extremely high file loading speed and preview response speed.

[0048] Please refer to Figure 3 , Figure 3A flowchart of another method for previewing a mini-program provided in an embodiment of the present application, wherein process 300 includes the following steps:

[0049] Step 301 , in response to receiving a test request of a target applet, extracting compiled code from the test request.

[0050] Step 302: convert the compiled code into an intermediate file in a large-capacity binary object format, and convert the intermediate file into a file to be previewed based on the operating environment of the local browser.

[0051] Step 303: Use a local browser to browse the visual interface of the file to be previewed.

[0052] The above steps 301-303 are the same as those described above. Figure 2 Steps 201-203 of the illustrated embodiment are consistent, and for the same contents, please refer to the corresponding parts of the previous embodiment, which will not be repeated here.

[0053] Step 304: in response to receiving the updated compiled code, update the intermediate file according to the updated compiled code.

[0054] In this embodiment, the user can obtain the compilation process, code execution status, and preview results of the mini-program based on the visual interface generated in the above step 303. After determining that there is content that needs to be modified or optimized, an updated compilation code for adjusting the preview results can be generated accordingly for the content. After the above-mentioned execution subject obtains the updated compilation code, the intermediate file in the large-capacity binary object format is adjusted accordingly according to the content of the updated compilation code.

[0055] Step 305: Update the file to be previewed based on the updated intermediate file.

[0056] In this embodiment, after the intermediate file is updated in the above step 304, a new file to be previewed is generated according to the updated intermediate file to replace the current file to be previewed, so as to complete the update of the file to be previewed.

[0057] Step 306: Use a local browser to browse the updated visual interface of the file to be previewed.

[0058] In this embodiment, this part of the content is consistent with the above Figure 2 Step 203 in the illustrated embodiment is similar and will not be described in detail.

[0059] The preview method of the mini program provided in this embodiment is as follows: Figure 2Further on the basis of the illustrated embodiment, after receiving the updated compilation code, the corresponding update to be previewed is completed to help the user to perform real-time and dynamic compilation according to the display results of the visual interface, so as to enhance the user's flexibility in compiling and previewing the mini-program.

[0060] Based on any of the above embodiments, in some optional embodiments of the present application, before using the local browser to browse the visual interface of the file to be previewed, it also includes: obtaining a basic function library of the host program corresponding to the target applet.

[0061] Specifically, in order to ensure that the source code involved in the target applet and the coding code corresponding to the target applet can be executed and previewed smoothly, the function library corresponding to the host program hosted by the target applet is obtained to prevent the compilation and preview of the target applet from being affected by the lack of corresponding configuration information of the referenced function during the compilation process of the target applet, thereby improving the reliability of the preview method of the entire applet.

[0062] On the basis of any of the above embodiments, in some optional embodiments of the present application, the compiled code is converted into an intermediate file in a large-capacity binary object format, and the intermediate file is converted into a file to be previewed based on the operating environment of the local browser, including: based on a web worker process, the compiled code is converted into an intermediate file in a large-capacity binary object format, and the intermediate file is converted into a file to be previewed based on the web worker process. Wherein, the web worker process Web Worker is usually installed in the browser by default, so that the browser can realize the functions of video playback, web page interface loading and add-on configuration through the web worker process.

[0063] Usually, the operations of generating intermediate files and files to be previewed are placed in the same process and executed sequentially. Therefore, whenever the compiled code is modified according to the preview result, it is necessary to use the modified compiled code to re-run the process, making it impossible to preview the real-time modification results of the compiled code in real time. To solve this problem, the characteristics of the Web Worker process can also be used to create a multi-threaded environment. The created multi-threaded environment may include a main thread and multiple sub-threads. The main thread can assign some tasks to the sub-threads for execution, and then execute different tasks in a mutually isolated manner, thereby eliminating interference. For example, the operation of converting the compiled code to obtain the intermediate file is placed in the first sub-thread for execution, and the operation of converting the intermediate file to obtain the file to be previewed is placed in the second sub-thread for execution, and the output of the first sub-thread is set to be used as the input of the second sub-thread with the help of the main thread, so that the output of the second sub-thread will be directly recognized and previewed by the browser, and the real-time modification results of the compiled code are previewed in real time, and the potential threat of data conflicts is eliminated. While improving the modification efficiency, the operation reliability is also improved.

[0064] To deepen understanding, this application also combines a specific mini program scenario and provides a specific implementation solution. Taking the target mini program as an example, please refer to Figure 4 Flow 400 is shown.

[0065] Step 401 , in response to receiving a test request of a target applet, extracting compiled code from the test request.

[0066] Step 402, a local browser-based web worker process converts the compiled code into an intermediate file in a large binary object format.

[0067] Specifically, based on the network worker process in the local browser, the swan template is parsed into the mini-program kernel san framework executable template, and the executable context is added to the mini-program js file, and the dependencies between js files are processed. Next, the custom components are processed and packaged into the allCusomComponents.swan.js file, the sjs file is processed, the allRegisteredSJS.js file is packaged, and finally the app.json file is processed, and the static resource file path is changed from the standard Uniform Resource Locator (URL) to the BLOB URL to obtain an intermediate file in the large-capacity binary object format.

[0068] Step 403: The network worker process based on the local browser converts the intermediate file into a file to be previewed.

[0069] Specifically, the intermediate file in the large-capacity binary object format obtained in the above step 402 is obtained, and the intermediate file is converted into a file mapping file based on the network worker process in the local browser and then stored.

[0070] Step 404, obtaining the basic function library of the host program corresponding to the target applet.

[0071] Step 405: Use a local browser to browse the visual interface of the file to be previewed.

[0072] The present application unifies the encoding code by integrating the compiled code into an intermediate file in a large-capacity binary object format, so that the intermediate file can be converted into a file to be previewed through a local browser, and finally the local browser is used to directly generate a corresponding visual interface based on the file to be previewed to realize the preview of the mini-program, so as to completely rely on the local browser to realize the compilation and preview of the mini-program, save development resources, improve the concurrency of compilation work, and improve the response speed of users during compilation. Furthermore, considering that the common method of sequentially generating intermediate files and files to be previewed through the same process is not convenient for presenting the preview results of the compiled code after real-time modification, the operations of generating intermediate files and files to be previewed can also be placed in two isolated processes for execution, so that the real-time modification of the compiled code does not affect the normal preview effect of the file to be previewed when it is converted into a new intermediate file, and the potential risk of data conflicts is also eliminated.

[0073] Further references Figure 5 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a preview device for a small program, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0074] like Figure 5 As shown, the mini-program preview device 500 of this embodiment may include: a compiled code extraction unit 501, a file to be previewed generation unit 502, and a visual interface generation unit 503. The compiled code extraction unit 501 is configured to extract the compiled code from the test request in response to receiving a test request of the target mini-program; the file to be previewed generation unit 502 is configured to convert the compiled code into an intermediate file in a large-capacity binary object format, and convert the intermediate file into a file to be previewed based on the operating environment of the local browser; the visual interface generation unit 503 is configured to use the local browser to browse the visual interface of the file to be previewed.

[0075] In the present embodiment, in the preview device 500 of the mini program, the specific processing of the compiled code extraction unit 501, the preview file generation unit 502, and the visual interface generation unit 503 and the technical effects thereof can be referred to in Figure 2 The relevant descriptions of steps 201 - 203 in the corresponding embodiment are not repeated here.

[0076] In some optional implementations of this embodiment, the preview device 500 of the mini-program also includes: a function library acquisition unit, which is configured to acquire a basic function library of a host program corresponding to the target mini-program when the target mini-program is a target mini-program.

[0077] In some optional implementations of this embodiment, the file to be previewed generated by the file to be previewed generating unit 502 includes: a file mapping file; and the visual interface generating unit 503 is further configured to, in response to receiving a preview request, determine the file mapping file corresponding to the preview request based on a large-capacity binary object resource location standard; and use the local browser to browse the visual interface of the file mapping file.

[0078] In some optional implementations of the present embodiment, the preview device 500 of the mini program also includes: an intermediate file updating unit, configured to update the intermediate file according to the updated compiled code in response to receiving the updated compiled code; a file to be previewed updating unit, configured to update the file to be previewed based on the updated intermediate file; and the visual interface generating unit 503 is further configured to use the local browser to browse the updated visual interface of the file to be previewed.

[0079] In some optional implementations of this embodiment, the to-be-previewed file generating unit 502 is further configured to, based on a network worker process, convert the compiled code into an intermediate file in a large-capacity binary object format, and convert the intermediate file into a to-be-previewed file based on the network worker process.

[0080] This embodiment exists as an apparatus embodiment corresponding to the above-mentioned method embodiment. The preview device of the mini-program provided by this embodiment unifies the encoding code by integrating the compiled code into an intermediate file in a large-capacity binary object format, so as to convert the intermediate file into a file to be previewed through a local browser, and finally use the local browser to directly generate a corresponding visual interface based on the file to be previewed to realize the preview of the mini-program, so as to completely rely on the local browser to realize the compilation and preview of the mini-program, save development resources, improve the concurrency capability of compilation work, and improve the response speed of users during compilation.

[0081] According to an embodiment of the present application, the present application also provides an electronic device, a readable storage medium and a computer program product.

[0082] Figure 6A schematic block diagram of an example electronic device 600 that can be used to implement an embodiment of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.

[0083] like Figure 6 As shown, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0084] A number of components in the device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0085] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as the preview method of the applet. For example, in some embodiments, the preview method of the applet may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the preview method of the applet described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to execute the preview method of the applet in any other appropriate manner (e.g., by means of firmware).

[0086] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0087] The program code for implementing the method of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, implements the functions / operations specified in the flow chart and / or block diagram. The program code can be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0088] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0089] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0090] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0091] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and virtual private servers (VPS) services. The server can also be divided into a server of a distributed system, or a server combined with a blockchain.

[0092] According to the technical solution of the embodiment of the present application, the encoding code is unified by integrating the compiled code into an intermediate file in a large-capacity binary object format, so that the intermediate file can be converted into a file to be previewed through a local browser, and finally the local browser is used to directly generate a corresponding visual interface based on the file to be previewed to realize the preview of the applet, so that the compilation and preview of the applet can be realized completely by relying on the local browser, saving development resources, improving the concurrency of the compilation work, and improving the response speed of the user during compilation. Furthermore, considering that the common method of sequentially generating intermediate files and files to be previewed through the same process is not convenient for presenting the preview results of the compiled code after real-time modification, the operations of generating intermediate files and files to be previewed can also be placed in two isolated processes for execution, so that the real-time modification of the compiled code does not affect the normal preview effect of the file to be previewed when it is converted into a new intermediate file, and the potential risk of data conflicts is eliminated.

[0093] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.

[0094] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.

Claims

1. A method for previewing a mini program, comprising: In response to receiving a test request of a target applet, extracting a compiled code from the test request, wherein the compiled code includes a source code of the target applet; Converting the compiled code into an intermediate file in a large-capacity binary object format, and converting the intermediate file into a file to be previewed based on the operating environment of the local browser; The local browser is used to browse the visual interface of the file to be previewed.

2. The method according to claim 1, wherein: Before using the local browser to browse the visual interface of the file to be previewed, the method further includes: Obtain a basic function library of a host program corresponding to the target applet.

3. The method according to claim 1, wherein: The files to be previewed include: file mapping file; and The method of using the local browser to browse the visual interface of the file to be previewed includes: In response to receiving a preview request, determining a file mapping file corresponding to the preview request based on a large binary object resource location standard; The local browser is used to browse the visual interface of the file mapping file.

4. The method according to claim 1, after using the local browser to browse the visual interface of the file to be previewed, further comprises: In response to receiving the updated compiled code, updating the intermediate file according to the updated compiled code; Updating the file to be previewed based on the updated intermediate file; The updated visual interface of the file to be previewed is browsed using the local browser.

5. The method according to any one of claims 1 to 4, wherein: The step of converting the compiled code into an intermediate file in a large-capacity binary object format, and converting the intermediate file into a file to be previewed based on the operating environment of the local browser, includes: Based on a network worker process, the compiled code is converted into an intermediate file in a large-capacity binary object format, and based on the network worker process, the intermediate file is converted into a file to be previewed.

6. A mini-program preview device, comprising: A compiled code extraction unit, configured to extract compiled code from a test request of a target applet in response to receiving the test request, wherein the compiled code includes a source code of the target applet; A to-be-previewed file generating unit is configured to convert the compiled code into an intermediate file in a large-capacity binary object format, and convert the intermediate file into a to-be-previewed file based on a local browser's operating environment; The visualization interface generating unit is configured to use the local browser to browse the visualization interface of the file to be previewed.

7. The apparatus according to claim 6, further comprising: The function library acquisition unit is configured to acquire a basic function library of a host program corresponding to the target applet.

8. The device according to claim 6, wherein: The file to be previewed generated by the file to be previewed generating unit includes: file mapping file; and The visualization interface generation unit is further configured to, in response to receiving a preview request, determine a file mapping file corresponding to the preview request based on a large-capacity binary object resource location standard; The local browser is used to browse the visual interface of the file mapping file.

9. The apparatus according to claim 6, further comprising: an intermediate file updating unit, configured to update the intermediate file according to the updated compiled code in response to receiving the updated compiled code; a to-be-previewed file updating unit, configured to update the to-be-previewed file based on the updated intermediate file; as well as The visual interface generating unit is further configured to use the local browser to browse the updated visual interface of the file to be previewed.

10. The device according to any one of claims 6 to 9, wherein: The to-be-previewed file generating unit is further configured to, based on a network worker process, convert the compiled code into an intermediate file in a large-capacity binary object format, and convert the intermediate file into a to-be-previewed file based on the network worker process.

11. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the preview method of the applet described in any one of claims 1-5.

12. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the method for previewing a small program according to any one of claims 1 to 5.

13. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method for previewing a small program according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Applet updating method and device

    CN110569050A

  • Online preview method and device for Web system with separated front and back ends

    CN110889054A