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
mode conversion
project
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 transfer mode conversion method and device, electronic equipment and readable storage medium
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a data transmission mode conversion method, a data transmission mode conversion device, electronic equipment and a readable storage medium.
Background
At present, in the domestic front-end industry, a front-end framework is widely used for front-end project development, and data transmission among projects is of great importance. For example, in the vue framework, for data transfer between components, three modes, namely, props/$ emit, $ emit/$ on, and vuex, are common, and the three modes have respective use scenarios. The use scene of the props/$ emit is mainly seen in a simple single data stream communication mode of a parent-child component; the use scene of $ emit/$ on is in a small data center mode, and the parent-child components can be used for mutual communication among small and medium-sized complex components; the use scene of vuex is a large data management center of unidirectional data flow, mainly faces to a complex application scene, all data needing to be transmitted are sent to the data management center to be uniformly stored, modified and transmitted, the method is an ultimate solution of complex projects to data transmission, and is a more complex and heavyweight mode. For a project, often initially from a small project, the initial approach may be to simply pass data between components in a props/$ emit fashion. However, with the continuous deepening and iteration of project development, data transfer of parent and child components is increasingly complex and difficult to maintain, and in the development process, the two modes of props/$ emit and $ emit/$ on are used for data transfer, so that the method is not suitable for the current complex scene any more. A more robust vuex needs to be used. However, at this time, the project data transmission mode is converted into vuex, and the following problems are faced:
1. the use of vuex, the idea of having its unique unidirectional data flow, and the specific syntax and method to implement, has considerable practical difficulty for general developers, and may greatly cause the later project maintenance and development to become more difficult.
2. After vuex is used, in order to ensure that all data transmission is managed uniformly through vuex, which is a data management center, and avoid the situation that data management is disordered due to the mixed use of multiple data transmission modes, all codes for data transmission through the props/$ emit and $ emit/$ on modes need to be replaced by vuex modes, which not only needs to comb the existing logic through a large amount of manpower, but also needs developers to be familiar with the writing methods of the three modes at the same time, and for a project, the development efficiency is low.
3. Different developers have different comprehension degrees on the integral control of the project and the vuex grammar, so that the situations that the grammar is not standard and the writing method is not uniform in the process of writing the vuex grammar are easily caused, the reading difficulty is increased in the process of reading and modifying codes of other developers, and the maintainability and the expansibility of the integral project are reduced.
In summary, the prior art has the problems that the data transmission method in the front-end item is difficult to convert, and the conversion standard is not uniform. Therefore, a method for compiling and converting the data transmission mode in the framework component is needed.
Disclosure of Invention
The invention provides a data transmission mode conversion method, a data transmission mode conversion device, electronic equipment and a readable storage medium, and mainly aims to solve the problem that the data transmission mode conversion is difficult.
In order to achieve the above object, the present invention provides a data transmission mode conversion method, including:
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.
Optionally, the constructing a data transfer mode 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.
Optionally, before introducing the basic file of the target delivery method into the data delivery method conversion item, the method further includes:
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.
Optionally, the finding out the target component in the standard transfer mode conversion item based on the entry file includes:
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.
Optionally, the identifying a raw data transfer mode in the target component includes:
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.
Optionally, the determining whether the sub-component performs data communication with the parent component includes:
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.
Optionally, the performing variable migration on the variable to be compiled in the original data transfer manner 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 transfer mode is a second data transfer mode, copying variables transmitted in the sub-components through the second data transfer mode into the object attributes, and adding a modified variable function, a trigger variable function and an event callback function into the object attributes.
In order to solve the above problem, the present invention further provides a data transfer mode conversion apparatus, including:
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.
In order to solve the above problem, the present invention also provides an electronic device, including:
a memory storing at least one computer program; and
and the processor executes the computer program stored in the memory to realize the data transmission mode conversion method.
In order to solve the above problem, the present invention further provides a computer-readable storage medium, in which at least one computer program is stored, and the at least one computer program is executed by a processor in an electronic device to implement the data transfer manner conversion method described above.
According to the method and the device, the data transfer mode conversion item is directly constructed in the front-end item, the target component is searched by identifying the entry file of the standard transfer mode conversion item, the original data transfer mode in the target component is determined, the variable to be compiled in the original data transfer mode is subjected to variable migration, component compilation is not needed afterwards, and the efficiency of data transfer mode conversion is greatly improved. Meanwhile, different original data transfer modes in the target assembly are directly subjected to variable migration, the data transfer modes of different target assemblies can be unified, and maintainability and expandability of development are improved. Therefore, the data transfer mode conversion method, the data transfer mode conversion device, the electronic equipment and the computer readable storage medium can solve the problem that the data transfer mode conversion is difficult.
Drawings
Fig. 1 is a schematic flow chart of a data transmission method according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart showing a detailed implementation of one of the steps in FIG. 1;
FIG. 3 is a schematic flow chart showing another step of FIG. 1;
FIG. 4 is a schematic flow chart showing another step of FIG. 1;
FIG. 5 is a schematic flow chart showing a detailed implementation of one of the steps in FIG. 4;
FIG. 6 is a schematic flow chart showing another step of FIG. 1;
FIG. 7 is a functional block diagram of a data transmission method conversion apparatus according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device for implementing the data transfer mode conversion method according to an embodiment of the present invention.
The implementation, functional features and advantages of the present invention will be further described with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the invention provides a data transmission mode conversion method. The execution subject of the data transfer 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 transfer method may be executed by software or hardware installed in the terminal device or the server device, and the software may be a block chain 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 may be an independent server, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like.
Fig. 1 is a schematic flow chart of a data transmission method according to an embodiment of the present invention. In this embodiment, the data transfer manner conversion method includes the following steps S1-S5:
and S1, constructing a data transfer mode conversion project of the 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.
In the embodiment of the invention, the front-end project is a project for realizing user interface interaction of an internet product through HTML, CSS and JavaScript and various derived technologies, frames and solutions, such as an XXapp development project, an XX company official website development project, an XX product page development project, an XX applet development project and the like.
In detail, referring to fig. 2, the data transmission mode conversion item of the build front end item includes the following steps S10-S11:
s10, positioning a root directory of the front-end item, and adding a data transfer mode conversion tool in the root directory;
and S11, setting a conversion configuration file in the data transfer mode conversion tool, adding a data transfer mode conversion command in the 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.
In the embodiment of the present invention, the data transfer method conversion item is used to perform the following steps S2 to S4 in the front page to convert the data transfer method. For example, in the command line (the mac system is the terminal), the current front-end item root directory is located, and the command: npmi data-transfer-vuex-D, then a data transfer mode conversion tool may be added to the current framework project, a conversion configuration file config. And performing npm run transform-vuex to obtain a data transfer mode conversion item, wherein the configuration content in the conversion configuration file comprises: 1. a directory where the project development files are located; 2. an item entry file address, etc.
In detail, before introducing the basic file of the target delivery method into the data delivery method conversion item, the method further includes:
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.
In an optional embodiment of the present invention, the target delivery manner may be a vuex delivery manner, for example, in an vue framework, it is first determined whether a vuex delivery manner is included, by determining whether a vuex library file is included in a project and searching for a package json file in a front-end project, where the file is a file of a management dependent package in the project, and searching whether a dependencies attribute in the file includes vuex, if so, it is indicated that the project itself already has the vuex library file, and if not, it is required to install a vue library file into the front-end project by the following command npivuex-save.
Specifically, according to a first configuration item configured in the conversion configuration file config.js: the method comprises the steps of determining directory addresses of all development files, creating a store folder (namely a management center directory) serving as a root directory of a vuex data management center under the directory, and initializing a file named index. Then, introducing a method createStore for initializing a vuex transfer mode from a vuex library, and when the method is called, introducing three object attributes which are respectively the following three points: state objects (for holding variables and data), actions objects (for managing exposed modified variable methods), and events objects (for managing internal modified variable methods). Because the original data transfer modes (the props/$ emit mode, $ emit/$ on mode, etc.) are not compiled into the target transfer mode (the vuex mode) at present, the three objects are all in the form of empty objects temporarily, and contents are added into the empty objects continuously in the post-compilation process.
S2, identifying the entry file of the standard transfer mode conversion project, and finding out the target component in the standard transfer mode conversion project based on the entry file.
In the embodiment of the present invention, taking an vue frame as an example, because the front-end project of vue adopts a single page, starting with an entry page, various associated page components are introduced to form a tree-distributed file reference relationship using an entry file as a backbone, the parent-child structure relationship of all subsequent files can be deduced only by using the entry file.
In an optional embodiment of the present invention, by converting the second configuration item configured in the configuration file config.js: and the corresponding entry file can be found according to the entry file address of the item.
Specifically, referring to FIG. 3, the finding of the target component in the standard transitive transformation project based on the portal file includes the following steps S20-S21:
s20, searching a file containing a target suffix from the entry file by using a preset import grammar to serve as a parent component;
and S21, repeatedly utilizing the introduced grammar to search the components of the parent component to obtain all sub-components of the parent component, and taking the searched sub-components as target components.
In an optional embodiment of the present invention, since the entry file is obtained by introducing other page components into the current file through the import syntax, it is only necessary to identify, in the current entry file, which files contain the file at the end of vue, which is the vue component (i.e. the parent component), and perform depth search repeatedly by using the import syntax to obtain a sub-component at the next stage of vue components as the target component.
And S3, identifying the original data transmission mode in the target component.
In the embodiment of the present invention, the original data transfer mode refers to a data transfer mode in a current target component, for example, a pps/$ emit, $ emit/$ on mode and the like in an vue component.
In detail, referring to FIG. 4, the identifying the original data delivery manner in the target component includes the following steps S30-S34:
s30, judging whether the sub-components contain preset keywords or not;
if the sub-component contains the keyword, executing S31, and 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, executing S32, and judging whether the sub-component and the parent component carry out data communication;
if the sub-component and the parent component do not carry out data communication, executing S33, 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 sub-component and the parent component carry out data communication, executing S34 and determining that the original data transmission mode in the target component is a second data transmission mode.
In the embodiment of the invention, because the variables needing to be converted are different in different data transmission modes, the accuracy and the efficiency of data transmission mode conversion can be improved by refining the different data transmission modes in the target component.
In an optional embodiment of the present invention, in an vue framework, first, it is determined whether a sub-component includes a tips keyword, if so, it is determined that the sub-component performs data transfer using a tips/$ event mode (a first data transfer mode), if not, it is determined that the sub-component does not use a dynamic parameter transferred to a parent component, it is determined whether the sub-component includes a this. $ event keyword, it is determined that the sub-component performs data transfer using the tips/$ event mode, if not, it is determined whether data communication is performed between the parent and child components, and if so, it is determined that the sub-component performs data transfer using a $ event/$ on mode (a second data transfer mode).
Further, referring to fig. 5, the determining whether the sub-component performs data communication with the parent component includes the following steps S340 to S344:
s340, instantiating a component library by utilizing the introduction grammar, and carrying out outward export operation on the component library through a preset export keyword;
s341, if the component library cannot be exported outwards, determining that the sub-component and the parent component do not carry out data communication;
s342, 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, executing S343, and determining that the sub-component and the parent component do not carry out data communication;
and if the object event method exists in the sub-component, executing S344, and determining that the sub-component and the parent component carry out data communication.
In an optional embodiment of the present invention, vue library (component library) is introduced into the sub-component through import syntax, vue library is instantiated through new keyword, then export is conducted outwards through export keyword, if export cannot be conducted outwards, it is determined that data communication is not conducted between the sub-component and the parent component, if export can be conducted outwards, it is determined whether there is an object event method using import data center, for example, $ emit method triggering event in object and introducing variable, or $ on method declaring an event in object, if not, it is determined that data communication is not conducted between the sub-component and the parent component, otherwise, data communication is conducted.
And S4, 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.
In the embodiment of the invention, the data transmission mode is converted by compiling and converting the variables in different data transmission methods and transferring the variables to the object attribute.
In detail, referring to fig. 6, the performing variable migration on the variable to be compiled in the original data transfer manner includes the following steps S50-S51:
s50, 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 into the object attribute;
and S51, if the original data transfer mode is a second data transfer mode, copying variables transmitted in the sub-components through the second data transfer mode into the object attributes, and adding a modified variable function, a trigger variable function and an event callback function into the object attributes.
In an optional embodiment of the present invention, for the first data transfer mode (i.e., the prps/$ emit transfer mode), the variable data migration is performed through the following steps:
1.1, calling a currently used sub-component to a parent component to transfer into a method, and copying a part of variables transferred during calling into a state object;
and 1.2, searching whether the current variable is in the parent component, and whether an operation for modifying the variable exists, for example, the variable is reassigned, and the syntax is this. If such a scenario exists, the next operation is performed. If the variable does not exist, the variable is described to be purely static, the variable is only transmitted by the parent component, and the variable migration is finished;
1.3, generating a method function (a modified variable function) for modifying the state variable in the events object;
1.4, generating a function (trigger variable function) for triggering the generation of the step 1.3 in actions objects;
1.5, introducing the function generated in the step 1.4 into the sub-component, and replacing the function into the code corresponding to the original modified variable by triggering the modification of the variable in a dispatch mode to finish the migration of the variable to be compiled.
In another optional embodiment of the present invention, for the second data transfer mode (i.e., $ emit/$ on transfer mode), the variable data migration is performed through the following steps:
2.1, copying a variable transmitted by a $ emit method trigger event into a state object;
2.2, generating a method function (a modified variable function) for modifying the state variable in the events object;
2.3, generating a function (trigger variable function) for triggering the generation in the step 2.3 in actions objects;
2.4, declaring an event through a $ on method, taking a second parameter of the event, namely an event callback function, replacing the code for modifying the variable function with the code for triggering variable modification through a dispatch mode, and completing the migration of the variable to be compiled.
According to the method and the device, the data transfer mode conversion item is directly constructed in the front-end item, the target component is searched by identifying the entry file of the standard transfer mode conversion item, the original data transfer mode in the target component is determined, the variable to be compiled in the original data transfer mode is subjected to variable migration, component compilation is not needed afterwards, and the efficiency of data transfer mode conversion is greatly improved. Meanwhile, different original data transfer modes in the target assembly are directly subjected to variable migration, the data transfer modes of different target assemblies can be unified, and maintainability and expandability of development are improved. Therefore, the data transmission mode conversion method provided by the invention can solve the problem of difficult data transmission mode conversion.
Fig. 7 is a functional block diagram of a data transmission method conversion apparatus according to an embodiment of the present invention.
The data transmission system conversion apparatus 100 according to the present invention may be installed in an electronic device. According to the implemented functions, the data transfer method conversion apparatus 100 may include a data transfer method conversion item construction module 101, a target component search module 102, a data transfer method identification module 103, and a data transfer method conversion module 104. The module of the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and that can perform a fixed function, and that are stored in a memory of the electronic device.
In the present embodiment, the functions regarding the respective modules/units are as follows:
the data transfer mode conversion project construction module 101 is configured to 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;
the target component searching module 102 is configured to identify an entry file of the standard transfer manner conversion item, and search for a target component in the standard transfer manner conversion item based on the entry file;
the data transfer mode identification module 103 is configured to identify an original data transfer mode in the target component;
the data transfer mode conversion module 104 is configured to perform variable migration on a variable to be compiled in the original data transfer mode to obtain a front-end item of the target transfer mode.
In detail, the data transmission method conversion apparatus 100 includes the following modules:
step one, a data transfer mode conversion project of a front-end project is constructed, and a basic file of a target transfer mode is introduced into the data transfer mode conversion project to obtain a standard transfer mode conversion project.
In the embodiment of the invention, the front-end project is a project for realizing user interface interaction of an internet product through HTML, CSS and JavaScript and various derived technologies, frames and solutions, such as an XXapp development project, an XX company official website development project, an XX product page development project, an XX applet development project and the like.
In detail, the constructing of the data transmission mode 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.
In the embodiment of the present invention, the data transfer method conversion item is used to perform the following steps two to four in the front-end page to convert the data transfer method. For example, in the command line (the mac system is the terminal), the current front-end item root directory is located, and the command: npmi data-transfer-vuex-D, then a data transfer mode conversion tool may be added to the current framework project, a conversion configuration file config. And performing npm run transform-vuex to obtain a data transfer mode conversion item, wherein the configuration content in the conversion configuration file comprises: 1. a directory where the project development files are located; 2. an item entry file address, etc.
In detail, before the basic file of the target delivery method is introduced into the data delivery method conversion item, the method further includes:
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.
In an optional embodiment of the present invention, the target delivery manner may be a vuex delivery manner, for example, in an vue framework, it is first determined whether a vuex delivery manner is included, by determining whether a vuex library file is included in a project and searching for a package json file in a front-end project, where the file is a file of a management dependent package in the project, and searching whether a dependencies attribute in the file includes vuex, if so, it is indicated that the project itself already has the vuex library file, and if not, it is required to install a vue library file into the front-end project by the following command npivuex-save.
Specifically, according to a first configuration item configured in the conversion configuration file config.js: the method comprises the steps of determining directory addresses of all development files, creating a store folder (namely a management center directory) under the directory, wherein the store folder serves as a root directory of a vuex data management center, initializing a file (namely a management file) named as index. Then, introducing a method createStore for initializing a vuex transfer mode from a vuex library, and when the method is called, introducing three object attributes which are respectively the following three points: state objects (for holding variables and data), actions objects (for managing the exposed-to-the-outside modified variable methods), and events objects (for managing the inside modified variable methods). Because the original data transfer modes (the props/$ emit mode, $ emit/$ on mode, etc.) are not compiled into the target transfer mode (the vuex mode) at present, the three objects are all in the form of empty objects temporarily, and contents are added into the empty objects continuously in the post-compilation process.
And step two, 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.
In the embodiment of the present invention, taking an vue frame as an example, because the front-end project of vue adopts a single page, starting with an entry page, various associated page components are introduced to form a tree-distributed file reference relationship using an entry file as a backbone, the parent-child structure relationship of all subsequent files can be deduced only by using the entry file.
In an optional embodiment of the present invention, by converting the second configuration item configured in the configuration file config.js: and (4) finding a corresponding entry file by the entry file address of the item.
Specifically, the finding out the target component in the standard transfer mode conversion item based on the entry file includes:
searching a file containing a target suffix from the entry file by using a preset import grammar to serve 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.
In an optional embodiment of the present invention, since the entry file is obtained by introducing other page components into the current file through the import syntax, it is only necessary to identify, in the current entry file, which files include the file at the end of. vue, which is the vue component (i.e., the parent component), through the import syntax, and at the same time, the depth search is repeatedly performed by using the import syntax, so as to obtain a sub-component at the next stage of the vue component as the target component.
And thirdly, identifying the original data transmission mode in the target assembly.
In the embodiment of the present invention, the original data transfer mode refers to a data transfer mode in a current target component, for example, in vue components, a prps/$ emit, $ emit/$ on mode, and the like.
In detail, the identifying of the original data transfer mode in the target component includes:
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.
In the embodiment of the invention, because the variables needing to be converted are different in different data transmission modes, the accuracy and the efficiency of data transmission mode conversion can be improved by refining the different data transmission modes in the target component.
In an optional embodiment of the present invention, in an vue framework, first, it is determined whether a sub-component includes a tips keyword, if so, it is determined that the sub-component performs data transfer using a tips/$ event mode (a first data transfer mode), if not, it is determined that the sub-component does not use a dynamic parameter transferred to a parent component, it is determined whether the sub-component includes a this. $ event keyword, it is determined that the sub-component performs data transfer using the tips/$ event mode, if not, it is determined whether data communication is performed between the parent and child components, and if so, it is determined that the sub-component performs data transfer using a $ event/$ on mode (a second data transfer mode).
Further, the determining whether the sub-component communicates with the parent component includes:
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.
In an optional embodiment of the present invention, vue library (component library) is introduced into the sub-component through import syntax, vue library is instantiated through new keyword, then export is conducted outwards through export keyword, if export cannot be conducted outwards, it is determined that data communication is not conducted between the sub-component and the parent component, if export can be conducted outwards, it is determined whether there is an object event method using import data center, for example, $ emit method triggering event in object and introducing variable, or $ on method declaring an event in object, if not, it is determined that data communication is not conducted between the sub-component and the parent component, otherwise, data communication is conducted.
And step four, 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.
In the embodiment of the invention, the data transmission mode is converted by compiling and converting the variables in different data transmission methods and transferring the variables to the object attribute.
In detail, 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.
In an optional embodiment of the present invention, for the first data transfer mode (i.e., the prps/$ emit transfer mode), the variable data migration is performed through the following steps:
1.1, calling a child component used currently to a parent component to transfer into a method, and copying a copy of a variable transferred during calling into a state object;
and 1.2, searching whether the current variable is in the parent component, and whether an operation for modifying the variable exists, for example, the variable is reassigned, and the syntax is this. If such a scenario exists, the next operation is performed. If not, the variable is purely static, only the parent component transmits the variable, and the variable migration is finished;
1.3, generating a method function (a modified variable function) for modifying the state variable in the events object;
1.4, generating a function (trigger variable function) for triggering the generation of the step 1.3 in actions objects;
and 1.5, introducing the function generated in the step 1.4 into the subcomponent, and replacing the function in the code corresponding to the original modified variable with a function triggered by a dispatch mode to complete the migration of the variable to be compiled.
In another optional embodiment of the present invention, for the second data transfer mode (i.e., $ emit/$ on transfer mode), the variable data migration is performed through the following steps:
2.1, copying a variable transmitted by a $ emit method trigger event into a state object;
2.2, generating a method function (a modified variable function) for modifying the state variable in the events object;
2.3, generating a function (trigger variable function) for triggering the generation of the step 2.3 in actions objects;
2.4, declaring an event through a $ on method, taking a second parameter of the event, namely an event callback function, replacing the code in which the variable function is modified and modified with a code which triggers variable modification through a dispatch mode, and completing the migration of the variable to be compiled.
According to the method and the device, the data transfer mode conversion item is directly constructed in the front-end item, the target component is searched by identifying the entry file of the standard transfer mode conversion item, the original data transfer mode in the target component is determined, the variable to be compiled in the original data transfer mode is subjected to variable migration, component compilation is not needed afterwards, and the efficiency of data transfer mode conversion is greatly improved. Meanwhile, different original data transfer modes in the target assembly are directly subjected to variable migration, the data transfer modes of different target assemblies can be unified, and maintainability and expandability of development are improved. Therefore, the data transmission mode conversion device provided by the invention can solve the problem that the data transmission mode conversion is difficult.
Fig. 8 is a schematic structural diagram of an electronic device for implementing a data transfer method according to an embodiment of the present invention.
The electronic device may include a processor 10, a memory 11, a communication interface 12 and a bus 13, and may further include a computer program, such as a data transfer mode conversion program, stored in the memory 11 and executable on the processor 10.
The memory 11 includes at least one type of readable storage medium, which includes flash memory, removable hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device, for example a removable hard disk of the electronic device. The memory 11 may also be an external storage device of the electronic device in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device. The memory 11 may be used to store not only application software installed in the electronic device and various types of data, such as codes of a data transfer method conversion program, but also temporarily store data that has been output or is to be output.
The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same or different functions, including one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the electronic device by using various interfaces and lines, and executes various functions and processes data of the electronic device by running or executing programs or modules (e.g., data transfer mode conversion programs, etc.) stored in the memory 11 and calling data stored in the memory 11.
The communication interface 12 is used for communication between the electronic device and other devices, and includes a network interface and a user interface. Optionally, the network interface may include a wired interface and/or a wireless interface (e.g., WI-FI interface, bluetooth interface, etc.), which are typically 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 a standard wired interface, a wireless interface. Alternatively, 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) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable, among other things, for displaying information processed in the electronic device and for displaying a visualized user interface.
The bus 13 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus 13 may be divided into an address bus, a data bus, a control bus, etc. The bus 13 is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
Fig. 8 shows only an electronic device having components, and those skilled in the art will appreciate that the structure shown in fig. 8 does not constitute a limitation of the electronic device, and may include fewer or more components than those shown, or some components may be combined, or a different arrangement of components.
For example, although not shown, the electronic device may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so that functions of charge management, discharge management, power consumption management and the like are realized through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
Further, the electronic device may further include a network interface, and optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), which are generally used to establish a communication connection between the electronic device and another electronic device.
Optionally, the electronic device may further comprise a user interface, which may be a Display (Display), an input unit (such as a Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, 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) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable, among other things, for displaying information processed in the electronic device and for displaying a visualized user interface.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The data transmission mode conversion program stored in the memory 11 of the electronic device is a combination of a plurality of instructions, and when running in the processor 10, can realize:
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.
Specifically, the specific implementation method of the instruction by the processor 10 may refer to the description of the relevant steps in the embodiment corresponding to the drawings, which is not described herein again.
Further, the electronic device integrated module/unit, if implemented in the form of a software functional unit and sold or used as a separate product, 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 said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
The present invention also provides a computer-readable storage medium storing a computer program which, when executed by a processor of an electronic device, implements:
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.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The embodiment of the invention can acquire and process related data based on an artificial intelligence technology. Among them, Artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
The artificial intelligence base technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention 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 content of the first and second substances,
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 平安普惠企业管理有限公司 Communication unification method, device, equipment and storage medium for VUE parent-child assembly

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 平安普惠企业管理有限公司 Communication unification method, device, equipment and storage medium for VUE parent-child assembly

Similar Documents

Publication Publication Date Title
US8745584B2 (en) Dependency injection by static code generation
CN112085217A (en) Method, device, equipment and computer medium for deploying artificial intelligence service
CN113238929B (en) Code testing method and device based on Mock data, electronic equipment and storage medium
CN112506779A (en) Software interface testing method and device, electronic equipment and storage medium
CN113377661A (en) Interface testing method and device, electronic equipment and storage medium
CN112486490A (en) Front-end code packaging method and device, electronic equipment and storage medium
CN114398194A (en) Data collection method and device, electronic equipment and readable storage medium
CN113806434A (en) Big data processing method, device, equipment and medium
CN115129753A (en) Data blood relationship analysis method and device, electronic equipment and storage medium
CN115048111A (en) Code generation method, device, equipment and medium based on metadata
CN114625376A (en) Data transfer mode conversion method and device, electronic equipment and readable storage medium
CN105573763A (en) Embedded system modeling method supporting RTOS
CN112631903A (en) Task testing method and device, electronic equipment and storage medium
CN113297180A (en) Data migration method and device, electronic equipment and storage medium
CN114816371B (en) Message processing method, device, equipment and medium
CN114385155A (en) vue project visualization tool generation method, device, equipment and storage medium
CN114489861A (en) Target component conversion method and device, electronic equipment and readable storage medium
CN114936111A (en) Front-end variable anomaly detection and restoration method, device, equipment and storage medium
CN114896164A (en) Interface optimization method and device, electronic equipment and storage medium
CN114356379A (en) Backup-based service upgrading method, device, equipment and storage medium
CN114020414A (en) Symbiotic method and device of Android system and bottom layer Linux, electronic equipment and storage medium
CN114385497A (en) Test environment generation method and device, electronic equipment and storage medium
CN112527443A (en) Prompt box display method and device, electronic equipment and computer readable storage medium
WO2022105494A1 (en) Automatic data backfilling method and apparatus, electronic device, and computer storage medium
CN113485711A (en) Task triggering method and device based on dependency relationship, electronic equipment and 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