CN116974567A - Method, apparatus, device, medium and program product for packaging components of applet - Google Patents

Method, apparatus, device, medium and program product for packaging components of applet Download PDF

Info

Publication number
CN116974567A
CN116974567A CN202310658583.6A CN202310658583A CN116974567A CN 116974567 A CN116974567 A CN 116974567A CN 202310658583 A CN202310658583 A CN 202310658583A CN 116974567 A CN116974567 A CN 116974567A
Authority
CN
China
Prior art keywords
compiling
file
script
component source
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310658583.6A
Other languages
Chinese (zh)
Inventor
毕琛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bank of China Ltd
Original Assignee
Bank of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN202310658583.6A priority Critical patent/CN116974567A/en
Publication of CN116974567A publication Critical patent/CN116974567A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The application relates to the technical field of big data, and provides a method, a device, equipment, a medium and a program product for packaging components of a small program, wherein the method comprises the following steps: determining compiling parameter configuration information according to the acquired component source codes; based on the compiling parameter configuration information, adjusting a first compiling rule and a second compiling rule; the first compiling rule is used for generating a weback compiling script; the second compiling rule is used for generating a gulp compiling script; and translating corresponding parts in the component source code by adopting the weback compiling script and the gulp compiling script to obtain a target compiling file corresponding to the component source code. The application not only can reduce the operation difficulty of verifying and debugging the components in the applet, but also can effectively improve the development efficiency of the applet components.

Description

Method, apparatus, device, medium and program product for packaging components of applet
Technical Field
The present application relates to the field of big data technologies, and in particular, to a method, an apparatus, a device, a medium, and a program product for packaging components of a small program.
Background
An applet is a mobile end application developed based on a specific programming language without the need for manual download and installation by a user. In general, the running of the applet needs to depend on an application platform, for example, a WeChat applet using a WeChat platform as a carrier platform.
However, since the development tool for performing applet development and debugging has not yet been provided with a perfect engineering compiling capability, there is a problem that the efficiency is low when the component development of the applet is performed by using the existing development tool.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a method, apparatus, device, medium, and program product for packaging components of an applet.
In a first aspect, the present application provides a method for packaging components of an applet, the method comprising:
determining compiling parameter configuration information according to the acquired component source codes;
based on the compiling parameter configuration information, adjusting a first compiling rule and a second compiling rule; the first compiling rule is used for generating a weback compiling script; the second compiling rule is used for generating a gulp compiling script;
and translating corresponding parts in the component source code by adopting the weback compiling script and the gulp compiling script to obtain a target compiling file corresponding to the component source code.
In one embodiment, the translating the corresponding reference portion in the component source code by using the weback compiling script and the gulp compiling script to obtain the target compiling file corresponding to the component source code includes:
adopting the weback compiling script to abstract and package the dynamic scripting language part referenced in the component source code to obtain a first compiling result; adopting the gulp compiling script to analyze the structural style language part in the component source code to obtain a second compiling result; the structural style language part comprises a WXML file and a WXSS file; and integrating the first compiling result and the second compiling result according to the configuration item data in the compiling parameter configuration information to obtain the target compiling file.
In one embodiment, the performing abstract packaging processing on the dynamic scripting language portion referenced in the component source code by using the weback compiling script to obtain a first compiling result includes:
acquiring a JavaScript file and an independent code block which are referenced in the component source code based on an entry file name in the compiling parameter configuration information; and carrying out abstract packaging processing and compression processing on the independent code blocks and the JavaScript file in sequence to obtain the first compiling result.
In one embodiment, the sequentially performing abstract packaging processing and compression processing on the independent code block and the JavaScript file to obtain the first compiling result, where the first compiling result includes:
sequentially carrying out abstract packaging treatment and compression treatment on the independent code blocks to obtain a first target code block; performing recursion operation on the JavaScript file, positioning each code block in the JavaScript file, and sequentially performing abstract packaging treatment and compression treatment on each code block to obtain a second target code block; and summarizing the first target code block and the second target code block to obtain the first compiling result.
In one embodiment, the parsing the structural style language part in the component source code by adopting the gulp compiling script to obtain a second compiling result includes:
compressing the WXML file to obtain a target WXML file; calling a corresponding plug-in under the condition that a preprocessing language exists in the WXSS file, and analyzing the WXSS file to obtain a target WXSS file; and acquiring the second compiling result based on the target WXML file and the target WXSS file.
In one embodiment, the method further comprises:
under the condition that a static resource file exists in the dynamic scripting language part or the WXSS file, determining whether the occupied space of the static resource file is larger than a preset threshold value; if the occupied space of the static resource file is larger than the preset threshold value, the static resource file is copied to an outlet file address in the compiling parameter configuration information in parallel, and a hash value is added in the file name of the static resource file; and if the occupied space of the static resource file is smaller than or equal to the preset threshold value, performing BASE64 coding processing on the static resource file.
In a second aspect, the present application also provides an assembly packaging apparatus for an applet, the apparatus comprising:
the compiling parameter obtaining module is used for determining compiling parameter configuration information according to the obtained component source codes;
the compiling rule determining module is used for adjusting the first compiling rule and the second compiling rule based on the compiling parameter configuration information; the first compiling rule is used for generating a weback compiling script; the second compiling rule is used for generating a gulp compiling script;
And the target file output module is used for translating corresponding parts in the component source codes by adopting the weback compiling script and the gulp compiling script to obtain target compiling files corresponding to the component source codes.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor implementing the steps of the above method when the processor executes the computer program.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the above method.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the steps of the above method.
The method, the device, the equipment, the medium and the program product for packaging the components of the small program are characterized in that firstly, compiling parameter configuration information is determined according to acquired component source codes. Then, based on the compiling parameter configuration information, a first compiling rule for generating a weback compiling script and a second compiling rule for generating a gulp compiling script are adjusted. And finally, translating corresponding parts in the component source codes by adopting a weback compiling script and a gulp compiling script to obtain target compiling files corresponding to the component source codes. The application is based on weback compiling script and gulp compiling script, and carries out translation processing aiming at corresponding parts in the component source code, so that the package compiling of the component source code of the applet into the standard engineering file which can be directly accessed by a development tool of the applet is realized, the operation difficulty of verifying and debugging the component in the applet can be reduced, and the development efficiency of the applet component can be effectively improved.
Drawings
FIG. 1 is a flow diagram of a method for component packaging of an applet, provided in one embodiment;
FIG. 2 is a flow diagram that provides one embodiment of a specific way to obtain a target compiled file;
FIG. 3 is a flowchart illustrating a specific manner of obtaining a first compiling result according to an embodiment;
FIG. 4 is a flowchart illustrating a specific manner of obtaining a first compiling result based on an independent code block and a JavaScript file according to an embodiment;
FIG. 5 is a flowchart illustrating a specific manner of obtaining the second compiling result according to one embodiment;
FIG. 6 is a flow diagram that provides one embodiment of a specific manner in which static resource files that exist in a dynamic scripting language portion or WXSS file are processed;
FIG. 7 is a block diagram of the components packaging apparatus of an applet, provided in one embodiment;
FIG. 8 is an internal block diagram of a computer device provided in one embodiment;
fig. 9 is an internal structural diagram of a computer device provided in another embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
The method for packaging the components of the applet, provided by the embodiment of the application, can be applied to a server or a terminal for execution. The terminal can be, but is not limited to, various personal computers, notebook computers and tablet computers; the server can be realized by an independent server or a server cluster formed by a plurality of servers; the data storage system can store data which the server needs to process; the data storage system may be integrated on a server or may be placed on a cloud or other network server.
As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," and/or the like, specify the presence of stated features, integers, steps, operations, elements, components, or groups thereof, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, or groups thereof. Also, the term "and/or" as used in this specification includes any and all combinations of the associated listed items.
In one embodiment, as shown in fig. 1, there is provided a component packaging method of an applet, which is applied to a server execution case, including the steps of:
Step S110, according to the acquired component source codes, compiling parameter configuration information is determined.
In this step, the component source code refers to the component source code of the applet; the compiling parameter configuration information refers to parameter configuration information required in the process of compiling component source codes of the applet.
Specifically, the specific expression forms of the applet may include a WeChat applet, a Payment applet, and the like; the specific form of compiling parameter configuration information may be a compiling parameter configuration file, for example, a vue.config.js file similar to H5 vue.
In practical applications, the specific content of the compiling parameter configuration file may include the contents of an entry file name, an exit file address, a compiling mode, a plug-in, configuration item data, and the like. The method comprises the steps of compiling a component source code, wherein the component source code comprises an entry file name used for representing the name of an entry file adopted in the compiling process of the component source code, and the entry file can be used as an entry to start recursive retrieval in the compiling process; an exit file address for characterizing a storage path of a file generated during compilation of component source code; the compiling mode is used for representing the engineering types corresponding to the compiling process of the component source code, such as WeChat applet, weChat game and the like, and the compiling processes corresponding to different engineering types are also different; a plug-in for characterizing plug-in tools provided by a third party that may need to be used in the compilation of component source code; configuration item data, configuration item content for characterizing development tools of the applet (e.g., for developing and debugging the applet IDE), which may include wxappid (i.e., app id of the applet, which may be directly written into configuration items of the applet IDE through a compilation process), whether hot update (i.e., whether the applet IDE needs to be enabled for hot update functions), URL check (i.e., whether URL check functions of the applet IDE need to be enabled), code compression (i.e., whether compression functions need to be enabled when the applet IDE uploads code), and the like.
Step S120, based on the compiling parameter configuration information, adjusting a first compiling rule and a second compiling rule; the first compiling rule is used for generating a weback compiling script; the second compiling rule is used for generating a gulp compiling script.
In this step, compiling parameter configuration information, which is required in the process of compiling component source codes for the applet; the first compiling rule is used for generating a weback compiling script; the second compiling rule is used for generating a gulp compiling script; the weback compiling script refers to a weback compiling script generated based on a first compiling rule; the gulp compiling script refers to a gulp compiling script generated based on the second compiling rule.
Specifically, the specific expression form of the compiling parameter configuration information may be a compiling parameter configuration file, for example, a vue.config.js file similar to H5 vue; the concrete expression form of the weback compiling script can be a weback compiling script constructed based on a static module packaging and code compiling tool weback for carrying out modern JavaScript application programs; the concrete expression form of the gulp compiling script can be a stream (stream) -based automatic construction tool gulp, and the constructed gulp compiling script is formed.
And step S130, translating corresponding parts in the component source codes by adopting a weback compiling script and a gulp compiling script to obtain target compiling files corresponding to the component source codes.
In this step, the weback compiling script refers to a weback compiling script generated based on a first compiling rule; the gulp compiling script refers to a gulp compiling script generated based on the second compiling rule; the first compiling rule is used for generating a weback compiling script; the second compiling rule is used for generating a gulp compiling script; component source code, which refers to the component source code of the applet; the target compiling file, namely the target compiling file corresponding to the component source code, refers to the target compiling file corresponding to the obtained component source code after translating the corresponding part in the component source code by adopting a weback compiling script and a gulp compiling script.
Specifically, the concrete expression form of the weback compiling script can be a weback compiling script constructed based on a static module packaging and code compiling tool weback for carrying out modern JavaScript application programs; the concrete expression form of the gulp compiling script can be a stream (stream) -based automatic construction tool gulp, and the constructed gulp compiling script is formed; the specific expression forms of the applet can comprise a WeChat applet, a Payment applet and the like; the concrete expression form of the corresponding part in the component source code can comprise a dynamic script language part, a structural style language part and the like.
In practical application, the target compiling file corresponding to the component source code can be directly accessed through the WeChat applet IDE, and the target compiling file can keep a plurality of verified development period engineering capabilities.
According to the component packaging method of the applet, firstly, compiling parameter configuration information is determined according to the acquired component source code. Then, based on the compiling parameter configuration information, a first compiling rule for generating a weback compiling script and a second compiling rule for generating a gulp compiling script are adjusted. And finally, translating corresponding parts in the component source codes by adopting a weback compiling script and a gulp compiling script to obtain target compiling files corresponding to the component source codes. The application is based on weback compiling script and gulp compiling script, and carries out translation processing aiming at corresponding parts in the component source code, so that the package compiling of the component source code of the applet into the standard engineering file which can be directly accessed by a development tool of the applet is realized, the operation difficulty of verifying and debugging the component in the applet can be reduced, and the development efficiency of the applet component can be effectively improved.
For a specific manner of acquiring the target compiled file, in one embodiment, as shown in fig. 2, the step S130 specifically includes the following steps:
step S210, adopting weback compiling script to abstract and package the dynamic scripting language part referenced in the component source code, and obtaining a first compiling result.
In this step, the weback compiling script refers to a weback compiling script generated based on a first compiling rule; the first compiling rule is used for generating a weback compiling script; component source code, which refers to the component source code of the applet; the first compiling result is obtained by adopting a weback compiling script to abstract and package a dynamic scripting language part referenced in the component source code.
Specifically, the concrete expression form of the dynamic script language part referenced in the component source code can include a JavaScript file and a JavaScript code block referenced in the component source code.
In practical application, weback compiling script is adopted, after abstract packaging processing is performed on dynamic scripting language parts referenced in component source codes, compression processing can be performed on the dynamic scripting language parts after abstract packaging processing, so that storage space occupied by the obtained first compiling result is reduced.
Step S220, adopting a gulp compiling script to analyze and process the structural style language part in the component source code to obtain a second compiling result; the aforementioned structural style language part includes a WXML file and a WXSS file.
In this step, the gulp compiling script refers to a gulp compiling script generated based on the second compiling rule; the second compiling rule is used for generating a gulp compiling script; component source code, which refers to the component source code of the applet; the second compiling result refers to a second compiling result obtained after the structural style language part in the component source code is analyzed by adopting a gulp compiling script, and the concrete expression form of the second compiling result can comprise a WXML file (a program file written based on a micro beacon language) and a WXSS file (a program file written based on a micro message cascading style sheet).
In practical application, before analyzing the structural style language part in the component source code, compression processing can be performed in advance for the structural style language part in the component source code, so as to reduce the code volume of the file to be analyzed later.
Step S230, integrating the first compiling result and the second compiling result according to the configuration item data in the compiling parameter configuration information to obtain the target compiling file.
In this step, compiling parameter configuration information, which is required in the process of compiling component source codes for the applet; configuration item data, i.e., configuration item data in compiled parameter configuration information, which may be used to characterize the configuration item content of development tools for applets (e.g., for development and debugging IDE of WeChat applets); the first compiling result is obtained after abstract packaging processing is carried out on a dynamic scripting language part referenced in the component source code by adopting a weback compiling script; the second compiling result is obtained after analyzing the structural style language part in the component source code by adopting a gulp compiling script; the target compiling file, namely, the target compiling file corresponding to the component source code, refers to the target compiling file corresponding to the obtained component source code after integrating the first compiling result and the second compiling result according to the configuration item data in the compiling parameter configuration information.
Specifically, the target compiling file can be directly accessed through a WeChat applet IDE, and the target compiling file can reserve a plurality of verified development period engineering capabilities, and based on the target compiling file, the specific expression form of the target compiling file can be a standard engineering file which corresponds to the component source code and can be directly accessed by adopting a development tool of the applet.
In practical applications, compiling the configuration item data in the parameter configuration information may include wxappid (i.e. app id of the applet, where wxappid may be directly written into the configuration item of the applet IDE through a compiling process), whether hot update (i.e. whether the applet IDE needs to enable a hot update function), URL check (i.e. whether URL check function of the applet IDE needs to be started), code compression (i.e. whether compression function needs to be enabled when the applet IDE uploads code), and so on.
According to the embodiment of the application, the first compiling result obtained by adopting the weback compiling script and the second compiling result obtained by adopting the gulp compiling script are integrated according to the configuration item data in the compiling parameter configuration information, so that the mode of obtaining the target compiling file corresponding to the component source code is obtained, the operation difficulty of verifying and debugging the component in the applet is reduced, and the development efficiency of the applet component is further effectively improved.
For a specific way of obtaining the first compiling result, in one embodiment, as shown in fig. 3, the step S210 specifically includes the following steps:
step S310, based on the entry file name in the compiling parameter configuration information, a JavaScript file and an independent code block which are referenced in the component source code are obtained.
In this step, compiling parameter configuration information, which is required in the process of compiling component source codes for the applet; the entry file name is used for representing the name of an entry file adopted in the compiling process of the component source code, and the entry file can be used as an entry to start recursive retrieval in the compiling process; component source code, which refers to the component source code of the applet; the JavaScript file refers to a JavaScript file referenced in the component source code, and is obtained based on the entry file name in the compiling parameter configuration information; the independent code blocks, namely JavaScript code blocks which independently exist in the component source code, refer to JavaScript code blocks which independently exist in the obtained component source code and are obtained based on the entry file name in the compiling parameter configuration information.
Step S320, abstract packaging processing and compression processing are sequentially carried out on the independent code blocks and the JavaScript file, and a first compiling result is obtained.
In the step, the independent code blocks, namely JavaScript code blocks which independently exist in the component source code, refer to JavaScript code blocks which independently exist in the obtained component source code based on the entry file name in the compiling parameter configuration information; the JavaScript file refers to a JavaScript file referenced in the component source code, and is obtained based on the entry file name in the compiling parameter configuration information; the first compiling result is obtained after abstract packaging processing and compression processing are sequentially performed on the independent code blocks and the JavaScript file.
The specific way of sequentially carrying out abstract packaging treatment and compression treatment on the independent code blocks and the JavaScript file can be that the abstract packaging treatment and the compression treatment are firstly carried out on the independent code blocks sequentially to obtain the independent code blocks after the treatment is completed, then the abstract packaging treatment and the compression treatment are sequentially carried out on each code block in the JavaScript file to obtain the JavaScript file after the treatment is completed, and finally the first compiling result is obtained based on the independent code blocks after the treatment is completed and the JavaScript file after the treatment is completed.
According to the embodiment of the application, the JavaScript file and the JavaScript code block which are referenced in the component source code are obtained based on the entry file name in the compiling parameter configuration information, and the JavaScript code block and the JavaScript file are subjected to abstract packaging processing and compression processing in sequence, so that a first compiling result is obtained, and the operation difficulty of verifying and debugging the component in the applet is effectively reduced.
For a specific way of obtaining the first compiling result based on the independent code block and the JavaScript file, in one embodiment, as shown in fig. 4, the step S320 specifically includes the following steps:
Step S410, abstract packaging processing and compression processing are sequentially carried out on the independent code blocks, and a first target code block is obtained.
In the step, the independent code blocks, namely JavaScript code blocks which independently exist in the component source code, refer to JavaScript code blocks which independently exist in the obtained component source code based on the entry file name in the compiling parameter configuration information; the first target code block is obtained by sequentially carrying out abstract packaging processing and compression processing on independent code blocks.
And step S420, performing recursion operation on the JavaScript file, positioning each code block in the JavaScript file, and sequentially performing abstract encapsulation processing and compression processing on each code block to obtain a second target code block.
In the step, a JavaScript file, namely a JavaScript file quoted in a component source code, refers to a JavaScript file quoted in the obtained component source code based on an entry file name in compiling parameter configuration information; each code block, namely each code block in the JavaScript file; the second target code block is obtained by performing recursive operation on the JavaScript file, positioning each code block in the JavaScript file, and then sequentially performing abstract encapsulation processing and compression processing on each code block in the JavaScript file.
Step S430, summarizing the first target code block and the second target code block to obtain a first compiling result.
In the step, the first target code block is obtained after abstract packaging processing and compression processing are sequentially carried out on independent code blocks; the second target code block is obtained by performing recursive operation on the JavaScript file, positioning each code block in the JavaScript file, and then sequentially performing abstract encapsulation and compression on each code block in the JavaScript file; the first compiling result refers to a first compiling result obtained by collecting the first target code block and the second target code block.
According to the embodiment of the application, the JavaScript code blocks and the JavaScript files are subjected to abstract packaging processing and compression processing in sequence, so that a first compiling result containing the first target code blocks corresponding to the JavaScript code blocks and the second target code blocks corresponding to the JavaScript files is obtained, the efficiency of standard translation of the component source code is improved, and the development efficiency of the applet component is further effectively improved.
For a specific manner of obtaining the second compiling result, in one embodiment, as shown in fig. 5, the step S220 specifically includes the following steps:
And step S510, compressing the WXML file to obtain the target WXML file.
In the step, the WXML file refers to the WXML file in the structural style language part in the component source code; the target WXML file refers to a target WXML file obtained by compressing the WXML file.
Specifically, the target wuml file may be a compressed wuml file with a reduced code volume.
And step S520, calling a corresponding plug-in under the condition that the preprocessing language exists in the WXSS file, and analyzing the WXSS file to obtain the target WXSS file.
In the step, the WXSS file refers to the WXSS file in the structural style language part in the component source code; the corresponding plug-in refers to a corresponding preprocessing language analyzing plug-in for analyzing and processing the preprocessing language existing in the WXSS file; the target WXSS file refers to a target WXSS file obtained by calling a corresponding plug-in under the condition that a preprocessing language exists in the WXSS file and analyzing the WXSS file.
Specifically, the concrete expression forms of the preprocessing language may include CSS preprocessing language les, CSS preprocessing language SASS, and the like; the target WXSS file may be in a concrete form as a native WXSS file.
Step S530, obtaining a second compiling result based on the target WXML file and the target WXSS file.
In the step, the target WXML file refers to the obtained target WXML file after the WXML file is compressed; the target WXSS file refers to a target WXSS file obtained by calling a corresponding plug-in under the condition that a preprocessing language exists in the WXSS file and analyzing the WXSS file; the second compiling result is obtained based on the target WXML file and the target WXSS file.
Specifically, the specific expression form of the target WXML file can be a WXML file with reduced code volume after compression treatment; the target WXSS file may be in a concrete form as a native WXSS file.
According to the embodiment of the application, the target WXML file is obtained by compressing the WXML file, the corresponding plug-in is called under the condition that the preprocessing language exists in the WXSS file, the target WXSS file is obtained by analyzing the WXSS file, and the second compiling result is obtained based on the target WXML file and the target WXSS file, so that the efficiency of standard translation of the component source code is effectively improved, and the development efficiency of the applet component is further ensured.
For the specific manner in which the static resource file present in the dynamic scripting language portion or the WXSS file is processed, in one embodiment, as shown in FIG. 6, the method further comprises the steps of:
in step S610, in the case that the static resource file exists in the dynamic scripting language portion or the WXSS file, it is determined whether the occupied space of the static resource file is greater than a preset threshold.
In this step, a dynamic scripting language portion, that is, a dynamic scripting language portion referenced in the component source code; WXSS files refer to WXSS files in the structural style language part in the component source code; the concrete expression form of the static resource file exists in the dynamic scripting language part or the WXSS file, and the static resource file introduced into the dynamic scripting language part or the WXSS file exists; static resource files refer to static resource files introduced in a dynamic scripting language portion or WXSS files; the preset threshold is a preset threshold used for comparing with the occupied space of the static resource file, and the static resource file can be determined to be a larger file under the condition that the occupied space of any static resource file is larger than the preset threshold.
Specifically, the concrete expression form of the dynamic script language part can include a JavaScript file and a JavaScript code block which are referenced in the component source code; the specific reason for determining whether the occupied space of the static resource file is larger than the preset threshold value may be to determine whether the static resource file introduced in the dynamic scripting language portion (i.e. the JavaScript file and JavaScript code block referenced in the component source code) or the WXSS file is a larger file; the concrete expression form of the static resource file can be a picture file.
In step S620, if the occupied space of the static resource file is greater than the preset threshold, the static resource file is copied to the exit file address in the compiling parameter configuration information in parallel, and a hash value is added in the file name of the static resource file.
In the step, the static resource file refers to a static resource file introduced in a dynamic scripting language part or a WXSS file; the concrete expression form of the dynamic script language part can comprise JavaScript files and JavaScript code blocks referenced in the component source code; the preset threshold value is used for comparing with the occupied space of the static resource file, and the static resource file can be determined to be a larger file under the condition that the occupied space of any static resource file is larger than the preset threshold value; compiling parameter configuration information, which is parameter configuration information required in the compiling process aiming at component source codes of the applet; the export file address, i.e. the export file address in the compiled parameter configuration information.
Specifically, the specific purpose of adding the hash value to the file name of the static resource file may be to avoid generating a cache during loading; under the condition that the occupied space of the static resource file is larger than a preset threshold value, the static resource file introduced in the current JavaScript file, the current JavaScript code block or the current WXSS file can be determined to be a larger file, the static resource file is further copied to an outlet file address in compiling parameter configuration information in parallel, and a hash value is added in the file name of the static resource file, so that cache during loading is avoided.
In step S630, if the occupied space of the static resource file is less than or equal to the preset threshold, the BASE64 encoding process is performed on the static resource file.
In the step, the static resource file refers to a static resource file introduced in a dynamic scripting language part or a WXSS file; the concrete expression form of the dynamic script language part can comprise JavaScript files and JavaScript code blocks referenced in the component source code; the preset threshold is a preset threshold used for comparing with the occupied space of the static resource file, and can determine that the static resource file is a larger file when the occupied space of any static resource file is larger than the preset threshold, and can determine that the static resource file is a smaller file when the occupied space of any static resource file is smaller than or equal to the preset threshold.
Specifically, the specific way to perform BASE64 encoding processing on the static resource file may be to perform BASE64 encoding processing on the static resource file first, and then replace the original static resource file with the static resource file after BASE64 encoding processing.
According to the embodiment of the application, the occupation space of the static resource file introduced in the dynamic scripting language part or the WXSS file is compared with the preset threshold value, so that the specific operation mode of processing the static resource file in the translation process is determined, the efficiency of carrying out standard translation on the component source code can be effectively improved, and the operation difficulty of verifying and debugging the component in the applet can be reduced.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a device for packaging the components of the small program for realizing the method for packaging the components of the small program. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiment of the component packaging device for one or more applets provided below may be referred to the limitation of the component packaging method for an applet hereinabove, and will not be repeated herein.
In one embodiment, as shown in FIG. 7, an applet component packaging apparatus is provided, the apparatus comprising:
a compiling parameter obtaining module 710, configured to determine compiling parameter configuration information according to the obtained component source code;
a compiling rule determining module 720, configured to adjust a first compiling rule and a second compiling rule based on the compiling parameter configuration information; the first compiling rule is used for generating a weback compiling script; the second compiling rule is used for generating a gulp compiling script;
and the target file output module 730 is configured to translate a corresponding portion of the component source code by using the weback compiling script and the gulp compiling script to obtain a target compiling file corresponding to the component source code.
In one embodiment, the object file output module 730 is specifically configured to use the weback compiling script to perform abstract packaging processing on the dynamic scripting language portion referenced in the component source code, so as to obtain a first compiling result; adopting the gulp compiling script to analyze the structural style language part in the component source code to obtain a second compiling result; the structural style language part comprises a WXML file and a WXSS file; and integrating the first compiling result and the second compiling result according to the configuration item data in the compiling parameter configuration information to obtain the target compiling file.
In one embodiment, the target file output module 730 is further configured to obtain a JavaScript file and an independent code block referenced in the component source code based on the entry file name in the compiling parameter configuration information; and carrying out abstract packaging processing and compression processing on the independent code blocks and the JavaScript file in sequence to obtain the first compiling result.
In one embodiment, the target file output module 730 is further configured to sequentially perform abstract encapsulation processing and compression processing on the independent code blocks to obtain a first target code block; performing recursion operation on the JavaScript file, positioning each code block in the JavaScript file, and sequentially performing abstract packaging treatment and compression treatment on each code block to obtain a second target code block; and summarizing the first target code block and the second target code block to obtain the first compiling result.
In one embodiment, the target file output module 730 is further configured to compress the wuml file to obtain a target wuml file; calling a corresponding plug-in under the condition that a preprocessing language exists in the WXSS file, and analyzing the WXSS file to obtain a target WXSS file; and acquiring the second compiling result based on the target WXML file and the target WXSS file.
In one embodiment, the target file output module 730 is further configured to determine, if a static resource file exists in the dynamic scripting language portion or the WXSS file, whether an occupied space of the static resource file is greater than a preset threshold; if the occupied space of the static resource file is larger than the preset threshold value, the static resource file is copied to an outlet file address in the compiling parameter configuration information in parallel, and a hash value is added in the file name of the static resource file; and if the occupied space of the static resource file is smaller than or equal to the preset threshold value, performing BASE64 coding processing on the static resource file.
The individual modules in the component packaging apparatus of the applet described above may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 8. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing data such as applet component development related data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a method for packaging components of an applet.
In one embodiment, a computer device is provided, which may be a terminal, and the internal structure thereof may be as shown in fig. 9. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless mode can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program, when executed by a processor, implements a method for packaging components of an applet. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, can also be keys, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by persons skilled in the art that the structures shown in fig. 8 and 9 are merely block diagrams of portions of structures associated with aspects of the application and are not intended to limit the computer apparatus to which aspects of the application may be applied, and that a particular computer apparatus may include more or less components than those shown, or may combine some of the components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or sufficiently authorized by each party.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.

Claims (10)

1. A method of packaging components of an applet, the method comprising:
Determining compiling parameter configuration information according to the acquired component source codes;
based on the compiling parameter configuration information, adjusting a first compiling rule and a second compiling rule; the first compiling rule is used for generating a weback compiling script; the second compiling rule is used for generating a gulp compiling script;
and translating corresponding parts in the component source code by adopting the weback compiling script and the gulp compiling script to obtain a target compiling file corresponding to the component source code.
2. The method of claim 1, wherein the translating the corresponding reference portion in the component source code by using the weback compiling script and the gulp compiling script to obtain the target compiling file corresponding to the component source code includes:
adopting the weback compiling script to abstract and package the dynamic scripting language part referenced in the component source code to obtain a first compiling result;
adopting the gulp compiling script to analyze the structural style language part in the component source code to obtain a second compiling result; the structural style language part comprises a WXML file and a WXSS file;
And integrating the first compiling result and the second compiling result according to the configuration item data in the compiling parameter configuration information to obtain the target compiling file.
3. The method of claim 2, wherein the performing abstract packaging processing on the dynamic scripting language portion referenced in the component source code by using the weback compiling script to obtain a first compiling result includes:
acquiring the JavaScript file and the independent code block referenced in the component source code based on an entry file name in the compiling parameter configuration information;
and carrying out abstract packaging processing and compression processing on the independent code blocks and the JavaScript file in sequence to obtain the first compiling result.
4. The method of claim 3, wherein the sequentially performing abstract packaging processing and compression processing on the independent code blocks and the JavaScript file to obtain the first compiling result comprises:
sequentially carrying out abstract packaging treatment and compression treatment on the independent code blocks to obtain a first target code block;
performing recursion operation on the JavaScript file, positioning each code block in the JavaScript file, and sequentially performing abstract packaging treatment and compression treatment on each code block to obtain a second target code block;
And summarizing the first target code block and the second target code block to obtain the first compiling result.
5. The method according to claim 2, wherein the parsing the structural style language part in the component source code by using the gulp compiling script to obtain a second compiling result includes:
compressing the WXML file to obtain a target WXML file;
calling a corresponding plug-in under the condition that a preprocessing language exists in the WXSS file, and analyzing the WXSS file to obtain a target WXSS file;
and acquiring the second compiling result based on the target WXML file and the target WXSS file.
6. The method according to any one of claims 2 to 5, further comprising:
under the condition that a static resource file exists in the dynamic scripting language part or the WXSS file, determining whether the occupied space of the static resource file is larger than a preset threshold value;
if the occupied space of the static resource file is larger than the preset threshold value, the static resource file is copied to an outlet file address in the compiling parameter configuration information in parallel, and a hash value is added in the file name of the static resource file;
And if the occupied space of the static resource file is smaller than or equal to the preset threshold value, performing BASE64 coding processing on the static resource file.
7. An applet component packaging apparatus, said apparatus comprising:
the compiling parameter obtaining module is used for determining compiling parameter configuration information according to the obtained component source codes;
the compiling rule determining module is used for adjusting the first compiling rule and the second compiling rule based on the compiling parameter configuration information; the first compiling rule is used for generating a weback compiling script; the second compiling rule is used for generating a gulp compiling script;
and the target file output module is used for translating corresponding parts in the component source codes by adopting the weback compiling script and the gulp compiling script to obtain target compiling files corresponding to the component source codes.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
CN202310658583.6A 2023-06-05 2023-06-05 Method, apparatus, device, medium and program product for packaging components of applet Pending CN116974567A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310658583.6A CN116974567A (en) 2023-06-05 2023-06-05 Method, apparatus, device, medium and program product for packaging components of applet

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310658583.6A CN116974567A (en) 2023-06-05 2023-06-05 Method, apparatus, device, medium and program product for packaging components of applet

Publications (1)

Publication Number Publication Date
CN116974567A true CN116974567A (en) 2023-10-31

Family

ID=88470232

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310658583.6A Pending CN116974567A (en) 2023-06-05 2023-06-05 Method, apparatus, device, medium and program product for packaging components of applet

Country Status (1)

Country Link
CN (1) CN116974567A (en)

Similar Documents

Publication Publication Date Title
WO2020253061A1 (en) Page generating method and apparatus, computer device, and storage medium
CN111061475B (en) Software code generating method, device, computer equipment and storage medium
CN112765023B (en) Test case generation method and device
CN112988284B (en) Application program starting method and device, computer equipment and storage medium
CN110231994B (en) Memory analysis method, memory analysis device and computer readable storage medium
CN110895471A (en) Installation package generation method, device, medium and electronic equipment
CN111666497A (en) Application program loading method and device, electronic equipment and readable storage medium
CN111722873A (en) Code reconstruction method, device, equipment and medium
CN110955434B (en) Software development kit processing method and device, computer equipment and storage medium
CN111400170A (en) Data permission testing method and device
CN112667246A (en) Application function extension method and device and electronic equipment
CN116954680A (en) Plug-in updating method, device, equipment, medium and program product of storage system
CN114780497B (en) Batch file processing method, apparatus, computer device, medium, and program product
CN116974567A (en) Method, apparatus, device, medium and program product for packaging components of applet
CN109002710B (en) Detection method, detection device and computer readable storage medium
CN115130002A (en) Recommendation request processing method and device, computer equipment and storage medium
CN115221852A (en) Vxe-table based dynamic calculation table implementation method, device and computer equipment
CN114329152A (en) Application program generation method, device, equipment and medium based on browser engine
US20120204159A1 (en) Methods and System for Managing Assets in Programming Code Translation
CN113377376A (en) Data packet generation method, data packet generation device, electronic device, and storage medium
CN115202673A (en) Application construction method and device based on cloud server and computer equipment
RU2595763C2 (en) Method and apparatus for managing load on basis of android browser
CN111399846B (en) Android mobile phone application program capacity monitoring method and device
CN115129300A (en) Application development method, apparatus, device, medium, and program product
CN114053719A (en) Resource storage and reading method and device, computer equipment and storage medium

Legal Events

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