[go: up one dir, main page]

CN114625376A - Data transfer mode conversion method and device, electronic equipment and readable storage medium - Google Patents

Data transfer mode conversion method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN114625376A
CN114625376A CN202210278451.6A CN202210278451A CN114625376A CN 114625376 A CN114625376 A CN 114625376A CN 202210278451 A CN202210278451 A CN 202210278451A CN 114625376 A CN114625376 A CN 114625376A
Authority
CN
China
Prior art keywords
transfer mode
component
data transfer
project
mode conversion
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210278451.6A
Other languages
Chinese (zh)
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.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management 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 Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202210278451.6A priority Critical patent/CN114625376A/en
Publication of CN114625376A publication Critical patent/CN114625376A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention relates to an artificial intelligence technology, and discloses a data transmission mode conversion method, which comprises the following steps: the method comprises the steps of constructing a data transfer mode conversion project of a front-end project, introducing a basic file of a target transfer mode into the data transfer mode conversion project to obtain a standard transfer mode conversion project, identifying an entry file of the standard transfer mode conversion project, finding out a target assembly in the standard transfer mode conversion project based on the entry file, identifying an original data transfer mode in the target assembly, and carrying out variable migration on a variable to be compiled in the original data transfer mode to obtain the front-end project of the target transfer mode. In addition, the invention also relates to a block chain technology, and the front-end item can be obtained from a node of the block chain. The invention also provides a data transmission mode conversion device, electronic equipment and a readable storage medium. The invention can solve the problem of difficult data transmission mode conversion.

Description

数据传递方式转化方法、装置、电子设备及可读存储介质Data transmission mode conversion method, device, electronic device and readable storage medium

技术领域technical field

本发明涉及人工智能技术领域,尤其涉及一种数据传递方式转化方法、装置、电子设备及可读存储介质。The present invention relates to the technical field of artificial intelligence, and in particular, to a data transmission mode conversion method, device, electronic device and readable storage medium.

背景技术Background technique

目前在国内前端行业内,广泛使用前端框架进行前端项目开发,项目间的数据传递至关重要。例如,vue框架中,对于组件间的数据传递,常见的主要有props/$emit、$emit/$on和vuex三种方式,三种方式有各自的使用场景。props/$emit的使用场景主要见于简单的父子组件单项数据流通讯方式;$emit/$on的使用场景是以一个小型数据中心的模式,在中小型复杂的组件间父子组件相互通信会使用到;而vuex的使用场景是一个单向数据流的大型数据管理中心,主要面对的是复杂的应用场景,将所有需要传递的数据,都交给数据管理中心统一保存、修改、传递,是复杂项目对于数据传递的终极解决方案,也是较为复杂和重量级的方式。对于一个项目来说,往往一开始是从一个小项目开始做起,最初使用的方式可能仅仅是通过props/$emit的方式进行组件间的数据传递。但是随着项目开发的不断深入及迭代,对于父子组件的数据传递越发复杂和难以维护,在这个发展的过程中,使用到的props/$emit、$emit/$on这两种方式进行数据传递,变得不再适合当前复杂场景。需要使用到更加强大的vuex。但是这个时候再将项目数据传递方式转变为vuex,会面临以下几个问题:At present, in the domestic front-end industry, front-end frameworks are widely used for front-end project development, and data transfer between projects is very important. For example, in the vue framework, for data transfer between components, there are three common methods: props/$emit, $emit/$on and vuex, and the three methods have their own usage scenarios. The usage scenario of props/$emit is mainly seen in the simple data flow communication method of parent-child components; the usage scenario of $emit/$on is a small data center mode, and the communication between parent and child components between small and medium-sized complex components will use ; The usage scenario of vuex is a large data management center with one-way data flow, which mainly faces complex application scenarios. All the data that needs to be transferred are handed over to the data management center for unified storage, modification, and transfer, which is complex. The project's ultimate solution for data transfer is also a more complex and heavyweight way. For a project, it often starts with a small project, and the initial method may be only to transfer data between components through props/$emit. However, with the continuous deepening and iteration of project development, the data transfer of parent-child components has become more complex and difficult to maintain. In the process of development, the two methods of props/$emit and $emit/$on are used for data transfer. , becomes no longer suitable for the current complex scene. Need to use a more powerful vuex. However, at this time, when the project data transmission method is changed to vuex, the following problems will be faced:

1、vuex的使用,具有其独特的单向数据流的思想,以及特有的语法、方法去实现,对于一般的开发者来说,有相当的上手难度,极大可能导致后期项目维护和开发变得更加困难。1. The use of vuex has its unique idea of one-way data flow, as well as its unique syntax and methods to achieve. For ordinary developers, it is quite difficult to get started, which may lead to changes in later project maintenance and development. more difficult.

2、vuex使用后,为了保证所有数据传递都是通过vuex这个数据管理中心统一管理,避免出现多种数据传递方式混用,导致数据管理混乱的情况发生,需要将所有通过props/$emit、$emit/$on方式进行数据传递的代码,都进行替换为vuex方式,这不仅仅需要通过大量的人力梳理现有逻辑,还需要开发人员同时熟悉这三种方式的写法,对于一个项目来说,开发效率低下。2. After vuex is used, in order to ensure that all data transfer is managed by the data management center of vuex, and to avoid the mixed use of multiple data transfer methods, which may lead to confusion in data management, it is necessary to transfer all data through props/$emit, $emit The code for data transfer in the /$on method is replaced by the vuex method, which not only requires a lot of manpower to sort out the existing logic, but also requires developers to be familiar with the writing methods of these three methods at the same time. For a project, development low efficiency.

3、不同的开发者,对于项目的整体把控,以及对于vuex语法的理解程度不同,很容易造成在编写vuex语法过程中,出现语法不规范,写法不统一的情况,会造成其他开发者在阅读、修改代码过程中,增加阅读的难度,降低了整体项目的可维护性和扩展性。3. Different developers have different overall control of the project and different degrees of understanding of vuex grammar. It is easy to cause irregular grammar and inconsistent writing in the process of writing vuex grammar, which will cause other developers to In the process of reading and modifying the code, it increases the difficulty of reading and reduces the maintainability and scalability of the overall project.

综上所述,现有技术下会存在前端项目中数据传递方式转换困难、且转换标准不统一的问题。因此亟需一种将框架组件中数据传递方式进行编译转化的方法。To sum up, there are problems in the prior art that the conversion of data transmission methods in front-end projects is difficult and the conversion standards are not uniform. Therefore, there is an urgent need for a method for compiling and transforming the data transmission method in the framework components.

发明内容SUMMARY OF THE INVENTION

本发明提供一种数据传递方式转化方法、装置、电子设备及可读存储介质,其主要目的在于解决数据传递方式转化困难的问题。The present invention provides a method, device, electronic device and readable storage medium for data transmission mode conversion, the main purpose of which is to solve the problem of difficulty in data transmission mode conversion.

为实现上述目的,本发明提供的一种数据传递方式转化方法,包括:In order to achieve the above-mentioned purpose, a kind of data transmission mode conversion method provided by the present invention comprises:

构建前端项目的数据传递方式转化项目,在所述数据传递方式转化项目中引入目标传递方式的基础文件,得到标准传递方式转化项目;Building a data transfer mode conversion project of the front-end project, and introducing the basic file of the target transfer mode into the data transfer mode conversion project to obtain a standard transfer mode conversion project;

识别出所述标准传递方式转化项目的入口文件,基于所述入口文件查找出所述标准传递方式转化项目中的目标组件;Identifying the entry file of the standard delivery method transformation project, and finding out the target component in the standard delivery method transformation project based on the entry file;

识别所述目标组件中的原始数据传递方式;Identify the original data transfer method in the target component;

对所述原始数据传递方式中的待编译变量进行变量迁移,得到所述目标传递方式的前端项目。Perform variable migration on the to-be-compiled variables in the original data transfer mode to obtain the front-end project of the target transfer mode.

可选地,所述构建前端项目的数据传递方式转化项目,包括:Optionally, the data transfer mode conversion project for constructing the front-end project includes:

定位所述前端项目的根目录,在所述根目录中添加数据传递方式转化工具;Locate the root directory of the front-end project, and add a data transfer mode conversion tool in the root directory;

在所述数据传递方式转化工具中设置转化配置文件,并在添加完转化配置文件的根目录中添加数据传递方式转化命令,执行所述数据传递方式转化命令,得到所述数据传递方式转化项目。A conversion configuration file is set in the data transfer mode conversion tool, and a data transfer mode conversion command is added to the root directory where the conversion configuration file is added, and the data transfer mode conversion command is executed to obtain the data transfer mode conversion item.

可选地,所述在所述数据传递方式转化项目中引入目标传递方式的基础文件之前,还包括:Optionally, before the basic file of the target transmission mode is introduced into the data transmission mode conversion project, it also includes:

根据所述转化配置文件创建管理中心目录;Create a management center directory according to the conversion configuration file;

在所述管理中心目录下初始化一个管理文件,在所述管理文件中添加所述目标传递方式的多个对象属性,得到所述基础文件。A management file is initialized in the management center directory, and multiple object attributes of the target delivery method are added to the management file to obtain the basic file.

可选地,所述基于所述入口文件查找出所述标准传递方式转化项目中的目标组件,包括:Optionally, finding out the target component in the standard delivery mode conversion project based on the entry file, including:

利用预设的引入语法从所述入口文件中查找出包含目标后缀的文件作为父组件;Use the preset import syntax to find out the file containing the target suffix from the entry file as the parent component;

重复利用所述引入语法对所述父组件进行组件查找,得到所述父组件的所有子组件,并将查找到的子组件作为目标组件。The parent component is searched repeatedly by using the import syntax to obtain all child components of the parent component, and the found child components are used as target components.

可选地,所述识别所述目标组件中的原始数据传递方式,包括:Optionally, the identifying the original data transmission mode in the target component includes:

判断所述子组件中是否包含预设的关键词;judging whether the subcomponent contains a preset keyword;

若所述子组件中包含所述关键词,则确定所述目标组件中的原始数据传递方式为第一数据传递方式;If the subcomponent contains the keyword, determine that the original data transmission mode in the target component is the first data transmission mode;

若所述子组件中不包含所述关键词,则判断所述子组件是否和所述父组件进行数据通讯;If the subcomponent does not contain the keyword, determine whether the subcomponent performs data communication with the parent component;

若所述子组件和所述父组件未进行数据通讯,则返回所述重复利用所述引入语法对所述父组件进行组件查找的步骤,直至所有子组件均被判断;If the child component and the parent component do not perform data communication, then return to the step of repeatedly using the import grammar to perform component search on the parent component until all child components are judged;

若所述子组件和所述父组件进行数据通讯,则确定所述目标组件中的原始数据传递方式为第二数据传递方式。If the child component and the parent component perform data communication, it is determined that the original data transmission mode in the target component is the second data transmission mode.

可选地,所述判断所述子组件是否和所述父组件进行数据通讯,包括:Optionally, the judging whether the child component performs data communication with the parent component includes:

利用所述引入语法实例化一个组件库,并通过预设的导出关键字对所述组件库中进行对外导出操作;Use the import syntax to instantiate a component library, and perform an external export operation on the component library through a preset export keyword;

若所述组件库不能对外导出,则确定所述子组件和所述父组件未进行数据通讯;If the component library cannot be exported externally, it is determined that the child component and the parent component do not perform data communication;

若所述组件库能对外导出,则判断所述子组件中是否存在对象事件方法;If the component library can be exported externally, determine whether there is an object event method in the subcomponent;

若所述子组件中不存在对象事件方法,则确定所述子组件和所述父组件未进行数据通讯;If there is no object event method in the subcomponent, determine that the subcomponent and the parent component do not perform data communication;

若所述子组件中存在对象事件方法,则确定所述子组件和所述父组件进行数据通讯。If there is an object event method in the child component, it is determined that the child component and the parent component communicate with each other.

可选地,所述对所述原始数据传递方式中的待编译变量进行变量迁移,包括:Optionally, performing variable migration on the to-be-compiled variables in the original data transmission mode includes:

若所述原始数据传递方式为第一数据传递方式,则将所述子组件中通过所述第一数据传递方式调用的变量复制到所述对象属性中,并在所述对象属性中添加修改变量函数及触发变量函数;If the original data transmission method is the first data transmission method, copy the variable called by the first data transmission method in the subcomponent to the object property, and add a modified variable to the object property function and trigger variable function;

若所述原始数据传递方式为第二数据传递方式,则将所述子组件中通过所述第二数据传递方式传入的变量复制到所述对象属性中,并在所述对象属性中添加修改变量函数、触发变量函数及事件回调函数。If the original data transmission method is the second data transmission method, copy the variable passed in through the second data transmission method in the subcomponent to the object attribute, and add modifications to the object attribute Variable function, trigger variable function and event callback function.

为了解决上述问题,本发明还提供一种数据传递方式转化装置,所述装置包括:In order to solve the above problems, the present invention also provides a data transmission mode conversion device, the device includes:

数据传递方式转化项目构建模块,用于构建前端项目的数据传递方式转化项目,在所述数据传递方式转化项目中引入目标传递方式的基础文件,得到标准传递方式转化项目;The data transmission mode conversion project building module is used to construct the data transmission mode conversion project of the front-end project, and the basic file of the target transmission mode is introduced into the data transmission mode conversion project to obtain the standard transmission mode conversion project;

目标组件查找模块,用于识别出所述标准传递方式转化项目的入口文件,基于所述入口文件查找出所述标准传递方式转化项目中的目标组件;A target component search module, for identifying the entry file of the standard delivery method conversion project, and finding out the target component in the standard delivery method transformation project based on the entry file;

数据传递方式识别模块,用于识别所述目标组件中的原始数据传递方式;a data transfer mode identification module, used to identify the original data transfer mode in the target component;

数据传递方式转化模块,用于对所述原始数据传递方式中的待编译变量进行变量迁移,得到所述目标传递方式的前端项目。The data transfer mode conversion module is used to perform variable migration on the to-be-compiled variables in the original data transfer mode to obtain the front-end project of the target transfer mode.

为了解决上述问题,本发明还提供一种电子设备,所述电子设备包括:In order to solve the above problems, the present invention also provides an electronic device, the electronic device includes:

存储器,存储至少一个计算机程序;及a memory that stores at least one computer program; and

处理器,执行所述存储器中存储的计算机程序以实现上述所述的数据传递方式转化方法。The processor executes the computer program stored in the memory to implement the above-mentioned data transfer mode conversion method.

为了解决上述问题,本发明还提供一种计算机可读存储介质,所述计算机可读存储介质中存储有至少一个计算机程序,所述至少一个计算机程序被电子设备中的处理器执行以实现上述所述的数据传递方式转化方法。In order to solve the above problems, the present invention also provides a computer-readable storage medium, where at least one computer program is stored in the computer-readable storage medium, and the at least one computer program is executed by a processor in an electronic device to realize the above-mentioned The data transfer mode conversion method described above.

本发明通过直接在前端项目中构建数据传递方式转化项目,并通过识别出标准传递方式转化项目的入口文件进行目标组件的查找,通过确定目标组件中的原始数据传递方式,并对原始数据传递方式中的待编译变量进行变量迁移,无需事后人工进行组件编译,大大提高了数据传递方式转化的效率。同时,直接将目标组件中不同原始数据传递方式进行变量迁移,可以将不同目标组件的数据传递方式进行统一,提高了开发的可维护性及可扩展性。因此本发明提出的数据传递方式转化方法、装置、电子设备及计算机可读存储介质,可以解决数据传递方式转化困难的问题。The present invention transforms the project by constructing the data transfer mode directly in the front-end project, and searches the target component by identifying the entry file of the standard transfer mode conversion project, determines the original data transfer mode in the target component, and determines the original data transfer mode. The variables to be compiled in can be migrated, and there is no need to manually compile components afterwards, which greatly improves the efficiency of data transfer mode conversion. At the same time, by directly migrating different original data transmission methods in target components, the data transmission methods of different target components can be unified, and the maintainability and scalability of development can be improved. Therefore, the method, device, electronic device and computer-readable storage medium for data transmission mode conversion proposed by the present invention can solve the problem of difficulty in data transmission mode conversion.

附图说明Description of drawings

图1为本发明一实施例提供的数据传递方式转化方法的流程示意图;1 is a schematic flowchart of a data transmission mode conversion method provided by an embodiment of the present invention;

图2为图1中其中一个步骤的详细实施流程示意图;Fig. 2 is a detailed implementation flow diagram of one of the steps in Fig. 1;

图3为图1中另一个步骤的详细实施流程示意图;Fig. 3 is the detailed implementation flow schematic diagram of another step in Fig. 1;

图4为图1中另一个步骤的详细实施流程示意图;Fig. 4 is a detailed implementation flow diagram of another step in Fig. 1;

图5为图4中其中一个步骤的详细实施流程示意图;Fig. 5 is a detailed implementation flow diagram of one of the steps in Fig. 4;

图6为图1中另一个步骤的详细实施流程示意图;Fig. 6 is the detailed implementation flow schematic diagram of another step in Fig. 1;

图7为本发明一实施例提供的数据传递方式转化装置的功能模块图;7 is a functional block diagram of a data transmission mode conversion device provided by an embodiment of the present invention;

图8为本发明一实施例提供的实现所述数据传递方式转化方法的电子设备的结构示意图。FIG. 8 is a schematic structural diagram of an electronic device implementing the method for converting a data transmission mode according to an embodiment of the present invention.

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

具体实施方式Detailed ways

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

本发明实施例提供一种数据传递方式转化方法。所述数据传递方式转化方法的执行主体包括但不限于服务端、终端等能够被配置为执行本发明实施例提供的该方法的电子设备中的至少一种。换言之,所述数据传递方式转化方法可以由安装在终端设备或服务端设备的软件或硬件来执行,所述软件可以是区块链平台。所述服务端包括但不限于:单台服务器、服务器集群、云端服务器或云端服务器集群等。所述服务器可以是独立的服务器,也可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、内容分发网络(ContentDelivery Network,CDN)、以及大数据和人工智能平台等基础云计算服务的云服务器。The embodiment of the present invention provides a data transmission mode conversion method. The execution subject of the data transmission mode conversion method includes, but is not limited to, at least one of electronic devices that can be configured to execute the method provided by the embodiment of the present invention, such as a server and a terminal. In other words, the data transmission mode conversion method can be executed by software or hardware installed in a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like. The server can be an independent server, or can provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery network (Content Delivery Network) , CDN), and cloud servers for basic cloud computing services such as big data and artificial intelligence platforms.

参照图1所示,为本发明一实施例提供的数据传递方式转化方法的流程示意图。在本实施例中,所述数据传递方式转化方法包括以下步骤S1-S5:Referring to FIG. 1 , it is a schematic flowchart of a method for converting a data transmission mode according to an embodiment of the present invention. In this embodiment, the data transmission mode conversion method includes the following steps S1-S5:

S1、构建前端项目的数据传递方式转化项目,在所述数据传递方式转化项目中引入目标传递方式的基础文件,得到标准传递方式转化项目。S1. Construct a data transfer mode conversion project of a front-end project, and introduce a basic file of a target transfer mode into the data transfer mode conversion project to obtain a standard transfer mode conversion project.

本发明实施例中,所述前端项目是指通过HTML,CSS及JavaScript以及衍生出来的各种技术、框架、解决方案,来实现互联网产品的用户界面交互的项目,例如,XXapp开发项目、XX公司官网开发项目、XX产品页面开发项目、XX小程序开发项目等。In the embodiment of the present invention, the front-end project refers to a project that realizes the user interface interaction of Internet products through HTML, CSS, JavaScript and various derived technologies, frameworks, and solutions, for example, XXapp development project, XX company Official website development project, XX product page development project, XX applet development project, etc.

详细地,参照图2所示,所述构建前端项目的数据传递方式转化项目,包括以下步骤S10-S11:In detail, as shown in FIG. 2 , the data transfer mode conversion project for constructing the front-end project includes the following steps S10-S11:

S10、定位所述前端项目的根目录,在所述根目录中添加数据传递方式转化工具;S10, locate the root directory of the front-end project, and add a data transfer mode conversion tool in the root directory;

S11、在所述数据传递方式转化工具中设置转化配置文件,并在添加完转化配置文件的根目录中添加数据传递方式转化命令,执行所述数据传递方式转化命令,得到所述数据传递方式转化项目。S11, set a conversion configuration file in the data transfer mode conversion tool, and add a data transfer mode conversion command in the root directory where the conversion configuration file is added, execute the data transfer mode conversion command, and obtain the data transfer mode conversion project.

本发明实施例中,所述数据传递方式转化项目用来在前端页面中执行下述S2至S4的步骤来转换数据传递方式。例如,在命令行(mac系统为终端),定位当前前端项目根目录,执行命令:npmi data-transfer-transform-vuex-D,则可以添加数据传递方式转化工具到当前框架项目中,设置转化配置文件config.js,在转化配置文件中添加数据传递方式转化命令:npm run transform-vuex并执行,得到数据传递方式转化项目,其中,转化配置文件中的配置内容包括:1、项目开发文件所在目录;2、项目入口文件地址等。In the embodiment of the present invention, the data transmission mode conversion item is used to perform the following steps S2 to S4 in the front-end page to convert the data transmission mode. For example, on the command line (the mac system is the terminal), locate the root directory of the current front-end project, and execute the command: npmi data-transfer-transform-vuex-D, you can add the data transfer method conversion tool to the current framework project and set the conversion configuration In the file config.js, add the data transfer mode transformation command in the transformation configuration file: npm run transform-vuex and execute it to get the data transfer mode transformation project. The configuration content in the transformation configuration file includes: 1. The directory where the project development file is located ; 2. The project entry file address, etc.

详细地,所述在所述数据传递方式转化项目中引入目标传递方式的基础文件之前,还包括:In detail, before the basic file of the target transfer mode is introduced into the data transfer mode conversion project, it also includes:

根据所述转化配置文件创建管理中心目录;Create a management center directory according to the conversion configuration file;

在所述管理中心目录下初始化一个管理文件,在所述管理文件中添加所述目标传递方式的多个对象属性,得到所述基础文件。A management file is initialized in the management center directory, and multiple object attributes of the target delivery method are added to the management file to obtain the basic file.

本发明一可选实施例中,所述目标传递方式可以为vuex传递方式,例如在vue框架中,首先确定是否包含vuex传递方式,通过判断项目中是否包含vuex库文件,并查找前端项目中的package.json文件,该文件是项目中管理依赖包的文件,查找该文件中的dependencies属性中是否包含vuex,如果包含,则说明项目本身已经具有了vuex库文件,如果不包含,则需要通过以下命令npmivuex–save将vue库文件安装到前端项目中来。In an optional embodiment of the present invention, the target delivery method may be the vuex delivery method. For example, in the vue framework, first determine whether the vuex delivery method is included, by judging whether the project contains the vuex library file, and find the front-end project. The package.json file, which is the file for managing dependent packages in the project, find out whether the dependencies property in the file contains vuex, if so, it means that the project itself already has the vuex library file, if not, you need to pass the following The command npmivuex-save installs the vue library file into the front-end project.

具体地,根据转化配置文件config.js中所配置的第一个配置项:项目开发文件所在目录,确定所有开发文件所在的目录地址,并在此目录下,创建了一个store文件夹(即所述管理中心目录),作为vuex数据管理中心的根目录,在store目录下,初始化一个名为index.js文件(即管理文件),该文件是vuex的核心文件,作用为统一保存变量数据、统一对外暴露修改变量的方法、统一执行修改变量的操作等。然后从vuex库中,引入初始化vuex传递方式的方法createStore,调用该方法时,会传入三个对象属性,分别为以下三点:state对象(用于保存变量和数据)、actions对象(用于管理对外暴露修改变量方法)、mutations对象(用于管理内部修改变量方法)。由于当前还未将原有数据传递方式(props/$emit、$emit/$on方式等)进行编译为目标传递方式(vuex方式),所以该三个对象暂时都为空对象形式,后期编译过程中,将会不断往里面添加内容。Specifically, according to the first configuration item configured in the conversion configuration file config.js: the directory where the project development files are located, determine the directory addresses where all the development files are located, and create a store folder (that is, all the development files) in this directory. The management center directory), as the root directory of the vuex data management center, in the store directory, initialize a file named index. Expose the method of modifying variables to the outside world, and uniformly execute the operation of modifying variables. Then from the vuex library, the method createStore is introduced to initialize the vuex delivery method. When calling this method, three object attributes are passed in, which are the following three points: state object (used to save variables and data), actions object (used to save variables and data) Manage externally exposed modification variable methods), mutations object (used to manage internal modification variable methods). Since the original data transfer method (props/$emit, $emit/$on method, etc.) has not yet been compiled into the target transfer method (vuex method), the three objects are temporarily in the form of empty objects, and the later compilation process , will continue to add content to it.

S2、识别出所述标准传递方式转化项目的入口文件,基于所述入口文件查找出所述标准传递方式转化项目中的目标组件。S2. Identify the entry file of the standard delivery mode conversion project, and find out the target component in the standard delivery mode transformation project based on the entry file.

本发明实施例中,以vue框架为例,由于vue的前端项目都是采用单页面,由一个入口页面开始,引入各类关联页面组件,形成一个以入口文件为主干的树形分布的文件引用关系,所以只需要通过入口文件,就可以将后续所有文件的父子结构关系推导出来。In the embodiment of the present invention, taking the Vue framework as an example, since the front-end projects of Vue all use a single page, starting from an entry page, various associated page components are introduced to form a tree-shaped distribution file reference with the entry file as the backbone Therefore, the parent-child structure relationship of all subsequent files can be deduced only through the entry file.

本发明一可选实施例中,通过转化配置文件config.js中,所配置的第二个配置项:项目入口文件地址,可以找到对应的入口文件。In an optional embodiment of the present invention, by converting the second configuration item configured in the configuration file config.js: the address of the project entry file, the corresponding entry file can be found.

具体地,参照图3所示,所述基于所述入口文件查找出所述标准传递方式转化项目中的目标组件,包括以下步骤S20-S21:Specifically, referring to FIG. 3 , finding out the target component in the standard delivery mode conversion project based on the entry file includes the following steps S20-S21:

S20、利用预设的引入语法从所述入口文件中查找出包含目标后缀的文件作为父组件;S20, utilize the preset import syntax to find out the file containing the target suffix as the parent component from the entry file;

S21、重复利用所述引入语法对所述父组件进行组件查找,得到所述父组件的所有子组件,并将查找到的子组件作为目标组件。S21. Perform component search on the parent component by repeatedly using the import syntax to obtain all child components of the parent component, and use the found child components as a target component.

本发明一可选实施例中,由于入口文件是通过语法import将其他页面组件引入到当前文件中来,所以只需要在当前入口文件中,通过import语法识别哪些包含了.vue结尾的文件,该文件便是vue组件(即父组件),同时利用import语法重复进行深度查找,得到vue组件后一级的子组件作为目标组件。In an optional embodiment of the present invention, since the entry file introduces other page components into the current file through the import syntax, it is only necessary to identify the files ending with .vue in the current entry file through the import syntax. The file is the vue component (that is, the parent component), and at the same time, the import syntax is used to repeatedly perform in-depth search, and the sub-component after the vue component is obtained as the target component.

S3、识别所述目标组件中的原始数据传递方式。S3. Identify the original data transmission mode in the target component.

本发明实施例中,所述原始数据传递方式是指当前目标组件中的数据传递方式,例如,vue组件中,props/$emit、$emit/$on方式等。In the embodiment of the present invention, the original data transmission mode refers to the data transmission mode in the current target component, for example, in the vue component, the props/$emit, $emit/$on mode, and the like.

详细地,参照图4所示,所述识别所述目标组件中的原始数据传递方式,包括以下步骤S30-S34:In detail, referring to FIG. 4 , the identifying the original data transmission mode in the target component includes the following steps S30-S34:

S30、判断所述子组件中是否包含预设的关键词;S30, judging whether a preset keyword is included in the subcomponent;

若所述子组件中包含所述关键词,则执行S31、确定所述目标组件中的原始数据传递方式为第一数据传递方式;If the subcomponent contains the keyword, then perform S31, and determine that the original data transmission mode in the target component is the first data transmission mode;

若所述子组件中不包含所述关键词,则执行S32、判断所述子组件是否和所述父组件进行数据通讯;If the subassembly does not contain the keyword, then execute S32 to determine whether the subassembly performs data communication with the parent assembly;

若所述子组件和所述父组件未进行数据通讯,则执行S33、返回所述重复利用所述引入语法对所述父组件进行组件查找的步骤,直至所有子组件均被判断;If the child component and the parent component do not perform data communication, then execute S33, and return to the step of repeating the introduction of the grammar to perform component search on the parent component, until all child components are judged;

若所述子组件和所述父组件进行数据通讯,则执行S34、确定所述目标组件中的原始数据传递方式为第二数据传递方式。If the child component and the parent component perform data communication, S34 is executed to determine that the original data transmission mode in the target component is the second data transmission mode.

本发明实施例中,由于不同数据传递方式中需要转换的变量不同,因此通过细化目标组件中的不同数据传递方式,可以提高数据传递方式转化的准确率及效率。In the embodiment of the present invention, since the variables that need to be converted are different in different data transmission modes, the accuracy and efficiency of data transmission mode conversion can be improved by refining different data transmission modes in the target component.

本发明一可选实施例中,在vue框架中,首先判断子组件中是否包含props关键字,如果包含,确定该子组件使用props/$emit方式(第一数据传递方式)进行数据传递,如果不包含,则说明该子组件没有使用到父组件传递的动态参数,则判断子组件中是否包括this.$emit关键字,确定该子组件使用props/$emit方式进行数据传递,如果不包含,判断父子组件之间是否有进行数据通讯,若存在,确定子组件使用$emit/$on方式(第二数据传递方式)进行数据传递。In an optional embodiment of the present invention, in the vue framework, it is first judged whether the subcomponent contains the props keyword. If so, it is determined that the subcomponent uses the props/$emit method (the first data transmission method) for data transmission. If If not included, it means that the child component does not use the dynamic parameters passed by the parent component, then judge whether the child component includes the this.$emit keyword, and determine whether the child component uses the props/$emit method for data transmission. If not included, Determine whether there is data communication between the parent and child components, and if so, determine that the child component uses the $emit/$on method (the second data transmission method) to transmit data.

进一步地,参照图5所示,所述判断所述子组件是否和所述父组件进行数据通讯,包括以下步骤S340-S344:Further, as shown in FIG. 5 , the judging whether the child component performs data communication with the parent component includes the following steps S340-S344:

S340、利用所述引入语法实例化一个组件库,并通过预设的导出关键字对所述组件库中进行对外导出操作;S340, instantiate a component library using the import syntax, and perform an external export operation in the component library through a preset export keyword;

S341、若所述组件库不能对外导出,则确定所述子组件和所述父组件未进行数据通讯;S341, if the component library cannot be exported externally, determine that the subcomponent and the parent component do not perform data communication;

S342、若所述组件库能对外导出,则判断所述子组件中是否存在对象事件方法;S342, if the component library can be exported externally, determine whether there is an object event method in the subcomponent;

若所述子组件中不存在对象事件方法,则执行S343、确定所述子组件和所述父组件未进行数据通讯;If there is no object event method in the subcomponent, then perform S343, determine that the subcomponent and the parent component do not perform data communication;

若所述子组件中存在对象事件方法,则执行S344、确定所述子组件和所述父组件进行数据通讯。If there is an object event method in the subcomponent, perform S344 to determine that the subcomponent and the parent component perform data communication.

本发明一可选实施例中,通过import语法在所述子组件中引入vue库(组件库),并通过new关键词实例化vue库,再通过export关键字对外导出,如果不能对外导出,则确定所述子组件和所述父组件未进行数据通讯,如果能够对外导出,判断是否有使用引入数据中心的对象事件方法,如使用对象内的$emit方法触发事件,并传入变量,或使用对象内的$on方法申明一个事件,如果不存在,则确定所述子组件和所述父组件未进行数据通讯,反之则进行数据通讯。In an optional embodiment of the present invention, the vue library (component library) is introduced into the sub-component through the import syntax, and the vue library is instantiated through the new keyword, and then exported through the export keyword. Make sure that the child component and the parent component do not communicate with each other. If they can be exported externally, determine whether there is an object event method introduced into the data center. For example, use the $emit method in the object to trigger an event and pass in a variable, or use The $on method in the object declares an event. If it does not exist, it is determined that the child component and the parent component do not communicate with each other, otherwise, data communication is performed.

S4、对所述原始数据传递方式中的待编译变量进行变量迁移,得到所述目标传递方式的前端项目。S4. Perform variable migration on the variables to be compiled in the original data transfer mode to obtain a front-end project in the target transfer mode.

本发明实施例中,通过将不同数据传递方试中的变量进行编译转化,并迁移到所述对象属性中,从而将数据传递方式进行转换。In the embodiment of the present invention, the data transmission modes are converted by compiling and transforming variables in different data transmission methods and migrating them to the object attributes.

详细地,参照图6所示,所述对所述原始数据传递方式中的待编译变量进行变量迁移,包括以下步骤S50-S51:In detail, referring to FIG. 6 , the variable migration for the variables to be compiled in the original data transfer mode includes the following steps S50-S51:

S50、若所述原始数据传递方式为第一数据传递方式,则将所述子组件中通过所述第一数据传递方式调用的变量复制到所述对象属性中,并在所述对象属性中添加修改变量函数及触发变量函数;S50. If the original data transmission mode is the first data transmission mode, copy the variable called by the first data transmission mode in the subcomponent to the object attribute, and add the variable in the object attribute Modify variable functions and trigger variable functions;

S51、若所述原始数据传递方式为第二数据传递方式,则将所述子组件中通过所述第二数据传递方式传入的变量复制到所述对象属性中,并在所述对象属性中添加修改变量函数、触发变量函数及事件回调函数。S51. If the original data transmission mode is the second data transmission mode, copy the variable passed in through the second data transmission mode in the subcomponent into the object attribute, and store the variable in the object attribute Add modify variable function, trigger variable function and event callback function.

本发明一可选实施例中,对于第一数据传递方式(即props/$emit传递方式),通过下述步骤进行变量数据迁移:In an optional embodiment of the present invention, for the first data transmission mode (that is, the props/$emit transmission mode), variable data migration is performed through the following steps:

1.1、将当前使用的子组件调用父组件传入方法,并在调用时传入的变量,复制一份到state对象中;1.1. Call the currently used child component to the parent component to pass in the method, and copy the variables passed in during the call to the state object;

1.2、查找当前变量在父组件中,是否有修改变量的操作,例如,变量的重新赋值,语法为this.变量=新变量值。如果存在这种场景,则进行下一步操作。如果不存在,则说明该变量纯粹静态的,只是由父组件传入,结束变量迁移;1.2. Find out whether the current variable is in the parent component, and whether there is an operation to modify the variable, such as reassignment of the variable, the syntax is this. variable = new variable value. If such a scenario exists, proceed to the next step. If it does not exist, it means that the variable is purely static, only passed in by the parent component, ending the variable migration;

1.3、在mutations对象中,生成一条用于修改state变量的方法函数(修改变量函数);1.3. In the mutations object, generate a method function (modify variable function) for modifying the state variable;

1.4、在actions对象中,生成一条用于触发步骤1.3生成的函数(触发变量函数);1.4. In the actions object, generate a function (trigger variable function) for triggering the generation of step 1.3;

1.5、将步骤1.4生成的函数,引入到该子组件中去,并在对应原修改变量的代码中,替换为通过dispatch方式触发变量的修改,完成待编译变量的迁移。1.5. Introduce the function generated in step 1.4 into the subcomponent, and replace the code corresponding to the original modified variable with the modification of the variable triggered by dispatch to complete the migration of the variable to be compiled.

本发明另一可选实施例中,对于第二数据传递方式(即$emit/$on传递方式),通过下述步骤进行变量数据迁移:In another optional embodiment of the present invention, for the second data transmission mode (that is, the $emit/$on transmission mode), variable data migration is performed through the following steps:

2.1、将通过$emit方法触发事件传入的变量,复制一份到state对象中;2.1. Copy the variable passed in through the $emit method triggering the event to the state object;

2.2、在mutations对象中,生成一条用于修改state变量的方法函数(修改变量函数);2.2. In the mutations object, generate a method function (modify variable function) for modifying the state variable;

2.3、在actions对象中,生成一条用于触发步骤2.3生成的函数(触发变量函数);2.3. In the actions object, generate a function (trigger variable function) for triggering the generation of step 2.3;

2.4、通过$on方法申明一个事件,取其第二个参数,即事件回调函数,将其中修改修改变量函数的代码,替换为通过dispatch方式触发变量修改,完成待编译变量的迁移。2.4. Declare an event through the $on method, take its second parameter, the event callback function, and replace the code of the function that modifies the variable with the variable modification triggered by dispatch to complete the migration of the variable to be compiled.

本发明通过直接在前端项目中构建数据传递方式转化项目,并通过识别出标准传递方式转化项目的入口文件进行目标组件的查找,通过确定目标组件中的原始数据传递方式,并对原始数据传递方式中的待编译变量进行变量迁移,无需事后人工进行组件编译,大大提高了数据传递方式转化的效率。同时,直接将目标组件中不同原始数据传递方式进行变量迁移,可以将不同目标组件的数据传递方式进行统一,提高了开发的可维护性及可扩展性。因此本发明提出的数据传递方式转化方法,可以解决数据传递方式转化困难的问题。The present invention transforms the project by constructing the data transfer mode directly in the front-end project, and searches the target component by identifying the entry file of the standard transfer mode conversion project, determines the original data transfer mode in the target component, and determines the original data transfer mode. The variables to be compiled in can be migrated, and there is no need to manually compile components afterwards, which greatly improves the efficiency of data transfer mode conversion. At the same time, by directly migrating different original data transmission methods in target components, the data transmission methods of different target components can be unified, and the maintainability and scalability of development can be improved. Therefore, the data transmission mode conversion method proposed by the present invention can solve the problem of difficulty in data transmission mode conversion.

如图7所示,是本发明一实施例提供的数据传递方式转化装置的功能模块图。As shown in FIG. 7 , it is a functional block diagram of an apparatus for converting a data transmission mode provided by an embodiment of the present invention.

本发明所述数据传递方式转化装置100可以安装于电子设备中。根据实现的功能,所述数据传递方式转化装置100可以包括数据传递方式转化项目构建模块101、目标组件查找模块102、数据传递方式识别模块103及数据传递方式转化模块104。本发明所述模块也可以称之为单元,是指一种能够被电子设备处理器所执行,并且能够完成固定功能的一系列计算机程序段,其存储在电子设备的存储器中。The data transmission mode conversion apparatus 100 of the present invention can be installed in an electronic device. According to the realized functions, the data transmission mode conversion apparatus 100 may include a data transmission mode conversion project construction module 101 , a target component search module 102 , a data transmission mode identification module 103 and a data transmission mode conversion module 104 . The modules in the present invention may also be called units, which refer to a series of computer program segments that can be executed by the electronic device processor and can perform fixed functions, and are stored in the memory of the electronic device.

在本实施例中,关于各模块/单元的功能如下:In this embodiment, the functions of each module/unit are as follows:

所述数据传递方式转化项目构建模块101,用于构建前端项目的数据传递方式转化项目,在所述数据传递方式转化项目中引入目标传递方式的基础文件,得到标准传递方式转化项目;The data transmission mode conversion project building module 101 is used to construct a data transmission mode conversion project of the front-end project, and the basic file of the target transmission mode is introduced into the data transmission mode conversion project to obtain a standard transmission mode conversion project;

所述目标组件查找模块102,用于识别出所述标准传递方式转化项目的入口文件,基于所述入口文件查找出所述标准传递方式转化项目中的目标组件;The target component search module 102 is used to identify the entry file of the standard delivery method conversion project, and find out the target component in the standard delivery method transformation project based on the entry file;

所述数据传递方式识别模块103,用于识别所述目标组件中的原始数据传递方式;The data transfer mode identification module 103 is used to identify the original data transfer mode in the target component;

所述数据传递方式转化模块104,用于对所述原始数据传递方式中的待编译变量进行变量迁移,得到所述目标传递方式的前端项目。The data transfer mode conversion module 104 is configured to perform variable migration on the variables to be compiled in the original data transfer mode to obtain the front-end project of the target transfer mode.

详细地,所述数据传递方式转化装置100各模块的具体实施方式如下:In detail, the specific implementation of each module of the data transmission mode conversion device 100 is as follows:

步骤一、构建前端项目的数据传递方式转化项目,在所述数据传递方式转化项目中引入目标传递方式的基础文件,得到标准传递方式转化项目。Step 1: Build a data transfer mode conversion project of the front-end project, and introduce the basic file of the target transfer mode into the data transfer mode conversion project to obtain a standard transfer mode conversion project.

本发明实施例中,所述前端项目是指通过HTML,CSS及JavaScript以及衍生出来的各种技术、框架、解决方案,来实现互联网产品的用户界面交互的项目,例如,XXapp开发项目、XX公司官网开发项目、XX产品页面开发项目、XX小程序开发项目等。In the embodiment of the present invention, the front-end project refers to a project that realizes the user interface interaction of Internet products through HTML, CSS, JavaScript and various derived technologies, frameworks, and solutions, for example, XXapp development project, XX company Official website development project, XX product page development project, XX applet development project, etc.

详细地,所述构建前端项目的数据传递方式转化项目,包括:In detail, the data transfer mode conversion project for constructing the front-end project includes:

定位所述前端项目的根目录,在所述根目录中添加数据传递方式转化工具;Locate the root directory of the front-end project, and add a data transfer mode conversion tool in the root directory;

在所述数据传递方式转化工具中设置转化配置文件,并在添加完转化配置文件的根目录中添加数据传递方式转化命令,执行所述数据传递方式转化命令,得到所述数据传递方式转化项目。A conversion configuration file is set in the data transfer mode conversion tool, and a data transfer mode conversion command is added in the root directory where the conversion configuration file is added, and the data transfer mode conversion command is executed to obtain the data transfer mode conversion item.

本发明实施例中,所述数据传递方式转化项目用来在前端页面中执行下述步骤二至步骤四来转换数据传递方式。例如,在命令行(mac系统为终端),定位当前前端项目根目录,执行命令:npmi data-transfer-transform-vuex-D,则可以添加数据传递方式转化工具到当前框架项目中,设置转化配置文件config.js,在转化配置文件中添加数据传递方式转化命令:npm run transform-vuex并执行,得到数据传递方式转化项目,其中,转化配置文件中的配置内容包括:1、项目开发文件所在目录;2、项目入口文件地址等。In the embodiment of the present invention, the data transmission mode conversion item is used to perform the following steps 2 to 4 on the front-end page to convert the data transmission mode. For example, on the command line (the mac system is the terminal), locate the root directory of the current front-end project, and execute the command: npmi data-transfer-transform-vuex-D, you can add the data transfer method conversion tool to the current framework project and set the conversion configuration In the file config.js, add the data transfer mode transformation command in the transformation configuration file: npm run transform-vuex and execute it to get the data transfer mode transformation project. The configuration content in the transformation configuration file includes: 1. The directory where the project development file is located ; 2. The project entry file address, etc.

详细地,所述在所述数据传递方式转化项目中引入目标传递方式的基础文件之前,还包括:In detail, before the basic file of the target transfer mode is introduced into the data transfer mode conversion project, it also includes:

根据所述转化配置文件创建管理中心目录;Create a management center directory according to the conversion configuration file;

在所述管理中心目录下初始化一个管理文件,在所述管理文件中添加所述目标传递方式的多个对象属性,得到所述基础文件。A management file is initialized in the management center directory, and multiple object attributes of the target delivery method are added to the management file to obtain the basic file.

本发明一可选实施例中,所述目标传递方式可以为vuex传递方式,例如在vue框架中,首先确定是否包含vuex传递方式,通过判断项目中是否包含vuex库文件,并查找前端项目中的package.json文件,该文件是项目中管理依赖包的文件,查找该文件中的dependencies属性中是否包含vuex,如果包含,则说明项目本身已经具有了vuex库文件,如果不包含,则需要通过以下命令npmivuex–save将vue库文件安装到前端项目中来。In an optional embodiment of the present invention, the target delivery method may be the vuex delivery method. For example, in the vue framework, first determine whether the vuex delivery method is included, by judging whether the project contains the vuex library file, and find the front-end project. The package.json file, which is the file for managing dependent packages in the project, find out whether the dependencies property in the file contains vuex, if so, it means that the project itself already has the vuex library file, if not, you need to pass the following The command npmivuex-save installs the vue library file into the front-end project.

具体地,根据转化配置文件config.js中所配置的第一个配置项:项目开发文件所在目录,确定所有开发文件所在的目录地址,并在此目录下,创建了一个store文件夹(即所述管理中心目录),作为vuex数据管理中心的根目录,在store目录下,初始化一个名为index.js文件(即管理文件),该文件是vuex的核心文件,作用为统一保存变量数据、统一对外暴露修改变量的方法、统一执行修改变量的操作等。然后从vuex库中,引入初始化vuex传递方式的方法createStore,调用该方法时,会传入三个对象属性,分别为以下三点:state对象(用于保存变量和数据)、actions对象(用于管理对外暴露修改变量方法)、mutations对象(用于管理内部修改变量方法)。由于当前还未将原有数据传递方式(props/$emit、$emit/$on方式等)进行编译为目标传递方式(vuex方式),所以该三个对象暂时都为空对象形式,后期编译过程中,将会不断往里面添加内容。Specifically, according to the first configuration item configured in the conversion configuration file config.js: the directory where the project development files are located, determine the directory addresses where all the development files are located, and create a store folder (that is, all the development files) in this directory. The management center directory), as the root directory of the vuex data management center, in the store directory, initialize a file named index. Expose the method of modifying variables to the outside world, and uniformly execute the operation of modifying variables. Then from the vuex library, the method createStore is introduced to initialize the vuex delivery method. When calling this method, three object attributes are passed in, which are the following three points: state object (used to save variables and data), actions object (used to save variables and data) Manage externally exposed modification variable methods), mutations object (used to manage internal modification variable methods). Since the original data transfer method (props/$emit, $emit/$on method, etc.) has not yet been compiled into the target transfer method (vuex method), the three objects are temporarily in the form of empty objects, and the later compilation process , will continue to add content to it.

步骤二、识别出所述标准传递方式转化项目的入口文件,基于所述入口文件查找出所述标准传递方式转化项目中的目标组件。Step 2: Identify the entry file of the standard delivery method conversion project, and find out the target component in the standard delivery method transformation project based on the entry file.

本发明实施例中,以vue框架为例,由于vue的前端项目都是采用单页面,由一个入口页面开始,引入各类关联页面组件,形成一个以入口文件为主干的树形分布的文件引用关系,所以只需要通过入口文件,就可以将后续所有文件的父子结构关系推导出来。In the embodiment of the present invention, taking the Vue framework as an example, since the front-end projects of Vue all use a single page, starting from an entry page, various associated page components are introduced to form a tree-shaped distribution file reference with the entry file as the backbone Therefore, the parent-child structure relationship of all subsequent files can be deduced only through the entry file.

本发明一可选实施例中,通过转化配置文件config.js中,所配置的第二个配置项:项目入口文件地址,可以找到对应的入口文件。In an optional embodiment of the present invention, by converting the second configuration item configured in the configuration file config.js: the address of the project entry file, the corresponding entry file can be found.

具体地,所述基于所述入口文件查找出所述标准传递方式转化项目中的目标组件,包括:Specifically, finding out the target component in the standard delivery mode conversion project based on the entry file includes:

利用预设的引入语法从所述入口文件中查找出包含目标后缀的文件作为父组件;Use the preset import syntax to find out the file containing the target suffix from the entry file as the parent component;

重复利用所述引入语法对所述父组件进行组件查找,得到所述父组件的所有子组件,并将查找到的子组件作为目标组件。The parent component is searched repeatedly by using the import syntax to obtain all child components of the parent component, and the found child components are used as target components.

本发明一可选实施例中,由于入口文件是通过语法import将其他页面组件引入到当前文件中来,所以只需要在当前入口文件中,通过import语法识别哪些包含了.vue结尾的文件,该文件便是vue组件(即父组件),同时利用import语法重复进行深度查找,得到vue组件后一级的子组件作为目标组件。In an optional embodiment of the present invention, since the entry file introduces other page components into the current file through the import syntax, it is only necessary to identify the files ending with .vue in the current entry file through the import syntax. The file is the vue component (that is, the parent component), and at the same time, the import syntax is used to repeatedly perform in-depth search, and the sub-component after the vue component is obtained as the target component.

