A method for generating multi-platform program packages based on Hbuilderx plug-in
By registering compilation commands for multiple platforms and adding SDK files in the Hbuilderx plug-in, the problem of JavaScript project code files being unable to run on different platforms is solved, achieving cross-platform compatibility and improving generation efficiency.
Patent Information
- Application Number
- CN202310269359.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-15
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2043-03-15
AI Technical Summary
Existing JavaScript project code files cannot run on different platforms, resulting in cross-platform compatibility issues.
By registering the compilation commands of multiple platforms in the Hbuilderx plug-in, obtain the JavaScript project code file, select the corresponding compilation command according to the target platform to compile, generate the target platform package, and add the software development tool kit when the target platform package fails to run. SDK files to ensure that the package runs successfully on different platforms.
It enables JavaScript project code files to run on different platforms, solves cross-platform compatibility issues, and improves the efficiency of platform package generation.
Smart Images

Figure CN116382775B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a multi-platform program package generation method based on Hbuilderx plug-in. Background Art
[0002] With the development of computer technology, mini-programs have become an indispensable application for current users. In the related art, an existing set of JavaScript project code files can only be run in some platform mini-programs with relatively wide applications, but cannot be run in a specific platform mini-program. There is a problem that the existing JavaScript project code files cannot be run in a certain platform. Therefore, how to run the same JavaScript project code file on different platforms is an urgent problem to be solved. Summary of the invention
[0003] The present invention aims to solve one of the technical problems in the related art at least to a certain extent.
[0004] To this end, the first purpose of the present invention is to propose a multi-platform program package generation method based on the Hbuilderx plug-in, so as to compile JavaScript project code files into platform program packages for multiple platforms, thereby realizing the running of the same JavaScript project code file on different platforms, and solving the technical problem in the related technology that JavaScript project code files cannot be run on a certain platform.
[0005] The second object of the present invention is to provide a multi-platform program package generation device based on Hbuilderx plug-in.
[0006] A third objective of the present invention is to provide an electronic device.
[0007] A fourth object of the present invention is to provide a computer-readable storage medium.
[0008] A fifth object of the present invention is to provide a computer program product.
[0009] To achieve the above object, the first embodiment of the present invention proposes a method for generating a multi-platform program package based on an Hbuilderx plug-in. The method pre-registers compilation commands of at least two platforms in the Hbuilderx plug-in, including:
[0010] Get the JavaScript project code file;
[0011] Selecting a target compilation command corresponding to a target platform from the compilation commands of the at least two platforms to compile the JavaScript project code file to generate a target platform program package;
[0012] In the case that the target platform program package fails to run, a software development kit SDK file of the target platform is added to the target platform program package to enable the target platform program package to run successfully.
[0013] Optionally, as a first possible implementation manner of the first aspect, after adding the software development kit SDK file of the target platform to the target platform program package, the method further includes:
[0014] Adaptation data is added to the target platform program package, wherein the adaptation data is used to enable the target platform program package to normally display component information when the target platform is running.
[0015] Optionally, as a second possible implementation manner of the first aspect, adding the software development kit SDK file of the target platform to the target platform program package includes:
[0016] Add the SDK file of the target platform to the static file directory of the target platform program package;
[0017] Add reference data to the default page file of the target platform program package, wherein the reference data is used to reference the SDK file in the static file directory.
[0018] Optionally, as a third possible implementation manner of the first aspect, the SDK file includes an application programming interface API that supports the target platform package to run on the target platform, and the method further includes:
[0019] The API in the SDK file is called through the interface calling method.
[0020] Optionally, as a fourth possible implementation manner of the first aspect, calling the API in the SDK file through the interface calling method includes:
[0021] The target API in the SDK file is called according to the SDK file name, the target API name and the target parameters.
[0022] Optionally, as a fifth possible implementation manner of the first aspect, selecting a target compilation command corresponding to a target platform from the compilation commands of the at least two platforms to compile the JavaScript project code file to generate a target platform program package includes:
[0023] Determining, according to the platform name included in the compile command, a target compile command corresponding to the target platform from the compile commands of the at least two platforms;
[0024] The target compilation command is used to compile the JavaScript project code file to generate a target platform program package.
[0025] Optionally, as a sixth possible implementation manner of the first aspect, determining, according to the platform name included in the compile command, a target compile command corresponding to the target platform from the compile commands of the at least two platforms includes:
[0026] Determining, according to the contents after the target character in the compilation commands of the at least two platforms, platform names included in the compilation commands of the at least two platforms;
[0027] Matching the platform names included in the compilation commands of the at least two platforms with the platform name of the target platform;
[0028] The matching compile commands are determined as target compile commands.
[0029] Optionally, as a seventh possible implementation manner of the first aspect, the method further includes:
[0030] When there is no target compilation command corresponding to the target platform in the compilation commands of the at least two platforms, a prompt message indicating compilation failure is issued.
[0031] Optionally, as an eighth possible implementation of the first aspect, a method for uploading code is pre-registered in the Hbuilderx plug-in, and the method further includes:
[0032] When the target platform program package runs successfully, the target platform program package is uploaded to the target platform using the code upload method.
[0033] Optionally, as a ninth possible implementation manner of the first aspect, the method further includes:
[0034] When the target platform program package runs successfully, the target platform program package is stored.
[0035] To achieve the above object, the second embodiment of the present invention proposes a multi-platform package generation device based on Hbuilderx plug-in, which pre-registers compilation commands of at least two platforms in the Hbuilderx plug-in, including:
[0036] Get module, used to get JavaScript project code files;
[0037] A compiling module, used for selecting a target compiling command corresponding to a target platform from the compiling commands of the at least two platforms to compile the JavaScript project code file and generate a target platform program package;
[0038] The first adding module is used to add the software development kit SDK file of the target platform to the target platform program package when the target platform program package fails to run, so as to make the target platform program package run successfully.
[0039] Optionally, as a first possible implementation manner of the second aspect, the apparatus further includes:
[0040] The second adding module is used to add adaptation data to the target platform program package, wherein the adaptation data is used to enable the target platform program package to normally display component information when the target platform is running.
[0041] Optionally, as a second possible implementation manner of the second aspect, the first adding module is further used to:
[0042] Add the SDK file of the target platform to the static file directory of the target platform program package;
[0043] Add reference data to the default page file of the target platform program package, wherein the reference data is used to reference the SDK file in the static file directory.
[0044] Optionally, as a third possible implementation manner of the second aspect, the SDK file includes an application programming interface API that supports the target platform program package to run on the target platform, and the device further includes:
[0045] The calling module is used to call the API in the SDK file through the interface calling method.
[0046] Optionally, as a fourth possible implementation manner of the second aspect, the calling module is further used to:
[0047] The target API in the SDK file is called according to the SDK file name, the target API name and the target parameters.
[0048] Optionally, as a fifth possible implementation manner of the second aspect, the compiling module includes:
[0049] a determining unit, configured to determine, according to the platform name included in the compile command, a target compile command corresponding to the target platform from the compile commands of the at least two platforms;
[0050] The compiling unit is used to compile the JavaScript project code file using the target compiling command to generate a target platform program package.
[0051] Optionally, as a sixth possible implementation manner of the second aspect, the determining unit is further configured to:
[0052] Determining, according to the contents after the target character in the compilation commands of the at least two platforms, platform names included in the compilation commands of the at least two platforms;
[0053] Matching the platform names included in the compilation commands of the at least two platforms with the platform name of the target platform;
[0054] The matching compile commands are determined as target compile commands.
[0055] Optionally, as a seventh possible implementation manner of the second aspect, the apparatus further includes:
[0056] The prompt module is used to issue a prompt message indicating compilation failure when there is no target compilation command corresponding to the target platform in the compilation commands of the at least two platforms.
[0057] Optionally, as an eighth possible implementation of the second aspect, a method for uploading code is pre-registered in the Hbuilderx plug-in, and the device further includes:
[0058] The uploading module is used to upload the target platform program package to the target platform by using the uploading code method when the target platform program package runs successfully.
[0059] Optionally, as a ninth possible implementation manner of the second aspect, the apparatus further includes:
[0060] The storage module is used to store the target platform program package when the target platform program package runs successfully.
[0061] To achieve the above-mentioned purpose, a third aspect of the present invention provides an electronic device, including:
[0062] at least one processor; and
[0063] a memory communicatively connected to the at least one processor; wherein,
[0064] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the multi-platform program package generation method based on the Hbuilderx plug-in of the first aspect.
[0065] In order to achieve the above-mentioned purpose, the fourth aspect of the present invention proposes a computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the multi-platform program package generation method based on Hbuilderx plug-in of the first aspect.
[0066] In order to achieve the above-mentioned purpose, a fifth aspect of the present invention proposes a computer program product, including a computer program, which, when executed by a processor, implements the multi-platform program package generation method based on Hbuilderx plug-in of the first aspect.
[0067] The technical solution provided by the embodiment of the present invention has the following beneficial effects:
[0068] Register the compilation commands of at least two platforms in the Hbuilderx plug-in in advance, and by obtaining the JavaScript project code file, select the target compilation command corresponding to the target platform from the compilation commands of at least two platforms to compile the JavaScript project code file, generate the target platform program package, and add the software development kit SDK file of the target platform to the target platform program package when the target platform program package fails to run, so that the target platform program package runs successfully. Thus, by compiling the JavaScript project code file into the platform program package of multiple platforms, it is possible to run the same JavaScript project code file under different platforms, and solve the technical problem that the JavaScript project code file cannot run on a certain platform in the related art. At the same time, since the platform name contained in the compilation command can be determined according to the content after the target character in the compilation command, the target compilation command corresponding to the target platform is determined from the compilation commands of at least two platforms based on the platform name contained in the compilation command, and the automatic matching compilation command is realized, and the generation efficiency of the platform program package is improved.
[0069] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0071] Figure 1 A flow chart of a method for generating a multi-platform program package based on an Hbuilderx plug-in provided in an embodiment of the present invention;
[0072] Figure 2A flowchart of another method for generating a multi-platform program package based on the Hbuilderx plug-in provided by an embodiment of the present invention;
[0073] Figure 3 A flowchart of another method for generating a multi-platform program package based on the Hbuilderx plug-in provided by an embodiment of the present invention;
[0074] Figure 4 A flowchart of another method for generating a multi-platform program package based on the Hbuilderx plug-in provided by an embodiment of the present invention;
[0075] Figure 5 A flowchart of another method for generating a multi-platform program package based on the Hbuilderx plug-in provided by an embodiment of the present invention;
[0076] Figure 6 A flowchart of another method for generating a multi-platform program package based on the Hbuilderx plug-in provided by an embodiment of the present invention;
[0077] Figure 7 A flowchart of a method for generating a multi-platform program package based on an Hbuilderx plug-in in a scenario provided by an embodiment of the present invention;
[0078] Figure 8 A schematic diagram of the structure of a multi-platform program package generation device based on Hbuilderx plug-in provided by an embodiment of the present invention;
[0079] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0080] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0081] Aiming at the problem that the existing JavaScript project code files in the related art cannot be run on a certain platform, the present invention proposes a multi-platform program package generation method based on Hbuilderx plug-in.
[0082] The following describes a multi-platform program package generation method based on the Hbuilderx plug-in according to an embodiment of the present invention with reference to the accompanying drawings.
[0083] Figure 1A flowchart of a method for generating a multi-platform program package based on an Hbuilderx plug-in provided in an embodiment of the present invention.
[0084] It should be noted that the multi-platform program package generation method based on the Hbuilderx plug-in of the embodiment of the present invention can be executed by the multi-platform program package generation device based on the Hbuilderx plug-in provided by the embodiment of the present invention. The multi-platform program package generation device based on the Hbuilderx plug-in can be an electronic device, and can also be configured in an electronic device, so as to compile the JavaScript project code file into platform packages of multiple platforms, thereby realizing the running of the same JavaScript project code file on different platforms, and solving the technical problem in the related art that the JavaScript project code file cannot be run on a certain platform.
[0085] Among them, the electronic device can be any stationary or mobile computing device capable of data processing, such as mobile computing devices such as laptops, smart phones, wearable devices, or stationary computing devices such as desktop computers, or servers, or other types of computing devices, etc., which are not limited in this embodiment.
[0086] like Figure 1 As shown, the multi-platform program package generation method based on the Hbuilderx plug-in includes the following steps:
[0087] It should be noted that, in this embodiment, at least two platform compiling commands are pre-registered in the Hbuilderx plug-in, wherein the registered at least two platform compiling commands are used to compile the project code files to generate platform program packages of the corresponding platforms.
[0088] Step 101, obtain the JavaScript project code file.
[0089] In this embodiment, the JavaScript project code file may be a project code file of any set of JavaScript languages.
[0090] In this embodiment, a JavaScript project code file can be obtained, and the obtained project code file can be compiled according to the target platform type to generate a target platform program package, thereby solving the technical problem in the related art that the JavaScript project code file cannot run on a certain platform.
[0091] Step 102: Select a target compilation command corresponding to a target platform from compilation commands of at least two platforms to compile the JavaScript project code file to generate a target platform program package.
[0092] In this embodiment, the target compile command is a compile command corresponding to the target platform among the compile commands of at least two platforms pre-registered in the Hbuilderx plug-in.
[0093] In this embodiment, the target platform may be any application applet platform. Alternatively, the target platform may be an application applet platform selected by the user.
[0094] In this embodiment, the target compilation command corresponding to the target platform can be selected from the compilation commands of at least two platforms pre-registered in the Hbuilderx plug-in to compile the acquired JavaScript project code file to generate the target platform program package. For example, assuming that the target platform is the application 1 applet platform selected by the user, the target compilation command corresponding to the application 1 applet platform can be selected from the compilation commands of at least two platforms pre-registered in the Hbuilderx plug-in to compile the acquired JavaScript project code file to generate the application 1 applet platform program package.
[0095] Since the compile commands are automatically matched from the compile commands of at least two platforms pre-registered in the Hbuilderx plug-in, the generation efficiency of the platform program package is effectively improved.
[0096] It should be noted that, in the present invention, there is also a situation where there is no target compile command corresponding to the target platform in the compile commands of at least two platforms pre-registered in the Hbuilderx plug-in. At this time, a prompt message of compile failure can be issued. Specifically, in the case where there is no target compile command corresponding to the target platform in the compile commands of at least two platforms, a prompt message of compile failure can be issued in the form of a pop-up window.
[0097] Step 103, when the target platform program package fails to run, add the target platform software development kit SDK file to the target platform program package to make the target platform program package run successfully.
[0098] It is understandable that when the generated target platform package is running on the target platform, it may fail to run due to the lack of an operating environment, tools, class libraries, etc. that support the running. Therefore, in this embodiment, when the target platform package fails to run, the SDK (Software Development Kit) file of the target platform can be added to the target platform package to enable the target platform package to run successfully. Among them, the SDK file is used to support the target platform package to run on the target platform, and may include an operating environment, tools, class libraries, etc. that support the target platform package to run on the target platform.
[0099] In a possible implementation of this embodiment, the SDK file of the target platform can be added to the static file directory of the target platform program package, and reference data can be added to the default page file of the target platform program package, wherein the reference data is used to reference the SDK file in the static file directory. For example, the SDK file (madp.js) can be added to the / static / js directory in the target platform program package, and the SDK file can be introduced in the index.html of the target platform program package through the following reference data: <script src=". static js madp.js">< / script> Thus, an SDK file for supporting the target platform program package to run on the target platform is added to the target platform program package.
[0100] The multi-platform program package generation method based on the Hbuilderx plug-in provided in the embodiment of the present invention pre-registers the compilation commands of at least two platforms in the Hbuilderx plug-in, and by obtaining the JavaScript project code file, selects the target compilation command corresponding to the target platform from the compilation commands of at least two platforms to compile the JavaScript project code file to generate the target platform program package, so that in the case that the target platform program package fails to run, the software development kit SDK file of the target platform is added to the target platform program package to enable the target platform program package to run successfully. Therefore, by compiling the JavaScript project code file into the platform program packages of multiple platforms, it is possible to run the same JavaScript project code file on different platforms, solving the technical problem in the related art that the JavaScript project code file cannot run on a certain platform, and at the same time, because the compilation command can be automatically matched, the generation efficiency of the platform program package is effectively improved.
[0101] Through the above analysis, it can be known that in the embodiment of the present invention, the target compilation command corresponding to the target platform can be selected from the compilation commands of at least two platforms to compile the JavaScript project code file to generate the target platform program package. In order to clearly explain this process, this embodiment provides another multi-platform program package generation method based on Hbuilderx plug-in. Figure 2 A flowchart of another method for generating a multi-platform program package based on the Hbuilderx plug-in provided in an embodiment of the present invention.
[0102] like Figure 2 As shown, the multi-platform program package generation method based on the Hbuilderx plug-in may include the following steps:
[0103] Step 201, obtaining the JavaScript project code file.
[0104] It should be noted that the execution process of this step can refer to the execution process of step 101 in the previous embodiment, and the principles are the same, so it will not be repeated here.
[0105] Step 202: Determine a target compile command corresponding to the target platform from the compile commands of at least two platforms according to the platform name included in the compile command.
[0106] In this embodiment, the target compile command is a compile command corresponding to the target platform among the compile commands of at least two platforms pre-registered in the Hbuilderx plug-in.
[0107] In this embodiment, the target platform may be any application applet platform. Alternatively, the target platform may be an application applet platform selected by the user.
[0108] In a possible implementation of this embodiment, the platform names contained in the compilation commands of at least two platforms can be determined based on the content after the target character in the compilation commands of at least two platforms, and then the platform names contained in the compilation commands of at least two platforms are matched with the platform name of the target platform, so that the compilation commands that match the same can be determined as the target compilation commands. Among them, the target character in the compilation command can be selected when the compilation command is artificially named. For example, assuming that the artificially named compilation command is npm run build:yingyong1xiaochengxu, and the target character selected when the compilation command is artificially named is ":", then according to the content after the target character in the compilation command, that is, yingyong1xiaochengxu, it can be determined that the platform name contained in the compilation command is the application 1 applet platform.
[0109] Since the platform name contained in the compilation command can be determined according to the content after the target character in the compilation command, the target compilation command corresponding to the target platform can be determined from the compilation commands of at least two platforms based on the platform name contained in the compilation command, thereby achieving automatic matching of compilation commands and improving the generation efficiency of platform program packages.
[0110] It should be noted that, in the present invention, there is also a situation where there is no target compile command corresponding to the target platform in the compile commands of at least two platforms pre-registered in the Hbuilderx plug-in. At this time, a prompt message of compile failure can be issued. Specifically, in the case where there is no target compile command corresponding to the target platform in the compile commands of at least two platforms, a prompt message of compile failure can be issued in the form of a pop-up window.
[0111] Step 203, using the target compilation command to compile the JavaScript project code file to generate a target platform program package.
[0112] Step 204: in the case that the target platform program package fails to run, the target platform software development kit SDK file is added to the target platform program package to enable the target platform program package to run successfully.
[0113] It should be noted that the execution process of step 204 can refer to the execution process of step 103 in the previous embodiment, and the principles are the same, which will not be repeated here.
[0114] The multi-platform program package generation method based on Hbuilderx plug-in provided by the embodiment of the present invention determines the target compile command corresponding to the target platform from the compile commands of at least two platforms according to the platform name contained in the compile command, and realizes compiling the JavaScript project code file by using the target compile command to generate the target platform program package. Thus, automatic matching of compile commands can be realized, and the generation efficiency of platform program packages can be improved.
[0115] It should be noted that, in the present invention, the SDK file added in the target platform program package can also be called. In order to clearly explain this process, this embodiment provides another multi-platform program package generation method based on Hbuilderx plug-in. Figure 3 A flowchart of another method for generating a multi-platform program package based on the Hbuilderx plug-in provided in an embodiment of the present invention.
[0116] like Figure 3 As shown, the multi-platform program package generation method based on the Hbuilderx plug-in may include the following steps:
[0117] Step 301, obtain the JavaScript project code file.
[0118] Step 302: Select a target compilation command corresponding to a target platform from compilation commands of at least two platforms to compile the JavaScript project code file to generate a target platform program package.
[0119] Step 303: When the target platform program package fails to run, add the target platform software development kit SDK file to the target platform program package to enable the target platform program package to run successfully.
[0120] It should be noted that the execution process of steps 301-303 can refer to the execution process of steps 101-103 in the above embodiment, and the principles are the same, which will not be repeated here.
[0121] Step 304: Call the API in the SDK file through the interface calling method.
[0122] In this embodiment, the SDK file includes an API (Application Programming Interface) that supports the target platform program package to run on the target platform, so that the API in the SDK file can be called through an interface calling method.
[0123] In a possible implementation of this embodiment, the target in the SDK file can be called according to the SDK file name, target API name and target parameters. For example, in step 103 of the above embodiment, the SDK file (madp.js) is added to the / static / js directory in the target platform package, and the SDK file is introduced in the index.html of the target platform package through the following reference data: <script src=". static js madp.js">< / script> For example, the SDK file name is madp, so the target API in the SDK file can be called through madp.(target API name)(target parameter).
[0124] The multi-platform program package generation method based on Hbuilderx plug-in provided in the embodiment of the present invention can call the target in the SDK file according to the SDK file name, target API name and target parameters, thereby realizing calling the API in the SDK file through the interface calling method.
[0125] It should be noted that, in the present invention, adaptation data can also be added to the target platform program package so that the target platform program package can normally display component information when the target platform is running. In order to clearly explain this process, this embodiment provides another multi-platform program package generation method based on Hbuilderx plug-in. Figure 4 A flowchart of another method for generating a multi-platform program package based on the Hbuilderx plug-in provided in an embodiment of the present invention.
[0126] like Figure 4 As shown, the multi-platform program package generation method based on the Hbuilderx plug-in may include the following steps:
[0127] Step 401, obtain the JavaScript project code file.
[0128] Step 402: Select a target compilation command corresponding to a target platform from compilation commands of at least two platforms to compile the JavaScript project code file to generate a target platform program package.
[0129] Step 403: When the target platform program package fails to run, the target platform software development kit SDK file is added to the target platform program package to enable the target platform program package to run successfully.
[0130] It should be noted that the execution process of steps 401-403 can refer to the execution process of steps 101-103 in the above embodiment, and the principles are the same, which will not be repeated here.
[0131] Step 404: Add adaptation data to the target platform program package.
[0132] The adaptation data is used to enable the target platform program package to display component information normally when the target platform is running.
[0133] In this embodiment, after adding the software development kit SDK file of the target platform to the target platform program package, the adaptation data can be added to the target platform program package, so that the target platform program package can normally display the component information when the target platform is running.
[0134] As an example, you can add the following adaptation data to the target platform package:
[0135] uni-page-head{display:none;}
[0136] uni-tabbar{display:none! important;}
[0137] Among them, uni-page-head{display:none;} is used to avoid double title bars, and uni-tabbar{display:none!important;} is used to avoid double bottom navigation bars.
[0138] Specifically, you can create a new h5-common.css file in the / static directory of the target platform package, and write the following adaptation data into the h5-common.css file:
[0139] uni-page-head{display:none;}
[0140] uni-tabbar{display:none! important;}
[0141] Then in the index.html of the target platform package, use the following code <link rel=stylesheethref=". h5-common.css"> Import the h5-common.css file, thereby adding adaptation data to the target platform package.
[0142] The multi-platform program package generation method based on Hbuilderx plug-in provided in the embodiment of the present invention pre-registers the compilation commands of at least two platforms in the Hbuilderx plug-in, and by obtaining the JavaScript project code file, selects the target compilation command corresponding to the target platform from the compilation commands of at least two platforms to compile the JavaScript project code file to generate the target platform program package, so that when the target platform program package fails to run, the software development kit SDK file of the target platform is added to the target platform program package to make the target platform program package run successfully, and the adaptation data is added to the target platform program package to make the target platform program package display component information normally when the target platform runs. In this way, the project code file can run successfully on the target platform and display component information normally.
[0143] It should be noted that, in the present invention, the target platform program package can also be uploaded when the target platform program package runs successfully. In order to clearly illustrate this process, this embodiment provides another multi-platform program package generation method based on Hbuilderx plug-in. Figure 3 A flowchart of another method for generating a multi-platform program package based on an Hbuilderx plug-in provided in an embodiment of the present invention.
[0144] like Figure 5 As shown, the multi-platform program package generation method based on the Hbuilderx plug-in may include the following steps:
[0145] Step 501, obtain the JavaScript project code file.
[0146] Step 502: Select a target compilation command corresponding to a target platform from compilation commands of at least two platforms to compile the JavaScript project code file to generate a target platform program package.
[0147] Step 503: When the target platform program package fails to run, the target platform software development kit SDK file is added to the target platform program package to enable the target platform program package to run successfully.
[0148] It should be noted that the execution process of steps 501-503 can refer to the execution process of steps 101-103 in the above embodiment, and the principles are the same, which will not be repeated here.
[0149] Step 504: when the target platform program package runs successfully, the target platform program package is uploaded to the target platform using an upload code method.
[0150] It should be noted that, in this embodiment, the upload code method is pre-registered in the Hbuilderx plug-in. Optionally, the following upload code method is registered in the plug-in entry file (extension.js):
[0151] hx.commands.registerCommand('api.uploadMiniTemplate,function(){uploadMiniTemplate()})
[0152] In this embodiment, when the target platform program package runs successfully, the target platform program package can be uploaded to the target platform using the code upload method. Thus, the target platform program package can be directly uploaded using the Hbuilderx plug-in.
[0153] The multi-platform program package generation method based on the Hbuilderx plug-in provided in the embodiment of the present invention pre-registers the upload code method in the Hbuilderx plug-in, so that when the target platform program package runs successfully, the target platform program package is uploaded to the target platform using the upload code method. Thus, the target platform program package can be directly uploaded using the Hbuilderx plug-in.
[0154] It should be noted that, in the present invention, in addition to uploading the target platform program package when the target platform program package runs successfully, the target platform program package can also be stored when the target platform program package runs successfully for subsequent manual uploading of the target platform program package. In order to clearly illustrate this process, this embodiment provides another multi-platform program package generation method based on Hbuilderx plug-in, Figure 6 A flowchart of another method for generating a multi-platform program package based on the Hbuilderx plug-in provided in an embodiment of the present invention.
[0155] like Figure 6 As shown, the multi-platform program package generation method based on the Hbuilderx plug-in may include the following steps:
[0156] Step 601, obtain the JavaScript project code file.
[0157] Step 602: Select a target compilation command corresponding to a target platform from compilation commands of at least two platforms to compile the JavaScript project code file to generate a target platform program package.
[0158] Step 603: When the target platform program package fails to run, the target platform software development kit SDK file is added to the target platform program package to enable the target platform program package to run successfully.
[0159] It should be noted that the execution process of steps 601-603 can refer to the execution process of steps 101-103 in the above embodiment, and the principles are the same, which will not be repeated here.
[0160] Step 604: When the target platform program package runs successfully, the target platform program package is stored.
[0161] In this embodiment, the target platform program package can be stored when the target platform program package runs successfully. Optionally, the target platform program package can be compressed and stored. For example, the spwan of the child-process module can be used to execute the packaging command to compress and store the target platform program package. In this way, the target platform program package can be stored for subsequent manual uploading of the target platform program package in the target platform.
[0162] The multi-platform program package generation method based on the Hbuilderx plug-in provided in the embodiment of the present invention pre-registers the upload code method in the Hbuilderx plug-in, so that when the target platform program package runs successfully, the target platform program package is stored. Thus, the target platform program package can be stored for subsequent manual uploading of the target platform program package in the target platform.
[0163] In order to clearly illustrate the above embodiment, an example is now given for illustration.
[0164] Figure 7 A flowchart of a method for generating a multi-platform program package based on an Hbuilderx plug-in in a scenario provided by an embodiment of the present invention.
[0165] It should be noted that, in this embodiment, at least two platform compilation commands and code upload methods are pre-registered in the Hbuilderx plug-in. For example, the following plug-in execution method can be registered in the plug-in entry file extension.js:
[0166] {
[0167] hx.commands.registerCommand('api.uploadMiniTemplate,function(){uploadMiniTemplate()}) / / Upload code method
[0168] hx.commands.registerCommand('api.compileH5',()=>{compileH5()}) / / Compile and generate the applet platform package
[0169] …
[0170] }
[0171] like Figure 7 As shown, the multi-platform program package generation method based on the Hbuilderx plug-in includes the following steps:
[0172] Step 701, start.
[0173] Step 702, obtaining the JavaScript project code file.
[0174] Step 703: Select a target compilation command corresponding to the target platform from the compilation commands of at least two platforms to compile the JavaScript project code file to generate a target platform program package.
[0175] It should be noted that the execution process of steps 702-703 can refer to the execution process of steps 101-102 in the above embodiment, and the principles are the same, which will not be repeated here.
[0176] Step 704, determining whether the target platform package is successfully executed, is divided into two cases:
[0177] One is that the target platform program package runs successfully, and the process goes to step 707;
[0178] The other is that the target platform program package fails to run, and the process goes to step 705 .
[0179] Step 705: Add the target platform's software development kit SDK file to the target platform program package, so that the target platform program package runs successfully.
[0180] It should be noted that the execution process of this step can refer to the execution process of step 103 in the above embodiment, and the principles are the same, which will not be repeated here.
[0181] Step 706: Add adaptation data to the target platform program package, so that the target platform program package can normally display component information when the target platform is running.
[0182] It should be noted that the execution process of this step can refer to the execution process of step 404 in the above embodiment, and the principles are the same, which will not be repeated here.
[0183] Step 707, determining whether to directly upload the target platform package, is divided into two cases:
[0184] One is to directly upload the target platform package and go to step 708;
[0185] The other is not to directly upload the target platform program package, and proceed to step 709 .
[0186] Step 708: Upload the target platform program package to the target platform using an upload code method.
[0187] It should be noted that the execution process of this step can refer to the execution process of step 504 in the above embodiment, and the principles are the same, which will not be repeated here.
[0188] Step 709: store the target platform program package.
[0189] It should be noted that the execution process of this step can refer to the execution process of step 604 in the above embodiment, and the principles are the same, which will not be repeated here.
[0190] Step 710, end.
[0191] Therefore, by compiling the JavaScript project code file into platform packages for multiple platforms, it is possible to run the same JavaScript project code file on different platforms, thus solving the technical problem in the related art that the JavaScript project code file cannot be run on a certain platform.
[0192] In order to implement the above embodiment, the present invention also proposes a multi-platform program package generation device based on Hbuilderx plug-in.
[0193] Figure 8 A schematic diagram of the structure of a multi-platform program package generation device based on Hbuilderx plug-in provided in an embodiment of the present invention.
[0194] It should be noted that, in this embodiment, at least two platform compiling commands are pre-registered in the Hbuilderx plug-in, wherein the registered at least two platform compiling commands are used to compile the project code files to generate platform program packages of the corresponding platforms.
[0195] like Figure 8 As shown, the multi-platform program package generating device based on the Hbuilderx plug-in includes: an acquisition module 81, a compilation module 82 and a first adding module 83.
[0196] An acquisition module 81 is used to acquire a JavaScript project code file;
[0197] A compiling module 82, configured to select a target compiling command corresponding to a target platform from the compiling commands of at least two platforms to compile the JavaScript project code file and generate a target platform program package;
[0198] The first adding module 83 is used to add the software development kit SDK file of the target platform to the target platform program package when the target platform program package fails to run, so that the target platform program package can run successfully.
[0199] According to one embodiment of the present invention, the above device further includes:
[0200] The second adding module is used to add adaptation data to the target platform program package, wherein the adaptation data is used to enable the target platform program package to display component information normally when the target platform is running.
[0201] The calling module is used to call the API in the SDK file through the interface calling method.
[0202] According to one embodiment of the present invention, the first adding module 83 is further used for:
[0203] Add the SDK file of the target platform to the static file directory of the target platform package;
[0204] Add reference data to the default page file of the target platform package, where the reference data is used to reference the SDK file in the static file directory.
[0205] According to one embodiment of the present invention, the SDK file includes an application programming interface API that supports the target platform package to run on the target platform, and the above-mentioned device also includes:
[0206] The calling module is used to call the API in the SDK file through the interface calling method.
[0207] According to one embodiment of the present invention, the compiling module 82 includes:
[0208] a determination unit, configured to determine a target compilation command corresponding to a target platform from compilation commands of at least two platforms according to a platform name included in the compilation command;
[0209] The compilation unit is used to compile the JavaScript project code file using the target compilation command to generate a target platform package.
[0210] According to one embodiment of the present invention, the determining unit is further configured to:
[0211] Determining, according to the contents after the target character in the compilation commands of the at least two platforms, platform names included in the compilation commands of the at least two platforms;
[0212] Match the platform names included in the compilation commands for at least two platforms with the platform name of the target platform;
[0213] The matching compile commands are determined as target compile commands.
[0214] According to one embodiment of the present invention, the above device further includes:
[0215] The prompt module is used to issue a prompt message of compilation failure when there is no target compilation command corresponding to the target platform in the compilation commands of at least two platforms.
[0216] According to one embodiment of the present invention, the above device further includes:
[0217] The upload module is used to upload the target platform program package to the target platform by using the upload code method when the target platform program package runs successfully.
[0218] According to one embodiment of the present invention, the above device further includes:
[0219] The storage module is used to store the target platform program package when the target platform program package runs successfully.
[0220] It should be noted that the above explanation of the embodiment of the multi-platform program package generation method based on the Hbuilderx plug-in is also applicable to the multi-platform program package generation device based on the Hbuilderx plug-in of this embodiment, which will not be repeated here.
[0221] The multi-platform program package generation device based on Hbuilderx plug-in provided by the embodiment of the present invention pre-registers the compilation commands of at least two platforms in the Hbuilderx plug-in, and by obtaining the JavaScript project code file, selects the target compilation command corresponding to the target platform from the compilation commands of at least two platforms to compile the JavaScript project code file to generate the target platform program package, so that when the target platform program package fails to run, the software development kit SDK file of the target platform is added to the target platform program package to make the target platform program package run successfully. Thus, by compiling the JavaScript project code file into the platform program packages of multiple platforms, it is possible to run the same JavaScript project code file under different platforms, solving the technical problem that the JavaScript project code file cannot run on a certain platform in the related art. At the same time, since the platform name contained in the compilation command can be determined according to the content after the target character in the compilation command, the target compilation command corresponding to the target platform is determined from the compilation commands of at least two platforms based on the platform name contained in the compilation command, and the automatic matching of the compilation command is realized, thereby improving the generation efficiency of the platform program package.
[0222] In order to implement the above embodiments, the present invention also proposes an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the multi-platform package generation method based on the Hbuilderx plug-in proposed in any of the above embodiments of the present invention.
[0223] Fig. 9 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. It should be noted that: Fig. 9 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0224] like Fig. 9 As shown, the electronic device may include: a shell 11, a processor 12, a memory 13, a circuit board 14 and a power circuit 15, wherein the circuit board 14 is arranged inside the space enclosed by the shell 11, and the processor 12 and the memory 13 are arranged on the circuit board 14; the power circuit 15 is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory 13 is used to store executable program codes; the processor 12 runs the program corresponding to the executable program code by reading the executable program code stored in the memory 13, so as to execute the multi-platform program package generation method based on the Hbuilderx plug-in proposed in any of the above-mentioned embodiments of the present invention.
[0225] For details on the specific execution process of the above steps by the processor 12 and the steps further executed by the processor 12 by running the executable program code, please refer to the present invention. Figure 1-7 The description of the illustrated embodiment will not be repeated here.
[0226] In order to implement the above embodiments, the present invention further proposes a computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the multi-platform program package generation method based on Hbuilderx plug-in proposed in any of the above embodiments of the present invention.
[0227] In order to implement the above embodiments, the present invention further proposes a computer program product, including a computer program, which, when executed by a processor, implements the multi-platform program package generation method based on Hbuilderx plug-in proposed in any of the above embodiments of the present invention.
[0228] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0229] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0230] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.
[0231] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0232] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0233] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0234] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0235] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present invention. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.
Claims
1. A multi-platform program package generation method based on Hbuilderx plug-in, characterized in that: Registering at least two platform compilation commands in the Hbuilderx plug-in in advance, the method includes: Get the JavaScript project code file; From the compilation commands of the at least two platforms, a target compilation command corresponding to a target platform is selected to compile the JavaScript project code file to generate a target platform program package; the target platform is any application applet platform; In the case that the target platform program package fails to run, adding the SDK file of the target platform to the static file directory of the target platform program package; the SDK file is used to support the target platform program package to run on the target platform; Add reference data to the default page file of the target platform program package to enable the target platform program package to run successfully, wherein the reference data is used to reference the SDK file in the static file directory.
2. The method according to claim 1, characterized in that After adding the software development kit SDK file of the target platform to the target platform program package, the method further includes: Adaptation data is added to the target platform program package, wherein the adaptation data is used to enable the target platform program package to normally display component information when the target platform is running.
3. The method according to claim 1, characterized in that The SDK file includes an application programming interface API that supports the target platform package to run on the target platform, and the method further includes: The API in the SDK file is called through the interface calling method.
4. The method according to claim 3, characterized in that The calling of the API in the SDK file through the interface calling method includes: The target API in the SDK file is called according to the SDK file name, the target API name and the target parameters.
5. The method according to claim 1, characterized in that The step of selecting a target compilation command corresponding to a target platform from the compilation commands of the at least two platforms to compile the JavaScript project code file to generate a target platform program package includes: Determining, according to the platform name included in the compile command, a target compile command corresponding to the target platform from the compile commands of the at least two platforms; The target compilation command is used to compile the JavaScript project code file to generate a target platform program package.
6. The method according to claim 5, characterized in that The step of determining, according to the platform name included in the compile command, a target compile command corresponding to the target platform from the compile commands of the at least two platforms comprises: Determining, according to the contents after the target character in the compilation commands of the at least two platforms, platform names included in the compilation commands of the at least two platforms; Matching the platform names included in the compilation commands of the at least two platforms with the platform name of the target platform; The matching compile commands are determined as target compile commands.
7. The method according to claim 1, characterized in that The method further comprises: When there is no target compilation command corresponding to the target platform in the compilation commands of the at least two platforms, a prompt message indicating compilation failure is issued.
8. The method according to claim 1, characterized in that A method for uploading code is pre-registered in the Hbuilderx plug-in, the method further comprising: When the target platform program package runs successfully, the target platform program package is uploaded to the target platform using the code upload method.
9. The method according to claim 1, characterized in that: The method further comprises: When the target platform program package runs successfully, the target platform program package is stored.
