Mini-program page code generation method, device and computer equipment

By comparing and adapting and compiling the collection of mini program page components from different channels, the problem of inefficient page data compatibility is solved, and seamless adaptation and efficient development of pages from different channels are achieved.

CN113672224BActive Publication Date: 2024-10-25SHANGHAI BILIBILI TECH CO LTD
View PDF 12 Cites 0 Cited by

Patent Information

Application Number
CN202110961819.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-20
Publication Date
2024-10-25
Estimated Expiration
2041-08-20

AI Technical Summary

Technical Problem

In the existing technology, the efficiency of compatibility of the same page data to pages in different channels is low. Mini program page versions suitable for different channels need to be developed one by one, resulting in heavy development work and low efficiency.

Method used

Obtain the source code data and component collection of the target page under the first channel, compare the differences with the component collection of the second channel, perform adaptive compilation, convert the file name, directory path and API interface, and generate source code that conforms to the specifications of the second channel. data.

Benefits of technology

It improves the efficiency of compatibility of the same page data to different channel pages, allowing the page code to seamlessly adapt and run in different channels.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113672224B_ABST
    Figure CN113672224B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device and computer equipment for generating code for a mini-program page, the method comprising: obtaining first source code data of a target page under a first channel and a first component set including each page component; querying a second component set including each page component of the target page under a second channel according to a preset channel page component list; comparing the difference between the second component set and the first component set to obtain a differentiated component set; adapting and compiling the first source code data according to the differentiated component set to obtain the source code data of the target page under the second channel. The present application also provides a computer-readable storage medium. The present application can effectively improve the efficiency of making the same page data compatible with pages of different channels.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet technology, and in particular to a method, device and computer equipment for generating code for a mini-program page. Background Art

[0002] Mini Programs are applications that can be used without downloading and installing. They realize the dream of "apps at your fingertips". Users can open apps by scanning or searching. With the popularization of smart terminals and the development of computer technology, it is now possible to directly access the same data resources, such as page data, through different applications, that is, mini programs on different channels, so that users can quickly access hot topics or advantageous resources based on different applications.

[0003] For data service providers, it is also necessary to make the same data resource compatible with different channels. Therefore, when developing data resources, data service providers generally need to develop multiple versions, such as web versions and other mini-programs based on different channels. However, developing the same data resource, such as page data, into mini-program pages suitable for different channels usually requires development one by one, which is a heavy development workload and low development efficiency. Summary of the invention

[0004] The present application proposes a method, device and computer equipment for generating mini-program page code, which can solve the problem of low efficiency in the prior art when making the same page data compatible with pages of different channels.

[0005] First, to achieve the above purpose, the present application provides a method for generating a mini-program page code, the method comprising:

[0006] Acquire the first source code data of the target page under the first channel and the first component set including each page component; query the second component set including each page component of the target page under the second channel according to the preset channel page component list; compare the difference between the second component set and the first component set to obtain a differentiated component set; adapt and compile the first source code data according to the differentiated component set to obtain the source code data of the target page under the second channel.

[0007] In one example, before adapting and compiling the first source code data according to the differentiated component set, the method further includes: converting the file name and directory path corresponding to the first source code data into a file name and directory path that conforms to the naming and directory specifications of the source code data of the second channel; converting the API interface of the first source code data and the configuration parameters in the source code into an API interface and configuration parameters that conform to the configuration specifications of the source code data under the second channel.

[0008] In one example, converting the API interface of the first source code data and the configuration parameters in the source code into API interfaces and configuration parameters that comply with configuration specifications of the source code data under the second channel includes: mapping the API interface of the first source code data and the configuration parameters in the source code with the API interface and configuration parameters of the source code data under the second channel by adding an adaptation source code.

[0009] In one example, the API interface includes the calling interface data of the source code of each page component in the source code data; the configuration parameters include the variable parameters and the return value parameters in the source code.

[0010] In one example, the adapting and compiling the first source code data according to the differentiated component set to obtain the code data of the target page under the second channel includes: performing format conversion on the first source code data to obtain an intermediate source code of a code format corresponding to the second channel; adding and / or deleting source code data of corresponding functional components in the intermediate source code according to the differentiated component set to obtain the code data of the target page under the second channel.

[0011] In one example, performing format conversion on the first source code data to obtain an intermediate source code in a code format corresponding to a second channel includes: converting the first source code data into an abstract syntax tree; converting the source code corresponding to each node on the abstract syntax tree into an adaptation code in a code format corresponding to the second channel; and restoring the abstract syntax tree on which the code format conversion has been performed into a source code to obtain an intermediate source code in a code format corresponding to the second channel.

[0012] In one example, converting the source code corresponding to each node on the abstract syntax tree into an adaptation code in a code format corresponding to a second channel includes: identifying a code type of the source code corresponding to a target node on the abstract syntax tree, where the target node is any node on the abstract syntax tree; and calling a code conversion tool of a corresponding code type according to the code type to convert the code format of the source code corresponding to the target node, thereby obtaining a corresponding adaptation code.

[0013] In one example, the code type includes at least one of a Vue type, an HTML type, a JS type, and a CSS type; when the code type is a Vue type, calling a code conversion tool of a corresponding code type according to the code type to convert the code format of the source code corresponding to the target node, thereby obtaining the corresponding adaptation code, including: splitting the source code of the Vue type according to the code format of the code type, thereby obtaining at least one of the HTML type, the JS type, and the CSS type included therein

[0014] In addition, to achieve the above purpose, the present application also provides a device for generating a mini-program page code, the device comprising:

[0015] An acquisition module is used to acquire first source code data of a target page under a first channel and a first component set including each page component; a query module is used to query a second component set including each page component of the target page under a second channel according to a preset channel page component list; a comparison module is used to compare the difference between the second component set and the first component set to obtain a differentiated component set; a compilation module is used to adapt and compile the first source code data according to the differentiated component set to obtain the source code data of the target page under the second channel.

[0016] Furthermore, the present application also proposes a computer device, which includes a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the computer program is executed by the processor, the steps of the mini-program page code generation method as described above are implemented.

[0017] Furthermore, to achieve the above-mentioned purpose, the present application also provides a computer-readable storage medium, which stores a computer program, and the computer program can be executed by at least one processor to enable the at least one processor to perform the steps of the mini-program page code generation method as described above.

[0018] Compared with the prior art, the mini-program page code generation method, device, computer equipment and computer-readable storage medium proposed in this application can obtain the first source code data of the target page under the first channel and the first component set including each page component; query the second component set including each page component of the target page under the second channel according to the preset channel page component list; compare the difference between the second component set and the first component set to obtain a differentiated component set; adapt and compile the first source code data according to the differentiated component set to obtain the source code data of the target page under the second channel. According to the difference between other channel pages and the first channel page, the page source code corresponding to the first channel is adapted accordingly so that it can be applied to other channel pages, thereby effectively improving the efficiency of making the same page data compatible with pages of different channels. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 is a schematic diagram of an application environment of an embodiment of the present application;

[0020] Figure 2 This is a flowchart of a specific embodiment of the method for generating code for a small program page of the present application;

[0021] Figure 3 This is a flowchart of an exemplary example of the present application for adapting and encapsulating the channel API;

[0022] Figure 4 This is a flow chart of a code format conversion performed on source code in an exemplary example of the present application;

[0023] Figure 5 This is a flow chart of the code generation process of a mini-program page in an exemplary example of this application;

[0024] Figure 6 This is a schematic diagram of a program module of an embodiment of a device for generating a page code for a small program of the present application;

[0025] Figure 7 It is a schematic diagram of an optional hardware architecture of the computer device of the present application. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0027] It should be noted that the descriptions involving "first", "second", etc. in this application are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0028] Figure 1 Schematic diagram of the application environment of an embodiment of the present application. Figure 1 As shown, the computer device 1 can receive a display request triggered by a user to display the source code of the channel 1 applet to the channel 1 applet, or to display it to other channels, such as the channel 2 applet and the channel n applet. In this embodiment, the computer device 1 can receive a display request triggered by a user clicking or touching the interactive interface by providing an interactive interface, or can also receive a display request triggered by a user device ( Figure 1 The computer device 1 sends a display request to the computer device 1 (not shown). Then, the computer device 1 obtains the first source code data of the target page under the first channel and the first component set including each page component; queries the second component set including each page component of the target page under the second channel according to the preset channel page component list; compares the difference between the second component set and the first component set to obtain a differentiated component set; adapts and compiles the first source code data according to the differentiated component set to obtain the source code data of the target page under the second channel. Finally, the source code data of the target page under the second channel is displayed on the mini program page preset in the second channel.

[0029] In this embodiment, the computer device 1 can be used as a mobile phone, tablet, portable device, PC or server, etc.; it can also be used as an independent functional module and attached to other computer devices to realize the function of making the same page data compatible with mini-program pages of different applications.

[0030] Embodiment 1

[0031] Figure 2 It is a flowchart of an embodiment of the method for generating a page code of a small program of the present application. It can be understood that the flowchart in the embodiment of the present method is not used to limit the order of executing the steps. The following is an exemplary description using computer device 1 as the execution subject.

[0032] like Figure 2As shown, the mini-program page code generation method may include steps S200 to S206.

[0033] Step S200, obtaining first source code data of a target page under a first channel and a first component set including each page component.

[0034] Specifically, the computer device 1 can receive a display request triggered by a user to display the source code of the target page under the first channel on other channel pages, such as the channel 2 applet page and the channel n applet page. For example, the computer device 1 can receive a display request triggered by a user clicking or touching the interactive interface by providing an interactive interface, or can also receive a display request sent to the computer device 1 by a user terminal connected to the computer device 1.

[0035] Next, the computer device 1 obtains the first source code data corresponding to the target page under the first channel and the first component set including all page components under the target page. The page components include display components, interactive components, control components or other functional plug-ins on the page, etc. In an exemplary example, the computer device 1 can identify the function body of each page component in the first source code according to a preset data format, thereby identifying the source code of each page component, thereby determining the page components included in the target page, and recording all page components in the first component set.

[0036] Step S202: querying a second component set including each page component of the target page under the second channel according to a preset channel page component list.

[0037] Specifically, after obtaining the first source code data of the target page under the first channel and the first component set including each page component, the computer device 1 will further obtain the channel information to be displayed. For example, the computer device 1 receives a display request for the target page under the second channel triggered by the user through the interactive interface, that is, it is necessary to execute the display of the first source code of the target page of the first channel to the corresponding page under the second channel.

[0038] In another specific embodiment, after the computer device 1 obtains the first source code data of the target page under the first channel and the first component set including each page component, it will query the component set of all components included in the target page under each channel according to the preset channel page component list. Among them, the channel page component list is preset, including each channel and all page component information included in the target page under the channel. After the computer device 1 obtains all channels for displaying the target page, it will query the component set of the target page under the corresponding channel from the channel page component list. For example, if the target page to be displayed obtained by the computer device 1 is the second channel, the second component set of the second channel will be queried from the channel page component list.

[0039] Step S204: compare the differences between the second component set and the first component set to obtain a differentiated component set.

[0040] Step S206: Adapt and compile the first source code data according to the differentiated component set to obtain source code data of the target page under the second channel.

[0041] Specifically, after the computer device 1 obtains the first component set of the target page under the first channel and the second component set of the target page under the second channel, it will compare all page components in the two component sets one by one to find out the differentiated components and record them as differentiated component sets. Among them, the comparison of page components can include the comparison of component names and component types, or the comparison of functions and data bodies in component source codes. The differentiated components include the additional page components and missing page components of the target page under the second channel relative to the target page under the first channel.

[0042] After comparing the differential plug-in set between the target page under the second channel and the target page under the first channel, the computer device 1 will adapt and compile the first source code data according to the differential component set, thereby compiling the source code data of the target page under the second channel. Among them, the adaptation and compilation includes making corresponding adjustments to the first source code data according to the information of the differential components, and then performing the compilation. For example, the page components of the target page under the second channel are more than the page components of the target page under the first channel, then it means that the first source code data is missing some page components relative to the target page under the second channel, so the computer device 1 needs to add the code segments of the missing page components in the first source code data. For another example, the page components of the target page under the second channel are less than the page components of the target page under the first channel, then it means that the first source code data has some more page components relative to the target page under the second channel, so the computer device 1 needs to shield or delete the code segments of the extra page components in the first source code data.

[0043] In an exemplary example, before adapting and compiling the first source code data according to the differentiated component set, the computer device 1 further executes the steps of: converting the file name and directory path corresponding to the first source code data into a file name and directory path that conforms to the naming and directory specifications of the source code data of the second channel; converting the API interface of the first source code data and the configuration parameters in the source code into an API interface and configuration parameters that conform to the configuration specifications of the source code data under the second channel.

[0044] The computer device 1 converts the API interface of the first source code data and the configuration parameters in the source code into the API interface and configuration parameters that conform to the configuration specification of the source code data under the second channel, including: mapping the API interface of the first source code data and the configuration parameters in the source code with the API interface and configuration parameters of the source code data under the second channel by adding an adaptation source code. The API interface includes the calling interface data of the source code of each page component in the source code data; the configuration parameters include the variable parameters and the return value parameters in the source code.

[0045] Specifically, the computer device 1 replaces the file name and directory of each type of file in the first source code data with a default file name and directory, which has universal identifiability and can be used to call source code data under other channels. For example, the file name with the ".wx" suffix in the source code data under the WeChat applet will be replaced with the file name with the same name but without the ".wx" suffix, and then the directory is also replaced, for example, the "test.wx" directory is replaced with the "test" directory.

[0046] At the same time, the computer device 1 needs to process the API interface and configuration parameters in the first source code data accordingly. For example, first map the API interface of the source code of each page component included in the first source code data to the preset intermediate API interface; then when the first source code data is converted into the second source code data corresponding to the first channel, the intermediate API interface replaces the corresponding API interface in the first source code data; of course, in the generated second source code data, it is necessary to add a corresponding mapping function to map the intermediate API interface to the API interface of the source code applicable to the second channel. Similarly, the computer device 1 also needs to process the relevant configuration parameters in the first source code data accordingly, that is, add intermediate configuration parameters for mapping to the configuration parameters of the source code applicable to the second channel. Thereby, the differences between the API interface and configuration parameters in the source code data corresponding to the first channel and the second channel are smoothed out.

[0047] In the exemplary example, the computer device 1 can address the differences in APIs of different channels by performing secondary packaging on the API under the first channel and adapting it in the middle to ensure that API calls for the same page component from different channels can remain consistent with the usage of the first channel, including the name and usage of the API.

[0048] See also Figure 3 , is a flowchart of an exemplary example of the present application for adapting and encapsulating a channel API. In this embodiment, the computer device 1 pre-establishes a functional component that can adapt and encapsulate the API characteristics of different channels, that is, an adaptation layer; then encapsulates the API information corresponding to the source code, such as the Bilibili applet API, to obtain a channel API adapted to the target channel.

[0049] After executing the above steps, the computer device 1 further performs an adaptation compilation process on the first source code data.

[0050] In a specific embodiment, the computer device 1 adapts and compiles the first source code data according to the differentiated component set to obtain code data of the target page under the second channel, including: performing format conversion on the first source code data to obtain an intermediate source code of a code format corresponding to the second channel; adding and / or deleting source code data of corresponding functional components in the intermediate source code according to the differentiated component set to obtain code data of the target page under the second channel.

[0051] The computer device 1 performs format conversion on the first source code data to obtain an intermediate source code in a code format corresponding to the second channel, including: converting the first source code data into an abstract syntax tree; converting the source code corresponding to each node on the abstract syntax tree into an adaptation code in a code format corresponding to the second channel; restoring the abstract syntax tree on which the code format conversion has been performed into a source code to obtain an intermediate source code in a code format corresponding to the second channel.

[0052] The computer device 1 converts the source code corresponding to each node on the abstract syntax tree into an adaptation code of a code format corresponding to a second channel, including: identifying the code type of the source code corresponding to a target node on the abstract syntax tree, where the target node is any node on the abstract syntax tree; calling a code conversion tool of the corresponding code type according to the code type to convert the code format of the source code corresponding to the target node, thereby obtaining the corresponding adaptation code.

[0053] In this embodiment, the computer device 1 pre-establishes a format code segment for each page component under each channel and stores it in a preset code database; the format code segment is equivalent to the basic code for implementing the page component under the corresponding channel. When the computer device 1 performs adaptive compilation on the first source code according to the differentiated component set, it includes: when the differentiated component set is a missing page component, the format code of the required page component can be further queried from the code database, and then inserted into the first source code, thereby obtaining an intermediate source code for adaptive compilation; when the alienated component set is an extra page component, the source code of the corresponding page component in the first source code can be shielded by setting conditional compilation, or it can be directly deleted, thereby obtaining an intermediate source code for adaptive compilation.

[0054] In the process of adding and / or deleting source code data of corresponding functional components in the intermediate source code according to the differentiated component set, the computer device 1 needs to first convert the first source code data into a data body of an abstract syntax tree through a preset conversion tool, and each node on the abstract syntax tree represents the source code corresponding to a page component. Then, the computer device 1 obtains the intermediate source code by performing a comparison on each node on the abstract syntax tree, and subsequent addition or deletion operations.

[0055] In an exemplary example, the code type includes at least one of Vue type, HTML type, JS type and CSS type; when the code type is Vue type, the computer device 1 calls the code conversion tool of the corresponding code type according to the code type to convert the code format of the source code corresponding to the target node, thereby obtaining the corresponding adaptation code, including: splitting the source code of the Vue type according to the code format of the code type, thereby obtaining at least one of the HTML type, JS type and CSS type included therein.

[0056] Although the first channel and the second channel can both be composed of HTML type, JS type and CSS type codes, there are still differences in format. The Vue type data included in the source code is actually a code segment mixed with one or more of HTML type, JS type and CSS type. Therefore, when the computer device 1 performs format conversion on the first source code segment, it is necessary to classify all types of codes one by one, first identify the HTML type, JS type and CSS type codes in the Vue type code according to the code format of HTML type, JS type and CSS type, and then perform code conversion through HTML code converter, JS code converter and CSS code converter respectively, so as to obtain the intermediate source code under the second channel.

[0057] Finally, the computer device 1 compiles the intermediate source code to obtain source code data of the target page under the second channel.

[0058] See also Figure 4 , is a flow chart of a code format conversion performed on source code in an exemplary example of the present application.

[0059] Among them, the computer device 1 obtains the source code, and then identifies the type of the source code according to a preset code format. When the Vue type is identified, the source code of the Vue type is further split according to the code format, and the code identification is continued after the split; thereby finally identifying the HTML type, JS type and CSS type source code in the source code; then, the HTML type, JS type and CSS type source code are converted into code formats through the HTML converter, JS converter and CSS converter respectively; and finally the channel adaptation code is obtained, that is, the intermediate source code of the code format corresponding to the channel that needs to be displayed on the page, for compilation and display in subsequent steps.

[0060] See also Figure 5 , is a flowchart of the code generation process of a mini-program page in an exemplary example of the present application.

[0061] In this embodiment, the computer device 1 shown first identifies the target channel for executing the page code generation of the channel, and then maps the source code of the target page of the current channel to the files and directories of the target channel; then, the compilation process is started to obtain the compilation entry file, that is, the sequence of the source codes of each component in the source code is obtained in turn, and when there are differentiated components between the target page under the target channel and the target page under the current channel, the components and APIs of the adaptation channel are injected; then dependency collection is performed, that is, the sequence and dependency of the source codes of all components are collected; finally, code format conversion is performed on the source code; and finally, the channel source code is output.

[0062] In this embodiment, the computer device 1 identifies the configuration specifications of the source code under the current channel through the preset framework specification (Vue.js), including: config-configuration file, API-api file, Component-front-end display component and event-trigger event, etc.; when receiving the source code of the current channel, such as the applet source code A, the configuration specifications of the source code of the current channel will be identified in turn; then pre-compilation (Webpack+Loader) is performed, including conditional compilation and component format conversion, wherein the conditional compilation includes obtaining the page components and API interfaces of the target page under the target channel, and then performing component and API adaptation and differential smoothing according to the differences between the page components of the target page of the target channel and the source code under the current channel, including page components and APIs; finally, the source code generation and compilation of the target page under the target channel is performed. For example, for the generation and compilation of the source code of the target page under the current channel, since the source code has not changed, the NA that needs to be executed is performed. Adapter, that is, the specifications are summarized and compiled; for the source code generation and compilation of the target page under H5, the channel differences are not large, and only the specification summary is required for compilation; for other applets, such as WeChat, Taobao and QQ, it is necessary to further perform configuration verification and CSS verification, among which the configuration verification includes the verification of App.vue, global mounting, conf mapping, component mapping and dependent packages and other related files in the source code; the source code generation and compilation steps will be further executed after the pre-compiled source code is verified, and finally after Vue-mp conversion, the source code adapted to the display of the target page under the corresponding channel can be obtained for display on the target page under the corresponding channel.

[0063] In summary, the mini-program page code generation method proposed in this embodiment can obtain the first source code data of the target page under the first channel and the first component set including each page component; query the second component set including each page component of the target page under the second channel according to the preset channel page component list; compare the difference between the second component set and the first component set to obtain a differentiated component set; adapt and compile the first source code data according to the differentiated component set to obtain the source code data of the target page under the second channel. This application performs corresponding adaptation on the page source code corresponding to the first channel according to the difference between other channel pages and the first channel page, so that it can be applied to other channel pages, and therefore, can effectively improve the efficiency of making the same page data compatible with pages of different channels.

[0064] Embodiment 2

[0065] Figure 6A block diagram of a small program page code generation device according to Embodiment 2 of the present application is schematically shown, and the small program page code generation device can be divided into one or more program modules, and one or more program modules are stored in a storage medium and executed by one or more processors to complete the embodiment of the present application. The program module referred to in the embodiment of the present application refers to a series of computer program instruction segments that can complete specific functions. The following description will specifically introduce the functions of each program module in this embodiment.

[0066] like Figure 6 As shown, the mini-program page code generation device 400 may include an acquisition module 410, a query module 420, a comparison module 430 and a compilation module 440, wherein:

[0067] The acquisition module 410 is used to acquire the first source code data of the target page under the first channel and the first component set including each page component.

[0068] The query module 420 is used to query the second component set including each page component of the target page under the second channel according to the preset channel page component list.

[0069] The comparison module 430 is used to compare the differences between the second component set and the first component set to obtain a differentiated component set.

[0070] The compiling module 440 is used to adapt and compile the first source code data according to the differentiated component set to obtain source code data of the target page under the second channel.

[0071] In an exemplary embodiment, the acquisition module 410 is further used to: convert the file name and directory path corresponding to the first source code data into a file name and directory path that conforms to the naming and directory specifications of the source code data of the second channel; convert the API interface of the first source code data and the configuration parameters in the source code into an API interface and configuration parameters that conform to the configuration specifications of the source code data under the second channel. And by adding an adaptation source code, the API interface of the first source code data and the configuration parameters in the source code are mapped with the API interface and configuration parameters of the source code data under the second channel; the API interface includes the calling interface data of the source code of each page component in the source code data; the configuration parameters include the variable parameters and the return value parameters in the source code.

[0072] In an exemplary embodiment, the compiling module 440 is further used to: perform format conversion on the first source code data to obtain an intermediate source code of a code format corresponding to the second channel; add and / or delete source code data of corresponding functional components in the intermediate source code according to the differentiated component set to obtain code data of the target page under the second channel. The performing format conversion on the first source code data to obtain the intermediate source code of a code format corresponding to the second channel includes: converting the first source code data into an abstract syntax tree; converting the source code corresponding to each node on the abstract syntax tree into an adaptation code of a code format corresponding to the second channel; restoring the abstract syntax tree on which the code format conversion has been performed into a source code to obtain the intermediate source code of a code format corresponding to the second channel.

[0073] In an exemplary embodiment, the compiling module 440 is further used to: identify the code type of the source code corresponding to the target node on the abstract syntax tree, the target node being any node on the abstract syntax tree; and call a code conversion tool of a corresponding code type according to the code type to convert the code format of the source code corresponding to the target node, thereby obtaining the corresponding adaptation code. Wherein, the code type includes at least one of a Vue type, an HTML type, a JS type, and a CSS type; when the code type is a Vue type, the calling of a code conversion tool of a corresponding code type according to the code type to convert the code format of the source code corresponding to the target node, thereby obtaining the corresponding adaptation code, includes: splitting the source code of the Vue type according to the code format of the code type, thereby obtaining at least one of the HTML type, JS type, and CSS type included therein.

[0074] Embodiment 3

[0075] Figure 7 The schematic diagram of the hardware architecture of a computer device 1 suitable for implementing the method for generating the mini-program page code according to the third embodiment of the present application is shown schematically. In this embodiment, the computer device 1 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. For example, it can be a rack server, blade server, tower server or cabinet server (including an independent server, or a server cluster composed of multiple servers) with a gateway function. Figure 7 As shown, the computer device 1 includes at least but is not limited to: a memory 510, a processor 520, and a network interface 530 which can communicate with each other through a system bus. Among them:

[0076] The memory 510 includes at least one type of computer-readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 510 can be an internal storage module of the computer device 1, such as a hard disk or memory of the computer device 1. In other embodiments, the memory 510 can also be an external storage device of the computer device 1, such as a plug-in hard disk equipped on the computer device 1, a smart memory card (SmartMedia Card, referred to as SMC), a secure digital (Secure Digital, referred to as SD) card, a flash card, etc. Of course, the memory 510 can also include both the internal storage module of the computer device 1 and its external storage device. In this embodiment, the memory 510 is generally used to store the operating system and various application software installed on the computer device 1, such as the program code of the applet page code generation method, etc. In addition, the memory 510 can also be used to temporarily store various types of data that have been output or are to be output.

[0077] In some embodiments, the processor 520 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 520 is generally used to control the overall operation of the computer device 1, such as performing control and processing related to data interaction or communication with the computer device 1. In this embodiment, the processor 520 is used to run the program code stored in the memory 510 or process data.

[0078] The network interface 530 may include a wireless network interface or a wired network interface, and the network interface 530 is generally used to establish a communication link between the computer device 1 and other computer devices. For example, the network interface 530 is used to connect the computer device 1 to an external terminal through a network, and to establish a data transmission channel and a communication link between the computer device 1 and the external terminal. The network may be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, etc.

[0079] It should be pointed out that Figure 7 Only a computer device having components 510 - 530 is shown, but it should be understood that implementing all of the components shown is not a requirement, and more or fewer components may alternatively be implemented.

[0080] In this embodiment, the program code of the mini-program page code generation method stored in the memory 510 can also be divided into one or more program modules and executed by one or more processors (processor 520 in this embodiment) to complete the embodiment of the present application.

[0081] Embodiment 4

[0082] This embodiment also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0083] Acquire the first source code data of the target page under the first channel and the first component set including each page component; query the second component set including each page component of the target page under the second channel according to the preset channel page component list; compare the difference between the second component set and the first component set to obtain a differentiated component set; adapt and compile the first source code data according to the differentiated component set to obtain the source code data of the target page under the second channel.

[0084] In the present embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the computer-readable storage medium can be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium can also be an external storage device of a computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, referred to as SMC), a secure digital (Secure Digital, referred to as SD) card, a flash card (Flash Card), etc. Of course, the computer-readable storage medium can also include both the internal storage unit of the computer device and its external storage device. In the present embodiment, the computer-readable storage medium is generally used to store the operating system and various application software installed on the computer device, such as the program code of the applet page code generation method in the embodiment, etc. In addition, the computer-readable storage medium can also be used to temporarily store various types of data that have been output or are to be output.

[0085] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.

[0086] The above are only preferred embodiments of the embodiments of the present application, and are not intended to limit the patent scope of the embodiments of the present application. Any equivalent structure or equivalent process transformation made using the description and drawings of the embodiments of the present application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the embodiments of the present application.

Claims

1. A method for generating a mini program page code, characterized in that: The method comprises: Acquire first source code data of a target page under a first channel and a first component set including each page component; Querying a second component set including each page component of the target page under the second channel according to a preset channel page component list; Comparing the difference between the second component set and the first component set to obtain a differentiated component set, wherein the differentiated component set includes the additional page components and the missing page components of the target page under the second channel relative to the target page under the first channel, wherein all page components in the two component sets are compared one by one to find the differentiated components therein, and the comparison of the page components is achieved by comparing the component names and component types, or the functions and data bodies in the component source codes; The first source code data is adapted and compiled according to the differentiated component set to obtain source code data of a target page under a second channel.

2. The method for generating a mini program page code according to claim 1, wherein: Before adapting and compiling the first source code data according to the differentiated component set, the method further includes: Convert the file name and directory path corresponding to the first source code data into a file name and directory path that conforms to the naming and directory specifications of the source code data of the second channel; The API interface of the first source code data and the configuration parameters in the source code are converted into API interfaces and configuration parameters that conform to the configuration specification of the source code data under the second channel.

3. The method for generating a mini program page code according to claim 2, wherein: The step of converting the API interface of the first source code data and the configuration parameters in the source code into an API interface and configuration parameters that conform to the configuration specification of the source code data under the second channel includes: By adding an adaptation source code, the API interface of the first source code data and the configuration parameters in the source code are mapped with the API interface and configuration parameters of the source code data under the second channel.

4. The method for generating a mini program page code according to any one of claims 2 to 3, characterized in that: The API interface includes the calling interface data of the source code of each page component in the source code data; the configuration parameters include the variable parameters and return value parameters in the source code.

5. The method for generating a mini program page code according to claim 1, wherein: The step of adapting and compiling the first source code data according to the differentiated component set to obtain code data of a target page under a second channel includes: Performing format conversion on the first source code data to obtain an intermediate source code in a code format corresponding to the second channel; Source code data of corresponding functional components are added and / or deleted in the intermediate source code according to the differentiated component set, so as to obtain code data of the target page under the second channel.

6. The method for generating a mini program page code according to claim 5, wherein: The performing format conversion on the first source code data to obtain the intermediate source code of the code format corresponding to the second channel includes: Converting the first source code data into an abstract syntax tree; Converting the source code corresponding to each node on the abstract syntax tree into an adaptation code in a code format corresponding to the second channel; The abstract syntax tree that has been converted into the code format is restored to the source code to obtain the intermediate source code of the code format corresponding to the second channel.

7. The method for generating a mini program page code according to claim 6, wherein: The step of converting the source code corresponding to each node on the abstract syntax tree into an adaptation code in a code format corresponding to the second channel includes: Identify a code type of a source code corresponding to a target node on the abstract syntax tree, wherein the target node is any node on the abstract syntax tree; According to the code type, a code conversion tool corresponding to the code type is called to convert the code format of the source code corresponding to the target node, so as to obtain the corresponding adaptation code.

8. The method for generating a mini program page code according to claim 7, wherein: The code type includes at least one of a Vue type, an HTML type, a JS type, and a CSS type; When the code type is a Vue type, calling a code conversion tool of a corresponding code type according to the code type to convert the code format of the source code corresponding to the target node, thereby obtaining a corresponding adaptation code, includes: The source code of the Vue type is split according to the code format of the code type, thereby obtaining at least one of the HTML type, JS type and CSS type included therein.

9. A device for generating a code for a small program page, characterized in that: The device comprises: An acquisition module, used for acquiring first source code data of a target page under a first channel and a first component set including each page component; A query module, used for querying a second component set including each page component of the target page under the second channel according to a preset channel page component list; A comparison module, used for comparing the difference between the second component set and the first component set to obtain a differentiated component set, wherein the differentiated component set includes the additional page components and the missing page components of the target page under the second channel relative to the target page under the first channel, wherein all page components in the two component sets are compared one by one to find the differentiated components therein, and the comparison of the page components is achieved by comparing the component names and component types, or the functions and data bodies in the component source code; The compiling module is used to adapt and compile the first source code data according to the differentiated component set to obtain the source code data of the target page under the second channel.

10. A computer device, characterized in that: The computer device includes a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the computer program is executed by the processor, the steps of the mini-program page code generation method as described in any one of claims 1 to 8 are implemented.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program can be executed by at least one processor to enable the at least one processor to perform the steps of the mini-program page code generation method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Application function customizing method and device, computing equipment and storage medium

    CN108121563A

  • Generation method, updating method and device of applet

    CN109947433A

  • Modularized merge compiling method and device, equipment and storage medium

    CN110457045A

  • Application program development method and device

    CN110580147A

  • Applet conversion method and device

    CN110968325A