Movatterモバイル変換


[0]ホーム

URL:


CN110532029A - Small routine generation method, device, equipment and computer readable storage medium - Google Patents

Small routine generation method, device, equipment and computer readable storage medium
Download PDF

Info

Publication number
CN110532029A
CN110532029ACN201910835860.XACN201910835860ACN110532029ACN 110532029 ACN110532029 ACN 110532029ACN 201910835860 ACN201910835860 ACN 201910835860ACN 110532029 ACN110532029 ACN 110532029A
Authority
CN
China
Prior art keywords
path
file
resource
party
source code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910835860.XA
Other languages
Chinese (zh)
Other versions
CN110532029B (en
Inventor
黎俊标
文泽添
林挺
卢道和
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co LtdfiledCriticalWeBank Co Ltd
Priority to CN201910835860.XApriorityCriticalpatent/CN110532029B/en
Publication of CN110532029ApublicationCriticalpatent/CN110532029A/en
Application grantedgrantedCritical
Publication of CN110532029BpublicationCriticalpatent/CN110532029B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Classifications

Landscapes

Abstract

Translated fromChinese

本发明涉及金融科技技术领域,公开了一种小程序生成方法、装置、设备及计算机可读存储介质。该方法包括:获取第三方全局配置文件,并将所述第三方全局配置文件存储到预设目录下;读取所述第三方全局配置文件的第一目标字段信息,获取目标页面,并从源码目录中将与所述目标页面对应的页面文件复制到所述预设目录下;基于所述页面文件和预设规则分析所述页面文件的依赖资源,并获取所述依赖资源的路径;根据所述依赖资源的路径从所述源码目录中获取所述依赖资源的源代码,并复制到所述预设目录下,以生成第三方小程序。本发明能够解决现有技术中第三方接入小程序时、第三方小程序的代码难以维护的问题。

The invention relates to the technical field of financial science and technology, and discloses a small program generation method, device, equipment and computer-readable storage medium. The method includes: 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 a target page, and Copy the page file corresponding to the target page in the directory to the preset directory; analyze the dependent resources of the page file based on the page file and preset rules, and obtain the path of the dependent resource; according to the Obtain the source code of the dependent resource from the source code directory and copy it to the preset directory to generate a third-party applet. The invention can solve the problem in the prior art that when a third party accesses the applet, the code of the third-party applet is difficult to maintain.

Description

Translated fromChinese
小程序生成方法、装置、设备及计算机可读存储介质Small program generation method, device, equipment and computer-readable storage medium

技术领域technical field

本发明涉及金融科技(Fintech)技术领域,尤其涉及一种小程序生成方法、装置、设备及计算机可读存储介质。The present invention relates to the technical field of financial technology (Fintech), in particular to a small program generation method, device, equipment and computer-readable storage medium.

背景技术Background technique

随着计算机技术的发展,越来越多的技术(大数据、分布式、区块链Blockchain、人工智能等)应用在金融领域,传统金融业正在逐步向金融科技(Fintech)转变,但由于金融行业的安全性、实时性要求,也对技术提出了更高的要求。With the development of computer technology, more and more technologies (big data, distributed, blockchain, artificial intelligence, etc.) The industry's security and real-time requirements also put forward higher requirements for technology.

随着计算机技术的不断发展,各种应用走进了人们日常生活中,而小程序作为一种不需要下载安装即可使用的应用,更是得到了各行各业的广泛关注。目前,很多银行等金融机构会开发一些应用小程序,提供相关的功能,同时支持商户的接入。具体的,当有商户需要接入时,通常通过以下2种方式提供接入:1)开发一套比较通用的小程序,当需要接入具体商户时,从代码主分支拉取一个商户分支,并在该分支上为商户定制功能,甚至为商户做二次开发;2)只保留一套全功能的小程序,每个商户都部署同样的代码,通过开关来开启关闭商户功能。通过第1)种方式接入时,若接入商户数量较多,会产生多个代码副本,导致代码难以维护,例如小程序中某个通用功能升级时,需要把代码从主分支同步到各个商户分支;通过第2)种方式接入时,无论商户是否需要该功能,都需要把小程序的整个代码包下载到客户端本地。在项目后期,小程序功能较为多样化,代码包可能会超过预先规定的上限,从而导致项目无法继续维护。因此,现有技术中存在第三方(如商户)接入小程序时、第三方小程序的代码难以维护的问题,会影响第三方小程序的性能和体验。With the continuous development of computer technology, various applications have entered people's daily life, and applets, as an application that can be used without downloading and installing, have attracted widespread attention from all walks of life. At present, many banks and other financial institutions will develop some application applets to provide related functions and support merchants' access. Specifically, when a merchant needs to access, access is usually provided in the following two ways: 1) Develop a set of relatively general small programs, and when a specific merchant needs to be accessed, a merchant branch is pulled from the main branch of the code, And customize functions for merchants on this branch, and even do secondary development for merchants; 2) Only keep a set of full-featured applets, and each merchant deploys the same code to enable and disable merchant functions through switches. When accessing through method 1), if there are a large number of merchants, multiple code copies will be generated, making it difficult to maintain the code. Merchant branch; when accessing through method 2), no matter whether the merchant needs this function or not, it is necessary to download the entire code package of the applet to the local client. In the later stage of the project, the functions of the applet are more diversified, and the code package may exceed the pre-specified upper limit, resulting in the failure of the project to continue to be maintained. Therefore, in the prior art, when a third party (such as a merchant) accesses the applet, the code of the third-party applet is difficult to maintain, which will affect the performance and experience of the third-party applet.

发明内容Contents of the invention

本发明的主要目的在于提供一种小程序生成方法、装置、设备及计算机可读存储介质,旨在解决现有技术中第三方接入小程序时、第三方小程序的代码难以维护的问题。The main purpose of the present invention is to provide a small program generation method, device, equipment and computer-readable storage medium, aiming to solve the problem in the prior art that the code of the third-party small program is difficult to maintain when a third party accesses the small program.

为实现上述目的,本发明提供一种小程序生成方法,所述小程序生成方法包括:In order to achieve the above purpose, the present invention provides a small program generation method, the small program generation method 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 the target page, and copy the page file corresponding to the target page from the source code directory to the preset directory;

基于所述页面文件和预设规则分析所述页面文件的依赖资源,并获取所述依赖资源的路径;analyzing dependent resources of the page file based on the page file and preset rules, and obtaining paths of the dependent resources;

根据所述依赖资源的路径从所述源码目录中获取所述依赖资源的源代码,并复制到所述预设目录下,以生成第三方小程序。The source code of the dependent resource is obtained from the source code directory according to the path of the dependent resource, and copied to the preset directory to generate a third-party applet.

可选地,所述页面文件包括配置文件、逻辑文件、模板文件和样式文件,所述基于所述页面文件和预设规则分析所述页面文件的依赖资源,并获取所述依赖资源的路径的步骤包括:Optionally, the page file includes a configuration file, a logic file, a template file, and a style file, and the dependent resource of the page file is analyzed based on the page file and preset rules, and the path of the dependent resource is obtained. Steps include:

根据预设目标参数从所述配置文件中获取组件的路径;Obtain the path of the component from the configuration file according to the preset target parameter;

获取所述逻辑文件、所述模板文件和所述样式文件中所包含的依赖资源的路径信息;Obtain path information of dependent resources included in the logic file, the template file, and the style file;

根据所述路径信息,得到所述路径信息对应的依赖资源的路径。According to the path information, a path of dependent resources corresponding to the path information is obtained.

可选地,所述获取所述逻辑文件、所述模板文件和所述样式文件中所包含的依赖资源的路径信息的步骤包括:Optionally, the step of obtaining path information of dependent resources contained in the logic file, the template file and the style file includes:

通过预设工具分别将所述逻辑文件、所述模板文件和所述样式文件的源代码转换成抽象语法树;converting the source codes of the logic file, the template file, and the style file into an abstract syntax tree by a preset tool;

采用深度优先搜索算法遍历所述抽象语法树的各节点,读取各节点的元数据,所述元数据包括路径信息。Each node of the abstract syntax tree is traversed by adopting a depth-first search algorithm, and metadata of each node is read, and the metadata includes path information.

可选地,所述获取所述逻辑文件、所述模板文件和所述样式文件中所包含的依赖资源的路径信息的步骤包括:Optionally, the step of obtaining path information of dependent resources contained in the logic file, the template file and the style file includes:

采用预设正则表达式分别与所述逻辑文件、所述模板文件和所述样式文件的源代码进行匹配,根据匹配结果得到路径信息。The preset regular expressions are used to match the source codes of the logic file, the template file and the style file respectively, and path information is obtained according to the matching result.

可选地,所述根据所述路径信息,得到所述路径信息对应的依赖资源的路径的步骤包括:Optionally, the step of obtaining the resource-dependent path corresponding to the path information according to the path information includes:

检测所述路径信息是否满足预设条件;Detecting whether the path information satisfies a preset condition;

若所述路径信息满足预设条件,则确定所述路径信息对应的依赖资源的路径为预设路径;If the path information satisfies a preset condition, then determine that the resource-dependent path corresponding to the path information is a preset path;

若所述路径信息不满足预设条件,则判断所述路径信息对应的路径类型为绝对路径还是相对路径;If the path information does not satisfy the preset condition, then judging 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 resource-dependent path 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 a corresponding resource-dependent path according to the relative path and the path information.

可选地,所述根据所述依赖资源的路径从所述源码目录中获取所述依赖资源的源代码,并复制到所述预设目录下,以生成第三方小程序的步骤之前,还包括: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, further includes :

读取所述第三方全局配置文件的第二目标字段信息,并读取所述第二目标字段信息中的目标字段值,得到图标图片的路径;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;

根据所述图标图片的路径获取对应的图标图片,并复制到所述预设目录下。Obtain the corresponding icon picture according to the path of the icon picture, and copy it to the preset directory.

可选地,所述从源码目录中将与所述目标页面对应的页面文件复制到所述预设目录下的步骤包括:Optionally, the step of copying the page file corresponding to the target page from the source code directory to the preset directory includes:

从源码目录中获取与所述目标页面对应的页面文件,将所述页面文件中的预设指定参数编译为第三方标识号ID,并将编译后的页面文件复制到所述预设目录下;Obtaining the page file corresponding to the target page from the source code directory, compiling the preset specified parameters 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:

根据所述依赖资源的路径从所述源码目录中获取所述依赖资源的源代码,将所述依赖资源的源代码中的所述预设指定参数编译为所述第三方ID,并将编译后的依赖资源的源代码复制到所述预设目录下。Acquire the source code of the dependent resource from the source code directory according to the path of the dependent resource, compile the preset specified parameters in the source code of the dependent resource into the third-party ID, and compile the compiled The source code of the dependent resources is copied to the preset directory.

此外,为实现上述目的,本发明还提供一种小程序生成装置,所述小程序生成装置包括:In addition, in order to achieve the above object, the present invention also provides a small program generation device, the small program generation device includes:

文件获取模块,用于获取第三方全局配置文件,并将所述第三方全局配置文件存储到预设目录下;A file obtaining module, configured to obtain a third-party global configuration file, and store the third-party global configuration file in a preset directory;

第一复制模块,用于读取所述第三方全局配置文件的第一目标字段信息,获取目标页面,并从源码目录中将与所述目标页面对应的页面文件复制到所述预设目录下;The first copying module is used to 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 ;

路径获取模块,用于基于所述页面文件和预设规则分析所述页面文件的依赖资源,并获取所述依赖资源的路径;a path acquisition module, configured to analyze dependent resources of the page file based on the page file and preset rules, and acquire the path of the dependent resource;

第二复制模块,用于根据所述依赖资源的路径从所述源码目录中获取所述依赖资源的源代码,并复制到所述预设目录下,以生成第三方小程序。The second copying module is used to obtain the source code of the dependent resource from the source code directory according to the path of the dependent resource, and copy it to the preset directory to generate a third-party applet.

此外,为实现上述目的,本发明还提供一种小程序生成设备,所述小程序生成设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的小程序生成程序,所述小程序生成程序被所述处理器执行时实现如上所述的小程序生成方法的步骤。In addition, in order to achieve the above object, the present invention also provides a small program generation device, the small program generation device includes: a memory, a processor, and a small program generation device stored in the memory and operable on the processor. A program, when the applet generating program is executed by the processor, implements the steps of the applet generating method described above.

此外,为实现上述目的,本发明还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有小程序生成程序,所述小程序生成程序被处理器执行时实现如上所述的小程序生成方法的步骤。In addition, in order to achieve the above object, the present invention also provides a computer-readable storage medium, the computer-readable storage medium stores a small program generation program, and when the small program generation program is executed by a processor, the above-mentioned The steps of the applet generation method.

本发明提供一种小程序生成方法、装置、设备及计算机可读存储介质,通过获取第三方全局配置文件,并将第三方全局配置文件存储到预设目录下;读取第三方全局配置文件的第一目标字段信息,获取目标页面,并从源码目录中将与目标页面对应的页面文件复制到预设目录下;基于页面文件和预设规则分析页面文件的依赖资源,并获取依赖资源的路径;根据依赖资源的路径从源码目录中获取依赖资源的源代码,并复制到预设目录下,以生成第三方小程序。通过上述方式,通过获取第三方小程序的全局配置文件(即第三方全局配置文件),并根据该第三方全局配置文件生成最小代码量的适用并且满足对应第三方的小程序,可保证第三方小程序性能和体验。同时,通过配置化的方式,只需修改第三方全局配置文件,即可更新第三方小程序,从而可便于第三方小程序代码的维护。The present invention provides a small program generation method, device, equipment and computer-readable storage medium, by obtaining a third-party global configuration file and storing the third-party global configuration file in a preset directory; reading the third-party global configuration file First target field information, get the target page, and copy the page file corresponding to the target page from the source code directory to the preset directory; analyze the dependent resources of the page file based on the page file and preset rules, and obtain 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, and copy it to the preset directory to generate a third-party applet. Through the above method, by obtaining the global configuration file of the third-party applet (that is, the third-party global configuration file), and according to the third-party global configuration file to generate the minimum code amount applicable to the applet corresponding to the third party, it can ensure that the third-party Applet performance and experience. At the same time, through configuration, the third-party applet can be updated only by modifying the third-party global configuration file, which facilitates the maintenance of the code of the third-party applet.

附图说明Description of drawings

图1为本发明实施例方案涉及的硬件运行环境的设备结构示意图;FIG. 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the present invention;

图2为本发明小程序生成方法第一实施例的流程示意图;FIG. 2 is a schematic flowchart of the first embodiment of the applet generation method of the present invention;

图3为本发明小程序生成装置第一实施例的功能模块示意图。Fig. 3 is a schematic diagram of the functional modules of the first embodiment of the applet generation device of the present invention.

本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization of the purpose of the present invention, functional characteristics and advantages will be further described in conjunction with the embodiments and with reference to the accompanying drawings.

具体实施方式Detailed ways

应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.

参照图1,图1为本发明实施例方案涉及的硬件运行环境的设备结构示意图。Referring to FIG. 1 , FIG. 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the present invention.

本发明实施例小程序生成设备可以是智能手机,也可以是PC(PersonalComputer,个人计算机)、平板电脑、便携计算机等终端设备。The applet generation device in the embodiment of the present invention may be a smart phone, or a terminal device such as a PC (Personal Computer, personal computer), a tablet computer, or a portable computer.

如图1所示,该小程序生成设备可以包括:处理器1001,例如CPU,通信总线1002,用户接口1003,网络接口1004,存储器1005。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如Wi-Fi接口)。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。As shown in FIG. 1 , the applet 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 . Wherein, the communication bus 1002 is used to realize connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. Optionally, the network interface 1004 may include a standard wired interface and a wireless interface (such as a Wi-Fi interface). The memory 1005 can 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 .

本领域技术人员可以理解,图1中示出的小程序生成设备结构并不构成对小程序生成设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Those skilled in the art can understand that the structure of the applet generating device shown in FIG. layout of the components.

如图1所示,作为一种计算机存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及小程序生成程序。As shown in FIG. 1 , the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an applet generation program.

在图1所示的终端中,网络接口1004主要用于连接后台服务器,与后台服务器进行数据通信;用户接口1003主要用于连接客户端,与客户端进行数据通信;而处理器1001可以用于调用存储器1005中存储的小程序生成程序,并执行以下小程序生成方法的各个步骤。In the terminal shown in Figure 1, the network interface 1004 is mainly used to connect to the background server and perform data communication with the background server; the user interface 1003 is mainly used to connect to the client and perform data communication with the client; and the processor 1001 can be used for The applet generating program stored in the memory 1005 is called, and each step of the following applet generating method is executed.

基于上述硬件结构,提出本发明小程序生成方法的各实施例。Based on the above hardware structure, various embodiments of the applet generation method of the present invention are proposed.

本发明提供一种小程序生成方法。The invention provides a small program generating method.

参照图2,图2为本发明小程序生成方法第一实施例的流程示意图。Referring to FIG. 2 , FIG. 2 is a schematic flowchart of a first embodiment of a method for generating a small program according to the present invention.

在本实施例中,该小程序生成方法包括:In this embodiment, the applet generation method includes:

步骤S10,获取第三方全局配置文件,并将所述第三方全局配置文件存储到预设目录下;Step S10, obtaining a third-party global configuration file, and storing the third-party global configuration file in a preset directory;

本实施例的小程序生成方法是由小程序生成设备实现的,该设备以服务器为例进行说明。在本实施例中,当有第三方想要接入时,可根据第三方的需求在代码库中为接入的第三方维护一个全局配置文件,记为第三方全局配置文件,具体的,服务器获取第三方全局配置文件,并将第三方全局配置文件存储到预设目录下,以微信小程序为例,预设目录可以为dist目录(即微信服务器的代码目录),对于第三方全局配置文件的命令,需命名成app.json,以被微信识别。此外,存在多个第三方接入,可对应在dist目录下设置对应的多个运行代码包,将配置文件及后续的页面文件和依赖资源的源代码复制到对应运行代码包中。The applet generating method in this embodiment is implemented by an applet generating device, and the 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 in the code base for the accessed third party according to the requirements of the third party, which is recorded as the third-party global configuration file. Specifically, the server Obtain the third-party global configuration file, and store the third-party global configuration file in the default directory. Taking the WeChat applet as an example, the default directory can be the dist directory (that is, the code directory of the WeChat server). For the third-party global configuration file The command needs to be named app.json to be recognized by WeChat. In addition, there are multiple third-party accesses, and corresponding multiple running code packages can be set in the dist directory, and the configuration files, subsequent page files, and source codes of dependent resources can be copied to the corresponding running code packages.

步骤S20,读取所述第三方全局配置文件的第一目标字段信息,获取目标页面,并从源码目录中将与所述目标页面对应的页面文件复制到所述预设目录下;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;

读取第三方全局配置文件的第一目标字段信息,获取目标页面,其中,第一目标字段信息即为page(页面)字段对应的信息,在微信小程序中,page字段用于指定小程序由哪些页面组成,每一项都对应一个页面的路径(含文件名)信息,因此,通过读取第一目标字段信息,可获取得到目标页面(即第三方小程序的页面)。然后,从源码目录中将与目标页面对应的页面文件复制到预设目录下,即dist目录下。其中,页面文件包括配置文件、逻辑文件、模板文件和样式文件。Read the first target field information of the third-party global configuration file to obtain the target page, wherein the first target field information is the information corresponding to the page (page) field. In the WeChat applet, the page field is used to specify the applet by Which pages are composed, and each item corresponds to the path (including file name) information of a page. Therefore, by reading the information of the first target field, the target page (ie, the page of the third-party applet) 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. Among them, the page files include configuration files, logic files, template files and style files.

步骤S30,基于所述页面文件和预设规则分析所述页面文件的依赖资源,并获取所述依赖资源的路径;Step S30, analyzing dependent resources of the page file based on the page file and preset rules, and obtaining paths of the dependent resources;

然后,基于页面文件和预设规则分析页面文件的依赖资源,并获取依赖资源的路径。其中,页面文件的依赖资源包括代码依赖和静态资源依赖,代码依赖包括小程序自定义组件、本地提取复用的代码、npm(node package manager,node包管理器)安装的依赖包等,静态资源依赖包括图片、pdf(文件格式)文件、音视频文件等。Then, analyze the dependent resource of the page file based on the page file and preset rules, and obtain the path of the dependent resource. Among them, the dependent resources of the page file include code dependencies and static resource dependencies. Code dependencies include small program custom components, locally extracted and reused codes, dependent packages installed by npm (node package manager, node package manager), etc., static resources Dependencies include pictures, pdf (file format) files, audio and video files, etc.

在本实施例中,对于依赖资源路径的获取方式包括两类,具体的,第一类是对于小程序自定义组件的路径的获取,可直接根据预设目标参数从配置文件中获取组件的路径;第二类是对于依赖资源中本地提取复用的代码、npm安装的依赖包和图片的路径的获取,可通过以下两种方式:1)通过预设工具分别将逻辑文件、模板文件和样式文件的源代码转换成抽象语法树,然后采用深度优先搜索算法遍历抽象语法树的各节点,读取各节点的元数据,元数据包括路径信息,进而根据路径信息,得到路径信息对应的依赖资源的路径;2)通过正则表达式匹配的方法来获取路径信息,即采用预设正则表达式分别与逻辑文件、模板文件和样式文件的源代码进行匹配,根据匹配结果得到路径信息,进而根据路径信息,得到路径信息对应的依赖资源的路径。具体的获取过程可参照下述实施例,此处不作赘述。In this embodiment, there are two ways to obtain the path of dependent resources. Specifically, the first type is to obtain the path of the custom component of the applet. The path of the component can be directly obtained from the configuration file according to the preset target parameters. ; The second category is to obtain the paths of locally extracted and reused codes from dependent resources, dependent packages installed by npm, and images, in the following two ways: 1) Separate logic files, template files, and style files through preset tools The source code of the file is converted into an abstract syntax tree, and then the depth-first search algorithm is used to traverse each node of the abstract syntax tree, and the metadata of each node is read. The metadata includes path information, and then according to the path information, the dependent resources corresponding to the path information are obtained 2) Obtain path information by matching regular expressions, that is, use preset regular expressions to match the source codes of logic files, template files, and style files, and obtain path information according to the matching results, and then according to the path information to obtain the path of the dependent resource corresponding to the path information. For the specific acquisition process, reference may be made to the following embodiments, which will not be repeated here.

步骤S40,根据所述依赖资源的路径从所述源码目录中获取所述依赖资源的源代码,并复制到所述预设目录下,以生成第三方小程序。Step S40, obtain the source code of the dependent resource from the source code directory according to the path of the dependent resource, and copy it to the preset directory to generate a third-party applet.

最后,根据依赖资源的路径从源码目录中获取依赖资源的源代码,并复制到预设目录下,以生成第三方小程序。Finally, obtain the source code of the dependent resource from the source code directory according to the path of the dependent resource, and copy it to the preset directory to generate a third-party applet.

进一步地,在上述步骤S40之前,该小程序生成方法还包括:Further, before the above step S40, the applet generation method also includes:

读取所述第三方全局配置文件的第二目标字段信息,并读取所述第二目标字段信息中的目标字段值,得到图标图片的路径;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;

根据所述图标图片的路径获取对应的图标图片,并复制到所述预设目录下。Obtain the corresponding icon picture according to the path of the icon picture, and copy it to the preset directory.

在本实施例中,由于第三方全局配置文件下的tabBar字段可能也会有图片,对应的,可读取第三方全局配置文件的第二目标字段信息,并读取第二目标字段信息中的目标字段值,得到图标图片的路径,其中,第二目标字段信息即为tabBar(选项卡)字段的信息,如果小程序是一个多tab应用(客户端窗口的底部或顶部有tab(标签)栏可以切换页面),可以通过tabBar配置项指定tab栏的表现,以及tab切换时显示的对应页面;目标字段值即为icon(图标)路径的字段值,即iconpath(图标路径)。然后,在获取到图标图片的路径之后,根据该图标图片的路径获取对应的图标图片,并复制到预设目录下,即dist目录下。In this embodiment, since the tabBar field under the third-party global configuration file may also have pictures, correspondingly, the second target field information of the third-party global configuration file can be read, and the second target field information in the second target field information can be read Target field value, get the path of the icon image, where 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 (tab) bar at the bottom or top of the client window You can switch pages), you can specify the performance of the tab bar through the tabBar configuration item, and the corresponding page displayed when the tab is switched; the target field value is the field value of the icon (icon) path, that is, iconpath (icon path). Then, after the path of the icon picture is obtained, the corresponding icon picture is obtained according to the path of the icon picture, and copied to a preset directory, that is, a dist directory.

本发明实施例提供一种小程序生成方法,通过获取第三方全局配置文件,并将第三方全局配置文件存储到预设目录下;读取第三方全局配置文件的第一目标字段信息,获取目标页面,并从源码目录中将与目标页面对应的页面文件复制到预设目录下;基于页面文件和预设规则分析页面文件的依赖资源,并获取依赖资源的路径;根据依赖资源的路径从源码目录中获取依赖资源的源代码,并复制到预设目录下,以生成第三方小程序。通过上述方式,通过获取第三方小程序的全局配置文件(即第三方全局配置文件),并根据该第三方全局配置文件生成最小代码量的适用并且满足对应第三方的小程序,可保证第三方小程序性能和体验。同时,通过配置化的方式,只需修改第三方全局配置文件,即可更新第三方小程序,从而可便于第三方小程序代码的维护。The embodiment of the present invention provides a small program generation method, by obtaining the 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, and obtaining the target Page, and copy the page file corresponding to the target page from the source code directory to the preset directory; analyze the dependent resources of the page file based on the page file and preset rules, and obtain the path of the dependent resource; according to the path of the dependent resource from the source code Get the source code of dependent resources in the directory and copy it to the default directory to generate third-party applets. Through the above method, by obtaining the global configuration file of the third-party applet (that is, the third-party global configuration file), and according to the third-party global configuration file to generate the minimum code amount applicable to the applet corresponding to the third party, it can ensure that the third-party Applet performance and experience. At the same time, through configuration, the third-party applet can be updated only by modifying the third-party global configuration file, which facilitates the maintenance of the code of the third-party applet.

具体的,在上述第一实施例中,所述页面文件包括配置文件、逻辑文件、模板文件和样式文件,步骤S40包括:Specifically, in the first embodiment above, the page file includes a configuration file, a logic file, a template file, and a style file, and step S40 includes:

步骤a1,根据预设目标参数从所述配置文件中获取组件的路径;Step a1, obtaining the path of the component from the configuration file according to the preset target parameters;

对于组件路径的获取,可以直接根据预设目标参数从配置文件中获取组件的路径,其中,预设目标参数为using Components,直接读取配置文件的using Components字段,即可获取到组件的路径。For obtaining the path of the component, the path of the component can be directly obtained from the configuration file according to the preset target parameter, wherein the preset target parameter is using Components, and the path of the component can be obtained by directly reading the using Components field of the configuration file.

或者,所述步骤S40包括:Alternatively, the step S40 includes:

步骤a2,获取所述逻辑文件、所述模板文件和所述样式文件中所包含的依赖资源的路径信息;Step a2, obtaining path information of dependent resources included in the logic file, the template file and the style file;

然后,获取逻辑文件、模板文件和样式文件中所包含的依赖资源的路径信息。这三类文件中包含的依赖资源有本地提取复用的代码、npm安装的依赖包和图片。Then, the path information of the dependent resources contained in the logic file, the template file and the style file is obtained. The dependent resources contained in these three types of files include locally extracted and reused code, dependent packages and pictures installed by npm.

作为其中一种实施方式,步骤a2可以包括:As one of the implementation manners, step a2 may include:

步骤a21,通过预设工具分别将所述逻辑文件、所述模板文件和所述样式文件的源代码转换成抽象语法树;Step a21, converting the source codes of the logic file, the template file, and the style file into abstract syntax trees by preset tools;

步骤a22,采用深度优先搜索算法遍历所述抽象语法树的各节点,读取各节点的元数据,所述元数据包括路径信息。Step a22, using a depth-first search algorithm to traverse each node of the abstract syntax tree, and read metadata of each node, where the metadata includes path information.

在本实施例中,可通过预设工具分别将逻辑文件、模板文件和样式文件的源代码转换成抽象语法树(Abstract Syntax Tree,AST),其中,预设工具可以为babel(一个JavaScript编译器),当然,在具体实施例中,也可以采用其他方式将逻辑文件、模板文件和样式文件的源代码转换成抽象语法树。In this embodiment, the source codes of logic files, template files and style files can be converted into abstract syntax trees (Abstract Syntax Tree, AST) respectively by preset tools, wherein the preset tools can be babel (a JavaScript compiler ), of course, in specific embodiments, other ways can also be used to convert the source codes of logic files, template files and style files into abstract syntax trees.

然后采用深度优先搜索算法遍历抽象语法树的各节点,读取各节点的元数据,其中,元数据包括路径信息。具体的,当预设工具为babel时,可以利用babel-traverse对AST树进行遍历,并通过挂载的metadataVisitor读取对应的元数据。例如,页面代码中通过es6模块引入方式引入一个工具库,即“import{add}from"../util.js";”,在通过babylon解释器转换成AST树后,该语句对应AST树上一个类型为ImportDeclaration(进口申报)的节点,该节点包含了该语句的所有元数据。节点中元数据字段source表示该工具库文件的路径信息,将其提取出来作为寻找对应代码文件的依据。Then, a depth-first search algorithm is used to traverse each node of the abstract syntax tree, and read metadata of each node, wherein the metadata includes path information. Specifically, when the preset tool is babel, you can use babel-traverse to traverse the AST tree, and read the corresponding metadata through the mounted metadataVisitor. For example, a tool library is introduced in the page code 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 the AST tree A node of type ImportDeclaration, which contains all the metadata for the statement. The metadata field source in the node indicates the path information of the tool library file, which is extracted as the basis for finding the corresponding code file.

需要说明的是,深度优先搜索(Depth First Search,DFS)算法属于图算法的一种,是一个针对图和树的遍历算法,其过程简要来说是对每一个可能的分支路径深入到不能再深入为止,而且每个节点只能访问一次。当抽象语法树的节点较多时,用其他方法易产生内存溢出的情况,而采用深度优先搜索算法遍历抽象语法树的各节点,可减少内存消耗,避免内存溢出的情况。It should be noted that the depth-first search (Depth First Search, DFS) algorithm is a kind of graph algorithm, and it is a traversal algorithm for graphs and trees. So far, 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 by using other methods, but using the depth-first search algorithm to traverse each node of the abstract syntax tree can reduce memory consumption and avoid memory overflow.

作为另一种实施方式,步骤a2还可以包括:As another implementation, step a2 may also include:

步骤a23,采用预设正则表达式分别与所述逻辑文件、所述模板文件和所述样式文件的源代码进行匹配,根据匹配结果得到路径信息。Step a23, using preset regular expressions to match the source codes of the logic file, the template file and the style file respectively, and obtain path information according to the matching results.

在本实施例中,还可以通过正则表达式匹配的方法来获取路径信息,具体的,可采用预设正则表达式分别与逻辑文件、模板文件和样式文件的源代码进行匹配,根据匹配结果得到路径信息。例如,对于上述例中,页面代码中通过es6模块引入方式引入一个工具库,即“import{add}from"../util.js";”,可以采用以下的正则表达式来从源码中提取es6模块引入语句:“^(import)(?:.*?(as))?(?:.*?(as))?(?:.*?(from))*.*$”。该正则表示式对应的就是es6模块引入语句语法的所有模式,保证无论开发者以何种标准语法写该语句都能从源码中识别到。在拿到代码中的es6语句后就可以通过简单的字符串操作获取到from关键字后面的路径信息。In this embodiment, the path information can also be obtained through regular expression matching. Specifically, preset regular expressions can be used to match the source codes of the logic file, template file, and style file respectively, and according to the matching results, the path information. For example, in the above example, a tool library is introduced in the page code through the introduction of es6 modules, that is, "import{add}from"../util.js";", the following regular expressions can be used to extract from the source code The es6 module import statement: "^(import)(?:.*?(as))?(?:.*?(as))?(?:.*?(from))*.*$". This regular expression corresponds to all the patterns of the statement syntax introduced by the es6 module, ensuring that no matter what standard syntax the developer uses to write the statement, it can be recognized from the source code. After getting the es6 statement in the code, you can get the path information behind the from keyword through simple string operations.

步骤a3,根据所述路径信息,得到所述路径信息对应的依赖资源的路径。Step a3, according to the path information, obtain the path of the dependent resource corresponding to the path information.

在获取到路径信息之后,根据路径信息,得到路径信息对应的依赖资源的路径。具体的,步骤a3包括:After the path information is acquired, the path of the dependent resource corresponding to the path information is obtained according to the path information. Specifically, step a3 includes:

步骤a31,检测所述路径信息是否满足预设条件;Step a31, detecting whether the path information satisfies a preset condition;

步骤a32,若所述路径信息满足预设条件,则确定所述路径信息对应的依赖资源的路径为预设路径;Step a32, if the path information satisfies the preset condition, then determine the resource-dependent path corresponding to the path information as the preset path;

在本实施例中,先检测该路径信息是否满足预设条件,其中,该预设条件为路径信息中不含有/,若路径信息中不含有/,即满足预设条件时,则确定路径信息对应的依赖资源的路径为预设路径,例如,对于以下两个语句:In this embodiment, it is first detected whether the path information satisfies the preset condition, wherein 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, then the path information is determined The path of the corresponding dependent resource is a preset path, for example, for the following two statements:

import{Page}from'wxa';import { Page } from 'wxa';

import{Page}from'./wxa';import { Page } from './wxa';

上面两个语句的from后对应的是路径信息,第一个路径信息中是没有/的,说明是通过npm包管理工具安装的一个依赖工具,这个工具安装的路径默认为一个预设路径中,例如工程根目录下的node_modules目录中。而第二个路径信息有/的,说明这个是自己写的一个工具,则不满足预设条件,需根据该路径信息进一步确定路径。The from of the above two statements corresponds to the path information. There is no / in the first path information, indicating that it is a dependent tool installed through the npm package management tool. The path installed by this tool is a preset path by default. For example, in the node_modules directory under the project root directory. The second path information has /, indicating that this is a tool written by myself, which does not meet the preset conditions, and the path needs to be further determined according to the path information.

步骤a33,若所述路径信息不满足预设条件,则判断所述路径信息对应的路径类型为绝对路径还是相对路径;Step a33, if the path information does not satisfy the preset condition, then judge whether the path type corresponding to the path information is an absolute path or a relative path;

步骤a34,若所述路径信息对应的路径类型为绝对路径,则确定所述路径信息对应的依赖资源的路径为所述路径信息对应的路径;Step a34, if the path type corresponding to the path information is an absolute path, then determine that the resource-dependent path corresponding to the path information is the path corresponding to the path information;

步骤a35,若所述路径信息对应的路径类型为相对路径,则获取与所述路径信息对应的相对路径,并根据所述相对路径和所述路径信息得到对应的依赖资源的路径。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 a corresponding resource-dependent path according to the relative path and the path information.

若路径信息不满足预设条件,则需要进一步判断路径信息对应的路径类型为绝对路径还是相对路径。具体的可以根据路径信息的格式来判断为绝对路径还是相对路径,/表示根目录,为绝对路径;./表示当前路径,../表示上一层目录,属于相对路径。If the path information does not satisfy the preset condition, it is necessary to further determine whether the path type corresponding to the path information is an absolute path or a relative path. Specifically, you can judge whether it is an absolute path or a relative path according to the format of the path information. / means the root directory, which is an absolute path; ./ means the current path, and ../ means the upper directory, which is a relative path.

若路径信息对应的路径类型为绝对路径,则确定路径信息对应的依赖资源的路径为路径信息对应的路径,例如,获取到的路径信息为/util.js,则为绝对路径,可直接根据该路径获取对应的依赖资源。If the path type corresponding to the path information is an absolute path, then 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, which can be directly based on the Path to obtain the corresponding dependent resources.

若路径信息对应的路径类型为相对路径,则获取与路径信息对应的相对路径,并根据相对路径和路径信息得到对应的依赖资源的路径。例如,若路径信息为../util.js,则需获取对应的相对路径,例如/pages/index,然后对这两个路径组合,可得到对应的依赖资源的路径,如/pages/index/util.js。If the path type corresponding to the path information is a relative path, the relative path corresponding to the path information is obtained, and the corresponding resource-dependent path is obtained according to the relative path and the path information. For example, if the path information is ../util.js, you need to obtain the corresponding relative path, such as /pages/index, and then combine these two paths to get the corresponding resource-dependent path, such as /pages/index/ util.js.

进一步地,基于图2所示的第一实施例,提出本发明小程序生成方法的第二实施例。Further, based on the first embodiment shown in FIG. 2 , a second embodiment of the applet generating method of the present invention is proposed.

在本实施例中,步骤“从源码目录中将与所述目标页面对应的页面文件复制到所述预设目录下”包括:In this embodiment, the step "copy the page file corresponding to the target page from the source code directory to the preset directory" includes:

从源码目录中获取与所述目标页面对应的页面文件,将所述页面文件中的预设指定参数编译为第三方标识号ID,并将编译后的页面文件复制到所述预设目录下;Obtaining the page file corresponding to the target page from the source code directory, compiling the preset specified parameters in the page file into a third-party identification number ID, and copying the compiled page file to the preset directory;

在本实施例中,当不同第三方接入时,可根据第三方信息(如名称)或预设规则为各商户注册分配一个第三方ID(标识号),在复制过程中,对预设指定参数进行编译,将预设指定参数编译为第三方ID,进而将编译后的页面文件或源代码复制到预设目录下,以用于区分生成的各第三方小程序所属的第三方。In this embodiment, when different third parties access, a third-party ID (identification number) can be assigned to each merchant registration according to third-party information (such as name) or preset rules. Parameters are compiled, and the preset specified parameters are 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 party to which each generated third-party applet belongs.

具体的,服务器在读取第三方全局配置文件的第一目标字段信息(pages),获取到目标页面之后,从源码目录中获取与该目标页面对应的页面文件,然后将页面文件中的预设指定参数编译为第三方标识号ID,并将编译后的页面文件复制到预设目录下。其中,预设指定参数是根据小程序的源代码设定的,例如,代码里面需要签署一个协议,代码对应的路径分别是http://bank.com/BANK_APPID/xieyi.pdf,此时,可以设定预设指定参数为BANK_APPID。在编译时,可将BANK_APPID替换为第三方ID。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, and then converts the preset page file in the page file to Compile the specified parameters into a third-party identification number ID, and copy the compiled page file to the default directory. Among them, the preset specified parameters are set according to the source code of the applet. For example, an agreement needs to be signed in the code, and the paths corresponding to the code are http://bank.com/BANK_APPID/xieyi.pdf. At this time, you can Set the default specified parameter to BANK_APPID. At compile time, BANK_APPID can be replaced with the third-party ID.

在将编译后的页面文件复制到预设目录下后,基于页面文件和预设规则分析页面文件的依赖资源,并获取依赖资源的路径,具体的路径获取方法可参照上述实施例,此处不作赘述。After copying the compiled page file to the preset directory, analyze the dependent resources of the page file based on the page file and preset rules, and obtain the path of the dependent resource. The specific path acquisition method can refer to the above-mentioned embodiment, and will not be described here. repeat.

此时,步骤“根据所述依赖资源的路径从所述源码目录中获取所述依赖资源的源代码,并复制到所述预设目录下”包括: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:

根据所述依赖资源的路径从所述源码目录中获取所述依赖资源的源代码,将所述依赖资源的源代码中的所述预设指定参数编译为所述第三方ID,并将编译后的依赖资源的源代码复制到所述预设目录下。Acquire the source code of the dependent resource from the source code directory according to the path of the dependent resource, compile the preset specified parameters in the source code of the dependent resource into the third-party ID, and compile the compiled The source code of the dependent resources is copied to the preset directory.

在获取到依赖资源的路径之后,根据依赖资源的路径从源码目录中获取依赖资源的源代码,然后将依赖资源的源代码中的预设指定参数编译为该第三方ID,并将编译后的依赖资源的源代码复制到预设目录下,以生成第三方小程序。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 parameters in the source code of the dependent resource into the third-party ID, and compile the compiled The source code of dependent resources is copied to the default directory to generate third-party applets.

通过上述方式,在复制过程中,对预设指定参数进行编译,将预设指定参数编译为第三方ID,进而将编译后的页面文件或源代码复制到预设目录下,从而可实现对生成的各第三方小程序所属第三方的区分。Through the above method, during the copying process, the preset specified parameters are compiled, and the preset specified parameters are compiled into a third-party ID, and then the compiled page file or source code is copied to the preset directory, so that the generated The distinction between the third parties to which each third-party mini-program belongs.

本发明还提供一种小程序生成装置。The invention also provides a small program generating device.

参照图3,图3为本发明小程序生成装置第一实施例的功能模块示意图。Referring to FIG. 3 , FIG. 3 is a schematic diagram of functional modules of the first embodiment of the applet generation device of the present invention.

如图3所示,所述小程序生成装置包括:As shown in Figure 3, the applet generating device includes:

文件获取模块10,用于获取第三方全局配置文件,并将所述第三方全局配置文件存储到预设目录下;The file obtaining module 10 is used to obtain a third-party global configuration file, and store the third-party global configuration file in a preset directory;

第一复制模块20,用于读取所述第三方全局配置文件的第一目标字段信息,获取目标页面,并从源码目录中将与所述目标页面对应的页面文件复制到所述预设目录下;The first copy module 20 is used to 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 Down;

路径获取模块30,用于基于所述页面文件和预设规则分析所述页面文件的依赖资源,并获取所述依赖资源的路径;A path acquisition module 30, configured to analyze the dependent resources of the page file based on the page file and preset rules, and acquire the path of the dependent resources;

第二复制模块40,用于根据所述依赖资源的路径从所述源码目录中获取所述依赖资源的源代码,并复制到所述预设目录下,以生成第三方小程序。The second copying module 40 is configured to obtain the source code of the dependent resource from the source code directory according to the path of the dependent resource, and copy it to the preset directory to generate a third-party applet.

进一步地,所述路径获取模块30包括:Further, the path acquisition module 30 includes:

第一获取单元,用于根据预设目标参数从所述配置文件中获取组件的路径;a first obtaining unit, configured to obtain the path of the component from the configuration file according to a preset target parameter;

第二获取单元,用于获取所述逻辑文件、所述模板文件和所述样式文件中所包含的依赖资源的路径信息;a second acquiring unit, configured to acquire path information of dependent resources contained in the logic file, the template file, and the style file;

第三获取单元,用于根据所述路径信息,得到所述路径信息对应的依赖资源的路径。The third obtaining unit is configured to obtain a resource-dependent path corresponding to the path information according to the path information.

进一步地,所述第二获取单元具体用于:通过预设工具分别将所述逻辑文件、所述模板文件和所述样式文件的源代码转换成抽象语法树;采用深度优先搜索算法遍历所述抽象语法树的各节点,读取各节点的元数据,所述元数据包括路径信息。Further, the second acquisition unit is specifically configured to: respectively convert the source codes of the logic file, the template file, and the style file into an abstract syntax tree through a preset tool; traverse the Each node of the abstract syntax tree reads metadata of each node, and the metadata includes path information.

进一步地,所述第二获取单元还具体用于:采用预设正则表达式分别与所述逻辑文件、所述模板文件和所述样式文件的源代码进行匹配,根据匹配结果得到路径信息。Further, the second obtaining unit is further specifically configured to: use preset regular expressions to match the source codes of the logic file, the template file, and the style file respectively, and obtain path information according to the matching results.

进一步地,所述第三获取单元具体用于:检测所述路径信息是否满足预设条件;若所述路径信息满足预设条件,则确定所述路径信息对应的依赖资源的路径为预设路径;若所述路径信息不满足预设条件,则判断所述路径信息对应的路径类型为绝对路径还是相对路径;若所述路径信息对应的路径类型为绝对路径,则确定所述路径信息对应的依赖资源的路径为所述路径信息对应的路径;若所述路径信息对应的路径类型为相对路径,则获取与所述路径信息对应的相对路径,并根据所述相对路径和所述路径信息得到对应的依赖资源的路径。Further, the third acquiring unit is specifically configured to: detect whether the path information satisfies a preset condition; if the path information satisfies a preset condition, determine that the resource-dependent path corresponding to the path information is a preset path ; If the path information does not meet the preset conditions, then 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, then determine the path type corresponding to the path information The resource-dependent path 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 relative path according to the relative path and the path information The path of the corresponding dependent resource.

进一步地,所述小程序生成装置还包括:Further, the applet generation device also includes:

读取模块,用于读取所述第三方全局配置文件的第二目标字段信息,并读取所述第二目标字段信息中的目标字段值,得到图标图片的路径;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;

第三复制模块,用于根据所述图标图片的路径获取对应的图标图片,并复制到所述预设目录下。The third copying module is configured to obtain the corresponding icon picture according to the path of the icon picture, and copy it to the preset directory.

进一步地,所述第一复制模块20具体用于:Further, the first replication module 20 is specifically used for:

从源码目录中获取与所述目标页面对应的页面文件,将所述页面文件中的预设指定参数编译为第三方标识号ID,并将编译后的页面文件复制到所述预设目录下;Obtaining the page file corresponding to the target page from the source code directory, compiling the preset specified parameters in the page file into a third-party identification number ID, and copying the compiled page file to the preset directory;

进一步地,所述第二复制模块40具体用于:Further, the second replication module 40 is specifically used for:

根据所述依赖资源的路径从所述源码目录中获取所述依赖资源的源代码,将所述依赖资源的源代码中的所述预设指定参数编译为所述第三方ID,并将编译后的依赖资源的源代码复制到所述预设目录下。Acquire the source code of the dependent resource from the source code directory according to the path of the dependent resource, compile the preset specified parameters in the source code of the dependent resource into the third-party ID, and compile the compiled The source code of the dependent resources is copied to the preset directory.

其中,上述小程序生成装置中各个模块的功能实现与上述小程序生成方法实施例中各步骤相对应,其功能和实现过程在此处不再一一赘述。Wherein, the function implementation of each module in the above-mentioned applet generating device corresponds to each step in the above-mentioned embodiment of the applet generating method, and the functions and implementation processes thereof will not be repeated here.

本发明还提供一种计算机可读存储介质,该计算机可读存储介质上存储有小程序生成程序,所述小程序生成程序被处理器执行时实现如以上任一项实施例所述的小程序生成方法的步骤。The present invention also provides a computer-readable storage medium, where a small program generation program is stored on the computer-readable storage medium, and when the small program generation program is executed by a processor, the small program as described in any one of the above embodiments is realized. The steps to generate the method.

本发明计算机可读存储介质的具体实施例与上述小程序生成方法各实施例基本相同,在此不作赘述。The specific embodiments of the computer-readable storage medium of the present invention are basically the same as the above-mentioned embodiments of the applet generation method, and will not be repeated here.

需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。It should be noted that, as used herein, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or system comprising a set of elements includes not only those elements, It also includes other elements not expressly listed, or elements inherent in the process, method, article, or system. Without further limitations, an element defined by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article or system comprising that element.

上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the above embodiments of the present invention are for description only, and do not represent the advantages and disadvantages of the embodiments.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本发明各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general-purpose hardware platform, and of course also by hardware, but in many cases the former is better implementation. Based on such an understanding, the technical solution of the present invention can be embodied in the form of a software product in essence or in other words, the part that contributes to the prior art, and the computer software product is stored in a storage medium (such as ROM/RAM) as described above. , magnetic disk, optical disk), including several instructions to make a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) execute the method described in each embodiment of the present invention.

以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the description of the present invention and the contents of the accompanying drawings, or directly or indirectly used in other related technical fields , are all included in the scope of patent protection of the present invention in the same way.

Claims (10)

CN201910835860.XA2019-09-042019-09-04 Mini-program generation method, device, equipment, and computer-readable storage mediumActiveCN110532029B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201910835860.XACN110532029B (en)2019-09-042019-09-04 Mini-program generation method, device, equipment, and computer-readable storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201910835860.XACN110532029B (en)2019-09-042019-09-04 Mini-program generation method, device, equipment, and computer-readable storage medium

Publications (2)

Publication NumberPublication Date
CN110532029Atrue CN110532029A (en)2019-12-03
CN110532029B CN110532029B (en)2025-05-30

Family

ID=68667212

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201910835860.XAActiveCN110532029B (en)2019-09-042019-09-04 Mini-program generation method, device, equipment, and computer-readable storage medium

Country Status (1)

CountryLink
CN (1)CN110532029B (en)

Cited By (31)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN111367565A (en)*2020-03-202020-07-03成都药王科技股份有限公司Program release system
CN111399863A (en)*2020-03-132020-07-10深圳前海微众银行股份有限公司Dependent file packaging method, device, equipment and computer readable storage medium
CN111459537A (en)*2020-04-032020-07-28深圳前海微众银行股份有限公司Redundant code removing method, device, equipment and computer readable storage medium
CN111475142A (en)*2020-04-032020-07-31支付宝(杭州)信息技术有限公司Method, device and equipment for generating applet file package
CN111506300A (en)*2020-04-222020-08-07上海极链网络科技有限公司Applet generation method, device, equipment and storage medium
CN111580820A (en)*2020-05-252020-08-25泰康保险集团股份有限公司Applet generation method and device
CN111639019A (en)*2020-04-242020-09-08北京五八信息技术有限公司Code testing method and device and readable storage medium
CN111782197A (en)*2020-08-032020-10-16网易(杭州)网络有限公司Resource publishing method and device
CN111796829A (en)*2020-05-192020-10-20北京三快在线科技有限公司Applet updating method and device, electronic equipment and computer readable storage medium
CN111984300A (en)*2020-09-082020-11-24网易(杭州)网络有限公司Code copying method and device, electronic equipment and computer readable storage medium
CN112000572A (en)*2020-08-072020-11-27北京浪潮数据技术有限公司Source code scanning tool, method, equipment and medium
CN112181429A (en)*2020-09-282021-01-05百度在线网络技术(北京)有限公司Information processing method and device and electronic equipment
CN112286528A (en)*2020-11-042021-01-29豆盟(北京)科技股份有限公司Applet generation method, device and equipment and computer storage medium
CN112506854A (en)*2020-11-242021-03-16百度在线网络技术(北京)有限公司Method, device, equipment and medium for storing page template file and generating page
CN112685040A (en)*2021-01-222021-04-20爱驰汽车有限公司Method, device, equipment and storage medium for generating interface file in android system
CN112947990A (en)*2021-03-232021-06-11四川虹美智能科技有限公司Development library creating method and device and computer readable medium
CN112965719A (en)*2020-03-062021-06-15北京五八信息技术有限公司Method and device for generating small program
CN113094040A (en)*2021-03-082021-07-09南京唯优信息技术有限公司Applet compiling method and device
CN113268237A (en)*2021-05-252021-08-17平安科技(深圳)有限公司Function page generation method, device, equipment and medium of function module
CN113282291A (en)*2021-06-102021-08-20豆盟(北京)科技股份有限公司Method, device and equipment for generating small program and storage medium
CN113821252A (en)*2021-09-242021-12-21深圳市明源云采购科技有限公司Method and device for constructing small program, terminal device and storage medium
CN113886216A (en)*2020-07-032022-01-04腾讯科技(深圳)有限公司Interface test and tool configuration method, device, electronic equipment and storage medium
CN114168183A (en)*2021-11-172022-03-11北京五八信息技术有限公司Front-end resource information processing method, device, equipment and storage medium
CN114356288A (en)*2021-12-212022-04-15上海瑞家信息技术有限公司 Small program integration method, device, electronic device and storage medium
CN114564230A (en)*2022-02-232022-05-31北京布局未来教育科技有限公司One-key uploading implementation method and device of Hongming system, electronic equipment and medium
CN114579178A (en)*2022-03-102022-06-03平安普惠企业管理有限公司 Multi-version component operation method, device, terminal device and storage medium
CN114780075A (en)*2022-04-242022-07-22中国银行股份有限公司 Method and device for generating code frame
CN115061796A (en)*2022-06-172022-09-16特赞(上海)信息科技有限公司Execution method and system for calling between subtasks and electronic equipment
CN115291942A (en)*2022-08-182022-11-04中国工商银行股份有限公司Application program processing method and device and computer readable storage medium
CN116955279A (en)*2023-09-192023-10-27腾讯科技(深圳)有限公司File uploading method, device, equipment and storage medium
CN119556912A (en)*2025-01-272025-03-04中科南京智能技术研究院 Edge device program software development method, system, edge device and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
EP1113361A1 (en)*2000-01-032001-07-04Wimba.Com S.A.Process of communication between an applet and a local agent using a socket communication channel
US20150033365A1 (en)*2013-07-252015-01-29Oracle International CorporationExternal platform extensions in a multi-tenant environment
CN106980504A (en)*2017-03-282017-07-25腾讯科技(深圳)有限公司A kind of application development method and its instrument, equipment
US20180121315A1 (en)*2016-10-312018-05-03International Business Machines CorporationMethod for static and dynamic configuration verification
CN109426516A (en)*2017-06-212019-03-05北京信威通信技术股份有限公司Software version management method and device
CN110032358A (en)*2019-01-032019-07-19阿里巴巴集团控股有限公司A kind of application program generation method, device, equipment and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
EP1113361A1 (en)*2000-01-032001-07-04Wimba.Com S.A.Process of communication between an applet and a local agent using a socket communication channel
US20150033365A1 (en)*2013-07-252015-01-29Oracle International CorporationExternal platform extensions in a multi-tenant environment
US20180121315A1 (en)*2016-10-312018-05-03International Business Machines CorporationMethod for static and dynamic configuration verification
CN106980504A (en)*2017-03-282017-07-25腾讯科技(深圳)有限公司A kind of application development method and its instrument, equipment
CN109426516A (en)*2017-06-212019-03-05北京信威通信技术股份有限公司Software version management method and device
CN110032358A (en)*2019-01-032019-07-19阿里巴巴集团控股有限公司A kind of application program generation method, device, equipment and system

Cited By (45)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN112965719A (en)*2020-03-062021-06-15北京五八信息技术有限公司Method and device for generating small program
CN111399863B (en)*2020-03-132024-07-02深圳前海微众银行股份有限公司Method, apparatus, device and computer readable storage medium for packaging dependent files
CN111399863A (en)*2020-03-132020-07-10深圳前海微众银行股份有限公司Dependent file packaging method, device, equipment and computer readable storage medium
CN111367565A (en)*2020-03-202020-07-03成都药王科技股份有限公司Program release system
CN111459537A (en)*2020-04-032020-07-28深圳前海微众银行股份有限公司Redundant code removing method, device, equipment and computer readable storage medium
CN111475142A (en)*2020-04-032020-07-31支付宝(杭州)信息技术有限公司Method, device and equipment for generating applet file package
CN111506300A (en)*2020-04-222020-08-07上海极链网络科技有限公司Applet generation method, device, equipment and storage medium
CN111639019B (en)*2020-04-242023-08-25北京五八信息技术有限公司Code testing method, device and readable storage medium
CN111639019A (en)*2020-04-242020-09-08北京五八信息技术有限公司Code testing method and device and readable storage medium
CN111796829A (en)*2020-05-192020-10-20北京三快在线科技有限公司Applet updating method and device, electronic equipment and computer readable storage medium
CN111796829B (en)*2020-05-192024-06-07北京三快在线科技有限公司Applet updating method, device, electronic equipment and computer readable storage medium
CN111580820A (en)*2020-05-252020-08-25泰康保险集团股份有限公司Applet generation method and device
CN111580820B (en)*2020-05-252023-09-15泰康保险集团股份有限公司Applet generation method and device
CN113886216A (en)*2020-07-032022-01-04腾讯科技(深圳)有限公司Interface test and tool configuration method, device, electronic equipment and storage medium
CN111782197B (en)*2020-08-032023-12-29网易(杭州)网络有限公司Resource release method and device
CN111782197A (en)*2020-08-032020-10-16网易(杭州)网络有限公司Resource publishing method and device
CN112000572A (en)*2020-08-072020-11-27北京浪潮数据技术有限公司Source code scanning tool, method, equipment and medium
CN112000572B (en)*2020-08-072022-06-17北京浪潮数据技术有限公司Tool, method, equipment and medium for scanning source code
CN111984300B (en)*2020-09-082024-01-23网易(杭州)网络有限公司Code copying method and device, electronic equipment and computer readable storage medium
CN111984300A (en)*2020-09-082020-11-24网易(杭州)网络有限公司Code copying method and device, electronic equipment and computer readable storage medium
CN112181429B (en)*2020-09-282023-10-20百度在线网络技术(北京)有限公司Information processing method and device and electronic equipment
CN112181429A (en)*2020-09-282021-01-05百度在线网络技术(北京)有限公司Information processing method and device and electronic equipment
CN112286528A (en)*2020-11-042021-01-29豆盟(北京)科技股份有限公司Applet generation method, device and equipment and computer storage medium
CN112506854B (en)*2020-11-242024-04-02百度在线网络技术(北京)有限公司Page template file storage and page generation methods, devices, equipment and media
CN112506854A (en)*2020-11-242021-03-16百度在线网络技术(北京)有限公司Method, device, equipment and medium for storing page template file and generating page
CN112685040A (en)*2021-01-222021-04-20爱驰汽车有限公司Method, device, equipment and storage medium for generating interface file in android system
CN113094040A (en)*2021-03-082021-07-09南京唯优信息技术有限公司Applet compiling method and device
CN113094040B (en)*2021-03-082024-06-28南京唯优信息技术有限公司Applet compiling method and device
CN112947990A (en)*2021-03-232021-06-11四川虹美智能科技有限公司Development library creating method and device and computer readable medium
CN112947990B (en)*2021-03-232023-04-07四川虹美智能科技有限公司Development library creating method, device and computer readable medium
CN113268237A (en)*2021-05-252021-08-17平安科技(深圳)有限公司Function page generation method, device, equipment and medium of function module
CN113282291A (en)*2021-06-102021-08-20豆盟(北京)科技股份有限公司Method, device and equipment for generating small program and storage medium
CN113821252B (en)*2021-09-242024-05-14深圳市明源云采购科技有限公司Method and device for constructing applet, terminal equipment and storage medium
CN113821252A (en)*2021-09-242021-12-21深圳市明源云采购科技有限公司Method and device for constructing small program, terminal device and storage medium
CN114168183A (en)*2021-11-172022-03-11北京五八信息技术有限公司Front-end resource information processing method, device, equipment and storage medium
CN114356288A (en)*2021-12-212022-04-15上海瑞家信息技术有限公司 Small program integration method, device, electronic device and storage medium
CN114564230B (en)*2022-02-232024-01-16北京布局未来科技发展有限公司One-key uploading realization method and device of hong Monte-go system, electronic equipment and medium
CN114564230A (en)*2022-02-232022-05-31北京布局未来教育科技有限公司One-key uploading implementation method and device of Hongming system, electronic equipment and medium
CN114579178A (en)*2022-03-102022-06-03平安普惠企业管理有限公司 Multi-version component operation method, device, terminal device and storage medium
CN114780075A (en)*2022-04-242022-07-22中国银行股份有限公司 Method and device for generating code frame
CN115061796A (en)*2022-06-172022-09-16特赞(上海)信息科技有限公司Execution method and system for calling between subtasks and electronic equipment
CN115291942A (en)*2022-08-182022-11-04中国工商银行股份有限公司Application program processing method and device and computer readable storage medium
CN115291942B (en)*2022-08-182025-08-26中国工商银行股份有限公司 Application processing method, device and computer-readable storage medium
CN116955279A (en)*2023-09-192023-10-27腾讯科技(深圳)有限公司File uploading method, device, equipment and storage medium
CN119556912A (en)*2025-01-272025-03-04中科南京智能技术研究院 Edge device program software development method, system, edge device and storage medium

Also Published As

Publication numberPublication date
CN110532029B (en)2025-05-30

Similar Documents

PublicationPublication DateTitle
CN110532029A (en)Small routine generation method, device, equipment and computer readable storage medium
US20240114076A1 (en)System and Method for a Unified Interface to Networked Web Services
EP3605324B1 (en)Application development method and tool, and storage medium thereof
US20210149648A1 (en)System and a method for automating application development and deployment
WO2021017735A1 (en)Smart contract formal verification method, electronic apparatus and storage medium
US9811605B2 (en)Methods, apparatuses and computer program products for automated learning of data models
CN112114805B (en)Page generation method, device and equipment
CN107193570A (en)A kind of method and system for automatically generating API documents
Di Martino et al.A rule‐based procedure for automatic recognition of design patterns in UML diagrams
US20240126624A1 (en)Automatically generating application programming interfaces
CN114297700B (en)Dynamic and static combined mobile application privacy protocol extraction method and related equipment
US9898467B1 (en)System for data normalization
CN111260080A (en)Process optimization method, device, terminal and storage medium based on machine learning
CN116643814A (en) Method for building model library, method for invoking model based on model library, and related equipment
CN110213105A (en)It is a kind of cross-platform micro- using creation method
CN110244945A (en) Interface document generation method and terminal equipment
CN116560683A (en)Software updating method, device, equipment and storage medium
CN112187713A (en)Message conversion method, device, computer equipment and storage medium
US11604662B2 (en)System and method for accelerating modernization of user interfaces in a computing environment
CN110928896A (en)Data query method and device
KR102651294B1 (en)Method for assisting collect information about screen component
CN110837896B (en) Method and device for storing and invoking machine learning models
Rodriguez et al.Reducing efforts in web services refactoring
CN112783483A (en)Function creating method, device, equipment and medium based on suspension button assembly
CN111949309A (en)Method and device for pulling IDL file, computer equipment and storage medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp