A method, device and electronic device for packaging target application

By dividing the target view files and registering components, the problem of redundant loading of component resources and consumption of development resources in the prior art is solved, and faster loading speed and higher development efficiency are achieved.

CN114443053BActive Publication Date: 2025-03-28HANYUN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210088672.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-25
Publication Date
2025-03-28
Estimated Expiration
2042-01-25

AI Technical Summary

Technical Problem

In the prior art, applications load all components when loading, resulting in redundant loading of component resources, reducing loading speed, and developers need to write a lot of boilerplate code, resulting in resource consumption.

Method used

By dividing the target application into the target view files and obtaining the storage path information of the configuration files of the required components from the component directory based on the component call information of each target view file, the individual registration of the required components of each target view file is realized, and the components used are loaded only when the target view is loaded.

Benefits of technology

It improves loading speed, reduces resource consumption of registered components, improves development efficiency, and facilitates subsequent development modification and reconstruction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114443053B_ABST
    Figure CN114443053B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, electronic device and storage medium for packaging a target application. The packaging method includes: obtaining at least one target view file in the target application; for the component name of any target component required by any target view file, searching for the storage path information of the component configuration file of the target component from the component directory, and writing the storage path information of the target component configuration file of the target component to the location information of the component name of the target component in the target view file, so as to complete the registration of the target component in the target view file; based on each of the target view files that have completed the registration of the component, the target application is packaged. The present application can perform separate registration of the components required for each target view file, and can only load the used components when the target view is loaded, which can improve the loading speed and reduce the resource consumption of the registered components.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of program development technology, and in particular to a packaging method, device, electronic device and storage medium for a target application. Background Art

[0002] With the development and popularization of Internet information technology, more and more applications that affect and change people's lives are being developed. However, in the process of front-end development of the application, after completing the construction of the front-end framework of the application, a large number of components are needed to support the various functions of the application development framework.

[0003] In the prior art, developers or programmers are required to register all components used in the developed application. The traditional registration method is to first globally register all functional components required by the application, and then build the interface framework of the application after the global registration is completed. This results in that after the construction is completed, when the background program is loaded for the first time, all components in the application will be loaded, but some components do not need to be used in the current interface. Therefore, redundant loading of component resources is caused, which reduces the loading speed. In addition, when registering components, developers need to write a lot of boilerplate code, resulting in resource consumption. Summary of the invention

[0004] In view of this, the purpose of the present application is to provide a method, device, electronic device and storage medium for packaging a target application, which can separately register the components required for each target view file, and only load the used components when the target view is loaded, thereby improving the loading speed and reducing the resource consumption of registered components.

[0005] The present application embodiment provides a method for packaging a target application, the method comprising:

[0006] Obtain a component directory of components required by a target application, at least one target view file, and a preset call information parsing rule;

[0007] For any of the target view files, the target view file is parsed according to the preset call information parsing rule to obtain component call information of the components required by the target view file; the component call information includes the component name of each component and the location information of each component name;

[0008] For the component name of any target component required by any of the target view files, searching for storage path information of the component configuration file of the target component from the component directory, and writing the storage path information of the target component configuration file of the target component into the location information of the component name of the target component in the target view file, so as to complete the registration of the target component in the target view file;

[0009] The target application is packaged based on the target view files that complete the registration of the components.

[0010] Furthermore, according to the packaging method of claim 1, it is characterized in that, for any of the target view files, parsing the target view file according to the preset call information parsing rule to obtain component call information of the component required by the target view file includes:

[0011] For any target view file, convert the format of the target view file according to the format conversion rule in the preset call information parsing rule to obtain a target format file corresponding to the converted target view file;

[0012] For any of the target format files, determining whether there is preset file processing completion information in any of the target format files;

[0013] If there is no preset file processing completion information in any of the target format files, the component calling information of any of the target format files is screened according to the preset calling rule formula in the preset calling information parsing rule to obtain the component calling information of the component required by the target view file.

[0014] Furthermore, after determining whether there is preset file processing completion information in any of the target format files, the packaging method further includes:

[0015] If there is preset file processing completion information in any of the target format files, the parsing of the target view file corresponding to the target format file is terminated.

[0016] Furthermore, for the component name of any target component required by any target view file, searching the storage path information of the target component configuration file of the target component from the component directory includes:

[0017] For a component name of any target component required by any target view file, determine whether there is a component name matching the component name of any target component in the component directory;

[0018] If so, determining that the storage path information of the component configuration file of the component in the component directory is the storage path information of the target component configuration file of the target component;

[0019] If it does not exist, update the component directory of the component of the target application, and search for the storage path information of the target component configuration file of the target component from the updated component directory; the updated component directory includes the storage path information of the target component configuration file of the target component.

[0020] Furthermore, for the component name of any target component required by any target view file, determining whether there is a component name of a component matching the component name of any target component in the component directory includes:

[0021] Convert the component name of the component in the component directory and the component name of any target component required by any target view file into a preset format respectively, to generate a standard component name of the component in the component directory and a standard target component name of any target component required by any target view file;

[0022] For the standard target component name of any target component required by any of the target view files, it is determined whether there is a standard component name of a component matching the standard target component name of any target component in the component directory.

[0023] Furthermore, before packaging the target application based on each of the target view files that have completed the registration of the component, the packaging method further includes:

[0024] Adding preset file processing completion information at the first designated position of the target view file for completing component registration; the preset file processing completion information is used to indicate that the target view file has completed component registration;

[0025] Add file introduction information at a second designated position of the target view file for completing component registration; the file introduction information includes a standard component name of the component in the component directory.

[0026] The present application also provides a packaging device for a target application, the packaging device comprising:

[0027] Furthermore, the parsing module is specifically used for:

[0028] For any target view file, convert the format of the target view file according to the format conversion rule in the preset call information parsing rule to obtain a target format file corresponding to the converted target view file;

[0029] For any of the target format files, determining whether there is preset file processing completion information in any of the target format files;

[0030] If the preset file processing completion information does not exist in any of the target format files, the component calling information of any of the target format files is screened according to the preset calling rule formula in the preset calling information parsing rule to obtain the component calling information of the component required by the target view file; the calling rule formula is used to characterize the regular expression of the component calling information.

[0031] An embodiment of the present application also provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the packaging method described above are performed.

[0032] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the packaging method as described above are executed.

[0033] Compared with the prior art, the packaging method, device, electronic device and storage medium provided in the embodiments of the present application can realize separate registration of components required for each target view file by first dividing the target view files of the target application, and obtaining the storage path information of the target component configuration file required for the target view file from the configured component directory according to the component call information of any target view file. When the target view is loaded, only the used components can be loaded, which can improve the loading speed and reduce the resource consumption of the registered components. While improving the development efficiency, it is convenient for subsequent development modification and reconstruction.

[0034] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0036] Figure 1 A flowchart of a method for packaging a target application provided by an embodiment of the present application is shown;

[0037] Figure 2 A flowchart showing another method for packaging a target application provided in an embodiment of the present application is shown;

[0038] Figure 3 A schematic diagram of the structure of a packaging device for a target application provided in an embodiment of the present application is shown;

[0039] Figure 4 A schematic diagram of the structure of another target application packaging device provided in an embodiment of the present application is shown;

[0040] Figure 5 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown.

[0041] In the figure:

[0042] 300 - packaging device; 310 - acquisition module; 320 - parsing module; 330 - search module; 340 - packaging module; 350 - first adding module; 360 - second adding module; 500 - electronic device; 510 - processor; 520 - memory; 530 - bus. DETAILED DESCRIPTION

[0043] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, each other embodiment obtained by those skilled in the art without making creative work belongs to the scope of protection of the present application.

[0044] First, the application scenarios applicable to this application are introduced. After research, it is found that in the prior art, developers or programmers are required to register all components used in the developed application. The traditional registration method is to first globally register all functional components required by the application, and then build the interface framework of the application after the global registration is completed. This results in the background program loading all components in the application when it is loaded for the first time after the construction is completed, but some components do not need to be used in the current interface, thus causing redundant loading of component resources, reducing the loading speed, and developers need to write a lot of boilerplate code when registering components, resulting in resource consumption.

[0045] Based on this, the embodiments of the present application provide a method, device, electronic device and storage medium for a target application, which avoids redundant loading of component resources, increases loading speed, and further improves the user experience.

[0046] See also Figure 1 , Figure 1 The flowchart of a method for packaging a target application provided by an embodiment of the present application is as follows. Figure 1 As shown in the figure, the target application packaging method provided by the embodiment of the present application includes the following steps:

[0047] S101, obtaining a component directory of components required by a target application, at least one target view file, and preset call information parsing rules.

[0048] In this step, when developing the target application, it is first necessary to determine the functional positioning of the target application. On this basis, based on a static module packaging tool, such as webpack, the front-end architecture of the target application is built, at least one target view file of the target application is compiled according to the front-end architecture of the target application, and a component directory of the required components is configured for the target view file, and a preset call information parsing rule is set for any target view file.

[0049] Here, the embodiment provided by the present application is equivalent to inserting a plug-in into the original webpack, and then passing the configured component directory into the plug-in, and the preset call information parsing rule is to insert a new rule into the construction rule in the original webpack, forming a compilation selection component rule for the component in any target view file, and the preset call information parsing rule is used to encode and parse each target view file; the target view file (vue file) is a progressive scripting language (javascript) framework; the component of the target view file is a reusable target view file instance, that is, the target view file can be understood as an interface file displayed in the form of an interface in the target application.

[0050] Here, the registration of the required components in any target view file can be understood as storing the storage path information of the component configuration file of the target component required by the target view file in the target application from the component directory to the target component after building the interface framework of the target application. The process of obtaining and storing is equivalent to the component registration process, and the component reference refers to the process of marking the component standard component name of the target component required by the target view file in the component directory to the specified location of the target view file.

[0051] Among them, the preset call information parsing rules provided in this application include but are not limited to the specific coding expressions:

[0052] {include:[ / \.vue$ / , / \.vue\? vue / ],enforce:”post”,use:[loader:LOADER]; Among them, include is a computer professional term. One refers to the header file command included in the programming language, which is used to embed the specified header file into the source file; the other refers to the include instruction, which includes a static file in the programming language and parses the JavaServer Pages (JSP) statements in this file.

[0053] The construction rules in webpack provided in this application include but are not limited to the specific coding expressions:

[0054] compiler.options.module.rules;

[0055] A plug-in is a program written in accordance with a certain standard target application program interface. It can only run on the system platform specified by the target application (it may support multiple platforms at the same time) and cannot run independently from the specified platform. Because the plug-in needs to call the function library or data provided by the original pure system, many application software have plug-ins, and there are countless types of plug-ins. For example, in IE, after installing the relevant plug-in, the WEB browser can directly call the plug-in program to process specific types of files.

[0056] webpack is a static module packaging tool for modern scripting language (JavaScript, JS) applications. When webpack processes an application, it builds a dependency graph internally from one or more entry points, and then combines each module required in your project into one or more bundles, which are static resources for displaying your content; Among them, JS is a lightweight, interpreted or just-in-time compiled programming language with function priority. Although it is famous as a scripting language for developing web pages, it is also used in many non-browser environments. JS is a dynamic scripting language based on prototype programming and multiple paradigms, and supports object-oriented, imperative, declarative, and functional programming paradigms; dependency graph is a graphical representation of a program, which is a directed multigraph with labels. The program dependency graph can represent the control dependency and data dependency of the program; bundles are executable files.

[0057] S102. For any of the target view files, parse the target view file according to the preset call information parsing rule to obtain component call information of the components required by the target view file; the component call information includes the component name of each component and the location information of each component name.

[0058] In this step, for each target view file in the target application, the preset call information parsing rules will parse the target view file, obtain the component call information of the components required by the target view file, and generate a component call list corresponding to the target view file based on the component information of all required components.

[0059] Here, the component calling information and the component calling list include the component name of each component and the location information of each component name. The location information of each component name includes but is not limited to the starting position information of each component name string and the ending position information of each component name string in the code parsed from the target view file.

[0060] S103. For the component name of any target component required by any of the target view files, search for the storage path information of the component configuration file of the target component from the component directory, and write the storage path information of the target component configuration file of the target component into the location information of the component name of the target component in the target view file, so as to complete the registration of the target component in the target view file.

[0061] In this step, based on the component name of any target component in any target view file, the storage path information of the component configuration file of the target component is searched from the configured component directory, and based on the name string starting position information and the name string ending position information in the component name position information, the storage path information of the target component configuration file is written into any target component in any target view file, and then the other target components except the above target components in the component call list in any target view file are searched in the component directory in turn to complete the registration of the searched target components, thereby completing the registration of the target view file.

[0062] Preferably, for the component name of any target component required by any target view file, searching the storage path information of the target component configuration file of the target component from the component directory includes:

[0063] For the component name of any target component required by any target view file, it is determined whether there is a component name of a component matching the component name of any target component in the component directory.

[0064] Here, the component names of the components in the component directory and the component names of any target components required by any target view file are converted into preset formats respectively to generate standard component names of the components in the component directory and the standard target component names of any target components required by any target view file.

[0065] Here, when the component name of the component in the component directory and the component name of any target component required by any target view file are converted to a preset format, the specific format of the preset format conversion includes but is not limited to: converting the parsed code of the component name of the component and the component name of any target component required by any target view file into camelCase format.

[0066] For the standard target component name of any target component required by any of the target view files, it is determined whether there is a standard component name of a component matching the standard target component name of any target component in the component directory.

[0067] Here, after conversion to the camelCase preset format is performed, it is determined whether there is a component standard component name code matching the standard target component name code of any target component in the component directory, that is, whether the two contain the same camelCase preset format string.

[0068] If so, it is determined that the storage path information of the component configuration file of the component in the component directory is the storage path information of the target component configuration file of the target component.

[0069] Here, if there is a string in the component directory that is the same as the camelCase preset format string of the standard target component name of any target component, then the storage path information of the component configuration file of the component in the component directory is determined to be the storage path information of the target component configuration file of the target component.

[0070] If it does not exist, update the component directory of the component of the target application, and search for the storage path information of the target component configuration file of the target component from the updated component directory; the updated component directory includes the storage path information of the target component configuration file of the target component.

[0071] Here, if it does not exist, there are two situations. One is that the component required by the target application in the component directory is configured incorrectly. At this time, you can re-update the storage path of the configuration file of the component in the component directory; the other is that the target view file is parsed according to the preset call information parsing rules, and the component call information of the component is found to be incorrect. Re-parse the target view file to see if the problem can be solved.

[0072] S104: Packaging the target application based on the target view files that have completed component registration.

[0073] In this step, after completing the registration of the required components of any target view file in the target application, continue to complete the registration of the required components of all target view files in the target application according to the preset development framework, and then package the target application for release.

[0074] Here, the publishing place has various types of Internet platforms, which can be mobile terminals or computers, and there are no special limitations. The specific published application scenarios need to be determined and selected by developers or programmers based on the actual development needs.

[0075] Preferably, before packaging the target application based on each of the target view files that have completed component registration, the packaging method further includes:

[0076] Add preset file processing completion information at the first designated position of the target view file that completes the component registration; the preset file processing completion information is used to indicate that the target view file has completed the component registration.

[0077] Here, after all components in the component call list for any target view file have been registered, preset file processing completion information is added to the first specified position of the target view file; wherein the first specified position is the position specified by the developer or programmer in the code of the target view file.

[0078] In this way, the first designated position includes but is not limited to the head or tail of the code of the target view file.

[0079] At the same time, the encoding of the preset file processing completion information is a character string specially set by the developer or programmer, including but not limited to: " / / already auto import component by hy-vue-auto-import".

[0080] Add file introduction information at a second designated position of the target view file for completing component registration; the file introduction information includes a standard component name of the component in the component directory.

[0081] Here, after all components in the component call list of any target view file have been registered, file import information is added at the second specified position of the target view file, so that the storage path information of the component in the component directory is referenced to the target component required by the target view file, thereby realizing the reference of the component.

[0082] The import information includes but is not limited to: importhy_auto_import_+name from “component directory+standard component name”.

[0083] A specific embodiment for component configuration is given below, including the following steps:

[0084] Developers introduce the plug-in developed by this technology into the webpack configuration file, register the plug-in and pass the component directory of the component to the plug-in.

[0085] Start webpack to build the target application's skeleton.

[0086] The plug-in is used to insert the preset call information parsing rules into the framework construction rules of webpack, and the format of the target view file is converted according to the format conversion rules in the preset call information parsing rules to obtain the target format file corresponding to the converted target view file.

[0087] For any target format file, it is determined whether there is preset file processing completion information in any target format file.

[0088] If the preset file processing completion information does not exist in any target format file, the target application is parsed according to the regular expression in the preset call information parsing rule: " / _c\([\s\n\t]*['"](.+?)["']([,)]) / g", the component call information of the target view file is determined, and a component call list is generated.

[0089] The component names of the components in the component directory and the component names of any target components required by any target view file involved in the call information are converted into camelCase format according to preset formats, and the standard component names of the components in the component directory and the standard target component names in camelCase format of any target component required by any target view file are generated.

[0090] For any standard target component name in camelCase format required by any of the target view files, it is determined whether there is a standard component name of a component matching the standard target component name in camelCase format in the component directory.

[0091] If the component name of the target component is not included in the component call list, preset file processing completion information is added to the target view file.

[0092] If the component name of the target component is included in the component call list, the storage path information of the target component configuration file of the target component is written into the location information of the component name of the target component in the target view file "_c(+_hy_auto_import_+name)" according to the start, end, and name in the component call information.

[0093] The component call list is traversed to determine all target components of the target view file, and the registration of the target components is completed.

[0094] Add preset file processing completion information at the first designated position of the above-mentioned target view file, and add file import information at the second designated position of the above-mentioned target view file, wherein the file import information includes the standard component name of the component in the component directory, i.e., "component directory + standard component name".

[0095] Compared with the prior art, the packaging method provided in the embodiment of the present application can realize separate registration of components required for each target view file by first dividing the target view files of the target application, and obtaining the storage path information of the target component configuration file required for the target view file from the configured component directory according to the component call information of any target view file. When the target view is loaded, only the used components can be loaded, which can improve the loading speed and reduce the resource consumption of the registered components. While improving the development efficiency, it is convenient for subsequent development modification and reconstruction.

[0096] See also Figure 2 , Figure 2 FIG. 1 is a flowchart of a method for packaging a target application provided by another embodiment of the present application. Figure 2 As shown in , the packaging method of the standard application program provided in the embodiment of the present application includes the following steps:

[0097] S201, obtaining a component directory of components required by a target application, at least one target view file, and preset call information parsing rules.

[0098] S202: For any target view file, perform format conversion on the target view file according to the format conversion rule in the preset call information parsing rule to obtain a target format file corresponding to the converted target view file.

[0099] In this step, for any target view file, the target view file is format-converted according to the format conversion rules in the preset call information parsing rules to obtain a target format file having the same format as the preset file processing completion information.

[0100] S203: For any of the target format files, determine whether there is preset file processing completion information in any of the target format files.

[0101] In this step, the preset file processing completion information includes but is not limited to: " / / already auto importcomponent by hy-vue-auto-import".

[0102] Here, the preset file processing completion information is used to indicate that the target view file has completed component registration, thereby avoiding multiple processing of the target view file, resulting in waste of performance, parsing errors, etc.

[0103] S204. If there is no preset file processing completion information in any of the target format files, the component calling information of any of the target format files is screened according to the preset calling rule formula in the preset calling information parsing rule to obtain the component calling information of the components required by the target view file; the component calling information includes the component name of each component and the location information of each component name.

[0104] In this step, if there is no preset file processing completion information in any of the target format files, it means that the required component in the target view file corresponding to the target format file has not been processed. At this time, the component call information of any of the target format files is screened according to the preset call rule formula in the preset call information parsing rule to obtain the component call information of the component required by the target view file.

[0105] Here, the preset call information parsing rules include but are not limited to the use of regular expressions, and the component call information is obtained in a specific manner by calling an application programming interface (API) in the code of the target format file.

[0106] Among them, regular expression, also known as regular expression, is a logical formula for string operations in the code, that is, using some pre-defined specific characters and the combination of these specific characters to form a "regular string", which is used to express a filtering logic for the string.

[0107] Thus, the regular expression includes but is not limited to: " / _c\([\s\n\t]*['"](.+?)["']([,)]) / g".

[0108] Preferably, if there is preset file processing completion information in any of the target format files, parsing of the target view file corresponding to the target format file is terminated.

[0109] Here, if there is preset file processing completion information in any of the target format files, it means that the target component required in the target view file corresponding to the target format file has been registered and processed, and there is no need to repeatedly parse, register and reference the target component.

[0110] S205. For the component name of any target component required by any of the target view files, search for the storage path information of the component configuration file of the target component from the component directory, and write the storage path information of the target component configuration file of the target component into the location information of the component name of the target component in the target view file, so as to complete the registration of the target component in the target view file.

[0111] S206: Packaging the target application based on the target view files that have completed component registration.

[0112] Among them, the description of S201 and S205 to S206 can refer to the description of S101 and S103 to S104, and can achieve the same technical effect, which is not repeated here.

[0113] The target application packaging method provided in the embodiment of the present application, compared with the prior art, can realize separate registration of components required for each target view file by first dividing the target application into target view files, and obtaining the storage path information of the target component configuration file required for the target view file from the configured component directory according to the component call information of any target view file. When the target view is loaded, only the used components can be loaded, which can improve the loading speed and reduce the resource consumption of the registered components. While improving the development efficiency, it is convenient for subsequent development modification and reconstruction.

[0114] See also Figure 3 , Figure 4 , Figure 3 A schematic diagram of a target application program packaging device provided in an embodiment of the present application is shown in FIG. Figure 4 This is a schematic diagram of the structure of another target application packaging device provided in an embodiment of the present application. Figure 3 As shown in , the packaging device 300 includes:

[0115] The acquisition module 310 is used to acquire a component directory of components required by the target application, at least one target view file, and a preset call information parsing rule.

[0116] The parsing module 320 is used to parse any of the target view files according to the preset call information parsing rules to obtain component call information of the components required by the target view file; the component call information includes the component name of each component and the location information of each component name.

[0117] Preferably, the parsing module 320 is specifically used for:

[0118] For any target view file, the target view file is format converted according to the format conversion rule in the preset call information parsing rule to obtain a target format file corresponding to the converted target view file.

[0119] For any of the target format files, it is determined whether there is preset file processing completion information in any of the target format files.

[0120] If there is no preset file processing completion information in any of the target format files, the component calling information of any of the target format files is screened according to the preset calling rule formula in the preset calling information parsing rule to obtain the component calling information of the component required by the target view file.

[0121] Preferably, after determining whether there is preset file processing completion information in any of the target format files, the packaging method further includes:

[0122] If there is preset file processing completion information in any of the target format files, the parsing of the target view file corresponding to the target format file is terminated.

[0123] The search module 330 is used to search for the storage path information of the component configuration file of any target component required by any of the target view files from the component directory, and write the storage path information of the component configuration file of the target component into the location information of the component name of the target component in the target view file, so as to complete the collection of the target components in the target view file.

[0124] The packaging module 340 is used to package the target application based on the target view files collected by the completed components.

[0125] The target application packaging device 300 provided in the embodiment of the present application, compared with the prior art, can realize separate registration of components required for each target view file by first dividing the target application into target view files, and obtaining the storage path information of the target component configuration file required for the target view file from the configured component directory according to the component call information of any target view file. When the target view is loaded, only the used components can be loaded, which can improve the loading speed and reduce the resource consumption of the registered components. While improving the development efficiency, it is convenient for subsequent development modification and reconstruction.

[0126] Further, such as Figure 4 As shown, the packaging device 300 includes:

[0127] The acquisition module 310 is used to acquire a component directory of components required by the target application, at least one target view file, and a preset call information parsing rule.

[0128] The parsing module 320 is used to parse any of the target view files according to the preset call information parsing rules to obtain component call information of the components required by the target view file; the component call information includes the component name of each component and the location information of each component name.

[0129] The search module 330 is used to search for the storage path information of the component configuration file of any target component required by any of the target view files from the component directory, and write the storage path information of the component configuration file of the target component into the location information of the component name of the target component in the target view file, so as to complete the collection of the target components in the target view file.

[0130] Preferably, the search module 330 is specifically used for:

[0131] For the component name of any target component required by any target view file, it is determined whether there is a component name of a component matching the component name of any target component in the component directory.

[0132] Preferably, for the component name of any target component required by any target view file, judging whether there is a component name of a component matching the component name of any target component in the component directory includes:

[0133] The component names of the components in the component directory and the component names of any target components required by any target view file are converted into preset formats respectively to generate standard component names of the components in the component directory and the standard target component names of any target components required by any target view file.

[0134] For the standard target component name of any target component required by any of the target view files, it is determined whether there is a standard component name of a component matching the standard target component name of any target component in the component directory.

[0135] If so, it is determined that the storage path information of the component configuration file of the component in the component directory is the storage path information of the target component configuration file of the target component.

[0136] If it does not exist, update the component directory of the component of the target application, and search for the storage path information of the target component configuration file of the target component from the updated component directory; the updated component directory includes the storage path information of the target component configuration file of the target component.

[0137] The packaging module 340 is used to package the target application based on the target view files collected by the completed components.

[0138] Preferably, the packaging device 300 further includes:

[0139] The first adding module 350 is used to add preset file processing completion information at the first designated position of the target view file that completes the component registration; the preset file processing completion information is used to indicate that the target view file has completed the component registration.

[0140] The second adding module 360 ​​is used to add file import information at a second designated position of the target view file after completing the registration of the component; the file import information includes a standard component name of the component in the component directory.

[0141] The target application packaging device 300 provided in the embodiment of the present application, compared with the prior art, can realize separate registration of components required for each target view file by first dividing the target application into target view files, and obtaining the storage path information of the target component configuration file required for the target view file from the configured component directory according to the component call information of any target view file. When the target view is loaded, only the used components can be loaded, which can improve the loading speed and reduce the resource consumption of the registered components. While improving the development efficiency, it is convenient for subsequent development modification and reconstruction.

[0142] See also Figure 5, Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 5 As shown in , the electronic device 500 includes a processor 510 , a memory 520 and a bus 530 .

[0143] The memory 520 stores machine-readable instructions executable by the processor 510. When the electronic device 500 is running, the processor 510 communicates with the memory 520 via the bus 530. When the machine-readable instructions are executed by the processor 510, the above-mentioned Figure 1 as well as Figure 2 The specific implementation of the steps of the packaging method in the method embodiment shown can be found in the method embodiment, and will not be repeated here.

[0144] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the computer program can execute the above-mentioned Figure 1 as well as Figure 2 The specific implementation of the steps of the packaging method in the method embodiment shown can be found in the method embodiment, and will not be repeated here.

[0145] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0146] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0147] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0148] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0149] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0150] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A method for packaging a target application, characterized in that: The packaging method comprises: Obtain a component directory of components required by a target application, at least one target view file, and a preset call information parsing rule; For any of the target view files, the target view file is parsed according to the preset call information parsing rule to obtain component call information of the components required by the target view file; the component call information includes the component name of each component and the position information of each component name; the position information of each component name includes the starting position information of each component name string and the ending position information of each component name string in the code after the target view file is parsed; For the component name of any target component required by any of the target view files, searching for storage path information of the component configuration file of the target component from the component directory, and writing the storage path information of the target component configuration file of the target component into the location information of the component name of the target component in the target view file, so as to complete the registration of the target component in the target view file; The target application is packaged based on the target view files that complete the registration of the components.

2. The packaging method according to claim 1, characterized in that: The step of parsing any of the target view files according to the preset call information parsing rule to obtain component call information of the components required by the target view file includes: For any target view file, convert the format of the target view file according to the format conversion rule in the preset call information parsing rule to obtain a target format file corresponding to the converted target view file; For any of the target format files, determining whether there is preset file processing completion information in any of the target format files; If there is no preset file processing completion information in any of the target format files, the component calling information of any of the target format files is screened according to the preset calling rule formula in the preset calling information parsing rule to obtain the component calling information of the component required by the target view file.

3. The packaging method according to claim 2, characterized in that: After determining whether there is preset file processing completion information in any of the target format files, the packaging method further includes: If there is preset file processing completion information in any of the target format files, the parsing of the target view file corresponding to the target format file is terminated.

4. The packaging method according to claim 1, characterized in that: The component name of any target component required by any target view file, searching the storage path information of the target component configuration file of the target component from the component directory, includes: For a component name of any target component required by any target view file, determine whether there is a component name matching the component name of any target component in the component directory; If so, determining that the storage path information of the component configuration file of the component in the component directory is the storage path information of the target component configuration file of the target component; If it does not exist, update the component directory of the component of the target application, and search for the storage path information of the target component configuration file of the target component from the updated component directory; the updated component directory includes the storage path information of the target component configuration file of the target component.

5. The packaging method according to claim 4, characterized in that: For the component name of any target component required by any target view file, judging whether there is a component name matching the component name of any target component in the component directory includes: Convert the component name of the component in the component directory and the component name of any target component required by any target view file into a preset format respectively, to generate a standard component name of the component in the component directory and a standard target component name of any target component required by any target view file; For the standard target component name of any target component required by any of the target view files, it is determined whether there is a standard component name of a component matching the standard target component name of any target component in the component directory.

6. The packaging method according to claim 5, characterized in that: Before packaging the target application based on each of the target view files that complete the registration of the component, the packaging method further includes: Adding preset file processing completion information at the first designated position of the target view file for completing component registration; the preset file processing completion information is used to indicate that the target view file has completed component registration; Add file introduction information at a second designated position of the target view file for completing component registration; the file introduction information includes a standard component name of the component in the component directory.

7. A packaging device for a target application, characterized in that: The packaging device comprises: An acquisition module, used to acquire a component directory of components required by a target application, at least one target view file, and a preset call information parsing rule; A parsing module, for parsing any of the target view files according to the preset call information parsing rules to obtain component call information of the components required by the target view file; the component call information includes the component name of each component and the position information of each component name; the position information of each component name includes the starting position information of each component name string and the ending position information of each component name string in the code after the target view file is parsed; A search module is used to search for storage path information of a component configuration file of any target component required by any target view file from the component directory, and write the storage path information of the component configuration file of the target component to the location information of the component name of the target component in the target view file, so as to complete the collection of the target component in the target view file; The packaging module is used to package the target application based on the target view files collected by the completed components.

8. The packaging device according to claim 7, characterized in that: The analysis module is specifically used for: For any target view file, convert the format of the target view file according to the format conversion rule in the preset call information parsing rule to obtain a target format file corresponding to the converted target view file; For any of the target format files, determining whether there is preset file processing completion information in any of the target format files; If there is no preset file processing completion information in any of the target format files, screening the component calling information of any of the target format files according to the preset calling rule formula in the preset calling information parsing rule to obtain the component calling information of the component required by the target view file; The calling rule formula is used to represent the regular expression of the calling information of the component.

9. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of the packaging method as described in any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the packaging method according to any one of claims 1 to 6 are executed.

Citation Information

Patent Citations

  • Application generation method and device based on Android system and storage medium

    CN112925562A

  • Project packaging method and device and computer equipment

    CN113312109A