CN112965719A - Method and device for generating small program - Google Patents
Method and device for generating small program Download PDFInfo
- Publication number
- CN112965719A CN112965719A CN202110310967.XA CN202110310967A CN112965719A CN 112965719 A CN112965719 A CN 112965719A CN 202110310967 A CN202110310967 A CN 202110310967A CN 112965719 A CN112965719 A CN 112965719A
- Authority
- CN
- China
- Prior art keywords
- target
- native
- applet
- source code
- information
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The embodiment of the invention provides a method and a device for generating an applet, which are characterized in that program data of a native applet and program conversion information for a target applet are obtained, then native source code data and a native application program interface of the native applet are converted according to the program conversion information to obtain target source code data and a target application program interface which are adapted to the target applet, then a developer tool is integrated, and an instance of the target applet is output, so that syntax structure conversion of the source code data is performed through the native applet, source code data are not intrusive, no extra frame and maintenance risk brought by the frame are required to be introduced, the application program interfaces are adapted, differences among the applets are leveled, and stability after the applet is converted is ensured.
Description
The patent application of the invention is a divisional application of Chinese patent application with the application date of 3/6/2020, the application number of 202010153657.7 and the name of 'a small program generation method and device'.
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and an apparatus for generating an applet.
Background
With the development of information technology, more and more enterprises correspondingly launch small programs, and the small programs are mobile phone applications which can be used without downloading and installation. The method can be used immediately only by scanning the two-dimensional code or searching for one. The mobile phone has the characteristics of no need of installation and unloading, capability of being moved after being used up, and no occupation of the memory of the mobile phone.
Different enterprises follow the corresponding development specifications, and the small programs of various platforms are easily developed by using the corresponding languages to develop the small programs. In order to realize the interconversion between the applets, a developer can generate the applets through an anti (moving ant) or a multi-terminal same development framework taro. However, applet conversion by anti-move can only support applet conversion, and cannot support migration of plug-ins in applets; the small program conversion through taro needs to introduce a framework into the small program, so that the update maintenance is more delayed than the original small program, and the framework cannot support the functions which can be supported by the original small program, thereby influencing the use of the small program.
Disclosure of Invention
In view of the above problems, embodiments of the present invention are proposed to provide a generation method of an applet and a corresponding generation apparatus of an applet that overcome or at least partially solve the above problems.
In order to solve the above problem, an embodiment of the present invention discloses a method for generating an applet, including:
acquiring program data of a native applet and program conversion information for a target applet, the program data including native source code data and a native application program interface, the program conversion information including syntax conversion information and reference interface information;
converting the native source code data into target source code data adapted to the target applet according to the syntax conversion information;
converting the native application program interface into a target application program interface adapted to the target applet according to the reference interface information;
obtaining a developer tool for the target applet;
and generating the target applet according to the target source code data, the target application program interface and the developer tool.
Optionally, the converting the native source code data into target source code data adapted to the target applet according to the syntax conversion information includes:
traversing the source code directory of the native applet to obtain a native program file of the native source code data;
according to the syntax conversion information, carrying out syntax structure conversion on the original program file to generate a target program file adapted to the target applet, wherein the target program file comprises a target configuration file, a target structure file, a target style sheet file and a target logic file;
and generating target source code data adapted to the target applet by adopting the target configuration file, the target structure file, the target style sheet file and the target logic file.
Optionally, the converting the native application program interface into a target application program interface adapted to the target applet according to the reference interface information includes:
obtaining an operation framework of the native applet, the operation framework including native parameter information of the native application program interface;
converting the native parameter information into target parameter information adapted to the target applet according to the reference interface information;
and updating the native parameter information in the running frame by adopting the target parameter information to obtain a target application program interface of the target applet.
Optionally, the step of converting the native parameter information into target parameter information adapted to the target applet according to the reference interface information includes:
converting the native parameter name into a target parameter name by adopting the parameter mapping relation;
converting the native return value into a target return value by using the result mapping relation;
the updating, by using the target parameter information, the native parameter information in the running framework to obtain the target application program interface of the target applet includes:
updating native parameter names in the running framework with the target parameter names, and updating native return values in the running framework with the target return values;
and determining a platform identifier for the target parameter name and the target return value, and generating a target application program interface matched with the platform identifier.
Optionally, the reference interface information is generated by:
acquiring reference parameter information of a reference application program interface of a reference applet, wherein the reference parameter information comprises a reference parameter name and a reference return value;
acquiring target parameter information of a target application program interface of the target applet, wherein the target parameter information comprises the target parameter name and the target return value;
when the target parameter name is different from the reference parameter name, establishing a parameter mapping relation between the target parameter name and the reference parameter name;
and when the target return value is different from the reference return value, establishing a result mapping relation between the target return value and the reference return value.
Optionally, the method further comprises:
when the target return value is different from the baseline return value, encapsulating the native return value as a return value corresponding to the baseline return value.
Optionally, the developer tool includes at least one of a command line presentation tool, a logging tool, and a grammar detection tool, and the method further includes:
displaying target source code data of the target applet through the command line display tool;
carrying out grammar structure detection on the target source code data through the grammar detection tool to generate a detection result;
and outputting a log corresponding to the detection result through the log tool.
The embodiment of the invention also discloses a device for generating the small program, which comprises the following steps:
the data acquisition module is used for acquiring program data of a native applet and program conversion information aiming at a target applet, wherein the program data comprises native source code data and a native application program interface, and the program conversion information comprises syntax conversion information and reference interface information;
the grammar conversion module is used for converting the native source code data into target source code data which is suitable for the target small program according to the grammar conversion information;
the interface conversion module is used for converting the native application program interface into a target application program interface which is adapted to the target applet according to the reference interface information;
a developer tool acquisition module for acquiring a developer tool for the target applet;
and the applet generating module is used for generating the target applet according to the target source code data, the target application program interface and the developer tool.
Optionally, the syntax conversion module includes:
a native program file obtaining submodule, configured to traverse a source code directory of the native applet and obtain a native program file of the native source code data;
the program file conversion submodule is used for carrying out syntax structure conversion on the original program file according to the syntax conversion information to generate an object program file which is adapted to the object applet, wherein the object program file comprises an object configuration file, an object structure file, an object style sheet file and an object logic file;
and the source code data generation submodule is used for generating target source code data adapted to the target applet by adopting the target configuration file, the target structure file, the target style sheet file and the target logic file.
Optionally, the interface conversion module includes:
the operation framework acquisition submodule is used for acquiring an operation framework of the native applet, and the operation framework comprises native parameter information of the native application program interface;
the parameter information conversion submodule is used for converting the native parameter information into target parameter information adapted to the target applet according to the reference interface information;
and the application program interface obtaining submodule is used for updating the native parameter information in the operating frame by adopting the target parameter information and obtaining a target application program interface of the target small program.
Optionally, the standard interface information includes a parameter mapping relationship and a result mapping relationship, the native parameter information includes a native parameter name and a native return value, and the parameter information conversion sub-module is specifically configured to:
converting the native parameter name into a target parameter name by adopting the parameter mapping relation;
converting the native return value into a target return value by using the result mapping relation;
the application program interface obtaining submodule is specifically configured to:
updating native parameter names in the running framework with the target parameter names, and updating native return values in the running framework with the target return values;
and determining a platform identifier for the target parameter name and the target return value, and generating a target application program interface matched with the platform identifier.
Optionally, the reference interface information is generated by:
the system comprises a reference parameter information acquisition module, a reference parameter information acquisition module and a reference application program interface processing module, wherein the reference parameter information acquisition module is used for acquiring reference parameter information of a reference application program interface of a reference applet, and the reference parameter information comprises a reference parameter name and a reference return value;
a target parameter information obtaining module, configured to obtain target parameter information of a target application program interface of the target applet, where the target parameter information includes the target parameter name and the target return value;
the parameter mapping relation establishing module is used for establishing a parameter mapping relation between the target parameter name and the reference parameter name when the target parameter name is different from the reference parameter name;
and the result mapping relation establishing module is used for establishing a result mapping relation between the target return value and the reference return value when the target return value is different from the reference return value.
Optionally, the method further comprises:
a return value encapsulation module, configured to encapsulate the native return value as a return value corresponding to the reference return value when the target return value is different from the reference return value.
Optionally, the developer tool includes at least one of a command line presentation tool, a logging tool, and a grammar detection tool, and the apparatus further includes:
the source code data display module is used for displaying the target source code data of the target applet through the command line display tool;
the source code data detection module is used for carrying out grammar structure detection on the target source code data through the grammar detection tool to generate a detection result;
and the log output module is used for outputting a log corresponding to the detection result through the log tool.
The embodiment of the invention also discloses an electronic device, which comprises:
one or more processors; and
one or more machine readable media having instructions stored thereon that, when executed by the one or more processors, cause the electronic device to perform one or more methods as described above.
Embodiments of the invention also disclose one or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause the processors to perform one or more of the methods described above.
The embodiment of the invention has the following advantages:
in the embodiment of the invention, the native source code data and the native application program interface of the native applet are obtained by acquiring the program data of the native applet and the program conversion information aiming at the target applet, then the native source code data and the native application program interface of the native applet are converted according to the program conversion information to obtain the target source code data and the target application program interface which are adapted to the target applet, then a developer tool is integrated, and the instance of the target applet is output, so that the syntax structure conversion of the source code data is carried out through the native applet, the source code data is not intrusive, the maintenance risk caused by an additional lead-in frame and a lead-in frame is not needed, the application program interface is adapted, the difference between the applets is smoothed, and the stability after the applet is converted is ensured.
Drawings
FIG. 1 is a flow chart of the steps of one embodiment of a method of applet generation in accordance with the present invention;
FIG. 2 is a diagram illustrating syntax structure conversion in an embodiment of the present invention;
FIG. 3 is a diagram of an applet conversion architecture in an embodiment of the invention;
FIG. 4 is a schematic illustration of operational testing in an embodiment of the present invention;
fig. 5 is a block diagram of an embodiment of an applet generating apparatus according to the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
Referring to fig. 1, a flowchart illustrating steps of an embodiment of a method for generating an applet according to the present invention is shown, which may specifically include the following steps:
as an example, a developer may develop an applet using a corresponding language following a corresponding development specification, so that an applet adapted to a different platform may be developed. For applets between different platforms, there are certain differences between the program data of the applets, such as: the applet has different page display data, different parameter names in the program data, different API (Application Programming Interface) parameters, different return values, and the like.
In the embodiment of the present invention, the program data of the native applet may include native source code data and a native application program interface, where the native source code data may be page data describing a native applet page, the applet may obtain a corresponding return result through the application program interface, and different application program interfaces may correspond to different return results.
It should be noted that the program main part describing the whole program between different platforms may include a logic file, a common configuration file, a common style sheet file, and the like, and the program main part is the basic data for the applet to run. In the running framework of the small program, a rich native API is provided, and the capabilities provided by the application program can be conveniently called, such as obtaining user information through the API, reading local storage and payment functions and the like.
In a specific implementation, the program conversion information of the target applet of the target platform may be obtained first, so that the native source code data and the native application program interface of the native applet are converted into the target source code data and the target application program interface adapted to the target applet according to the program conversion information. The program conversion information may include syntax conversion information and reference interface information, the syntax conversion information may perform syntax structure conversion on native source code data of the native applet, and the reference interface information may perform adaptation on an application program interface, and smooth differences between the applets.
In one example, assuming that the target applet is a certain degree applet, program conversion information for the target applet, and native source code data and a native API of the native applet may be obtained, and then the native source code data and the native API are converted to fit the target applet according to the program conversion information.
102, converting the native source code data into target source code data adapted to the target applet according to the grammar conversion information;
in an example, the native source code data may be page data describing an applet, and may include program files such as a native configuration file, a native structure file, a native style sheet file, and a native logic file, and then each file in the native source code data may be converted into a file adapted to the target applet according to the syntax conversion information, so as to implement conversion of the source code data.
In an optional embodiment of the present invention, a native program file of native source code data may be obtained by traversing a source code directory of a native applet, and then syntax structure conversion is performed on the native program file according to syntax conversion information to generate a target program file adapted to a target applet, and then the target program file is adopted to generate target source code data adapted to the target applet. The target program file may include a target configuration file, a target structure file, a target style sheet file, and a target logic file.
In particular implementations, the configuration file may include configuration information for the applet page, such as window presentation, network timeout time, and the like; the structure file can comprise a tag language of an operation frame, a structure of a page can be constructed by combining a basic component, a time system and the like of an applet, and the structure file can provide functions of data binding, list rendering, condition rendering, templates, events and the like; the style sheet file may be a style language for describing component styles of the structure file, for example, may be used to determine how components of the structure file should be displayed, and may include information such as size units, style imports, inline styles, and selectors; the logic file may be the relevant logic that the applet page runs.
In an example, as shown in fig. 2, which illustrates a schematic diagram of syntactic structure conversion in an embodiment of the present invention, first, native source code data of a native applet is obtained, where the native source code data may include json file (i.e., configuration file), wxss (weixin Style sheets) file (i.e., Style sheet file), wxml (weixin Markup language) file (i.e., structure file), js file (i.e., logic file), and the like, and then, according to the syntactic conversion information, the program file may be subjected to syntactic structure conversion. Specifically, when the program file is a json file, format conversion, naming rule conversion, and the like may be performed to implement syntax structure conversion. For example, the global object of the native applet is named according to the naming rule of the target applet; when the program file is a wxss file, the processes such as file suffix processing, URL (Uniform Resource Locator) conversion, selector repair, renaming and the like can be performed, for example, a ". wxss" file in source code data can be modified into a file with a suffix name of ". css", and components in a selector can also be repaired, so that stable operation can be ensured after applet conversion; when the program file is a wxml file, attribute name replacement, convention rule conversion, suffix conversion, component naming conversion and the like can be performed, for example, ". wxml" file in the source code data can be modified into a file with a dropped name, ". swan", the component can be renamed according to the naming rule in the target applet, and the like; when the program file is a js file, bug repair can be performed, for example, repair can be performed on a place where an error occurs in the running logic, so that the program file of the native applet can be converted into a program file adapted to the target applet.
It should be noted that, for applets of different platforms, it is not necessary to convert all program files, and selective conversion may be performed according to the characteristics of different platforms, and each platform may correspond to one processing subclass, for example, for platform i, it only needs to convert json files; for platform two, it only needs to convert wxss file; for platform III, it only needs to convert wxml file; for the platform II, only js files and the like need to be converted, so that the conversion of a syntax structure can be carried out according to syntax conversion information aiming at the target small program, the source code data is not invaded, and extra frames and maintenance risks brought by the frames do not need to be introduced.
103, converting the native application program interface into a target application program interface adapted to the target applet according to the reference interface information;
in the embodiment of the present invention, in order to smooth the differences between different platform applets and ensure the stability of the API, the API of a certain applet may be used as a reference to obtain reference interface information of the reference API, and then the native API of the native applet is converted into a target API adapted to the target applet.
In a specific implementation, the reference interface information may include a parameter mapping relationship and a result mapping relationship, and the parameter mapping relationship between the target parameter name and the reference parameter name may be established by obtaining reference parameter information of a reference application program interface of the reference applet, the reference parameter information including the reference parameter name and a reference return value, and obtaining target parameter information of a target application program interface of the target applet, the target parameter information including the target parameter name and a target return value, and then matching the reference parameter information with the target parameter information, when the target parameter name is different from the reference parameter name; and when the target return value is different from the reference return value, establishing a result mapping relation between the target return value and the reference return value, or packaging the native return value into a return value corresponding to the reference return value, thereby establishing an API mapping relation between the target applet and the reference applet. Optionally, a mapping relationship between the applet of the other platform and the API of the reference applet may also be established, so that the reference applet is used as a bridge between the other platforms to perform parameter conversion of the API.
In the specific implementation, in the process of parameter mapping between the benchmark applet and other platform applets, if the API owned by the benchmark applet and other platforms do not have corresponding APIs, the standard applet and other platforms are degraded to an empty method due to incompatibility among the platforms; if the parameter names of the API are different between the reference applet and the other platform applets, establishing a parameter mapping relation of the parameter names, as shown in Table 1:
benchmark applet | Platform 1 | Platform 2 | Platform 3 |
API-1 | API-① | API-Ⅰ | API-one |
API-2 | API-② | API-Ⅱ | API-two |
API-3 | API-③ | API-Ⅲ | API-three |
API-4 | API-④ | API-Ⅳ | API-four |
API-5 | API-⑤ | API-Ⅴ | API-five |
TABLE 1
If API return values between the benchmark applet and other platform applets are different, a result mapping relation between the return values is established, or the return results are packaged, so that corresponding return values can be obtained according to the mapping relation or the packaging results, the benchmark applet is used as a bridge between other platforms to perform API parameter conversion, and differences between different applets are smoothed. The result mapping relationship of the returned value refers to the parameter mapping relationship of the parameter name, and the benchmark applet is used as a bridge to establish the corresponding relationship, which is not described herein again.
In an optional embodiment of the present invention, the applet running framework provides rich APIs, and differences of the APIs between applets of different platforms may include different parameter names and different return values, so that the applet running framework may be obtained first, and the native parameter information of the native API is obtained from the obtained API running framework, and then the native parameter information is converted into the target parameter information adapted to the target applet according to the reference interface information of the reference applet, so as to update the native parameter information in the running framework with the target parameter information and obtain the target application program interface of the target applet.
It should be noted that, in the embodiment of the present invention, the native applet and the target applet use the same framework as an example for description, and it can be understood that, when different operation frameworks are used, the native parameter information may be first converted into the target parameter information, and then the target parameter information is input into the operation framework of the target applet to construct the API of the target applet.
In the specific implementation, a parameter mapping relation is adopted to convert a native parameter name into a target parameter name, a result mapping relation is adopted to convert a native return value into a target return value, then the native parameter name in an operation frame is updated by the target parameter name, the native return value in the operation frame is updated by the target return value, a platform identifier for the target parameter name and the target return value is determined, and a target application program interface matched with the platform identifier is generated. Specifically, the parameters of the API may be converted according to the parameter mapping relationship and the result mapping relationship, and then a platform identifier corresponding to the target applet is generated so as to identify which platform the target applet belongs to, and then writing compatibility is performed, thereby implementing the adaptive conversion of the API between the applets.
in one example, the developer tools may include a CLI (Command-Line Interface) Command Line presentation tool, a logging tool, a grammar detection tool, and the like. The command line display tool can be used for displaying target source code data of the target applet, the grammar detection tool can be used for detecting a grammar structure of the target source code data, and the log tool can output a corresponding log according to a detection result.
And 105, generating the target applet according to the target source code data, the target application program interface and the developer tool.
In one example, as shown in FIG. 3, which shows a schematic diagram of an applet conversion architecture in an embodiment of the present invention, the architecture may include a compilation layer, a run-time layer, and an integration layer. After the program data of the native applet is obtained, the program data can be input into a compiling layer to perform centralized processing of a grammar structure to obtain target source code data adapted to the target applet, then the API adaptation conversion is performed through a running layer, and then the running debugging and the grammar detection are performed through a tool integrated in an integration layer. As shown in fig. 4, which shows a schematic diagram of the operation detection in the embodiment of the present invention, the rule summarization and rule packing can be performed by a line detector (i.e. a syntax detection tool) in the integration layer, and two passes of scanning (command line detection and file integrity detection) are performed according to the rule, and a summary log is output by a log logger tool. Specifically, if it is detected that attr, events, fns, and tags are not supported, the detection rule may be converted into a corresponding detection rule, such as wxmllfilerules, wxmlllinerules, wxsssfilerules, wxssslinerules, scriptFileRules, and scriptLineRules, and then the detection tool, including LintLine and LintFlie, is scanned, and then the detection rule is received, the detection result is detected and summarized, and the detection result is input to the log logger tool, and different detection results are printed with different effects. After the detection is finished, target source code data can be used as codes for running the target small program, a target API is constructed in a running framework, various development tools are integrated, and an example of the target small program is generated, so that grammar structure conversion of the source code data is carried out through the native small program, source code data is not intrusive, maintenance risks caused by extra frame introduction and frame introduction are not needed, an application program interface is adapted, differences among the small programs are smoothed, and stability after the small programs are converted is guaranteed.
In the embodiment of the invention, the native source code data and the native application program interface of the native applet are obtained by acquiring the program data of the native applet and the program conversion information aiming at the target applet, then the native source code data and the native application program interface of the native applet are converted according to the program conversion information to obtain the target source code data and the target application program interface which are adapted to the target applet, then a developer tool is integrated, and the instance of the target applet is output, so that the syntax structure conversion of the source code data is carried out through the native applet, the source code data is not intrusive, the maintenance risk caused by an additional lead-in frame and a lead-in frame is not needed, the application program interface is adapted, the difference between the applets is smoothed, and the stability after the applet is converted is ensured.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Referring to fig. 5, a block diagram of an embodiment of an applet generating apparatus according to the present invention is shown, and specifically includes the following modules:
a data obtaining module 501, configured to obtain program data of a native applet, and program conversion information for a target applet, where the program data includes native source code data and a native application program interface, and the program conversion information includes syntax conversion information and reference interface information;
a syntax conversion module 502, configured to convert the native source code data into target source code data adapted to the target applet according to the syntax conversion information;
an interface conversion module 503, configured to convert the native application program interface into a target application program interface adapted to the target applet according to the reference interface information;
a developer tool acquisition module 504 for acquiring a developer tool for the target applet;
and an applet generating module 505, configured to generate the target applet according to the target source code data, the target application program interface, and the developer tool.
In an optional embodiment of the present invention, the syntax transformation module 502 comprises:
a native program file obtaining submodule, configured to traverse a source code directory of the native applet and obtain a native program file of the native source code data;
the program file conversion submodule is used for carrying out syntax structure conversion on the original program file according to the syntax conversion information to generate an object program file which is adapted to the object applet, wherein the object program file comprises an object configuration file, an object structure file, an object style sheet file and an object logic file;
and the source code data generation submodule is used for generating target source code data adapted to the target applet by adopting the target configuration file, the target structure file, the target style sheet file and the target logic file.
In an optional embodiment of the present invention, the interface conversion module 503 includes:
the operation framework acquisition submodule is used for acquiring an operation framework of the native applet, and the operation framework comprises native parameter information of the native application program interface;
the parameter information conversion submodule is used for converting the native parameter information into target parameter information adapted to the target applet according to the reference interface information;
and the application program interface obtaining submodule is used for updating the native parameter information in the operating frame by adopting the target parameter information and obtaining a target application program interface of the target small program.
In an optional embodiment of the present invention, the standard interface information includes a parameter mapping relationship and a result mapping relationship, the native parameter information includes a native parameter name and a native return value, and the parameter information conversion sub-module is specifically configured to:
converting the native parameter name into a target parameter name by adopting the parameter mapping relation;
converting the native return value into a target return value by using the result mapping relation;
the application program interface obtaining submodule is specifically configured to:
updating native parameter names in the running framework with the target parameter names, and updating native return values in the running framework with the target return values;
and determining a platform identifier for the target parameter name and the target return value, and generating a target application program interface matched with the platform identifier.
In an optional embodiment of the present invention, the reference interface information is generated by:
the system comprises a reference parameter information acquisition module, a reference parameter information acquisition module and a reference application program interface processing module, wherein the reference parameter information acquisition module is used for acquiring reference parameter information of a reference application program interface of a reference applet, and the reference parameter information comprises a reference parameter name and a reference return value;
a target parameter information obtaining module, configured to obtain target parameter information of a target application program interface of the target applet, where the target parameter information includes the target parameter name and the target return value;
the parameter mapping relation establishing module is used for establishing a parameter mapping relation between the target parameter name and the reference parameter name when the target parameter name is different from the reference parameter name;
and the result mapping relation establishing module is used for establishing a result mapping relation between the target return value and the reference return value when the target return value is different from the reference return value.
In an optional embodiment of the present invention, further comprising:
a return value encapsulation module, configured to encapsulate the native return value as a return value corresponding to the reference return value when the target return value is different from the reference return value.
In an optional embodiment of the invention, the developer tool comprises at least one of a command line presentation tool, a logging tool, a grammar detection tool, the apparatus further comprising:
the source code data display module is used for displaying the target source code data of the target applet through the command line display tool;
the source code data detection module is used for carrying out grammar structure detection on the target source code data through the grammar detection tool to generate a detection result;
and the log output module is used for outputting a log corresponding to the detection result through the log tool.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
An embodiment of the present invention further provides an electronic device, including:
one or more processors; and
one or more machine-readable media having instructions stored thereon, which when executed by the one or more processors, cause the electronic device to perform methods as described in embodiments of the invention.
Embodiments of the invention also provide one or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause the processors to perform the methods described in embodiments of the invention.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, EEPROM, Flash, eMMC, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The above describes in detail a method and an apparatus for generating an applet, which are provided by the present invention, and a specific example is applied in the present document to explain the principle and the implementation of the present invention, and the above description of the embodiment is only used to help understand the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.
Claims (10)
1. A method for generating an applet, comprising:
acquiring program data of a native applet and program conversion information for a target applet, the program data including native source code data and a native application program interface, the program conversion information including syntax conversion information and reference interface information;
converting the native source code data into target source code data adapted to the target applet according to the syntax conversion information;
obtaining an operation framework of the native applet, the operation framework including native parameter information of the native application program interface;
converting the native parameter information into target parameter information adapted to the target applet according to the reference interface information;
updating the native parameter information in the running frame by adopting the target parameter information to obtain a target application program interface of the target applet;
and generating the target applet according to the target source code data and the target application program interface.
2. The method of claim 1, wherein the converting the native source code data into target source code data adapted to the target applet according to the syntax transformation information comprises:
traversing the source code directory of the native applet to obtain a native program file of the native source code data;
according to the syntax conversion information, carrying out syntax structure conversion on the original program file to generate a target program file adapted to the target applet, wherein the target program file comprises a target configuration file, a target structure file, a target style sheet file and a target logic file;
and generating target source code data adapted to the target applet by adopting the target configuration file, the target structure file, the target style sheet file and the target logic file.
3. The method of claim 1 or 2, wherein generating the target applet from the target source code data and the target application program interface comprises:
obtaining a developer tool for the target applet;
and generating the target applet by adopting the target source code data, the target application program interface and the developer tool.
4. The method of claim 1, wherein the baseline interface information comprises a parameter mapping relationship and a result mapping relationship, wherein the native parameter information comprises a native parameter name and a native return value, and wherein converting the native parameter information into target parameter information adapted to the target applet according to the baseline interface information comprises:
converting the native parameter name into a target parameter name by adopting the parameter mapping relation;
converting the native return value into a target return value by using the result mapping relation;
the updating, by using the target parameter information, the native parameter information in the running framework to obtain the target application program interface of the target applet includes:
updating native parameter names in the running framework with the target parameter names, and updating native return values in the running framework with the target return values;
and determining a platform identifier for the target parameter name and the target return value, and generating a target application program interface matched with the platform identifier.
5. The method of claim 4, wherein the reference interface information is generated by:
acquiring reference parameter information of a reference application program interface of a reference applet, wherein the reference parameter information comprises a reference parameter name and a reference return value;
acquiring target parameter information of a target application program interface of the target applet, wherein the target parameter information comprises the target parameter name and the target return value;
when the target parameter name is different from the reference parameter name, establishing a parameter mapping relation between the target parameter name and the reference parameter name;
and when the target return value is different from the reference return value, establishing a result mapping relation between the target return value and the reference return value.
6. The method of claim 5, further comprising:
when the target return value is different from the baseline return value, encapsulating the native return value as a return value corresponding to the baseline return value.
7. The method of claim 3, wherein the developer tools include at least one of a command line presentation tool, a logging tool, and a grammar detection tool, the method further comprising:
displaying target source code data of the target applet through the command line display tool;
carrying out grammar structure detection on the target source code data through the grammar detection tool to generate a detection result;
and outputting a log corresponding to the detection result through the log tool.
8. An applet generating apparatus, comprising:
the data acquisition module is used for acquiring program data of a native applet and program conversion information aiming at a target applet, wherein the program data comprises native source code data and a native application program interface, and the program conversion information comprises syntax conversion information and reference interface information;
the grammar conversion module is used for converting the native source code data into target source code data which is suitable for the target small program according to the grammar conversion information;
the operation framework acquisition submodule is used for acquiring an operation framework of the native applet, and the operation framework comprises native parameter information of the native application program interface;
the parameter information conversion submodule is used for converting the native parameter information into target parameter information adapted to the target applet according to the reference interface information;
an application program interface obtaining submodule, configured to update native parameter information in the operating frame with the target parameter information, and obtain a target application program interface of the target applet;
and the applet generating module is used for generating the target applet according to the target source code data and the target application program interface.
9. An electronic device, comprising:
one or more processors; and
one or more machine-readable media having instructions stored thereon that, when executed by the one or more processors, cause the electronic device to perform the method of one or more of claims 1-7.
10. One or more machine readable media having instructions stored thereon that, when executed by one or more processors, cause the processors to perform the method of one or more of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110310967.XA CN112965719B (en) | 2020-03-06 | 2020-03-06 | Method and device for generating small program |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110310967.XA CN112965719B (en) | 2020-03-06 | 2020-03-06 | Method and device for generating small program |
CN202010153657.7A CN111381825B (en) | 2020-03-06 | 2020-03-06 | Method and device for generating small program |
Related Parent Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010153657.7A Division CN111381825B (en) | 2020-03-06 | 2020-03-06 | Method and device for generating small program |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112965719A true CN112965719A (en) | 2021-06-15 |
CN112965719B CN112965719B (en) | 2022-06-17 |
Family
ID=71215358
Family Applications (3)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010153657.7A Active CN111381825B (en) | 2020-03-06 | 2020-03-06 | Method and device for generating small program |
CN202110310967.XA Active CN112965719B (en) | 2020-03-06 | 2020-03-06 | Method and device for generating small program |
CN202110310977.3A Active CN113110825B (en) | 2020-03-06 | 2020-03-06 | Method and device for converting interfaces of small programs |
Family Applications Before (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010153657.7A Active CN111381825B (en) | 2020-03-06 | 2020-03-06 | Method and device for generating small program |
Family Applications After (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110310977.3A Active CN113110825B (en) | 2020-03-06 | 2020-03-06 | Method and device for converting interfaces of small programs |
Country Status (1)
Country | Link |
---|---|
CN (3) | CN111381825B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114185551A (en) * | 2022-02-17 | 2022-03-15 | 浙江口碑网络技术有限公司 | Applet compiling method, applet running method and device and storage medium |
Families Citing this family (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111381825B (en) * | 2020-03-06 | 2021-04-09 | 北京五八信息技术有限公司 | Method and device for generating small program |
CN112083949B (en) * | 2020-09-08 | 2024-05-24 | 中国平安财产保险股份有限公司 | Self-adaptive cross-platform method, device, computer equipment and storage medium |
CN112286528A (en) * | 2020-11-04 | 2021-01-29 | 豆盟(北京)科技股份有限公司 | Applet generation method, device and equipment and computer storage medium |
CN112527415A (en) * | 2020-12-23 | 2021-03-19 | 深圳尚米网络技术有限公司 | Method, device, equipment and medium for migrating applets across platforms |
CN113312055B (en) * | 2021-05-28 | 2023-02-24 | 支付宝(中国)网络技术有限公司 | Applet launching method, device and equipment |
CN113672224B (en) * | 2021-08-20 | 2024-10-25 | 上海哔哩哔哩科技有限公司 | Method and device for generating applet page code and computer equipment |
CN113946384B (en) * | 2021-10-15 | 2023-06-13 | 中电金信软件有限公司 | Method and device for running applet and electronic equipment |
Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090172710A1 (en) * | 2007-12-28 | 2009-07-02 | Arman Toorians | Method and system for enabling a mini program on a computing device to access an auxiliary system |
CN107239318A (en) * | 2017-06-13 | 2017-10-10 | 腾讯科技(深圳)有限公司 | Using conversion method, device and equipment |
CN109213519A (en) * | 2018-09-14 | 2019-01-15 | 北京数聚鑫云信息技术有限公司 | A kind of isomery API adaptation processing method and system |
CN109710260A (en) * | 2018-11-16 | 2019-05-03 | 青岛特锐德电气股份有限公司 | It is a kind of based on multi-platform applet code converting system and conversion method |
CN109918073A (en) * | 2019-01-29 | 2019-06-21 | 维沃移动通信有限公司 | A kind of generation method of sound code file, device and terminal |
CN109947433A (en) * | 2019-03-28 | 2019-06-28 | 优信拍(北京)信息科技有限公司 | A kind of generation method of small routine, update method and device |
CN110333863A (en) * | 2019-06-17 | 2019-10-15 | 无线生活(杭州)信息科技有限公司 | A kind of method and device for generating, showing the small routine page |
CN110532029A (en) * | 2019-09-04 | 2019-12-03 | 深圳前海微众银行股份有限公司 | Small routine generation method, device, equipment and computer readable storage medium |
CN110764791A (en) * | 2019-10-25 | 2020-02-07 | 网易(杭州)网络有限公司 | Channel adaptation method and device of applet and electronic equipment |
CN111381825B (en) * | 2020-03-06 | 2021-04-09 | 北京五八信息技术有限公司 | Method and device for generating small program |
Family Cites Families (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR100410557B1 (en) * | 2001-11-19 | 2003-12-18 | 주식회사 하이닉스반도체 | Microcontroller with program patching capability and method for operating the same |
US7356808B2 (en) * | 2004-09-23 | 2008-04-08 | International Business Machines Corporation | Method, system and program product for porting code utilizing a portable execution environment |
CN100361456C (en) * | 2005-10-13 | 2008-01-09 | 华为技术有限公司 | Terminal equipment managing method |
CN105653254B (en) * | 2014-12-03 | 2019-07-09 | 科大讯飞股份有限公司 | Primary interface adaptation method, device and the electronic equipment using it |
CN105183476B (en) * | 2015-09-09 | 2018-08-28 | 中国银行股份有限公司 | A kind of construction method and device of cross-platform program |
US9886249B2 (en) * | 2015-11-16 | 2018-02-06 | Sap Se | Universal transcompiling framework |
DE102017130295A1 (en) * | 2017-12-18 | 2019-06-19 | Huf Hülsbeck & Fürst Gmbh & Co. Kg | Tire pressure monitoring unit with expandable program library and method for supplementing a program library of a tire pressure monitoring unit |
CN108268262A (en) * | 2017-12-27 | 2018-07-10 | 广东耐思尼克信息技术有限公司 | Realize the method, apparatus and system that HTML is converted to wechat small routine |
CN108196832A (en) * | 2018-01-09 | 2018-06-22 | 安徽小马创意科技股份有限公司 | It is a kind of to realize the method that wechat small routine is made to support the exploitation of Custom component formula |
CN108664248A (en) * | 2018-05-14 | 2018-10-16 | 北京汉能光伏投资有限公司 | A kind of generation method and device of wechat small routine |
CN110209388A (en) * | 2019-05-29 | 2019-09-06 | 广州酷车信息科技有限公司 | The generation method of applet file |
CN110362792B (en) * | 2019-07-05 | 2023-05-23 | 五八有限公司 | Method and device for converting RN file into applet file and conversion equipment |
CN110489088A (en) * | 2019-08-13 | 2019-11-22 | 绿漫科技有限公司 | A kind of cross-platform small routine development approach |
-
2020
- 2020-03-06 CN CN202010153657.7A patent/CN111381825B/en active Active
- 2020-03-06 CN CN202110310967.XA patent/CN112965719B/en active Active
- 2020-03-06 CN CN202110310977.3A patent/CN113110825B/en active Active
Patent Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090172710A1 (en) * | 2007-12-28 | 2009-07-02 | Arman Toorians | Method and system for enabling a mini program on a computing device to access an auxiliary system |
CN107239318A (en) * | 2017-06-13 | 2017-10-10 | 腾讯科技(深圳)有限公司 | Using conversion method, device and equipment |
CN109213519A (en) * | 2018-09-14 | 2019-01-15 | 北京数聚鑫云信息技术有限公司 | A kind of isomery API adaptation processing method and system |
CN109710260A (en) * | 2018-11-16 | 2019-05-03 | 青岛特锐德电气股份有限公司 | It is a kind of based on multi-platform applet code converting system and conversion method |
CN109918073A (en) * | 2019-01-29 | 2019-06-21 | 维沃移动通信有限公司 | A kind of generation method of sound code file, device and terminal |
CN109947433A (en) * | 2019-03-28 | 2019-06-28 | 优信拍(北京)信息科技有限公司 | A kind of generation method of small routine, update method and device |
CN110333863A (en) * | 2019-06-17 | 2019-10-15 | 无线生活(杭州)信息科技有限公司 | A kind of method and device for generating, showing the small routine page |
CN110532029A (en) * | 2019-09-04 | 2019-12-03 | 深圳前海微众银行股份有限公司 | Small routine generation method, device, equipment and computer readable storage medium |
CN110764791A (en) * | 2019-10-25 | 2020-02-07 | 网易(杭州)网络有限公司 | Channel adaptation method and device of applet and electronic equipment |
CN111381825B (en) * | 2020-03-06 | 2021-04-09 | 北京五八信息技术有限公司 | Method and device for generating small program |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114185551A (en) * | 2022-02-17 | 2022-03-15 | 浙江口碑网络技术有限公司 | Applet compiling method, applet running method and device and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN113110825A (en) | 2021-07-13 |
CN111381825B (en) | 2021-04-09 |
CN112965719B (en) | 2022-06-17 |
CN113110825B (en) | 2022-06-03 |
CN111381825A (en) | 2020-07-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112965719B (en) | Method and device for generating small program | |
CN111680253B (en) | Page application data packet generation method and device, computer equipment and storage medium | |
CN111399853B (en) | Templated deployment method for machine learning model and custom operator | |
US7039833B2 (en) | Stack trace generated code compared with database to find error resolution information | |
US9471282B2 (en) | System and method for using annotations to automatically generate a framework for a custom javaserver faces (JSF) component | |
US20150082298A1 (en) | Packaging and deploying hybrid applications | |
US10606586B2 (en) | Application architecture generation | |
US20130007706A1 (en) | Building optimized download modules leveraging modularized dependencies | |
CN102932197A (en) | Testing method and system | |
CN110362792B (en) | Method and device for converting RN file into applet file and conversion equipment | |
CN111813385B (en) | Page plug-in method, device and equipment based on Web application | |
CN110806868A (en) | Single-page building and loading method | |
EP3447635A1 (en) | Application architecture generation | |
CN111459465A (en) | Method and device for generating Flutter engineering file | |
CN111240987B (en) | Method and device for detecting migration program, electronic equipment and computer readable storage medium | |
CN112685105A (en) | Front-end component sharing method and device, computer equipment and storage medium | |
CN102779045A (en) | Interface generating method, interface editor and electronic equipment | |
US10606569B2 (en) | Declarative configuration elements | |
CN110321138B (en) | Program updating and migration method and device | |
CN111679828A (en) | Data processing method and device, electronic equipment and storage medium | |
US8943476B2 (en) | System and method to in-line script dependencies | |
CN113126998B (en) | Incremental source code acquisition method and device, electronic equipment and storage medium | |
CN115794214A (en) | Application module metadata management method, device, storage medium and device | |
US11740995B2 (en) | Source quality check service | |
CN104461557A (en) | Puppet configuration data processing method and device |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |