CN113672224A - Method and device for generating small program page code and computer equipment - Google Patents
Method and device for generating small program page code and computer equipment Download PDFInfo
- Publication number
- CN113672224A CN113672224A CN202110961819.4A CN202110961819A CN113672224A CN 113672224 A CN113672224 A CN 113672224A CN 202110961819 A CN202110961819 A CN 202110961819A CN 113672224 A CN113672224 A CN 113672224A
- Authority
- CN
- China
- Prior art keywords
- source code
- code
- channel
- page
- component
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 42
- 230000003044 adaptive effect Effects 0.000 claims abstract description 31
- 230000004069 differentiation Effects 0.000 claims abstract description 16
- 238000006243 chemical reaction Methods 0.000 claims description 36
- 238000013507 mapping Methods 0.000 claims description 10
- 238000004590 computer program Methods 0.000 claims description 9
- 230000006870 function Effects 0.000 description 7
- 230000006978 adaptation Effects 0.000 description 6
- 238000010586 diagram Methods 0.000 description 6
- 230000002452 interceptive effect Effects 0.000 description 5
- 230000008569 process Effects 0.000 description 5
- 238000012545 processing Methods 0.000 description 5
- 230000001960 triggered effect Effects 0.000 description 5
- 239000008186 active pharmaceutical agent Substances 0.000 description 4
- 230000000694 effects Effects 0.000 description 4
- 238000012795 verification Methods 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 238000011161 development Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 230000003993 interaction Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000004806 packaging method and process Methods 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000008094 contradictory effect Effects 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000009517 secondary packaging Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/38—Creation or generation of source code for implementing user interfaces
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The application discloses a method, a device and computer equipment for generating an applet page code, wherein the method comprises the following steps: acquiring first source code data of a target page under a first channel and a first component set comprising each page component; inquiring a second component set comprising 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 difference component set; and performing adaptive compiling on the first source code data according to the differentiation component set to obtain source code data of a target page in a second channel. The present application also provides a computer-readable storage medium. The method and the device can effectively improve the efficiency of the compatibility of the same page data to the pages of different channels.
Description
Technical Field
The present application relates to the field of internet technologies, and in particular, to a method and an apparatus for generating an applet page code, and a computer device.
Background
An application applet, abbreviated as applet, the english name Mini Program, is an application that can be used without downloading and installation, and realizes the dream of being "reachable by a touch hand" of an application, and a user can open the application by scanning or searching once. With the popularization of intelligent terminals and the development of computer technologies, the same data resources, such as page data, can be directly accessed through different applications, namely, applets in different channels, so that a user can conveniently and quickly access popular topics or advantageous resources based on different applications.
It is also necessary for data service providers to be compatible with the same data resource in different channels. Therefore, when developing data resources, data service providers generally need to develop multiple versions, for example, for web (web page) versions and other small programs based on different channels. However, the same data resources, such as page data, are developed into versions suitable for the applet pages without channels, and usually need to be developed one by one, which is heavy in development work and low in development efficiency.
Disclosure of Invention
The application provides a small program page code generation method, a small program page code generation device and computer equipment, and can solve the problem that in the prior art, efficiency is low when the same page data is compatible with pages of different channels.
First, to achieve the above object, the present application provides a method for generating an applet page code, where the method includes:
acquiring first source code data of a target page under a first channel and a first component set comprising each page component; inquiring a second component set comprising 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 difference component set; and performing adaptive compiling on the first source code data according to the differentiation component set to obtain source code data of a target page in a second channel.
In one example, prior to the adaptively compiling the first source code data according to the set of differencing components, the method further comprises: converting the file name and the directory path corresponding to the first source code data into a file name and a directory path which meet the naming and directory specifications of the source code data of a second channel; and converting the API interface of the first source code data and the configuration parameters in the source code into the API interface and the configuration parameters which conform to the configuration specification of the source code data in the second channel.
In one example, the converting the API interface of the first source code data and the configuration parameters in the source code into API interface and configuration parameters conforming to the configuration specification of the source code data in the second channel includes: and mapping the API interface of the first source code data and the configuration parameters in the source code with the API interface and the configuration parameters of the source code data in the second channel by increasing a mode of adapting the source code.
In one example, the API interface includes call interface data of the source code for each page component in the source code data; the configuration parameters include variable parameters and return value parameters in the source code.
In an example, the adaptively compiling the first source code data according to the differentiated component set to obtain the code data of the target page in 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 a second channel; and adding and/or deleting source code data of the corresponding functional component in the intermediate source code according to the differentiation component set to obtain code data of a target page in a second channel.
In one example, the 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 adaptive code in a code format corresponding to a second channel; and restoring the abstract syntax tree subjected to code format conversion into a source code to obtain an intermediate source code of a code format corresponding to the second channel.
In one example, the converting the source code corresponding to each node on the abstract syntax tree into the adaptive code in the format of the corresponding code of the second channel includes: identifying 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; and calling a code conversion tool corresponding to the code type according to the code type to perform code format conversion on the source code corresponding to the target node, so as to obtain a corresponding adaptive code.
In one 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 calling a code conversion tool corresponding to the code type according to the code type to perform code format conversion on the source code corresponding to the target node, so as to obtain a corresponding adaptive code, including: splitting the Vue type source code according to the code format of the code type, thereby obtaining at least one of an HTML type, a JS type and a CSS type contained in the source code
In addition, to achieve the above object, the present application also provides an applet page code generating apparatus, including:
the acquisition module is used for acquiring first source code data of a target page under a first channel and a first component set comprising each page component; the query module is used for querying a second component set comprising each page component of the target page under a second channel according to a preset channel page component list; the comparison module is used for comparing the difference between the second component set and the first component set to obtain a differentiated component set; and the compiling module is used for carrying out adaptive compiling on the first source code data according to the differentiated component set to obtain the source code data of the target page in the second channel.
Further, 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 executed on the processor, and the computer program, when executed by the processor, implements the steps of the applet page code generation method as described above.
Further, to achieve the above object, the present application also provides a computer-readable storage medium storing a computer program, which is executable by at least one processor to cause the at least one processor to perform the steps of the applet page code generation method as described above.
Compared with the prior art, the method, the device, the computer equipment and the computer-readable storage medium for generating the applet page code can acquire first source code data of a target page under a first channel and a first component set comprising each page component; inquiring a second component set comprising 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 difference component set; and performing adaptive compiling on the first source code data according to the differentiation component set to obtain source code data of a target page in a second channel. According to the difference between the other channel pages and the first channel page, corresponding adaptation is performed on the page source code corresponding to the first channel, so that the page source code can be applied to the other channel pages, and therefore the efficiency of enabling the same page data to be compatible with the pages of different channels can be effectively improved.
Drawings
FIG. 1 is a schematic diagram of an application environment according to an embodiment of the present application;
FIG. 2 is a flowchart illustrating a method for generating an applet page code according to an embodiment of the present disclosure;
FIG. 3 is a flow chart of an illustrative example of the present application for adaptive packaging of channel APIs;
FIG. 4 is a flowchart illustrating an effect of performing code format conversion on source code according to an illustrative example of the present application;
FIG. 5 is a flowchart illustrating an effect of the generation of applet page code according to an illustrative example of the present application;
FIG. 6 is a schematic diagram of program modules of an embodiment of an apparatus for generating applet page codes according to the present application;
FIG. 7 is a diagram of an alternative hardware architecture of the computer device of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the descriptions in this application referring to "first", "second", etc. are for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In addition, technical solutions between various embodiments may be combined with each other, but must be realized by a person skilled in the art, and when the technical solutions are contradictory or cannot be realized, such a combination should not be considered to exist, and is not within the protection scope of the present application.
Fig. 1 is a schematic diagram of an application environment according to an embodiment of the present application. Referring to fig. 1, the computer apparatus 1 can receive a user-triggered display request for displaying the source code of a channel 1 applet to a channel 1 applet or to another channel, for example, a channel 2 applet, a channel n applet. In this embodiment, the computer device 1 may receive a display request triggered by a user clicking or touching the interactive interface by providing the interactive interface, or may also receive a display request sent to the computer device 1 by a user device (not shown in fig. 1) connected to the computer device 1. Next, the computer device 1 acquires first source code data of a target page under a first channel and a first component set including each page component; inquiring a second component set comprising 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 difference component set; and performing adaptive compiling on the first source code data according to the differentiation component set to obtain source code data of a target page in a second channel. And finally, displaying the small program page preset in the second channel according to the source code data of the target page in the second channel.
In this embodiment, the computer device 1 may be a mobile phone, a tablet, a portable device, a PC, a server, or the like; or as a separate functional module attached to other computer devices to implement the function of compatible the same page data to applet pages of different applications.
Example one
Fig. 2 is a flowchart illustrating an embodiment of a method for generating an applet page code according to the present application. It is to be understood that the flow charts in the embodiments of the present method are not intended to limit the order in which the steps are performed. The following description is made by way of example with the computer apparatus 1 as the execution subject.
As shown in fig. 2, the applet page code generating method may include steps S200 to S206.
Step S200, acquiring first source code data of a target page under a first channel and a first component set comprising each page component.
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 to other channel pages, such as a channel 2 applet page and a channel n applet page. For example, the computer device 1 may receive a display request triggered by a user clicking or touching the interactive interface by providing the interactive interface, or may also receive a display request sent to the computer device 1 by a user side connected to the computer device 1.
Then, the computer device 1 obtains first source code data corresponding to a target page under the first channel and a first component set including all page components under the target page. The page components include a display component, an interaction component, a control component or other functional plug-ins, and the like on the page. In an illustrative example, the computer device 1 is capable of identifying 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 the page components into the first component set.
Step S202, a second component set comprising each page component of the target page under the second channel is inquired according to a preset channel page component list.
Specifically, after the first source code data of the target page under the first channel and the first component set including each page component are obtained, the computer device 1 further obtains the channel information to be displayed. For example, the computer device 1 receives a user-triggered display request for the target page under the second channel through the interactive interface, that is, it needs to perform displaying the first source code of the target page of the first channel to the corresponding page under the second channel.
In another embodiment, 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 queries, according to a preset channel page component list, a component set of all components included in the target page under each channel. The channel page component list is preset and comprises all page component information included in each channel and the target page under the channel. After the computer device 1 acquires all channels of the target page to be displayed, the component set of the target page in the corresponding channel is queried from the channel page component list, for example, if the target page to be displayed acquired by the computer device 1 is a second channel, the second component set of the second channel is queried from the channel page component list.
Step S204, comparing the difference between the second component set and the first component set to obtain a differentiated component set.
Step S206, performing adaptive compiling on the first source code data according to the differentiation component set to obtain source code data of a target page in a second channel.
Specifically, after the computer device 1 obtains the first component set of the target page in the first channel and the second component set of the target page in the second channel, all the page components in the two component sets are compared one by one, so that the differential component in the two component sets is found out and recorded as the differential component set. The comparison of the page components may include a component name and a component type, or a comparison of a function in the component source code and a data body. The differential components comprise excessive page components and missing page components of the target page under the second channel relative to the target page under the first channel.
After comparing the difference plug-in sets between the target page in the second channel and the page components of the target page in the first channel, the computer device 1 adaptively compiles the first source code data according to the difference plug-in sets, so as to compile the source code data of the target page in the second channel. And adapting the compiling, wherein the adapting the compiling comprises correspondingly adjusting the first source code data according to the information of the differential assembly, and then executing the compiling. For example, if there are more page components of the target page in the second channel than page components of the target page in the first channel, it means that the first source code data lacks some page components relative to the target page in the second channel, and therefore, the computer device 1 needs to add code segments of the missing page components to the first source code data. For another example, if the page components of the target page in the second channel are fewer than the page components of the target page in the first channel, it indicates that the first source code data has some more page components than the target page in the second channel, and therefore, the computer device 1 needs to mask or delete the code segments of the more page components in the first source code data.
In an illustrative example, before adaptively compiling the first source code data according to the set of differencing components, the computer device 1 further performs the following steps: converting the file name and the directory path corresponding to the first source code data into a file name and a directory path which meet the naming and directory specifications of the source code data of a second channel; and converting the API interface of the first source code data and the configuration parameters in the source code into the API interface and the configuration parameters which conform to the configuration specification of the source code data in the second channel.
Wherein, the converting, by the computer device 1, the API interface of the first source code data and the configuration parameters in the source code into the API interface and the configuration parameters conforming to the configuration specification of the source code data in the second channel includes: and mapping the API interface of the first source code data and the configuration parameters in the source code with the API interface and the configuration parameters of the source code data in the second channel by increasing a mode of adapting the source code. The API interface comprises calling interface data of the source code of each page component in the source code data; the configuration parameters include variable parameters and return value parameters in the source code.
Specifically, the computer device 1 replaces the file name and directory of each type of file in the first source code data with default file name and directory, and the default file name and directory have universal identification and can be used for calling source code data in other channels. For example, the source code data under the WeChat applet will have its filename with the ". wx" suffix replaced the filename of the same name without the ". wx" suffix, and then its directory will also be replaced, e.g., the "test. wx" directory is replaced with the "test" directory.
Meanwhile, the computer device 1 needs to perform corresponding processing on the API interface and the configuration parameter in the first source code data, for example, mapping the API interface of the source code of each page component included in the first source code data to a preset intermediate API interface; then when the first source code data is converted into second source code data corresponding to the first channel, replacing the corresponding API interface in the first source code data with the intermediate API interface; certainly, in the generated second source code data, a corresponding mapping function needs to be added to map the intermediate API interface to the API interface of the source code suitable for the second channel. Similarly, the computer device 1 also needs to perform corresponding processing on the relevant configuration parameters in the first source code data, that is, add intermediate configuration parameters for mapping to the configuration parameters applicable to the source code in the second channel. Therefore, differences between the API interface and the configuration parameters in the source code data corresponding to the first channel and the second channel are smoothed.
In an illustrative example, the computer device 1 may perform adaptation in the middle by performing secondary packaging on the API under the first channel for the difference of the APIs of different channels, so as to ensure that the calling of the API of the same page component by different channels can keep consistent with the usage of the first channel, including the name and usage of the API.
Referring to fig. 3, a flow chart of an exemplary embodiment of the present application for adaptive packaging of channel APIs is shown. In this embodiment, the computer device 1 pre-establishes a functional component, that is, an adaptation layer, that can adapt and encapsulate API characteristics of different channels; and then encapsulating API information corresponding to the source code, such as a Bilibili applet API, so as to obtain a channel API adapted to the target channel.
After the above steps are performed, the computer device 1 further performs an adaptive compiling process for the first source code data.
In a specific embodiment, the adapting and compiling, by the computer device 1, the first source code data according to the differentiation component set to obtain code data of a target page in a second channel includes: performing format conversion on the first source code data to obtain an intermediate source code of a code format corresponding to a second channel; and adding and/or deleting source code data of the corresponding functional component in the intermediate source code according to the differentiation component set to obtain code data of a target page in a second channel.
Wherein, the computer device 1 performs format conversion on the first source code data to obtain an intermediate source code of a code format corresponding to a second channel, and the method 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 adaptive code in a code format corresponding to a second channel; and restoring the abstract syntax tree subjected to code format conversion into a source code to obtain an intermediate source code of a code format corresponding to the second channel.
The computer device 1 converts the source code corresponding to each node in the abstract syntax tree into an adaptive code in a code format corresponding to a second channel, and includes: identifying 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; and calling a code conversion tool corresponding to the code type according to the code type to perform code format conversion on the source code corresponding to the target node, so as to obtain a corresponding adaptive code.
In this embodiment, the computer device 1 establishes a format code segment in advance for each page component in each channel, and stores the format code segment in a preset code database; the format code segment corresponds to the basic code that implements the page component under the corresponding channel. When the computer device 1 performs adaptive compilation on the first source code according to the set of differencing components, the method includes: when the differentiated component set is a missing page component, a format code of the needed page component can be further inquired from a code database and then inserted into the first source code, so that an intermediate source code for adapting to compiling is obtained; when the dissimilarity component set is an extra page component, the source code of the corresponding page component in the first source code may be masked by setting a conditional compilation mode, or may be directly deleted, so as to obtain an intermediate source code for adaptive compilation.
In the process of adding and/or deleting source code data of a corresponding functional component in the intermediate source code according to the differentiation component set, the computer device 1 needs to convert the first source code data into a data body of an abstract syntax tree by a preset conversion tool, and each node on the abstract syntax tree represents a source code corresponding to one page component. Then, the computer device 1 obtains an intermediate source code by performing comparison and subsequent addition or deletion operations on each node on the abstract syntax tree.
In an illustrative 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 invokes a code conversion tool corresponding to the code type to perform code format conversion on the source code corresponding to the target node according to the code type, so as to obtain a corresponding adaptive code, including: and splitting the Vue type source code according to the code format of the code type, so as to obtain at least one of an HTML type, a JS type and a CSS type.
Although the first channel and the second channel may each be composed of codes of HTML type, JS type, and CSS type, there is a difference in format therebetween. And Vue type's that includes in the source code, is the code segment that is actually mixed by one or more in HTML type, JS type and CSS type, therefore, computer equipment 1 is right when first source code segment carries out format conversion, need classify out wherein code of all types one by one, first according to HTML type, JS type and CSS type's code format with HTML type, JS type and CSS type in Vue type's code the code of HTML type, JS type and CSS type is discerned, then carries out transcoding respectively via HTML transcoder, JS transcoder and CSS transcoder to obtain the intermediate source code under the second channel.
Finally, the computer device 1 compiles the intermediate source code to obtain the source code data of the target page in the second channel.
Referring to fig. 4, a flowchart illustrating an effect of performing code format conversion on source code according to an exemplary embodiment of the present application is shown.
The computer device 1 acquires a source code, performs type identification on the source code according to a preset code format, further splits the source code of Vue type according to the code format when identifying Vue type in the source code, and continues to perform code identification after splitting; finally identifying the source codes of the HTML type, the JS type and the CSS type in the source codes; then, respectively carrying out code format conversion on source codes of the HTML type, the JS type and the CSS type through an HTML converter, a JS converter and a CSS converter; finally, the channel adaptation code, that is, the intermediate source code of the code format corresponding to the channel that needs to be displayed on the page is obtained for compiling and displaying in the subsequent steps.
Referring to fig. 5, a flowchart illustrating an effect of the generation of the applet page code according to an exemplary embodiment of the present application is shown.
In this embodiment, the computer device 1 first identifies a target channel that needs to be generated by a page code of an execution channel, and then performs file and directory mapping on a target channel on a source code of a target page of a current channel; then, starting a compiling process, acquiring a compiling entry file, namely sequentially acquiring the sequence of the source codes of all the components in the source codes, and injecting components and an API (application programming interface) of an adaptive channel under the condition that a target page under a target channel and a target page under a current channel have differentiated components; then, performing dependency collection, namely collecting the sequence and the dependency relationship of the source codes of all the components; finally, code format conversion is carried out on the source code; and finally outputting the channel source code.
In this embodiment, the identifying, by the computer device 1, the configuration specification of the source code under the current channel through a preset framework specification (vue.js) includes: config-configuration file, API-API file, Component-front-end display Component and event-trigger event, etc.; when a source code of a current channel is received, for example, an applet source code A, the configuration specifications of the source code of the current channel are sequentially identified; then, performing precompilation (Webpack + Loader) comprising conditional compilation and component format conversion, wherein the conditional compilation comprises performing component and API adaptation and differentiated flattening according to the page component and API interface of the target page under the acquired target channel and the difference between the page component of the small target page of the target channel and the source code under the current channel, wherein the page component and the API are included; finally, executing the generation and compilation of the source code of the target page under the target channel, for example, as for the generation and compilation of the source code of the target page under the current channel, as the source code is not changed, the NA Adapter which needs to be executed is carried out, namely, the source code is compiled after the specification is summarized; for source code generation and compilation of a target page under H5, the difference of channels is not great, and only specification summarization needs to be executed for compilation; for other applets, such as WeChat, Taobao and QQ, configuration verification and CSS verification need to be further performed, wherein the configuration verification comprises verification of related files such as App.vue, global mount, conf mapping, component mapping and dependency package in source codes; and after verifying the source code subjected to precompilation, further executing the generation and compilation steps of the source code, and finally obtaining the source code which is adapted to the display of the target page under the corresponding channel after Vue-mp conversion so as to be used for displaying the target page under the corresponding channel.
In summary, the applet page code generating method provided in this embodiment can obtain the first source code data of the target page in the first channel and the first component set including each page component; inquiring a second component set comprising 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 difference component set; and performing adaptive compiling on the first source code data according to the differentiation component set to obtain source code data of a target page in a second channel. According to the method and the device, the corresponding adaptation is executed on the page source code corresponding to the first channel according to the difference between the page of the other channel and the page of the first channel, so that the page source code can be applied to the page of the other channel, and therefore the efficiency of enabling the same page data to be compatible with the pages of different channels can be effectively improved.
Example two
Fig. 6 schematically shows a block diagram of an applet page code generation apparatus according to a second embodiment of the present application, which may be divided into one or more program modules, which are stored in a storage medium and executed by one or more processors to implement the second embodiment of the present application. The program modules referred to in the embodiments of the present application refer to a series of computer program instruction segments that can perform specific functions, and the following description will specifically describe the functions of the program modules in the embodiments.
As shown in fig. 6, the applet page code generating apparatus 400 may include an obtaining module 410, a querying module 420, a comparing module 430 and a compiling module 440, wherein:
an obtaining module 410 is configured to obtain first source code data of a target page under a first channel and a first component set including each page component.
The query module 420 is configured to query a second component set including each page component of the target page in the second channel according to a preset channel page component list.
A comparing module 430, configured to compare differences between the second component set and the first component set to obtain a differentiated component set.
And the compiling module 440 is configured to perform adaptive compiling on the first source code data according to the differentiation component set to obtain source code data of a target page in a second channel.
In an exemplary embodiment, the obtaining module 410 is further configured to: converting the file name and the directory path corresponding to the first source code data into a file name and a directory path which meet the naming and directory specifications of the source code data of a second channel; and converting the API interface of the first source code data and the configuration parameters in the source code into the API interface and the configuration parameters which conform to the configuration specification of the source code data in the second channel. Mapping the API interface of the first source code data and the configuration parameters in the source code with the API interface and the configuration parameters of the source code data in a second channel by increasing a mode of adapting the source code; the API interface comprises calling interface data of the source code of each page component in the source code data; the configuration parameters include variable parameters and return value parameters in the source code.
In an exemplary embodiment, the compiling module 440 is further configured to: performing format conversion on the first source code data to obtain an intermediate source code of a code format corresponding to a second channel; and adding and/or deleting source code data of the corresponding functional component in the intermediate source code according to the differentiation component set to obtain code data of a target page in a second channel. Wherein, the performing format conversion on the first source code data to obtain an intermediate source code of a code format corresponding to a second channel comprises: 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 adaptive code in a code format corresponding to a second channel; and restoring the abstract syntax tree subjected to code format conversion into a source code to obtain an intermediate source code of a code format corresponding to the second channel.
In an exemplary embodiment, the compiling module 440 is further configured to: identifying 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; and calling a code conversion tool corresponding to the code type according to the code type to perform code format conversion on the source code corresponding to the target node, so as to obtain a corresponding adaptive code. Wherein the code type comprises at least one of Vue type, HTML type, JS type, and CSS type; when the code type is Vue type, the calling a code conversion tool corresponding to the code type according to the code type to perform code format conversion on the source code corresponding to the target node, so as to obtain a corresponding adaptive code, including: and splitting the Vue type source code according to the code format of the code type, so as to obtain at least one of an HTML type, a JS type and a CSS type.
EXAMPLE III
Fig. 7 schematically shows a hardware architecture diagram of a computer device 1 suitable for implementing the applet page code generation method according to a third embodiment of the present application. In the present embodiment, the computer device 1 is a device capable of automatically performing numerical calculation and/or information processing in accordance with a command set or stored in advance. For example, the server may be a rack server, a blade server, a tower server or a rack server (including an independent server or a server cluster composed of a plurality of servers) with a gateway function. As shown in fig. 7, the computer device 1 includes at least, but is not limited to: memory 510, processor 520, and network interface 530 may be communicatively linked to each other by a system bus. Wherein:
the memory 510 includes at least one type of computer-readable storage medium including a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the storage 510 may be an internal storage module of the computer device 1, such as a hard disk or a memory of the computer device 1. In other embodiments, the memory 510 may also be an external storage device of the computer device 1, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the computer device 1. Of course, the memory 510 may also comprise both an internal memory module of the computer device 1 and an external memory device thereof. In this embodiment, the memory 510 is generally used for storing an operating system installed in the computer device 1 and various types of application software, such as program codes of an applet page code generation method. In addition, the memory 510 may also be used to temporarily store various types of data that have been output or are to be output.
Processor 520 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 520 is generally used for controlling 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, processor 520 is configured to execute program codes stored in memory 510 or process data.
It should be noted that FIG. 7 only shows a computer device having components 510 and 530, but it should be understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead.
In this embodiment, the program code of the applet page code generation method stored in the memory 510 may also be divided into one or more program modules and executed by one or more processors (in this embodiment, the processor 520) to implement the embodiments of the present application.
Example four
The present embodiments also provide a computer-readable storage medium having a computer program stored thereon, the computer program, when executed by a processor, implementing the steps of:
acquiring first source code data of a target page under a first channel and a first component set comprising each page component; inquiring a second component set comprising 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 difference component set; and performing adaptive compiling on the first source code data according to the differentiation component set to obtain source code data of a target page in a second channel.
In this embodiment, the computer-readable storage medium includes a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the computer readable storage medium may be an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. In other embodiments, the computer readable storage medium may be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the computer device. Of course, the computer-readable storage medium may also include both internal and external storage devices of the computer device. In this embodiment, the computer-readable storage medium is generally used for storing an operating system and various types of application software installed in the computer device, for example, the program code of the applet page code generation method in the embodiment. Further, the computer-readable storage medium may also be used to temporarily store various types of data that have been output or are to be output.
It will be apparent to those skilled in the art that the modules or steps of the embodiments of the present application described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different from that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, embodiments of the present application are not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications that can be made by the use of the equivalent structures or equivalent processes in the specification and drawings of the present application or that can be directly or indirectly applied to other related technologies are also included in the scope of the present application.
Claims (11)
1. A method for applet page code generation, the method comprising:
acquiring first source code data of a target page under a first channel and a first component set comprising each page component;
inquiring a second component set comprising 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 difference component set;
and performing adaptive compiling on the first source code data according to the differentiation component set to obtain source code data of a target page in a second channel.
2. The applet page code generation method according to claim 1, wherein before the adapted compiling of the first source code data according to the set of differencing components, the method further comprises:
converting the file name and the directory path corresponding to the first source code data into a file name and a directory path which meet the naming and directory specifications of the source code data of a second channel;
and converting the API interface of the first source code data and the configuration parameters in the source code into the API interface and the configuration parameters which conform to the configuration specification of the source code data in the second channel.
3. The applet page code generation method according to claim 2, wherein the converting the API interface of the first source code data and the configuration parameters in the source code into API interface and configuration parameters conforming to the configuration specification of the source code data in a second channel comprises:
and mapping the API interface of the first source code data and the configuration parameters in the source code with the API interface and the configuration parameters of the source code data in the second channel by increasing a mode of adapting the source code.
4. The applet page code generation method according to any one of claims 1-3, characterized in that the API interface comprises call interface data of the source code of each page component in the source code data; the configuration parameters include variable parameters and return value parameters in the source code.
5. The applet page code generation method according to claim 1, wherein the adapting and compiling the first source code data according to the differentiation component set to obtain code data of a target page in a second channel includes:
performing format conversion on the first source code data to obtain an intermediate source code of a code format corresponding to a second channel;
and adding and/or deleting source code data of the corresponding functional component in the intermediate source code according to the differentiation component set to obtain code data of a target page in a second channel.
6. The method for generating channel package applet page code according to claim 5, wherein the performing format conversion on the first source code data to obtain the intermediate source code in the code format corresponding to the second channel comprises:
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 adaptive code in a code format corresponding to a second channel;
and restoring the abstract syntax tree subjected to code format conversion into a source code to obtain an intermediate source code of a code format corresponding to the second channel.
7. The applet page code generation method according to claim 6, characterized in that said converting the source code corresponding to each node in the abstract syntax tree into an adapted code in a second channel corresponding code format comprises:
identifying 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;
and calling a code conversion tool corresponding to the code type according to the code type to perform code format conversion on the source code corresponding to the target node, so as to obtain a corresponding adaptive code.
8. The applet page code generation method according to claim 7,
the code type comprises at least one of Vue type, HTML type, JS type and CSS type;
when the code type is Vue type, the calling a code conversion tool corresponding to the code type according to the code type to perform code format conversion on the source code corresponding to the target node, so as to obtain a corresponding adaptive code, including:
and splitting the Vue type source code according to the code format of the code type, so as to obtain at least one of an HTML type, a JS type and a CSS type.
9. An apparatus for applet page code generation, the apparatus comprising:
the acquisition module is used for acquiring first source code data of a target page under a first channel and a first component set comprising each page component;
the query module is used for querying a second component set comprising each page component of the target page under a second channel according to a preset channel page component list;
the comparison module is used for comparing the difference between the second component set and the first component set to obtain a differentiated component set;
and the compiling module is used for carrying out adaptive compiling on the first source code data according to the differentiated component set to obtain the source code data of the target page in the second channel.
10. A computer arrangement, characterized in that the computer arrangement comprises a memory, a processor, the memory having stored thereon a computer program executable on the processor, the computer program, when executed by the processor, realizing the steps of the applet page code generation method according to any one of claims 1-8.
11. A computer-readable storage medium, characterized in that it stores a computer program which is executable by at least one processor for causing the at least one processor to carry out the steps of the applet page code generation method according to any one of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110961819.4A CN113672224A (en) | 2021-08-20 | 2021-08-20 | Method and device for generating small program page code and computer equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110961819.4A CN113672224A (en) | 2021-08-20 | 2021-08-20 | Method and device for generating small program page code and computer equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113672224A true CN113672224A (en) | 2021-11-19 |
Family
ID=78544587
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110961819.4A Pending CN113672224A (en) | 2021-08-20 | 2021-08-20 | Method and device for generating small program page code and computer equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113672224A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114185551A (en) * | 2022-02-17 | 2022-03-15 | 浙江口碑网络技术有限公司 | Applet compiling method, applet running method and device and storage medium |
CN114201236A (en) * | 2021-12-14 | 2022-03-18 | 平安壹钱包电子商务有限公司 | AST-based component configuration method, device, equipment and medium |
CN114416084A (en) * | 2021-12-31 | 2022-04-29 | 北京五八信息技术有限公司 | Data processing method and device, electronic equipment and storage medium |
CN115904393A (en) * | 2023-01-05 | 2023-04-04 | 拉扎斯网络科技(上海)有限公司 | Conditional compiling implementation method, device, medium and equipment |
Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2016163901A1 (en) * | 2015-04-07 | 2016-10-13 | Huawei Technologies Co., Ltd. | An apparatus for processing an abstract syntax tree being associated with a source code of a source program |
US20170139690A1 (en) * | 2015-11-16 | 2017-05-18 | Sap Se | Universal transcompiling framework |
CN108121563A (en) * | 2017-11-10 | 2018-06-05 | 广州阿里巴巴文学信息技术有限公司 | Application function method for customizing, device, computing device and storage medium |
CN109947433A (en) * | 2019-03-28 | 2019-06-28 | 优信拍(北京)信息科技有限公司 | A kind of generation method of small routine, update method and device |
CN110457045A (en) * | 2019-08-16 | 2019-11-15 | 百度在线网络技术(北京)有限公司 | Modularization merges Compilation Method, device, equipment and storage medium |
CN110580147A (en) * | 2018-06-07 | 2019-12-17 | 阿里巴巴集团控股有限公司 | application program development method and device |
CN110968325A (en) * | 2019-10-28 | 2020-04-07 | 苏宁云计算有限公司 | Applet conversion method and device |
CN111124576A (en) * | 2019-12-23 | 2020-05-08 | 焦点科技股份有限公司 | Multi-platform applet and H5 page adaptation method and system |
CN111381825A (en) * | 2020-03-06 | 2020-07-07 | 北京五八信息技术有限公司 | Method and device for generating small program |
CN111427583A (en) * | 2020-04-12 | 2020-07-17 | 中信银行股份有限公司 | Component compiling method and device, electronic equipment and computer readable storage medium |
CN112527415A (en) * | 2020-12-23 | 2021-03-19 | 深圳尚米网络技术有限公司 | Method, device, equipment and medium for migrating applets across platforms |
CN113268234A (en) * | 2021-05-17 | 2021-08-17 | 北京三快在线科技有限公司 | Page generation method, device, terminal and storage medium |
-
2021
- 2021-08-20 CN CN202110961819.4A patent/CN113672224A/en active Pending
Patent Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2016163901A1 (en) * | 2015-04-07 | 2016-10-13 | Huawei Technologies Co., Ltd. | An apparatus for processing an abstract syntax tree being associated with a source code of a source program |
US20170139690A1 (en) * | 2015-11-16 | 2017-05-18 | Sap Se | Universal transcompiling framework |
CN108121563A (en) * | 2017-11-10 | 2018-06-05 | 广州阿里巴巴文学信息技术有限公司 | Application function method for customizing, device, computing device and storage medium |
CN110580147A (en) * | 2018-06-07 | 2019-12-17 | 阿里巴巴集团控股有限公司 | application program development method and device |
CN109947433A (en) * | 2019-03-28 | 2019-06-28 | 优信拍(北京)信息科技有限公司 | A kind of generation method of small routine, update method and device |
CN110457045A (en) * | 2019-08-16 | 2019-11-15 | 百度在线网络技术(北京)有限公司 | Modularization merges Compilation Method, device, equipment and storage medium |
CN110968325A (en) * | 2019-10-28 | 2020-04-07 | 苏宁云计算有限公司 | Applet conversion method and device |
CN111124576A (en) * | 2019-12-23 | 2020-05-08 | 焦点科技股份有限公司 | Multi-platform applet and H5 page adaptation method and system |
CN111381825A (en) * | 2020-03-06 | 2020-07-07 | 北京五八信息技术有限公司 | Method and device for generating small program |
CN111427583A (en) * | 2020-04-12 | 2020-07-17 | 中信银行股份有限公司 | Component compiling method and device, electronic equipment and computer readable storage medium |
CN112527415A (en) * | 2020-12-23 | 2021-03-19 | 深圳尚米网络技术有限公司 | Method, device, equipment and medium for migrating applets across platforms |
CN113268234A (en) * | 2021-05-17 | 2021-08-17 | 北京三快在线科技有限公司 | Page generation method, device, terminal and storage medium |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114201236A (en) * | 2021-12-14 | 2022-03-18 | 平安壹钱包电子商务有限公司 | AST-based component configuration method, device, equipment and medium |
CN114416084A (en) * | 2021-12-31 | 2022-04-29 | 北京五八信息技术有限公司 | Data processing method and device, electronic equipment and storage medium |
CN114185551A (en) * | 2022-02-17 | 2022-03-15 | 浙江口碑网络技术有限公司 | Applet compiling method, applet running method and device and storage medium |
CN115904393A (en) * | 2023-01-05 | 2023-04-04 | 拉扎斯网络科技(上海)有限公司 | Conditional compiling implementation method, device, medium and equipment |
CN115904393B (en) * | 2023-01-05 | 2023-06-30 | 拉扎斯网络科技(上海)有限公司 | Condition compiling realization method, device, medium and equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113672224A (en) | Method and device for generating small program page code and computer equipment | |
CN109032662B (en) | Code file generation method and device, computer equipment and storage medium | |
CN108388454B (en) | Method and device for dynamically providing JS (JavaScript) compatible script content and terminal equipment | |
CN110308999B (en) | Method for dynamically sharing dependency package between applications, storage medium and mobile terminal | |
CN110175157B (en) | Query method and query device for column storage file | |
CN107797823B (en) | Business rule management method and device, storage medium and computer equipment | |
CN112527415A (en) | Method, device, equipment and medium for migrating applets across platforms | |
CN112769706B (en) | Componentized routing method and system | |
CN109062906B (en) | Translation method and device for program language resources | |
CN112612982A (en) | Webpage preloading method and device and computer equipment | |
KR101117165B1 (en) | Web platform unit for mobile terminal connectioned web-application program in heterogeneous operating system | |
US9411618B2 (en) | Metadata-based class loading using a content repository | |
CN112422450A (en) | Computer equipment, and flow control method and device for service request | |
CN111506368A (en) | Method, device, equipment and storage medium for transferring asynchronous call to synchronous call | |
CN113535206B (en) | Multi-version code upgrading method and system | |
CN114647422A (en) | Vehicle electronic control unit flashing method, device, equipment and medium | |
CN112214250A (en) | Application program assembly loading method and device | |
CN114003210A (en) | SDK-based multi-application program adaptation method, device, equipment and medium | |
CN111273940B (en) | Method and device for uploading program file to code warehouse | |
CN112783500B (en) | Method and device for generating compiling optimization information and electronic equipment | |
CN112416383A (en) | Hot updating method and device for golang program and computer equipment | |
CN113934460B (en) | Resource providing method and device | |
CN113129049B (en) | File configuration method and system for model training and application | |
CN114840217A (en) | Compiling method, device, equipment and readable storage medium | |
CN106502754B (en) | Activity component loading method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |