Mini-program generation method, device, equipment and computer-readable storage medium
By obtaining and processing third-party global configuration files, copying and analyzing page files and dependency resources, and generating third-party applets, the problem of difficult maintenance of third-party applet code in the existing technology is solved, and efficient maintenance and good performance experience is achieved.
Patent Information
- Application Number
- CN201910835860.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-04
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2039-09-04
AI Technical Summary
In the prior art, when third parties access applets, the code of third-party applets is difficult to maintain, resulting in performance and experience being affected.
By obtaining the third-party global configuration file, storing it in the preset directory, reading the target page information in the configuration file, copying the corresponding page file and dependency resources to the preset directory, and generating a third-party applet.
It realizes efficient maintenance of third-party applets, ensures performance and experience, and at the same time, it facilitates the update and maintenance of third-party applet code through configuration.
Smart Images

Figure CN110532029B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of financial technology (Fintech), and particularly to a method, device, equipment and computer-readable storage medium for generating a mini-program. Background Art
[0002] With the development of computer technology, more and more technologies (such as big data, distributed, blockchain, artificial intelligence, etc.) are applied in the financial field. The traditional financial industry is gradually transforming into financial technology (Fintech). However, due to the security and real-time requirements of the financial industry, higher requirements are also put forward for technologies.
[0003] With the continuous development of computer technology, various applications have entered people's daily lives. As an application that can be used without downloading and installing, mini-programs have received extensive attention from all walks of life. Currently, many financial institutions such as banks will develop some application mini-programs to provide relevant functions and support the access of merchants. Specifically, when a merchant needs to access, usually the following two methods are used to provide access: 1) Develop a relatively general mini-program. When a specific merchant needs to access, a merchant branch is pulled from the main code branch, and functions are customized for the merchant on this branch, and even secondary development is done for the merchant; 2) Only keep a set of full-function mini-programs, and the same code is deployed for each merchant, and the merchant functions are turned on and off through switches. When accessing through the first method, if the number of accessing merchants is large, multiple code copies will be generated, resulting in difficult code maintenance. For example, when a general function in the mini-program is upgraded, the code needs to be synchronized from the main branch to each merchant branch; when accessing through the second method, regardless of whether the merchant needs this function or not, the entire code package of the mini-program needs to be downloaded to the client local. In the later stage of the project, the functions of the mini-program are more diversified, and the code package may exceed the pre-specified limit, resulting in the inability to continue maintaining the project. Therefore, in the prior art, there is a problem that the code of the third-party (such as a merchant) mini-program is difficult to maintain when accessing the mini-program, which will affect the performance and experience of the third-party mini-program. Summary of the Invention
[0004] The main purpose of the present invention is to provide a method, device, equipment and computer-readable storage medium for generating a mini-program, aiming to solve the problem that the code of the third-party mini-program is difficult to maintain when the third party accesses the mini-program in the prior art.
[0005] To achieve the above object, the present invention provides a method for generating a mini-program, and the method for generating a mini-program includes:
[0006] Obtain a third-party global configuration file, and store the third-party global configuration file in a preset directory;
[0007] Read the first target field information of the third-party global configuration file, obtain the target page, and copy the page file corresponding to the target page from the source code directory to the preset directory;
[0008] Analyze the dependent resources of the page file based on the page file and preset rules, and obtain the paths of the dependent resources;
[0009] Obtain the source code of the dependent resources from the source code directory according to the paths of the dependent resources, and copy it to the preset directory to generate a third-party applet.
[0010] Optionally, the page file includes a configuration file, a logic file, a template file, and a style file. The step of analyzing the dependent resources of the page file based on the page file and preset rules, and obtaining the paths of the dependent resources includes:
[0011] Obtain the path of the component from the configuration file according to the preset target parameter;
[0012] Obtain the path information of the dependent resources included in the logic file, the template file, and the style file;
[0013] According to the path information, obtain the paths of the dependent resources corresponding to the path information.
[0014] Optionally, the step of obtaining the path information of the dependent resources included in the logic file, the template file, and the style file includes:
[0015] Convert the source code of the logic file, the template file, and the style file into abstract syntax trees respectively through a preset tool;
[0016] Traverse each node of the abstract syntax tree using a depth-first search algorithm, and read the metadata of each node. The metadata includes path information.
[0017] Optionally, the step of obtaining the path information of the dependent resources included in the logic file, the template file, and the style file includes:
[0018] Match the preset regular expressions with the source code of the logic file, the template file, and the style file respectively, and obtain the path information according to the matching results.
[0019] Optionally, the step of obtaining the paths of the dependent resources corresponding to the path information according to the path information includes:
[0020] Detect whether the path information meets the preset conditions;
[0021] If the path information meets the preset conditions, determine the path of the dependent resource corresponding to the path information as the preset path;
[0022] If the path information does not meet the preset conditions, determine whether the path type corresponding to the path information is an absolute path or a relative path;
[0023] If the path type corresponding to the path information is an absolute path, determine the path of the dependent resource corresponding to the path information as the path corresponding to the path information;
[0024] If the path type corresponding to the path information is a relative path, obtain the relative path corresponding to the path information, and obtain the path of the dependent resource corresponding according to the relative path and the path information.
[0025] Optionally, before the step of obtaining the source code of the dependent resource from the source code directory according to the path of the dependent resource and copying it to the preset directory to generate a third-party applet, the following steps are further included:
[0026] Read the second target field information of the third-party global configuration file, and read the target field value in the second target field information to obtain the path of the icon picture;
[0027] Obtain the corresponding icon picture according to the path of the icon picture, and copy it to the preset directory.
[0028] Optionally, the step of copying the page file corresponding to the target page from the source code directory to the preset directory includes:
[0029] Obtain the page file corresponding to the target page from the source code directory, compile the preset specified parameter in the page file into a third-party identification number ID, and copy the compiled page file to the preset directory;
[0030] The step of obtaining the source code of the dependent resource from the source code directory according to the path of the dependent resource and copying it to the preset directory includes:
[0031] Obtain the source code of the dependent resource from the source code directory according to the path of the dependent resource, compile the preset specified parameter in the source code of the dependent resource into the third-party ID, and copy the compiled source code of the dependent resource to the preset directory.
[0032] In addition, to achieve the above object, the present invention further provides an applet generation device, and the applet generation device includes:
[0033] A file acquisition module, configured to acquire a third-party global configuration file and store the third-party global configuration file in a preset directory;
[0034] A first copying module, configured to read first target field information of the third-party global configuration file, acquire a target page, and copy a page file corresponding to the target page from a source code directory to the preset directory;
[0035] A path acquisition module, configured to analyze dependent resources of the page file based on the page file and a preset rule, and acquire paths of the dependent resources;
[0036] A second copying module, configured to acquire source codes of the dependent resources from the source code directory according to the paths of the dependent resources, and copy the source codes to the preset directory to generate a third-party applet.
[0037] In addition, to achieve the above object, the present invention further provides an applet generation device, where the applet generation device includes: a memory, a processor, and an applet generation program stored on the memory and executable on the processor, and when the applet generation program is executed by the processor, the steps of the above applet generation method are implemented.
[0038] In addition, to achieve the above object, the present invention further provides a computer-readable storage medium, where an applet generation program is stored on the computer-readable storage medium, and when the applet generation program is executed by a processor, the steps of the above applet generation method are implemented.
[0039] The present invention provides an applet generation method, device, device, and computer-readable storage medium. By acquiring a third-party global configuration file and storing the third-party global configuration file in a preset directory; reading first target field information of the third-party global configuration file, acquiring a target page, and copying a page file corresponding to the target page from a source code directory to the preset directory; analyzing dependent resources of the page file based on the page file and a preset rule, and acquiring paths of the dependent resources; acquiring source codes of the dependent resources from the source code directory according to the paths of the dependent resources, and copying the source codes to the preset directory to generate a third-party applet. In this way, by acquiring the global configuration file of the third-party applet (i.e., the third-party global configuration file) and generating an applicable and third-party applet with the minimum code amount according to the third-party global configuration file, the performance and experience of the third-party applet can be ensured. At the same time, in a configuration-based manner, only by modifying the third-party global configuration file, the third-party applet can be updated, thereby facilitating the maintenance of the third-party applet code. Description of the Drawings
[0040] Figure 1It is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the present invention;
[0041] Figure 2 It is a schematic flowchart of the first embodiment of the method for generating a small program of the present invention;
[0042] Figure 3 It is a schematic diagram of the functional modules of the first embodiment of the device for generating a small program of the present invention.
[0043] The realization, functional features and advantages of the object of the present invention will be further described with reference to the embodiments and the accompanying drawings. Detailed Embodiment
[0044] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0045] Refer to Figure 1 , Figure 1 It is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the present invention.
[0046] The small program generating device in the embodiment of the present invention can be a smart phone, or a PC (Personal Computer), a tablet computer, a portable computer and other terminal devices.
[0047] As Figure 1 shown, the small program generating device may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display) and an input unit such as a keyboard (Keyboard). Optionally, the user interface 1003 may further include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0048] Those skilled in the art can understand that Figure 1 the structure of the small program generating device shown in
[0049] does not constitute a limitation on the small program generating device, and may include more or fewer components than shown, or combine some components, or have different component arrangements. Figure 1As shown in the figure, the memory 1005, which is a computer storage medium, may include an operating system, a network communication module, a user interface module, and a mini-program generation program.
[0050] In Figure 1 In the terminal shown, the network interface 1004 is mainly used to connect to the background server and communicate with the background server for data; the user interface 1003 is mainly used to connect to the client and communicate with the client for data; and the processor 1001 can be used to call the mini-program generation program stored in the memory 1005 and execute each step of the following mini-program generation method.
[0051] Based on the above hardware structure, each embodiment of the mini-program generation method of the present invention is proposed.
[0052] The present invention provides a mini-program generation method.
[0053] Referring to Figure 2 , Figure 2 is a schematic flowchart of the first embodiment of the mini-program generation method of the present invention.
[0054] In this embodiment, the mini-program generation method includes:
[0055] Step S10, obtain a third-party global configuration file and store the third-party global configuration file in a preset directory;
[0056] The mini-program generation method of this embodiment is implemented by a mini-program generation device, and this device is described by taking a server as an example. In this embodiment, when a third party wants to access, a global configuration file can be maintained for the accessing third party in the code library according to the needs of the third party, denoted as the third-party global configuration file. Specifically, the server obtains the third-party global configuration file and stores the third-party global configuration file in a preset directory. Taking a WeChat mini-program as an example, the preset directory can be the dist directory (i.e., the code directory of the WeChat server). For the command of the third-party global configuration file, it needs to be named app.json to be recognized by WeChat. In addition, when there are multiple third parties accessing, corresponding multiple running code packages can be set under the dist directory, and the configuration file and the source code of the subsequent page files and dependent resources are copied into the corresponding running code packages.
[0057] Step S20, read the first target field information of the third-party global configuration file, obtain the target page, and copy the page file corresponding to the target page from the source code directory to the preset directory;
[0058] Read the information of the first target field in the third-party global configuration file to obtain the target page. Among them, the information of the first target field is the information corresponding to the "page" field. In a WeChat mini-program, the "page" field is used to specify which pages the mini-program consists of, and each item corresponds to the path (including the file name) information of a page. Therefore, by reading the information of the first target field, the target page (i.e., the page of the third-party mini-program) can be obtained. Then, copy the page file corresponding to the target page from the source code directory to the preset directory, that is, the dist directory. The page file includes a configuration file, a logic file, a template file, and a style file.
[0059] Step S30: Analyze the dependent resources of the page file based on the page file and preset rules, and obtain the paths of the dependent resources.
[0060] Then, analyze the dependent resources of the page file based on the page file and preset rules, and obtain the paths of the dependent resources. Among them, the dependent resources of the page file include code dependencies and static resource dependencies. Code dependencies include custom components of the mini-program, locally extracted and reused code, dependencies installed by npm (Node Package Manager), etc. Static resource dependencies include images, PDF files, audio and video files, etc.
[0061] In this embodiment, there are two types of methods for obtaining the paths of dependent resources. Specifically, the first type is to obtain the path of the custom component of the mini-program, which can directly obtain the path of the component from the configuration file according to the preset target parameters; the second type is to obtain the paths of the locally extracted and reused code, dependencies installed by npm, and images in the dependent resources, which can be obtained through the following two methods: 1) Use a preset tool to convert the source code of the logic file, template file, and style file into an abstract syntax tree respectively, and then traverse each node of the abstract syntax tree using a depth-first search algorithm, read the metadata of each node, and the metadata includes path information. Then, according to the path information, obtain the paths of the dependent resources corresponding to the path information; 2) Use the method of regular expression matching to obtain the path information, that is, use a preset regular expression to match the source code of the logic file, template file, and style file respectively, obtain the path information according to the matching result, and then according to the path information, obtain the paths of the dependent resources corresponding to the path information. The specific obtaining process can refer to the following embodiments and will not be elaborated here.
[0062] Step S40: Obtain the source code of the dependent resources from the source code directory according to the paths of the dependent resources, and copy them to the preset directory to generate a third-party mini-program.
[0063] Finally, obtain the source code of the dependent resources from the source code directory according to the paths of the dependent resources, and copy it to the preset directory to generate a third-party applet.
[0064] Further, before the above step S40, the applet generation method further includes:
[0065] Read the second target field information of the third-party global configuration file, and read the target field value in the second target field information to obtain the path of the icon picture;
[0066] Obtain the corresponding icon picture according to the path of the icon picture, and copy it to the preset directory.
[0067] In this embodiment, since there may also be pictures in the tabBar field of the third-party global configuration file, correspondingly, the second target field information of the third-party global configuration file can be read, and the target field value in the second target field information can be read to obtain the path of the icon picture. Among them, the second target field information is the information of the tabBar (tab) field. If the applet is a multi-tab application (there is a tab (label) bar at the bottom or top of the client window to switch pages), the performance of the tab bar and the corresponding pages displayed when tab switching can be specified through the tabBar configuration item; the target field value is the field value of the icon (icon) path, that is, iconpath (icon path). Then, after obtaining the path of the icon picture, obtain the corresponding icon picture according to the path of the icon picture, and copy it to the preset directory, that is, the dist directory.
[0068] An embodiment of the present invention provides an applet generation method. By obtaining a third-party global configuration file and storing the third-party global configuration file in a preset directory; reading the first target field information of the third-party global configuration file, obtaining the target page, and copying the page file corresponding to the target page from the source code directory to the preset directory; analyzing the dependent resources of the page file based on the page file and preset rules, and obtaining the paths of the dependent resources; obtaining the source code of the dependent resources from the source code directory according to the paths of the dependent resources, and copying it to the preset directory to generate a third-party applet. In the above manner, by obtaining the global configuration file of the third-party applet (that is, the third-party global configuration file) and generating an applicable applet with the smallest code amount that meets the corresponding third party according to the third-party global configuration file, the performance and experience of the third-party applet can be guaranteed. At the same time, in a configuration-based manner, only by modifying the third-party global configuration file can the third-party applet be updated, thereby facilitating the maintenance of the third-party applet code.
[0069] Specifically, in the above first embodiment, the page file includes a configuration file, a logic file, a template file, and a style file, and step S40 includes:
[0070] Step a1, obtain the path of the component from the configuration file according to the preset target parameter;
[0071] For obtaining the component path, the path of the component can be directly obtained from the configuration file according to the preset target parameter. Among them, the preset target parameter is "using Components", and by directly reading the "using Components" field of the configuration file, the path of the component can be obtained.
[0072] Alternatively, step S40 includes:
[0073] Step a2, obtain the path information of the dependent resources included in the logic file, the template file, and the style file;
[0074] Then, obtain the path information of the dependent resources included in the logic file, the template file, and the style file. The dependent resources included in these three types of files are locally extracted and reused code, npm-installed dependent packages, and pictures.
[0075] As one implementation manner, step a2 may include:
[0076] Step a21, respectively convert the source codes of the logic file, the template file, and the style file into abstract syntax trees through a preset tool;
[0077] Step a22, traverse each node of the abstract syntax tree by using a depth-first search algorithm, and read the metadata of each node. The metadata includes path information.
[0078] In this embodiment, the source codes of the logic file, the template file, and the style file can be respectively converted into abstract syntax trees (Abstract Syntax Tree, AST) through a preset tool. Among them, the preset tool can be babel (a JavaScript compiler). Of course, in a specific embodiment, other methods can also be used to convert the source codes of the logic file, the template file, and the style file into abstract syntax trees.
[0079] Then, the depth - first search algorithm is used to traverse each node of the abstract syntax tree and read the metadata of each node, where the metadata includes path information. Specifically, when the preset tool is babel, babel - traverse can be used to traverse the AST tree, and the corresponding metadata can be read through the mounted metadataVisitor. For example, in the page code, a tool library is introduced through the es6 module import method, that is, "import{add}from \".. / util.js\";". After being converted into an AST tree by the babylon interpreter, this statement corresponds to a node of type ImportDeclaration (import declaration) on the AST tree, and this node contains all the metadata of this statement. The metadata field source in the node represents the path information of the tool library file, and it is extracted as the basis for finding the corresponding code file.
[0080] It should be noted that the depth - first search (DFS) algorithm belongs to a type of graph algorithm and is a traversal algorithm for graphs and trees. Briefly speaking, its process is to go deep into each possible branch path until it can no longer go deeper, and each node can only be visited once. When there are many nodes in the abstract syntax tree, it is easy to cause memory overflow using other methods. However, using the depth - first search algorithm to traverse each node of the abstract syntax tree can reduce memory consumption and avoid memory overflow.
[0081] As another implementation, step a2 may further include:
[0082] Step a23, using a preset regular expression to match the source codes of the logic file, the template file, and the style file respectively, and obtaining path information according to the matching results.
[0083] In this embodiment, path information can also be obtained by the method of regular expression matching. Specifically, a preset regular expression can be used to match the source codes of the logic file, the template file, and the style file respectively, and path information can be obtained according to the matching results. For example, in the above example, in the page code, a tool library is introduced through the es6 module import method, that is, "import{add}from \".. / util.js\";". The following regular expression can be used to extract the es6 module import statement from the source code: "^(import)(?:.*?(as))?(?:.*?(as))?(?:.*?(from))*.*$". This regular expression corresponds to all patterns of the es6 module import statement syntax, ensuring that no matter how the developer writes this statement in standard syntax, it can be recognized from the source code. After obtaining the es6 statement in the code, the path information after the from keyword can be obtained through simple string operations.
[0084] Step a3: Obtain the path of the dependent resource corresponding to the path information according to the path information.
[0085] After obtaining the path information, obtain the path of the dependent resource corresponding to the path information according to the path information. Specifically, step a3 includes:
[0086] Step a31: Detect whether the path information meets a preset condition;
[0087] Step a32: If the path information meets the preset condition, determine that the path of the dependent resource corresponding to the path information is the preset path;
[0088] In this embodiment, first detect whether the path information meets the preset condition. Here, the preset condition is that the path information does not contain / . If the path information does not contain / , that is, when the preset condition is met, determine that the path of the dependent resource corresponding to the path information is the preset path. For example, for the following two statements:
[0089] import{Page}from'wxa';
[0090] import{Page}from'. / wxa';
[0091] The part after 'from' in the above two statements corresponds to the path information. The first path information does not contain / , indicating that it is a dependent tool installed through the npm package management tool, and the installation path of this tool is defaulted to a preset path, such as the node_modules directory under the project root directory. While the second path information contains / , indicating that this is a tool written by oneself, so it does not meet the preset condition and needs to further determine the path according to this path information.
[0092] Step a33: If the path information does not meet the preset condition, determine whether the path type corresponding to the path information is an absolute path or a relative path;
[0093] Step a34: If the path type corresponding to the path information is an absolute path, determine that the path of the dependent resource corresponding to the path information is the path corresponding to the path information;
[0094] Step a35: If the path type corresponding to the path information is a relative path, obtain the relative path corresponding to the path information, and obtain the path of the corresponding dependent resource according to the relative path and the path information.
[0095] If the path information does not meet the preset conditions, it is necessary to further determine whether the path type corresponding to the path information is an absolute path or a relative path. Specifically, it can be determined as an absolute path or a relative path according to the format of the path information. / represents the root directory and is an absolute path;. / represents the current path, and.. / represents the upper-level directory, which belongs to the relative path.
[0096] If the path type corresponding to the path information is an absolute path, determine that the path of the dependent resource corresponding to the path information is the path corresponding to the path information. For example, if the obtained path information is / util.js, it is an absolute path, and the corresponding dependent resource can be directly obtained according to this path.
[0097] If the path type corresponding to the path information is a relative path, obtain the relative path corresponding to the path information, and obtain the path of the corresponding dependent resource according to the relative path and the path information. For example, if the path information is.. / util.js, it is necessary to obtain the corresponding relative path, such as / pages / index, and then combine these two paths to obtain the path of the corresponding dependent resource, such as / pages / index / util.js.
[0098] Further, based on Figure 2 the first embodiment shown, a second embodiment of the method for generating a mini-program of the present invention is proposed.
[0099] In this embodiment, the step of "copying the page file corresponding to the target page from the source code directory to the preset directory" includes:
[0100] Obtain the page file corresponding to the target page from the source code directory, compile the preset specified parameter in the page file into a third-party identification number ID, and copy the compiled page file to the preset directory.
[0101] In this embodiment, when different third parties are connected, a third-party ID (identification number) can be registered and assigned to each merchant according to the third-party information (such as name) or preset rules. During the copying process, the preset specified parameter is compiled, and the preset specified parameter is compiled into a third-party ID, and then the compiled page file or source code is copied to the preset directory to be used to distinguish the third parties to which the generated third-party mini-programs belong.
[0102] Specifically, after the server reads the first target field information (pages) of the third-party global configuration file and obtains the target page, it obtains the page file corresponding to the target page from the source code directory, then compiles the preset specified parameters in the page file into a third-party identification number ID, and copies the compiled page file to the preset directory. The preset specified parameters are set according to the source code of the applet. For example, if a protocol needs to be signed in the code and the corresponding paths are http: / / bank.com / BANK_APPID / xieyi.pdf, the preset specified parameter can be set as BANK_APPID at this time. During compilation, BANK_APPID can be replaced with the third-party ID.
[0103] After copying the compiled page file to the preset directory, analyze the dependent resources of the page file based on the page file and the preset rules, and obtain the paths of the dependent resources. The specific path acquisition method can refer to the above embodiments and will not be elaborated here.
[0104] At this time, the step of "obtaining the source code of the dependent resource from the source code directory according to the path of the dependent resource and copying it to the preset directory" includes:
[0105] Obtain the source code of the dependent resource from the source code directory according to the path of the dependent resource, compile the preset specified parameter in the source code of the dependent resource into the third-party ID, and copy the compiled source code of the dependent resource to the preset directory.
[0106] After obtaining the path of the dependent resource, obtain the source code of the dependent resource from the source code directory according to the path of the dependent resource, then compile the preset specified parameter in the source code of the dependent resource into the third-party ID, and copy the compiled source code of the dependent resource to the preset directory to generate a third-party applet.
[0107] In the above manner, during the copying process, the preset specified parameter is compiled, the preset specified parameter is compiled into a third-party ID, and then the compiled page file or source code is copied to the preset directory, so as to distinguish the third parties to which the generated third-party applets belong.
[0108] The present invention also provides an applet generation device.
[0109] Refer to Figure 3 , Figure 3 which is a schematic diagram of the functional modules of the first embodiment of the applet generation device of the present invention.
[0110] As Figure 3 shown, the applet generation device includes:
[0111] A file acquisition module 10, configured to acquire a third-party global configuration file and store the third-party global configuration file in a preset directory;
[0112] A first copying module 20, configured to read first target field information of the third-party global configuration file, acquire a target page, and copy a page file corresponding to the target page from a source code directory to the preset directory;
[0113] A path acquisition module 30, configured to analyze dependent resources of the page file based on the page file and a preset rule, and acquire paths of the dependent resources;
[0114] A second copying module 40, configured to acquire source codes of the dependent resources from the source code directory according to the paths of the dependent resources, and copy the source codes to the preset directory to generate a third-party applet.
[0115] Further, the path acquisition module 30 includes:
[0116] A first acquisition unit, configured to acquire paths of components from the configuration file according to preset target parameters;
[0117] A second acquisition unit, configured to acquire path information of dependent resources included in the logic file, the template file, and the style file;
[0118] A third acquisition unit, configured to obtain paths of the dependent resources corresponding to the path information according to the path information.
[0119] Further, the second acquisition unit is specifically configured to: respectively convert source codes of the logic file, the template file, and the style file into abstract syntax trees through a preset tool; traverse each node of the abstract syntax tree by using a depth-first search algorithm, and read metadata of each node, where the metadata includes path information.
[0120] Further, the second acquisition unit is also specifically configured to: respectively match a preset regular expression with source codes of the logic file, the template file, and the style file, and obtain path information according to a matching result.
[0121] Further, the third obtaining unit is specifically configured to: detect whether the path information meets a preset condition; if the path information meets the preset condition, determine the path of the dependent resource corresponding to the path information as a preset path; if the path information does not meet the preset condition, determine whether the path type corresponding to the path information is an absolute path or a relative path; if the path type corresponding to the path information is an absolute path, determine the path of the dependent resource corresponding to the path information as the path corresponding to the path information; if the path type corresponding to the path information is a relative path, obtain the relative path corresponding to the path information, and obtain the path of the corresponding dependent resource according to the relative path and the path information.
[0122] Further, the applet generation device further includes:
[0123] A reading module, configured to read the second target field information of the third-party global configuration file, and read the target field value in the second target field information to obtain the path of the icon picture;
[0124] A third copying module, configured to obtain the corresponding icon picture according to the path of the icon picture, and copy it to the preset directory.
[0125] Further, the first copying module 20 is specifically configured to:
[0126] Obtain the page file corresponding to the target page from the source code directory, compile the preset specified parameter in the page file into a third-party identification number ID, and copy the compiled page file to the preset directory;
[0127] Further, the second copying module 40 is specifically configured to:
[0128] Obtain the source code of the dependent resource from the source code directory according to the path of the dependent resource, compile the preset specified parameter in the source code of the dependent resource into the third-party ID, and copy the compiled source code of the dependent resource to the preset directory.
[0129] Wherein, the functions of each module in the above applet generation device correspond to the steps in the above applet generation method embodiments, and their functions and implementation processes will not be elaborated here one by one.
[0130] The present invention also provides a computer-readable storage medium, on which a program for generating an applet is stored, and when the program for generating an applet is executed by a processor, the steps of the applet generation method described in any one of the above embodiments are implemented.
[0131] The specific embodiments of the computer-readable storage medium of the present invention are substantially the same as those of the above-mentioned small program generation method, and will not be described in detail here.
[0132] It should be noted that in this document, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or system. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or system including the element.
[0133] The serial numbers of the above embodiments of the present invention are only for description and do not represent the superiority or inferiority of the embodiments.
[0134] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc) as described above, and includes several instructions for causing a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0135] The above are only the preferred embodiments of the present invention, and do not limit the patent scope of the present invention accordingly. Any equivalent structure or equivalent process transformation made by using the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present invention.
Claims
1. A method for generating a mini-program, characterized in that, the method for generating the mini-program includes: Obtain a third-party global configuration file and store the third-party global configuration file in a preset directory; Read the first target field information of the third-party global configuration file, obtain a target page, and copy the page file corresponding to the target page from the source code directory to the preset directory; wherein, the first target field information is the information corresponding to the page field, the page field is used to specify the page composition included in the third-party mini-program, each item in the page field corresponds to the path information of a page, the target page is the page of the third-party mini-program, and the target page is obtained by reading the information corresponding to the page field and then based on the path information of the page of the third-party mini-program corresponding to the information corresponding to the page field; Analyze the dependent resources of the page file based on the page file and preset rules, and obtain the paths of the dependent resources; Obtain the source code of the dependent resources from the source code directory according to the paths of the dependent resources and copy it to the preset directory to generate a third-party mini-program.
2. The method for generating a mini-program according to claim 1, characterized in that, the page file includes a configuration file, a logic file, a template file and a style file, and the step of analyzing the dependent resources of the page file based on the page file and preset rules and obtaining the paths of the dependent resources includes: Obtain the path of the component from the configuration file according to the preset target parameters; Obtain the path information of the dependent resources included in the logic file, the template file and the style file; According to the path information, obtain the paths of the dependent resources corresponding to the path information.
3. The method for generating a mini-program according to claim 2, characterized in that, the step of obtaining the path information of the dependent resources included in the logic file, the template file and the style file includes: Convert the source codes of the logic file, the template file and the style file into abstract syntax trees respectively through a preset tool; Traverse each node of the abstract syntax tree by using a depth-first search algorithm, and read the metadata of each node, and the metadata includes path information.
4. The method for generating a mini-program according to claim 2, characterized in that, the step of obtaining the path information of the dependent resources included in the logic file, the template file and the style file includes: Match a preset regular expression with the source codes of the logic file, the template file and the style file respectively, and obtain path information according to the matching results.
5. The method for generating a mini-program according to any one of claims 2 to 4, characterized in that, the step of obtaining the paths of the dependent resources corresponding to the path information according to the path information includes: Detect whether the path information meets a preset condition; If the path information meets the preset condition, determine that the path of the dependent resource corresponding to the path information is a preset path; If the path information does not meet the preset conditions, determine whether the path type corresponding to the path information is an absolute path or a relative path; If the path type corresponding to the path information is an absolute path, determine that the path of the dependent resource corresponding to the path information is the path corresponding to the path information; If the path type corresponding to the path information is a relative path, obtain the relative path corresponding to the path information, and obtain the path of the corresponding dependent resource according to the relative path and the path information.
6. The mini-program generation method according to claim 1, characterized in that, Before the step of obtaining the source code of the dependent resource from the source code directory according to the path of the dependent resource and copying it to the preset directory to generate a third-party mini-program, it further includes: Reading the second target field information of the third-party global configuration file, and reading the target field value in the second target field information to obtain the path of the icon picture; wherein, the second target field information is the information of the tab field, the target field value is the field value of the icon path in the information of the tab field, and the icon path is the path of the icon picture; Obtaining the corresponding icon picture according to the path of the icon picture, and copying it to the preset directory.
7. The mini-program generation method according to claim 1, characterized in that, The step of copying the page file corresponding to the target page from the source code directory to the preset directory includes: Obtaining the page file corresponding to the target page from the source code directory, compiling the preset specified parameter in the page file into a third-party identification number ID, and copying the compiled page file to the preset directory; The step of obtaining the source code of the dependent resource from the source code directory according to the path of the dependent resource and copying it to the preset directory includes: Obtaining the source code of the dependent resource from the source code directory according to the path of the dependent resource, compiling the preset specified parameter in the source code of the dependent resource into the third-party ID, and copying the compiled source code of the dependent resource to the preset directory.
8. A mini-program generation device, characterized in that, The mini-program generation device includes: A file acquisition module, configured to acquire a third-party global configuration file and store the third-party global configuration file in a preset directory; A first copying module, configured to read the first target field information of the third-party global configuration file, acquire a target page, and copy the page file corresponding to the target page from the source code directory to the preset directory; wherein, the first target field information is the information corresponding to the page field, the page field is used to specify the page composition included in the third-party mini-program, each item in the page field corresponds to the path information of a page, the target page is the page of the third-party mini-program, and the target page is obtained by reading the information corresponding to the page field and then based on the path information of the page of the third-party mini-program corresponding to the information corresponding to the page field; A path acquisition module, configured to analyze dependent resources of the page file based on the page file and a preset rule, and acquire paths of the dependent resources; A second copying module, configured to acquire source codes of the dependent resources from the source code directory according to the paths of the dependent resources, and copy the source codes to the preset directory to generate a third-party applet.
9. An applet generation device, characterized in that, the applet generation device includes: a memory, a processor, and an applet generation program stored on the memory and executable on the processor, and when the applet generation program is executed by the processor, the steps of the applet generation method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that, an applet generation program is stored on the computer-readable storage medium, and when the applet generation program is executed by a processor, the steps of the applet generation method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Software version management method and device
CN109426516A
Application program generation method, device, equipment and system
CN110032358A