步骤三、识别所述目标组件中的原始数据传递方式。Step 3: Identify the original data transmission mode in the target component.

本发明实施例中,所述原始数据传递方式是指当前目标组件中的数据传递方式,例如,vue组件中,props/$emit、$emit/$on方式等。In the embodiment of the present invention, the original data transmission mode refers to the data transmission mode in the current target component, for example, in the vue component, the props/$emit, $emit/$on mode, and the like.

详细地,所述识别所述目标组件中的原始数据传递方式,包括:In detail, the identifying the original data transmission mode in the target component includes:

判断所述子组件中是否包含预设的关键词;judging whether the subcomponent contains a preset keyword;

若所述子组件中包含所述关键词,则确定所述目标组件中的原始数据传递方式为第一数据传递方式;If the subcomponent contains the keyword, determine that the original data transmission mode in the target component is the first data transmission mode;

若所述子组件中不包含所述关键词,则判断所述子组件是否和所述父组件进行数据通讯;If the subcomponent does not contain the keyword, determine whether the subcomponent performs data communication with the parent component;

若所述子组件和所述父组件未进行数据通讯,则返回所述重复利用所述引入语法对所述父组件进行组件查找的步骤,直至所有子组件均被判断;If the child component and the parent component do not perform data communication, then return to the step of repeatedly using the import grammar to perform component search on the parent component until all child components are judged;

若所述子组件和所述父组件进行数据通讯,则确定所述目标组件中的原始数据传递方式为第二数据传递方式。If the child component and the parent component perform data communication, it is determined that the original data transmission mode in the target component is the second data transmission mode.

本发明实施例中,由于不同数据传递方式中需要转换的变量不同,因此通过细化目标组件中的不同数据传递方式,可以提高数据传递方式转化的准确率及效率。In the embodiment of the present invention, since the variables that need to be converted are different in different data transmission modes, the accuracy and efficiency of data transmission mode conversion can be improved by refining different data transmission modes in the target component.

本发明一可选实施例中,在vue框架中,首先判断子组件中是否包含props关键字,如果包含,确定该子组件使用props/$emit方式(第一数据传递方式)进行数据传递,如果不包含,则说明该子组件没有使用到父组件传递的动态参数,则判断子组件中是否包括this.$emit关键字,确定该子组件使用props/$emit方式进行数据传递,如果不包含,判断父子组件之间是否有进行数据通讯,若存在,确定子组件使用$emit/$on方式(第二数据传递方式)进行数据传递。In an optional embodiment of the present invention, in the Vue framework, it is first judged whether the subcomponent contains the props keyword. If so, it is determined that the subcomponent uses the props/$emit method (the first data transmission method) for data transmission. If If not included, it means that the child component does not use the dynamic parameters passed by the parent component, then judge whether the child component includes the this.$emit keyword, and determine whether the child component uses the props/$emit method for data transmission. If not included, Determine whether there is data communication between the parent and child components, and if so, determine that the child component uses the $emit/$on method (the second data transmission method) to transmit data.

进一步地,所述判断所述子组件是否和所述父组件进行数据通讯,包括:Further, the judging whether the child component performs data communication with the parent component includes:

利用所述引入语法实例化一个组件库,并通过预设的导出关键字对所述组件库中进行对外导出操作;Use the import syntax to instantiate a component library, and perform an external export operation on the component library through a preset export keyword;

若所述组件库不能对外导出,则确定所述子组件和所述父组件未进行数据通讯;If the component library cannot be exported externally, it is determined that the child component and the parent component do not perform data communication;

若所述组件库能对外导出,则判断所述子组件中是否存在对象事件方法;If the component library can be exported externally, determine whether there is an object event method in the subcomponent;

若所述子组件中不存在对象事件方法,则确定所述子组件和所述父组件未进行数据通讯;If there is no object event method in the subcomponent, determine that the subcomponent and the parent component do not perform data communication;

若所述子组件中存在对象事件方法,则确定所述子组件和所述父组件进行数据通讯。If there is an object event method in the child component, it is determined that the child component and the parent component communicate with each other.

本发明一可选实施例中,通过import语法在所述子组件中引入vue库(组件库),并通过new关键词实例化vue库,再通过export关键字对外导出,如果不能对外导出,则确定所述子组件和所述父组件未进行数据通讯,如果能够对外导出,判断是否有使用引入数据中心的对象事件方法,如使用对象内的$emit方法触发事件,并传入变量,或使用对象内的$on方法申明一个事件,如果不存在,则确定所述子组件和所述父组件未进行数据通讯,反之则进行数据通讯。In an optional embodiment of the present invention, the vue library (component library) is introduced into the sub-component through the import syntax, and the vue library is instantiated through the new keyword, and then exported through the export keyword. Make sure that the child component and the parent component do not communicate with each other, and if they can be exported externally, determine whether there is an object event method introduced into the data center, such as using the $emit method in the object to trigger an event and passing in a variable, or The $on method in the object declares an event. If it does not exist, it is determined that the child component and the parent component do not communicate with each other, otherwise, data communication is performed.

步骤四、对所述原始数据传递方式中的待编译变量进行变量迁移,得到所述目标传递方式的前端项目。Step 4: Perform variable migration on the to-be-compiled variables in the original data transfer mode to obtain a front-end project in the target transfer mode.

本发明实施例中,通过将不同数据传递方试中的变量进行编译转化,并迁移到所述对象属性中,从而将数据传递方式进行转换。In the embodiment of the present invention, the data transmission mode is converted by compiling and transforming variables in different data transmission methods, and migrating them to the object attributes.

详细地,所述对所述原始数据传递方式中的待编译变量进行变量迁移,包括:In detail, the variable migration for the variables to be compiled in the original data transmission mode includes:

若所述原始数据传递方式为第一数据传递方式,则将所述子组件中通过所述第一数据传递方式调用的变量复制到所述对象属性中,并在所述对象属性中添加修改变量函数及触发变量函数;If the original data transmission method is the first data transmission method, copy the variable called by the first data transmission method in the subcomponent to the object property, and add a modified variable to the object property function and trigger variable function;

若所述原始数据传递方式为第二数据传递方式,则将所述子组件中通过所述第二数据传递方式传入的变量复制到所述对象属性中,并在所述对象属性中添加修改变量函数、触发变量函数及事件回调函数。If the original data transmission method is the second data transmission method, copy the variable passed in through the second data transmission method in the subcomponent to the object attribute, and add modifications to the object attribute Variable function, trigger variable function and event callback function.

本发明一可选实施例中,对于第一数据传递方式(即props/$emit传递方式),通过下述步骤进行变量数据迁移:In an optional embodiment of the present invention, for the first data transmission mode (that is, the props/$emit transmission mode), variable data migration is performed through the following steps:

1.1、将当前使用的子组件调用父组件传入方法,并在调用时传入的变量,复制一份到state对象中;1.1. Call the currently used child component to the parent component to pass in the method, and copy the variables passed in during the call to the state object;

1.2、查找当前变量在父组件中,是否有修改变量的操作,例如,变量的重新赋值,语法为this.变量=新变量值。如果存在这种场景,则进行下一步操作。如果不存在,则说明该变量纯粹静态的,只是由父组件传入,结束变量迁移;1.2. Find out whether the current variable is in the parent component, and whether there is an operation to modify the variable, such as reassignment of the variable, the syntax is this. variable = new variable value. If such a scenario exists, proceed to the next step. If it does not exist, it means that the variable is purely static, only passed in by the parent component, ending the variable migration;

1.3、在mutations对象中,生成一条用于修改state变量的方法函数(修改变量函数);1.3. In the mutations object, generate a method function (modify variable function) for modifying the state variable;

1.4、在actions对象中,生成一条用于触发步骤1.3生成的函数(触发变量函数);1.4. In the actions object, generate a function (trigger variable function) for triggering the generation of step 1.3;

1.5、将步骤1.4生成的函数,引入到该子组件中去,并在对应原修改变量的代码中,替换为通过dispatch方式触发变量的修改,完成待编译变量的迁移。1.5. Introduce the function generated in step 1.4 into the subcomponent, and replace the code corresponding to the original modified variable with the modification of the variable triggered by dispatch to complete the migration of the variable to be compiled.

本发明另一可选实施例中,对于第二数据传递方式(即$emit/$on传递方式),通过下述步骤进行变量数据迁移:In another optional embodiment of the present invention, for the second data transmission mode (that is, the $emit/$on transmission mode), variable data migration is performed through the following steps:

2.1、将通过$emit方法触发事件传入的变量,复制一份到state对象中;2.1. Copy the variable passed in through the $emit method triggering the event to the state object;

2.2、在mutations对象中,生成一条用于修改state变量的方法函数(修改变量函数);2.2. In the mutations object, generate a method function (modify variable function) for modifying the state variable;

2.3、在actions对象中,生成一条用于触发步骤2.3生成的函数(触发变量函数);2.3. In the actions object, generate a function (trigger variable function) for triggering the generation of step 2.3;

2.4、通过$on方法申明一个事件,取其第二个参数,即事件回调函数,将其中修改修改变量函数的代码,替换为通过dispatch方式触发变量修改,完成待编译变量的迁移。2.4. Declare an event through the $on method, take its second parameter, the event callback function, and replace the code of the function that modifies the variable with the variable modification triggered by dispatch to complete the migration of the variable to be compiled.

本发明通过直接在前端项目中构建数据传递方式转化项目,并通过识别出标准传递方式转化项目的入口文件进行目标组件的查找,通过确定目标组件中的原始数据传递方式,并对原始数据传递方式中的待编译变量进行变量迁移,无需事后人工进行组件编译,大大提高了数据传递方式转化的效率。同时,直接将目标组件中不同原始数据传递方式进行变量迁移,可以将不同目标组件的数据传递方式进行统一,提高了开发的可维护性及可扩展性。因此本发明提出的数据传递方式转化装置,可以解决数据传递方式转化困难的问题。The present invention transforms the project by constructing the data transfer mode directly in the front-end project, and searches the target component by identifying the entry file of the standard transfer mode conversion project, determines the original data transfer mode in the target component, and determines the original data transfer mode. The variables to be compiled in can be migrated, and there is no need to manually compile components afterwards, which greatly improves the efficiency of data transfer mode conversion. At the same time, by directly migrating different original data transmission methods in target components, the data transmission methods of different target components can be unified, and the maintainability and scalability of development can be improved. Therefore, the data transmission mode conversion device proposed by the present invention can solve the problem of difficulty in data transmission mode conversion.

如图8所示,是本发明一实施例提供的实现数据传递方式转化方法的电子设备的结构示意图。As shown in FIG. 8 , it is a schematic structural diagram of an electronic device for implementing a data transmission mode conversion method provided by an embodiment of the present invention.

所述电子设备可以包括处理器10、存储器11、通信接口12和总线13,还可以包括存储在所述存储器11中并可在所述处理器10上运行的计算机程序,如数据传递方式转化程序。The electronic device may include a processor 10, a memory 11, a communication interface 12 and a bus 13, and may also include a computer program stored in the memory 11 and run on the processor 10, such as a data transfer mode conversion program .

其中,所述存储器11至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、移动硬盘、多媒体卡、卡型存储器(例如:SD或DX存储器等)、磁性存储器、磁盘、光盘等。所述存储器11在一些实施例中可以是电子设备的内部存储单元,例如该电子设备的移动硬盘。所述存储器11在另一些实施例中也可以是电子设备的外部存储设备,例如电子设备上配备的插接式移动硬盘、智能存储卡(Smart Media Card,SMC)、安全数字(SecureDigital,SD)卡、闪存卡(Flash Card)等。进一步地,所述存储器11还可以既包括电子设备的内部存储单元也包括外部存储设备。所述存储器11不仅可以用于存储安装于电子设备的应用软件及各类数据,例如数据传递方式转化程序的代码等,还可以用于暂时地存储已经输出或者将要输出的数据。Wherein, the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, magnetic disk, CD etc. In some embodiments, the memory 11 may be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 may also be an external storage device of the electronic device, such as a pluggable mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) equipped on the electronic device. Cards, Flash Cards, etc. Further, the memory 11 may also include both an internal storage unit of an electronic device and an external storage device. The memory 11 can not only be used to store application software installed in the electronic device and various types of data, such as the code of a data transfer mode conversion program, etc., but also can be used to temporarily store data that has been output or will be output.

所述处理器10在一些实施例中可以由集成电路组成,例如可以由单个封装的集成电路所组成,也可以是由多个相同功能或不同功能封装的集成电路所组成,包括一个或者多个中央处理器(Central Processing unit,CPU)、微处理器、数字处理芯片、图形处理器及各种控制芯片的组合等。所述处理器10是所述电子设备的控制核心(Control Unit),利用各种接口和线路连接整个电子设备的各个部件,通过运行或执行存储在所述存储器11内的程序或者模块(例如数据传递方式转化程序等),以及调用存储在所述存储器11内的数据,以执行电子设备的各种功能和处理数据。In some embodiments, the processor 10 may be composed of integrated circuits, for example, may be composed of a single packaged integrated circuit, or may be composed of multiple integrated circuits packaged with the same function or different functions, including one or more integrated circuits. Central processing unit (Central Processing Unit, CPU), microprocessor, digital processing chip, graphics processor and combination of various control chips, etc. The processor 10 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and by running or executing the programs or modules (such as data) stored in the memory 11. Transfer mode conversion program, etc.), and call the data stored in the memory 11 to execute various functions of the electronic device and process data.

所述通信接口12用于上述电子设备与其他设备之间的通信,包括网络接口和用户接口。可选地,所述网络接口可以包括有线接口和/或无线接口(如WI-FI接口、蓝牙接口等),通常用于在该电子设备与其他电子设备之间建立通信连接。所述用户接口可以是显示器(Display)、输入单元(比如键盘(Keyboard)),可选地,用户接口还可以是标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在电子设备中处理的信息以及用于显示可视化的用户界面。The communication interface 12 is used for communication between the above electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and/or a wireless interface (eg, a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, and the like. The display may also be appropriately called a display screen or a display unit, which is used for displaying information processed in the electronic device and for displaying a visual user interface.

所述总线13可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。该总线13可以分为地址总线、数据总线、控制总线等。所述总线13被设置为实现所述存储器11以及至少一个处理器10等之间的连接通信。The bus 13 may be a peripheral component interconnect (PCI for short) bus or an extended industry standard architecture (extended industry standard architecture, EISA for short) bus or the like. The bus 13 can be divided into an address bus, a data bus, a control bus, and the like. The bus 13 is configured to implement connection communication between the memory 11 and at least one processor 10 and the like.

图8仅示出了具有部件的电子设备,本领域技术人员可以理解的是,图8示出的结构并不构成对所述电子设备的限定,可以包括比图示更少或者更多的部件,或者组合某些部件,或者不同的部件布置。FIG. 8 only shows an electronic device with components. Those skilled in the art can understand that the structure shown in FIG. 8 does not constitute a limitation on the electronic device, and may include fewer or more components than those shown in the drawings. , or a combination of certain components, or a different arrangement of components.

例如,尽管未示出,所述电子设备还可以包括给各个部件供电的电源(比如电池),优选地,电源可以通过电源管理装置与所述至少一个处理器10逻辑相连,从而通过电源管理装置实现充电管理、放电管理、以及功耗管理等功能。电源还可以包括一个或一个以上的直流或交流电源、再充电装置、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。所述电子设备还可以包括多种传感器、蓝牙模块、Wi-Fi模块等,在此不再赘述。For example, although not shown, the electronic device may also include a power source (such as a battery) for powering the various components, preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power source can be logically connected through the power management device. Implement functions such as charge management, discharge management, and power management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and any other components. The electronic device may further include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.

进一步地,所述电子设备还可以包括网络接口,可选地,所述网络接口可以包括有线接口和/或无线接口(如WI-FI接口、蓝牙接口等),通常用于在该电子设备与其他电子设备之间建立通信连接。Further, the electronic device may also include a network interface, optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.) Establish a communication connection between other electronic devices.

可选地,该电子设备还可以包括用户接口,用户接口可以是显示器(Display)、输入单元(比如键盘(Keyboard)),可选地,用户接口还可以是标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在电子设备中处理的信息以及用于显示可视化的用户界面。Optionally, the electronic device may further include a user interface, and the user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), optionally, the user interface may also be a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, and the like. The display may also be appropriately called a display screen or a display unit, which is used for displaying information processed in the electronic device and for displaying a visual user interface.

应该了解,所述实施例仅为说明之用,在专利申请范围上并不受此结构的限制。It should be understood that the embodiments are only used for illustration, and are not limited by this structure in the scope of the patent application.

所述电子设备中的所述存储器11存储的数据传递方式转化程序是多个指令的组合,在所述处理器10中运行时,可以实现:The data transfer mode conversion program stored in the memory 11 in the electronic device is a combination of multiple instructions, and when running in the processor 10, it can realize:

构建前端项目的数据传递方式转化项目,在所述数据传递方式转化项目中引入目标传递方式的基础文件,得到标准传递方式转化项目;Building a data transfer mode conversion project of the front-end project, and introducing the basic file of the target transfer mode into the data transfer mode conversion project to obtain a standard transfer mode conversion project;

识别出所述标准传递方式转化项目的入口文件,基于所述入口文件查找出所述标准传递方式转化项目中的目标组件;Identifying the entry file of the standard delivery method transformation project, and finding out the target component in the standard delivery method transformation project based on the entry file;

识别所述目标组件中的原始数据传递方式;Identify the original data transfer method in the target component;

对所述原始数据传递方式中的待编译变量进行变量迁移,得到所述目标传递方式的前端项目。Perform variable migration on the to-be-compiled variables in the original data transfer mode to obtain the front-end project of the target transfer mode.

具体地,所述处理器10对上述指令的具体实现方法可参考附图对应实施例中相关步骤的描述,在此不赘述。Specifically, for the specific implementation method of the above-mentioned instruction by the processor 10, reference may be made to the description of the relevant steps in the embodiment corresponding to the accompanying drawings, which will not be repeated here.

进一步地,所述电子设备集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读存储介质中。所述计算机可读存储介质可以是易失性的,也可以是非易失性的。例如,所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)。Further, if the modules/units integrated in the electronic device are implemented in the form of software functional units and sold or used as independent products, they may be stored in a computer-readable storage medium. The computer-readable storage medium may be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a removable hard disk, a magnetic disk, an optical disc, a computer memory, a read-only memory (ROM, Read-Only). Memory).

本发明还提供一种计算机可读存储介质,所述可读存储介质存储有计算机程序,所述计算机程序在被电子设备的处理器所执行时,可以实现:The present invention also provides a computer-readable storage medium, where the readable storage medium stores a computer program, and when executed by a processor of an electronic device, the computer program can realize:

构建前端项目的数据传递方式转化项目,在所述数据传递方式转化项目中引入目标传递方式的基础文件,得到标准传递方式转化项目;Building a data transfer mode conversion project of the front-end project, and introducing the basic file of the target transfer mode into the data transfer mode conversion project to obtain a standard transfer mode conversion project;

识别出所述标准传递方式转化项目的入口文件,基于所述入口文件查找出所述标准传递方式转化项目中的目标组件;Identifying the entry file of the standard delivery method transformation project, and finding out the target component in the standard delivery method transformation project based on the entry file;

识别所述目标组件中的原始数据传递方式;Identify the original data transfer method in the target component;

对所述原始数据传递方式中的待编译变量进行变量迁移,得到所述目标传递方式的前端项目。Perform variable migration on the to-be-compiled variables in the original data transfer mode to obtain the front-end project of the target transfer mode.

在本发明所提供的几个实施例中,应该理解到,所揭露的设备,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus, apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are only illustrative. For example, the division of the modules is only a logical function division, and there may be other division manners in actual implementation.

所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The modules described as separate components may or may not be physically separated, and components shown as modules may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment.

另外,在本发明各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware, or can be implemented in the form of hardware plus software function modules.

对于本领域技术人员而言,显然本发明不限于上述示范性实施例的细节,而且在不背离本发明的精神或基本特征的情况下,能够以其他的具体形式实现本发明。It will be apparent to those skilled in the art that the present invention is not limited to the details of the above-described exemplary embodiments, but that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics of the invention.

因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本发明的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本发明内。不应将权利要求中的任何附关联图标记视为限制所涉及的权利要求。Therefore, the embodiments are to be regarded in all respects as illustrative and not restrictive, and the scope of the invention is to be defined by the appended claims rather than the foregoing description, which are therefore intended to fall within the scope of the claims. All changes within the meaning and range of the equivalents of , are included in the present invention. Any reference signs in the claims shall not be construed as limiting the involved claim.

本发明实施例可以基于人工智能技术对相关的数据进行获取和处理。其中,人工智能(Artificial Intelligence,AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。The embodiments of the present invention can acquire and process related data based on artificial intelligence technology. Among them, artificial intelligence (AI) is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. .

人工智能基础技术一般包括如传感器、专用人工智能芯片、云计算、分布式存储、大数据处理技术、操作/交互系统、机电一体化等技术。人工智能软件技术主要包括计算机视觉技术、机器人技术、生物识别技术、语音处理技术、自然语言处理技术以及机器学习/深度学习等几大方向。The basic technologies of artificial intelligence generally include technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation/interaction systems, and mechatronics. Artificial intelligence software technology mainly includes computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning/deep learning.

本发明所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。The blockchain referred to in the present invention is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain, essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify its Validity of information (anti-counterfeiting) and generation of the next block. The blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.

此外,显然“包括”一词不排除其他单元或步骤,单数不排除复数。系统权利要求中陈述的多个单元或装置也可以由一个单元或装置通过软件或者硬件来实现。第二等词语用来表示名称,而并不表示任何特定的顺序。Furthermore, it is clear that the word "comprising" does not exclude other units or steps and the singular does not exclude the plural. Several units or means recited in the system claims can also be realized by one unit or means by means of software or hardware. Second-class terms are used to denote names and do not denote any particular order.

最后应说明的是,以上实施例仅用以说明本发明的技术方案而非限制,尽管参照较佳实施例对本发明进行了详细说明,本领域的普通技术人员应当理解,可以对本发明的技术方案进行修改或等同替换,而不脱离本发明技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be Modifications or equivalent substitutions can be made without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A method for converting a data transmission mode, the method comprising:
constructing a data transfer mode conversion project of a front-end project, and introducing a basic file of a target transfer mode into the data transfer mode conversion project to obtain a standard transfer mode conversion project;
identifying an entry file of the standard transfer mode conversion project, and finding out a target component in the standard transfer mode conversion project based on the entry file;
identifying a raw data delivery style in the target component;
and carrying out variable migration on the variable to be compiled in the original data transfer mode to obtain a front-end project of the target transfer mode.
2. The data transfer method according to claim 1, wherein the constructing of the data transfer method conversion item of the front-end item includes:
positioning a root directory of the front-end item, and adding a data transfer mode conversion tool in the root directory;
and setting a conversion configuration file in the data transfer mode conversion tool, adding a data transfer mode conversion command in a root directory to which the conversion configuration file is added, and executing the data transfer mode conversion command to obtain the data transfer mode conversion item.
3. The data transfer method according to claim 2, wherein before introducing the basic file of the target transfer method into the data transfer method conversion item, the method further comprises:
creating a management center directory according to the conversion configuration file;
initializing a management file under the management center directory, and adding a plurality of object attributes of the target transmission mode into the management file to obtain the basic file.
4. The data transfer mode conversion method of claim 1, wherein finding the target component in the standard transfer mode conversion item based on the entry file comprises:
searching out a file containing a target suffix from the entry file by using a preset import grammar as a parent component;
and repeatedly utilizing the introduced grammar to carry out component search on the parent component to obtain all sub-components of the parent component, and taking the searched sub-components as target components.
5. The data transfer mode conversion method of claim 4, wherein the identifying of the original data transfer mode in the target component comprises:
judging whether the sub-components contain preset keywords or not;
if the sub-component contains the keyword, determining that the original data transmission mode in the target component is a first data transmission mode;
if the sub-component does not contain the keyword, judging whether the sub-component and the parent component carry out data communication or not;
if the sub-components and the parent component do not carry out data communication, returning to the step of repeatedly utilizing the introduced grammar to carry out component searching on the parent component until all the sub-components are judged;
and if the child component and the parent component carry out data communication, determining that the original data transmission mode in the target component is a second data transmission mode.
6. The method of claim 5, wherein the determining whether the child component is in data communication with the parent component comprises:
instantiating a component library by using the introduction grammar, and carrying out external export operation on the component library through a preset export keyword;
if the component library cannot be exported outwards, determining that the sub-component and the parent component do not carry out data communication;
if the component library can be exported outwards, judging whether an object event method exists in the sub-component;
if the sub-component does not have the object event method, determining that the sub-component and the parent component do not carry out data communication;
and if the sub-component has the object event method, determining that the sub-component and the parent component carry out data communication.
7. The data transfer mode conversion method according to claim 3, wherein the performing variable migration on the variable to be compiled in the original data transfer mode includes:
if the original data transfer mode is a first data transfer mode, copying a variable called by the first data transfer mode in the sub-component into the object attribute, and adding a modified variable function and a trigger variable function in the object attribute;
if the original data transmission mode is a second data transmission mode, copying variables transmitted in the sub-components through the second data transmission mode into the object attributes, and adding a modified variable function, a trigger variable function and an event callback function into the object attributes.
8. A data transfer mode conversion apparatus, comprising:
the data transfer mode conversion project construction module is used for constructing a data transfer mode conversion project of a front-end project, and introducing a basic file of a target transfer mode into the data transfer mode conversion project to obtain a standard transfer mode conversion project;
the target component searching module is used for identifying an entry file of the standard transfer mode conversion project and searching a target component in the standard transfer mode conversion project based on the entry file;
the data transfer mode identification module is used for identifying an original data transfer mode in the target assembly;
and the data transfer mode conversion module is used for carrying out variable migration on the variable to be compiled in the original data transfer mode to obtain a front-end project of the target transfer mode.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform the data transfer style translation method of any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the data transfer method according to any one of claims 1 to 7.
CN202210278451.6A 2022-03-21 2022-03-21 Data transfer mode conversion method and device, electronic equipment and readable storage medium Pending CN114625376A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210278451.6A CN114625376A (en) 2022-03-21 2022-03-21 Data transfer mode conversion method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210278451.6A CN114625376A (en) 2022-03-21 2022-03-21 Data transfer mode conversion method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN114625376A true CN114625376A (en) 2022-06-14

Family

ID=81903629

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210278451.6A Pending CN114625376A (en) 2022-03-21 2022-03-21 Data transfer mode conversion method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114625376A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114968243A (en) * 2022-06-20 2022-08-30 平安普惠企业管理有限公司 Unified communication method, device, device and storage medium for VUE parent-child components

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090125796A1 (en) * 2007-11-09 2009-05-14 Fred Day System, multi-tier interface and methods for management of operational structured data
CN110659028A (en) * 2019-09-30 2020-01-07 北京达佳互联信息技术有限公司 Data processing system, method, device, electronic equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090125796A1 (en) * 2007-11-09 2009-05-14 Fred Day System, multi-tier interface and methods for management of operational structured data
CN110659028A (en) * 2019-09-30 2020-01-07 北京达佳互联信息技术有限公司 Data processing system, method, device, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114968243A (en) * 2022-06-20 2022-08-30 平安普惠企业管理有限公司 Unified communication method, device, device and storage medium for VUE parent-child components

Similar Documents

Publication Publication Date Title
US10579344B2 (en) Converting visual diagrams into code
US20080276231A1 (en) Method and apparatus for dependency injection by static code generation
CN108027722A (en) The dynamically renewal application in compiling and deployment
CN111428458A (en) Universal report generation method and device and computer readable storage medium
CN114398282A (en) Test script generation method, device, device and storage medium
CN114385497A (en) Test environment generation method and device, electronic equipment and storage medium
CN112559337A (en) Code coverage rate testing method and device, electronic equipment and storage medium
CN112948228B (en) A streaming data-oriented multi-mode database evaluation benchmark system and its construction method
CN111538573A (en) Asynchronous task processing method, device and computer-readable storage medium
CN113032275A (en) Method and device for testing field, electronic equipment and storage medium
CN112631903A (en) Task testing method and device, electronic equipment and storage medium
CN112486490A (en) Front-end code packaging method and device, electronic equipment and storage medium
CN115129753A (en) Data blood relationship analysis method, device, electronic device and storage medium
CN115033489A (en) Code resource detection method and device, electronic equipment and storage medium
CN114625376A (en) Data transfer mode conversion method and device, electronic equipment and readable storage medium
CN114356379A (en) Backup-based service upgrade method, device, device and storage medium
CN114610340A (en) Project deployment method, device, equipment and storage medium
CN114385155A (en) Vue project visualization tool generation method, device, equipment and storage medium
CN105573763A (en) A Modeling Method of Embedded System Supporting RTOS
CN113778388A (en) Program development method and apparatus
CN111859452A (en) Page information verification method, apparatus, device, and computer-readable storage medium
CN114860252A (en) Code unified compiling method and device, electronic equipment and readable storage medium
CN114461531A (en) Platform adaptability testing method, device, equipment and storage medium of test case
WO2022105494A1 (en) Automatic data backfilling method and apparatus, electronic device, and computer storage medium
CN114721858A (en) Memory leak prevention method and device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination