Disclosure of Invention
The invention provides a method, a device, equipment and a medium for building a small program in a componentization mode, which solve the problems that in the prior art, when each new small program item is started, a large number of codes need to be rewritten according to respective item requirements, so that the development efficiency of the small program is reduced, and due to the fact that technical personnel participating in the small program have different coding capacities and styles, the difficulty is increased for later maintenance of the small program, and the maintenance cost is increased.
The invention provides a small program modular construction method, which comprises the following steps:
responding to an applet construction request sent by a demand end, and extracting service demand information corresponding to a target applet from the applet construction request;
searching at least one corresponding functional component to be converted from a preset functional component library according to the service demand information;
converting the original code based on a programming language corresponding to the original code in the functional component to be converted, generating a target functional component and caching the target functional component to a preset functional component list;
rendering all the target functional components in the functional component list to obtain at least one applet page;
and combining all the applet pages to generate the target applet and returning the target applet to the demand end.
Optionally, the step of searching for the corresponding at least one to-be-converted functional component from a preset functional component library according to the service requirement information includes:
analyzing the service requirement information and determining the type of the functional component required by the target applet;
and searching a preset functional component library according to the functional component type, and selecting at least one functional component to be converted according to the functional component type.
Optionally, the service requirement information further includes a requirement component version number, and the step of searching for the corresponding at least one to-be-converted functional component from a preset functional component library according to the service requirement information further includes:
extracting the component version number corresponding to each functional component to be converted;
and selecting the functional component to be converted with the same component version number as the required component version number as a new functional component to be converted.
Optionally, the step of converting the original code based on the programming language corresponding to the original code in the functional component to be converted, generating a target functional component, and caching the target functional component in a preset functional component list includes:
if the programming language corresponding to the original code in the functional component to be converted is JavaScript, analyzing the original code in the functional component to be converted, and constructing an original abstract syntax tree;
converting each tree node in the original abstract syntax tree according to the target code language required by the service requirement information to obtain a target abstract syntax tree which accords with the target code language;
traversing the target abstract syntax tree to generate a first target code character string;
and compiling the first target code character string to obtain a target function component and caching the target function component to a preset function component list.
Optionally, the step of converting the original code based on the programming language corresponding to the original code in the functional component to be converted, generating a target functional component, and caching the target functional component in a preset functional component list includes:
if the programming language corresponding to the original code in the functional component to be converted is a cascading style sheet, analyzing the original code in the functional component to be converted to obtain a dynamic analysis tree containing dynamic nodes;
converting the dynamic analysis tree into a static analysis tree according to the target code language of the service demand information demand;
traversing the static analysis tree to generate a second target code character string;
and compiling the second target code character string to obtain a target function component and caching the target function component to a preset function component list.
Optionally, the step of rendering all the target function components in the function component list to obtain at least one applet page includes:
creating at least one initial page;
updating the initial page according to a frame structure and a display style corresponding to the service demand information to obtain an intermediate page;
and loading the target function components from the function component list to each intermediate page one by one and rendering to obtain at least one applet page.
Optionally, the method further comprises:
when a component source code updating request is received, selecting a functional component to be updated from the functional component library based on the component source code updating request;
responding to the input source code updating information, and updating the code to be updated in the functional component to be updated to obtain an updated code;
when an update completion instruction for the code to be updated is received, compiling the update code to obtain an update functional component and updating a corresponding original version number;
and caching the updated functional component as a new functional component to the functional component library.
The invention provides a modular building device of small programs, comprising:
the service demand information extraction module is used for responding to an applet construction request sent by a demand end and extracting service demand information corresponding to a target applet from the applet construction request;
the to-be-converted functional component selection module is used for searching at least one corresponding to-be-converted functional component from a preset functional component library according to the service requirement information;
the code conversion and cache module is used for converting the original codes in the functional components to be converted based on the programming language corresponding to the original codes, generating target functional components and caching the target functional components to a preset functional component list;
the applet page generation module is used for rendering all the target function components in the function component list to obtain at least one applet page;
and the small program page combination module is used for combining all the small program pages, generating the target small program and returning the target small program to the demand side.
A third aspect of the present invention provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the computer program, when executed by the processor, causes the processor to perform the steps of the method for building a component of an applet according to any one of the first aspects of the present invention.
A fourth aspect of the present invention provides a computer-readable storage medium having stored thereon a computer program which, when executed, implements a modular construction method for an applet as claimed in any one of the first aspects of the present invention.
According to the technical scheme, the invention has the following advantages:
the method comprises the steps of responding to a small program construction request sent by a demand end, extracting business demand information corresponding to a demanded target small program from the small program construction request, searching at least one corresponding functional component to be converted from a preset functional component library according to the business demand information, further converting original codes in the functional components to be converted to generate a target functional component in order to realize the adaptation of codes of the small program of the demand end, and caching the generated target functional component into a preset functional component list; and after all the target function components are cached, rendering the target function components to obtain the corresponding small program pages, and finally combining the small program pages according to the small program page jump sequence in the service demand information to generate the target small program and returning the target small program to the demand end. Therefore, the common functions of the small programs are edited in a componentization mode, and the common functions are used for constructing the subsequent small programs in a functional component library mode, so that a large amount of repeated coding of codes is reduced, and the development efficiency of the small programs is improved; by adapting the code programming languages of various demand sides in a modular configuration mode, the uniformity of small program codes can be ensured under the condition that technical personnel have different coding capacities and styles, and the later maintenance difficulty and the maintenance cost are more effectively reduced; therefore, the invention adapts the small program requirements of various demand ends in the form of calling the functional component library by componentizing the functions of the small program, improves the reuse rate and the development efficiency of the small program codes and effectively reduces the maintenance cost of the small program.
Detailed Description
The embodiment of the invention provides a method, a device, equipment and a medium for building a small program in a componentization mode, which are used for solving the technical problems that in the prior art, when each new small program item is started, a large number of codes need to be rewritten according to respective item requirements, and the development efficiency of the small program is reduced due to different coding capacities and styles of technicians participating in the small program.
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the embodiments described below are only a part of the embodiments of the present invention, and not all of the embodiments. 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 invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for building a component of an applet according to an embodiment of the present invention.
The invention provides a small program modular construction method, which comprises the following steps:
step 101, responding to an applet construction request sent by a demand side, and extracting service demand information corresponding to a target applet from the applet construction request.
The applet construction request refers to request information sent by a platform supporting the applet application, such as a browser, communication software or payment software, of a demand side, and specifically includes service demand information, where the service demand information is used to indicate information such as a function required to be implemented by a demanded target applet, an applet page conversion sequence, a component version number of a functional component required by the applet, and an applet source code type supported by the platform.
In the embodiment of the invention, when an applet constructing request sent by any one of the platforms supporting the applet application is received, the applet constructing request can be analyzed so as to extract the service requirement information corresponding to the target applet required by the platform.
And step 102, searching at least one corresponding functional component to be converted from a preset functional component library according to the service requirement information.
The function component library refers to a database pre-stored locally, and includes a plurality of function components capable of implementing different functions, wherein each function component may have a plurality of versions at the same time and is identified by a component version number, including but not limited to a picture component, a carousel picture component, an N + N component, a menu component, a video component, a subscription component, a coupon component, a waterfall component of a commodity, and the like.
After the service requirement information is extracted, in order to determine the functional components required by the target applet, the service requirement information can be further analyzed, so that the obtained functional component types are searched in the functional component library to obtain at least one functional component to be converted.
It is worth mentioning that the functional components with the same function may have multiple versions, and the version number of the required component may be further obtained from the service requirement information, and compared with the component version numbers of the functional components in the functional component library according to the version number of the required component, so as to further screen the new functional components to be converted.
Step 103, converting the original code based on the programming language corresponding to the original code in the functional component to be converted, generating a target functional component and caching the target functional component to a preset functional component list.
The functional component list refers to a database storing a plurality of target functional components waiting for rendering.
In the embodiment of the present invention, the functional components in the functional component library may be written by a front-end developer using a programming component that is commonly used by the front-end developer, for example, a programming component that applies a JavaScript scripting language, a CSS (Cascading Style Sheets) programming component, a read language writing component used under a Taro framework, a CSS language writing component used under an Vue framework, and the like. However, the demand terminals corresponding to the received applet construction requests may not use the same programming language, and the code writing rules of the demand terminals are different, which may cause the demand terminals not to implement the functions of the target applet. And the target applet usually has a plurality of applet pages, and the functions realized by each applet page may be different, if rendering the applet pages on one target function component one by one, and then returning to select the target function component, the time is more.
Therefore, the original codes in the functional components to be converted can be converted, the original codes are converted into abstract syntax trees or static analysis trees and then are converted into target code character strings corresponding to the target code languages of the demand end, then the target code character strings are compiled, target functional components which accord with the demand end are obtained and are cached into a functional component list one by one, and the subsequent rendering is waited.
And 104, rendering all target function components in the function component list to obtain at least one applet page.
After all target function components are cached in the function component list, a corresponding applet page is generated, and all target function components in the function component list can be rendered, so that at least one applet page is generated.
And 105, combining all the applet pages to generate a target applet and returning to the demand side.
After at least one applet page is obtained, the jump between the applet pages or the function of the applet cannot be realized because the jump sequence does not exist in a single applet page.
Therefore, the jump logical relationship among the small program pages can be further established and combined according to the page sequence carried by the service demand information, the target small program is generated at the front end and returned to the demand end, and accordingly the target small program is constructed in a componentization mode in response to the demands of various platforms.
In the embodiment of the invention, by responding to an applet construction request sent by a demand end, business demand information corresponding to a demanded target applet is extracted from the request, and then at least one corresponding functional component to be converted is searched from a preset functional component library according to the business demand information, so that the adaptation of the applet code of the demand end is realized, the original code in the functional component to be converted can be further converted to generate a target functional component, and the generated target functional component is cached to a preset functional component list; and after all the target function components are cached, rendering the target function components to obtain the corresponding small program pages, and finally combining the small program pages according to the small program page jump sequence in the service demand information to generate the target small program and returning the target small program to the demand end. Therefore, the common functions of the small programs are edited in a componentization mode, and the common functions are used for constructing the subsequent small programs in a functional component library mode, so that a large amount of repeated coding of codes is reduced, and the development efficiency of the small programs is improved; by adapting the code programming languages of various demand sides in a modular configuration mode, the uniformity of small program codes can be ensured under the condition that technical personnel have different coding capacities and styles, and the later maintenance difficulty and the maintenance cost are more effectively reduced; therefore, the invention adapts the small program requirements of various demand ends in the form of calling the functional component library by componentizing the functions of the small program, improves the reuse rate and the development efficiency of the small program codes and effectively reduces the maintenance cost of the small program.
Referring to fig. 2, fig. 2 is a flowchart illustrating a method for building a component of an applet according to a second embodiment of the present invention.
The invention provides a small program modular construction method, which comprises the following steps:
step 201, responding to an applet constructing request sent by a demand side, and extracting service demand information corresponding to a target applet from the applet constructing request.
In the embodiment of the present invention, the specific implementation process of step 201 is similar to that of step 101, and is not described herein again.
Step 202, according to the service requirement information, searching at least one corresponding functional component to be converted from a preset functional component library.
Optionally, step 202 may include the following sub-steps:
analyzing the service requirement information, and determining the type of the functional component required by the target applet;
and searching a preset functional component library according to the type of the functional component, and selecting at least one functional component to be converted according with the type of the functional component.
In the embodiment of the invention, after the business requirement information is extracted and obtained, the business requirement information is analyzed so as to determine the type of the functional component required to be used by the target applet, the functional component library is further searched according to the type of the functional component, and at least one functional component to be converted, which accords with the type of the functional component, is selected.
Further, the service requirement information further includes a requirement component version number, and step 202 may further include the following sub-steps:
extracting the component version number corresponding to each functional component to be converted;
and selecting the functional component to be converted with the same component version number as the required component version number as a new functional component to be converted.
The component version number refers to an identification number of a functional component, enabling a user to know whether the used functional component is the latest version and the kind of function it provides.
In specific implementation, a plurality of versions may exist in the functional component for realizing the same function, in order to further improve the screening efficiency, after the functional component to be converted which accords with the type of the functional component is selected, the component version number corresponding to each functional component to be converted can be extracted, and the functional component to be converted which is the same as the required component version number can be selected from the component version numbers as a new functional component to be converted by comparing the required component version number in each component version number and the service requirement information, so that the refined screening of the functional component to be converted is realized.
It is worth mentioning that, because the functional components realizing the same function have multiple versions and multiple names, the required versions and named functional components can be screened from the required versions according to the names of the required components carried by the service requirement information.
Step 203, converting the original code based on the programming language corresponding to the original code in the functional component to be converted, generating a target functional component and caching the target functional component to a preset functional component list.
Optionally, step 203 may include the following sub-steps S11-S14:
if the programming language corresponding to the original code in the functional component to be converted is JavaScript, analyzing the original code in the functional component to be converted, and constructing an original abstract syntax tree;
converting each tree node in the original abstract syntax tree according to the target code language required by the service requirement information to obtain a target abstract syntax tree which accords with the target code language;
traversing the target abstract syntax tree to generate a first target code character string;
and compiling the first target code character string to obtain a target function component and caching the target function component to a preset function component list.
The abstract Syntax tree ast (abstract Syntax tree) refers to a tree structure corresponding to the source code Syntax. That is, for source code in a particular programming language, statements in the source code are mapped to each node in the tree by constructing a syntax tree, for example. The original abstract syntax tree refers to an abstract syntax tree mapped by statements in the original code, and the target abstract syntax tree refers to an abstract syntax tree mapped by statements in the target code language.
JavaScript ("JS") is a lightweight, interpreted or just-in-time programming language with function precedence. Although it is named as a scripting language for developing Web pages, it is also used in many non-browser environments, JavaScript is based on prototypical programming, multi-modal dynamic scripting languages, and supports object-oriented, imperative, declarative, functional programming paradigms.
In the embodiment of the present invention, since the functional component to be converted is written by a technician using a JavaScript type programming language, the code frames used by different clients are different, for example, the HTML5 language, the vue frame, or the Taro frame used by a browser, and the original code written by the JS language cannot run on the frame of the client.
Therefore, before rendering the functional component to generate the small program page, the original code of the functional component to be converted can be analyzed, statements in the original code are mapped to the structural form of the abstract syntax tree to obtain the original abstract syntax tree, then each tree node in the original abstract syntax tree is further converted according to the target code language required by the service requirement information to obtain the target abstract syntax tree which accords with the target code language, so that the conversion of the original abstract syntax tree is completed, the corresponding first target code character string is obtained by traversing the target abstract syntax tree, the first target code character string is compiled to generate the target functional component, the target functional component is cached to a preset functional component list, and the subsequent further page rendering is waited.
Taking an original code' var a ═ 1; for example, after mapping it to the original abstract syntax tree, the following form is obtained:
the value of the Keyword in the ast can be modified into a let, so that the converted first target code string is obtained as "let a equals to 1; ".
Optionally, step 203 may include the following sub-steps S21-S24:
if the programming language corresponding to the original code in the functional component to be converted is a cascading style sheet, analyzing the original code in the functional component to be converted to obtain a dynamic analysis tree containing dynamic nodes;
converting the dynamic analysis tree into a static analysis tree according to a target code language required by the service demand information;
traversing the static analysis tree to generate a second target code character string;
and compiling the second target code character string to obtain a target function component and caching the target function component to a preset function component list.
Parse trees refer to syntax parse trees, which are a graphical representation of the derivation that filters out the order in which productions are applied to non-terminal symbols during the derivation process. Each internal node of each parse tree represents a generative application. The internal node is labeled as the non-terminal symbol in the resulting header. The labels of the children of these nodes, from left to right, constitute the production entity that replaces this expression in the derivation process. The dynamic analysis tree refers to a syntax analysis tree of related nodes for dynamically generating original codes; the static parse tree refers to a parse tree obtained by mapping an original code into a form of a parse tree without running the original code.
In an example of the present invention, after a functional component to be converted is selected, if a programming language is a cascading style sheet, the functional component to be converted is further analyzed to obtain an original code to obtain a dynamic analysis tree including a plurality of dynamic nodes, the dynamic analysis tree is converted according to a target code language required by service requirement information to obtain a static analysis tree, and finally a second target code character string is obtained by traversing the static analysis tree, and the second target character string is compiled to obtain a target functional component and cache the target functional component in a functional component list.
Taking cascading style sheet CSS as an example, after the analysis tree of the DSL source code is obtained, the dynamic analysis tree containing the dynamic node may be converted into a static analysis tree, which is further converted into a CSS static analysis tree and traversed through the CSS static analysis tree, so as to obtain a CSS code and compile it, thereby obtaining a target functional component.
And step 204, rendering all target function components in the function component list to obtain at least one applet page.
Optionally, step 204 may include the following sub-steps:
creating at least one initial page;
updating the initial page according to the frame structure and the display style corresponding to the service demand information to obtain an intermediate page;
and loading the target function components one by one from the function component list to each intermediate page and rendering to obtain at least one applet page.
The framework structure refers to wxml and mainly comprises eight types of basic components such as a view container, basic content, a form component, an operation feedback component, a navigation component, a multimedia component, a map component and a canvas component.
Display style refers to wxss, which is used to determine how a component is displayed, and display settings typically include units of size and style imports, such as display, float, position, background, border, outline, text properties, font properties, margin and fill, and the like.
In the embodiment of the invention, after all target function components are cached in the function component list, in order to realize page preview in the local area, at least one initial page can be created in advance, the service requirement information is further analyzed, the corresponding frame structure and the display style are obtained, the frame structure and the display style are adopted to construct and update the initial page so as to obtain an intermediate page, and finally the target function components are loaded one by one from the function component list to each intermediate page and rendered so as to obtain at least one small program page.
It should be noted that in a specific implementation, an initial interface may be generated in advance by using a json file, target function components in the function component list are loaded one by loading a frame structure wxml and a display style wxss, a page constructor such as a page is called to generate a corresponding intermediate page, a final structure of each applet page is generated by page rendering, and an onload event is executed to perform callback.
And step 205, combining all the applet pages to generate a target applet and returning to the demand side.
After at least one applet page is obtained, the jump between the applet pages or the function of the applet cannot be realized because the jump sequence does not exist in a single applet page.
Therefore, the jump logic relations among the small program pages can be further established and combined according to the page sequence carried by the service requirement information, the target small program is generated at the front end and returned to the requirement end, and accordingly the target small program can be constructed in a componentized mode in response to the requirements of various platforms.
Referring to fig. 3, fig. 3 is a flow chart illustrating a procedure of picking up a merchandise according to an embodiment of the present invention.
In this embodiment, a developer may develop a series of components based on taro framework, such as a drawing component, a coupon component, and a menu component, in advance through components development tools, and upload the components to a functional component library, such as npm private server, through linux commands.
And after receiving an applet construction request sent by a demand end, operating an npm install command, downloading a picture component, a coupon component and the like which accord with a target version number from a private domain server, generating an applet source code through a taro packaging command, compiling, and returning the target applet to the demand end so that a user can see various pictures and take coupons on the demand end.
It should be noted that, when the user compiles the original code through the components tool, the resource modules that the file depends on are parsed and inferred according to statements such as import (es modules) or require (commonjs) appearing in the original code, and then the dependencies of each resource module are parsed, which is repeated in a cycle, and finally, a dependency tree among all the files used in the whole project is formed. For resource modules which cannot be represented by JavaScript codes, such as pictures or font files, the resource modules are generally copied to an output directory as resource files individually, and then an access path corresponding to the resource file is displayed as the module at the front end to wait for a user to perform an operation.
Step 206, when receiving the component source code updating request, selecting the functional component to be updated from the functional component library based on the component source code updating request.
The component source code updating request refers to request information generated in response to the triggering of the user on the local screen, and is used for specifying the functional component to be updated which needs to be updated.
When a user needs to update the versions of the target applets of each demand side, if the time spent on updating the target applets one by the platform is long, the development cost is increased. Therefore, when a component source code updating request is locally received, the component source code updating request is responded, the corresponding functional component to be updated is selected from the functional component library, and the original code in the functional component to be updated is further updated, so that when the functional component in the functional component library is acquired again at a subsequent demand end, the updated functional component can be directly acquired, the small program code does not need to be updated respectively for various demand ends, and the target small program with low time cost is updated.
And step 207, responding to the input source code updating information, and updating the code to be updated in the functional component to be updated to obtain an updated code.
The source code updating information refers to codes (such as js codes and css codes) input by various components written by a user (such as a front-end developer) and used for changing and optimizing the existing codes to be updated in each component.
After the functional component to be updated is selected, the user can further input source code updating information, and the code to be updated in the functional component to be updated is updated in a code typing or modifying mode to obtain an updated code.
And step 208, compiling the updating code to obtain the updating functional component and updating the corresponding original version number when receiving the updating completion instruction aiming at the code to be updated.
After the user updates the code to be updated, the code to be updated may be pre-compiled to determine whether a bug exists, and if not, an update completion instruction may be further input, for example, a click submission or the like. And at the moment, formally compiling the updating code to obtain the updating functional component.
Meanwhile, in order to distinguish the updated functional component from the functional component to be updated, the original version number corresponding to the functional component to be updated may be further modified.
Step 209, cache the updated functional component as a new functional component to the functional component library.
After the original version number of the updated functional component is updated, the updated functional component may be cached as a new functional component in the functional component library, and when the applet constructing request sent by the request end is received again, the step 201 and the step 205 are repeatedly executed, so as to complete the updating of the target applet.
In the embodiment of the invention, by responding to an applet construction request sent by a demand end, business demand information corresponding to a demanded target applet is extracted from the request, and then at least one corresponding functional component to be converted is searched from a preset functional component library according to the business demand information, so that the adaptation of the applet code of the demand end is realized, the original code in the functional component to be converted can be further converted to generate a target functional component, and the generated target functional component is cached to a preset functional component list; and after all the target function components are cached, rendering the target function components to obtain the corresponding small program pages, and finally combining the small program pages according to the small program page jump sequence in the service demand information to generate the target small program and returning the target small program to the demand end. Therefore, the common functions of the small programs are edited in a componentization mode, and the common functions are used for constructing the subsequent small programs in a functional component library mode, so that a large amount of repeated coding of codes is reduced, and the development efficiency of the small programs is improved; by adapting the code programming languages of various demand sides in a modular configuration mode, the uniformity of small program codes can be ensured under the condition that technical personnel have different coding capacities and styles, and the later maintenance difficulty and the maintenance cost are more effectively reduced; therefore, the invention adapts the small program requirements of various demand ends in the form of calling the functional component library by componentizing the functions of the small program, improves the reuse rate and the development efficiency of the small program codes and effectively reduces the maintenance cost of the small program.
Referring to fig. 4, fig. 4 is a block diagram of a device for building a small program into a component according to a third embodiment of the present invention.
The embodiment of the invention provides a small program modularization constructing device, which comprises:
a service requirement information extraction module 401, configured to respond to an applet constructing request sent by a requirement end, and extract service requirement information corresponding to a target applet from the applet constructing request;
a to-be-converted functional component selection module 402, configured to search, according to the service requirement information, at least one corresponding to-be-converted functional component from a preset functional component library;
a code conversion and cache module 403, configured to convert an original code based on a programming language corresponding to the original code in the functional component to be converted, generate a target functional component, and cache the target functional component in a preset functional component list;
an applet page generating module 404, configured to render all target functional components in the functional component list to obtain at least one applet page;
and the applet page combination module 405 is used for combining all the applet pages, generating the target applet and returning the target applet to the demand side.
Optionally, the to-be-converted functional component selecting module 402 is specifically configured to:
analyzing the service requirement information, and determining the type of the functional component required by the target applet;
and searching a preset functional component library according to the type of the functional component, and selecting at least one functional component to be converted, which accords with the type of the functional component.
Optionally, the service requirement information further includes a requirement component version number, and the to-be-converted functional component selecting module 402 is further specifically configured to:
extracting the component version number corresponding to each functional component to be converted;
and selecting the functional component to be converted with the same component version number as the required component version number as a new functional component to be converted.
Optionally, the code conversion and cache module 403 is specifically configured to:
if the programming language corresponding to the original code in the functional component to be converted is JavaScript, analyzing the original code in the functional component to be converted, and constructing an original abstract syntax tree;
converting each tree node in the original abstract syntax tree according to the target code language required by the service requirement information to obtain a target abstract syntax tree which accords with the target code language;
traversing the target abstract syntax tree to generate a first target code character string;
and compiling the first target code character string to obtain a target function component and caching the target function component to a preset function component list.
Optionally, the code conversion and cache module 403 is specifically configured to:
if the programming language corresponding to the original code in the functional component to be converted is a cascading style sheet, analyzing the original code in the functional component to be converted to obtain a dynamic analysis tree containing dynamic nodes;
converting the dynamic analysis tree into a static analysis tree according to a target code language required by the service demand information;
traversing the static analysis tree to generate a second target code character string;
and compiling the second target code character string to obtain a target function component and caching the target function component to a preset function component list.
Optionally, the applet page generating module 404 is specifically configured to:
creating at least one initial page;
updating the initial page according to the frame structure and the display style corresponding to the service demand information to obtain an intermediate page;
and loading the target function components one by one from the function component list to each intermediate page and rendering to obtain at least one applet page.
Optionally, the apparatus further comprises:
the to-be-updated functional component selection module is used for selecting the to-be-updated functional component from the functional component library based on the component source code updating request when the component source code updating request is received;
the code updating module is used for responding to the input source code updating information and updating the code to be updated in the functional component to be updated to obtain an updated code;
the component and version number updating module is used for compiling the updating code when receiving an updating completion instruction aiming at the code to be updated, obtaining an updating functional component and updating a corresponding original version number;
and the functional component caching module is used for caching the updated functional component as a new functional component to the functional component library.
An embodiment of the present invention provides an electronic device, which includes a memory and a processor, where the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method for building a component of an applet according to any one of the embodiments of the present invention.
The embodiment of the invention provides a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and when the computer program is executed, the computer program realizes the modular construction method of the small program according to any embodiment of the invention.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses and modules may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk, and various media capable of storing program codes.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.