Description file compression method, device and equipment generated based on Protobuf.js and storage medium
By using Protobuf.js to generate description files and perform on-demand compression in project development, the problem of untraceable data and excessive redundant data in the prior art is solved, and the applicability and bandwidth consumption of small and medium-sized projects are reduced.
Patent Information
- Application Number
- CN202411845312.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-03-28
AI Technical Summary
The construction results and differences of the description data generated by the prior art in project development are untraceable, and the redundant structure data generated are too much, resulting in file volume expansion, making it difficult to apply to small and medium-sized projects.
By obtaining the resource configuration and compression configuration of the target project, filter out the target proto file and call Protobuf.js to generate the first json description file, obtain the specified RPC function name and description structure name according to the compressed configuration, obtain the structure data from the first json description file, write the file to write a write stream to generate the second json description file, realize on-demand compression of the description file.
It realizes on-demand compression of description files, reduces user bandwidth consumption, is suitable for large and medium-sized projects, and reduces the volume of applications and the power consumption of data transmission.
Smart Images

Figure CN119719055A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data compression, and in particular to a description file compression method, device, equipment and storage medium generated based on Protobuf.js. Background Art
[0002] Protocol Buffers (Protobuf for short) is a multi-language, cross-platform, and extensible mechanism for serializing structured data formats. Protobuf.js is a Protobuf library implemented in pure JavaScript, which can help the front end communicate with the RPC (Remote Procedure Call) server through the protobuf format. It is implemented based on Google's Protocol Buffers protocol specification. Compared with traditional XML and JSON, the advantages of Protocol Buffers are mainly: smaller and faster. The use of Protobuf.js can improve the user experience of the application and reduce the user's traffic consumption. In IM (Instant Messaging) applications, the basic method to optimize excessive data traffic consumption is to use a highly compressed communication protocol, and the natural result of reduced traffic after data compression is power saving, because the transmission of large amounts of data will inevitably require longer network operations, data serialization and deserialization operations, which are the root causes of excessive power consumption. It can be seen that the data transmission rate and the size of the application have a great impact on users.
[0003] At present, in project development, proto files and related protocol parameters are usually generated based on project resources, description data is generated through Protobuf.js and related parameters, and the description data is written into a json file. However, the construction results and differences of this solution cannot be tracked, and too much redundant structure data is generated. With the iteration of business, the volume expands greatly, so it is only suitable for large projects. Summary of the invention
[0004] The present invention provides a description file compression method, device, equipment and storage medium generated based on Protobuf.js, which are used to compress the description file on demand and reduce the consumption of user bandwidth.
[0005] The present invention provides a description file compression method generated based on Protobuf.js, comprising:
[0006] Get the target resource configuration and target compression configuration of the target project;
[0007] According to the target resource configuration, filter out the target proto file from the proto file of the target project;
[0008] Call Protobuf.js to generate a first json description file according to the target proto file;
[0009] Create a file writable stream, and obtain a specified RPC function name and a specified description structure name from a project file of the target project according to the target compression configuration;
[0010] According to the specified RPC function name and the specified description structure name, obtain corresponding structure data from the first json description file;
[0011] The specified RPC function name, the specified description structure name and the structure data are written into the file writable stream to generate a second json description file, and the second json description file is determined as a target compressed file.
[0012] According to a description file compression method generated based on Protobuf.js provided by the present invention, after writing the specified RPC function name, the specified description structure name and the structure data into the file writable stream to generate a second json description file, and determining the second json description file as a target compressed file, the method further includes:
[0013] End the file writable stream and delete the first json description file.
[0014] According to a description file compression method generated based on Protobuf.js provided by the present invention, after calling Protobuf.js to generate a first json description file according to the target proto file, the method further includes:
[0015] Query whether there is a third json description file according to the compressed file address of the target project, wherein the third json description file is the compressed file saved last time;
[0016] If yes, read and save the last compressed data of the third JSON description file;
[0017] After acquiring corresponding structure data from the first json description file according to the specified RPC function name and the specified description structure name, the method further includes:
[0018] Performing data difference calculation on the structure data and the last compressed data to obtain a data difference result;
[0019] A difference record file is generated according to the data difference result.
[0020] According to a description file compression method generated based on Protobuf.js provided by the present invention, before calculating the data difference between the structure data and the last compressed data to obtain the data difference result, the method includes:
[0021] Determining whether the last compressed data is complete;
[0022] If yes, executing the step of calculating the data difference between the structure data and the last compressed data to obtain the data difference result;
[0023] If not, the structural data is determined as newly added data, and a difference record file is generated according to the structural data.
[0024] A description file compression method generated based on Protobuf.js provided by the present invention also includes:
[0025] The difference record file is uploaded to the application server to implement incremental update of the application.
[0026] According to a description file compression method generated based on Protobuf.js provided by the present invention, the difference record file includes: a difference data part, file difference information, and update time information.
[0027] According to a description file compression method generated based on Protobuf.js provided by the present invention, after obtaining corresponding structure data from the first json description file according to the specified RPC function name and the specified description structure name, the method includes:
[0028] Check whether the specified RPC function name and the specified description structure name in the structure data are missing;
[0029] If yes, generate and upload error information;
[0030] If not, execute the step of writing the specified RPC function name, the specified description structure name and the structure data into the file writable stream to generate a second json description file, and determine the second json description file as the target compressed file.
[0031] The present invention also provides a description file compression device generated based on Protobuf.js, comprising:
[0032] A first acquisition module is used to acquire a target resource configuration and a target compression configuration of a target project;
[0033] A filtering module, used to filter out a target proto file from the proto file of the target project according to the target resource configuration;
[0034] A first generation module is used to call Protobuf.js to generate a first json description file according to the target proto file;
[0035] A second acquisition module is used to create a file writable stream and acquire a specified RPC function name and a specified description structure name from a project file of the target project according to the target compression configuration;
[0036] A third acquisition module is used to acquire corresponding structure data from the first JSON description file according to the specified RPC function name and the specified description structure name;
[0037] The second generation module is used to write the specified RPC function name, the specified description structure name and the structure data into the file writable stream, generate a second json description file, and determine the second json description file as a target compressed file.
[0038] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the description file compression method generated based on Protobuf.js as described in any one of the above is implemented.
[0039] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the description file compression method generated based on Protobuf.js as described in any one of the above is implemented.
[0040] The present invention provides a description file compression method, device, equipment and storage medium based on Protobuf.js generation, by obtaining the resource configuration and compression configuration of the target project selected by the developer on demand, filtering out the corresponding proto file and calling Protobuf.js to generate a first json description file, obtaining the specified RPC function name and the specified description structure name according to the target compression configuration, obtaining the corresponding structure data from the first json description file, writing the specified RPC function name, the specified description structure name and the structure data into a file writable stream, generating a second json description file, and the second json description file is the description file after the first json description file is compressed. The present invention obtains the corresponding protocol function by scanning the file, thereby realizing on-demand compression of the description file, which can be applied to various large, medium and small projects, and reduces the consumption of user bandwidth. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1 This is one of the flow charts of a description file compression method generated based on Protobuf.js provided by the present invention;
[0043] Figure 2 This is the second flow chart of a description file compression method generated based on Protobuf.js provided by the present invention;
[0044] Figure 3 It is a structural schematic diagram of a description file compression device generated based on Protobuf.js provided by the present invention;
[0045] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] It should be noted that, in the description of the embodiments of the present invention, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "include one..." do not exclude the existence of other identical elements in the process, method, article or device including the elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances.
[0048] The terms "first", "second", etc. in the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" means at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0049] Combine the following Figure 1-Figure 4 The present invention describes a description file compression method, device, equipment and storage medium generated based on Protobuf.js.
[0050] like Figure 1 As shown, the present invention provides a description file compression method generated based on Protobuf.js, which specifically includes the following steps:
[0051] Step 110: Obtain target resource configuration and target compression configuration of the target project.
[0052] Step 120: Filter out a target proto file from the proto files of the target project according to the target resource configuration.
[0053] Specifically, the target project refers to the application development project. When the application development project is updated, the developer can select the resource configuration and compression configuration for this update and enter the node execution command to generate a description file for the updated resource data and compress it. First, filter out the target proto file from all proto files of the target project according to the target resource configuration.
[0054] In some embodiments, after obtaining the target resource configuration and the target compression configuration, it is possible to first verify whether the configuration parameters of the target resource configuration and the target compression configuration are correct. If the configuration parameters are correct, the subsequent compression logic is executed, otherwise the process is terminated and an error is reported.
[0055] Step 130, calling Protobuf.js to generate a first json description file according to the target proto file.
[0056] Specifically, Protobuf.js is called and a first json description file is generated locally according to the target proto file and relevant protocol parameters corresponding to Protobuf.js.
[0057] Step 140: Create a file writable stream, and obtain a specified RPC function name and a specified description structure name from the project file of the target project according to the target compression configuration.
[0058] Step 150: Obtain corresponding structure data from the first JSON description file according to the specified RPC function name and the specified description structure name.
[0059] Step 160, write the specified RPC function name, the specified description structure name and the structure data into the file writable stream to generate a second json description file, and determine the second json description file as the target compressed file.
[0060] Specifically, the compression configuration includes the matching rules of the RPC function name and the specified description structure name. According to the compression configuration of the target project, the entire project file of the target project is scanned to obtain the corresponding protocol function (specified RPC function name) and the specified description structure name, and then the structural data corresponding to the specified RPC function name and the specified description structure name are taken out from the source data of the first json description file, and the specified RPC function name, the specified description structure name and the structural data are written into the created file writable stream to generate a second json description file. The second json description file is the description file after the first json description file is compressed.
[0061] The compression configuration can also include specifying which types of files need to be scanned in the project. Some files do not need to be scanned, that is, there is no need to scan all project files, which can save time.
[0062] After the compression is completed to generate the second json description file, the file writable stream is ended and the first json description file is deleted, thereby retaining only the compressed description file and reducing the size of the target project.
[0063] In some embodiments, after step 150, the following steps may also be included:
[0064] Check whether the specified RPC function name and the specified description structure name in the structure data are missing;
[0065] If yes, generate and upload error information;
[0066] If not, execute step 160.
[0067] In this embodiment, after obtaining the structural data, it is checked whether the RPC function name and the description structure name in the structural data are missing to ensure that the structural data contains the RPC function name and the description structure name. If there is a missing, an error information log can be uploaded so that the developer can solve the corresponding problem in time.
[0068] The above-mentioned description file compression method based on Protobuf.js generation of the present invention obtains the resource configuration and compression configuration of the target project selected by the developer on demand, filters out the corresponding proto file and calls Protobuf.js to generate a first json description file, obtains the specified RPC function name and the specified description structure name according to the target compression configuration, obtains the corresponding structure data from the first json description file, writes the specified RPC function name, the specified description structure name and the structure data into the file writable stream, generates a second json description file, and the second json description file is the description file after the first json description file is compressed. The present invention obtains the corresponding protocol function by scanning the file, thereby realizing on-demand compression of the description file, which can be applied to various large, medium and small projects and reduces the consumption of user bandwidth.
[0069] Based on the above method of the present invention, it is also possible to realize visual update of file difference information so that developers can view the differences between each update and the project data of the last update, thereby solving the problem in the prior art that project build results and differences cannot be tracked.
[0070] In some embodiments, after step 130, the following steps may also be included:
[0071] Query whether there is a third json description file according to the compressed file address of the target project, wherein the third json description file is the compressed file saved last time;
[0072] If yes, read and save the last compressed data of the third JSON description file;
[0073] Accordingly, after step 150, the method further includes:
[0074] Performing data difference calculation on the structure data and the last compressed data to obtain a data difference result;
[0075] A difference record file is generated according to the data difference result.
[0076] Specifically, each compressed file will be saved to a specific local address. It can be understood that the compressed file address only saves the latest compressed file. Before executing the compression logic, the compressed file address of the target project is queried to see whether there is a compressed file. The compressed file is the third json description file generated by the last compression.
[0077] If the compressed file address does not contain the third json description file, that is, this compression is the first compression of the target project, the steps after step 130 can be directly executed to complete the compression. If the third json description file exists, the old compressed data in the third json description file needs to be read and saved first to facilitate the subsequent calculation of data differences.
[0078] According to the specified RPC function name and the specified description structure name, the corresponding structure data is pulled out from the project file, which is the new compressed data. After obtaining the structure data, you can use the Json difference comparison tool to compare the new and old compressed data, calculate the data difference, obtain the data difference result, and generate a difference record file (diff.json file).
[0079] The generated difference record file records the difference data part, file difference information and update time information. The difference record file is saved locally for developers to consult, making the differences visible and traceable.
[0080] In some embodiments, the method further includes: uploading the difference record file to an application server to implement incremental update of the application.
[0081] Specifically, the obtained difference record file can be used for application update, and only the difference part needs to be uploaded to the server to implement incremental update.
[0082] The data difference result is the difference between the new and old compressed data, and the file difference information is the difference type between the two data, such as addition, deletion, and addition. Addition means that the new compressed data has more data to be added than the old compressed data; correspondingly, deletion means that the new compressed data has less data than the old compressed data; addition means that the entire new compressed data is added.
[0083] In some embodiments, before calculating the data difference between the structure data and the last compressed data to obtain the data difference result, the method includes:
[0084] Determining whether the last compressed data is complete;
[0085] If yes, executing the step of calculating the data difference between the structure data and the last compressed data to obtain the data difference result;
[0086] If not, the structural data is determined as newly added data, and a difference record file is generated according to the structural data.
[0087] In this embodiment, in order to further improve the accuracy of data difference calculation, the integrity of the old compressed data is verified before calculation. If it is complete, the step of calculating the data difference is executed; if it is incomplete, the new compressed data is regarded as newly added data, and a difference record file is generated based on the entire new compressed data.
[0088] Figure 2 Flow chart of a description file compression method generated based on Protobuf.js according to an exemplary embodiment of the present invention, as shown in FIG. Figure 2 As shown, after obtaining the project resource configuration and compression configuration input by the developer, the configuration parameters are first verified. If the verification passes, the required proto file (i.e., the target proto file) is filtered out according to the resource configuration. Protobuf.js is used to generate the first json description file according to the target proto file and related protocol parameters. The first json description file is transferred to the compression tool for initialization, and the compressed file address of the target project is obtained. It is queried whether there is a compressed file at the compressed file address. If so, a copy of the old compressed data is saved first. A file writable stream is created, and the project file is scanned according to the compression configuration to obtain the specified RPC function name and the specified description structure name, and the corresponding structural data is taken out from the first json description file according to the specified RPC function name and the specified description structure name. The structural data is the data that needs to be compressed this time. After obtaining the structural data, first verify whether the specified RPC function name and the specified description structure name are missing in the data. If they are missing, an error message needs to be uploaded; if they are not missing, the old compressed data is checked to see if it is complete. When the old compressed data is complete, the data difference calculation is performed on the new compressed data (the above-mentioned structure data) and the old compressed data to obtain the data difference result, and a difference record file is generated according to the data difference result; if the old compressed data is incomplete, the structure data is regarded as the newly added data, and a difference record file is generated according to the structure data. After the difference record file is generated, the RPC function name, the specified description structure name and the structure data are written into the file writable stream to generate the second json description file. After the second json description file is generated, the file writable stream is ended and the first json description file is deleted at the same time, thereby completing the compression of the json description file. The second json description file is the file compressed on demand for the first json description file, and some redundant structure data are removed. Its file size is smaller than the size of the first json description file. When applied to application updates, incremental updates are realized, the size of the application update package is reduced, the data transmission rate is increased, and the user bandwidth consumption is reduced. For developers, compressing the entire project file can slow down the expansion speed of the project volume, which can be applied to large, medium and small projects; and the data difference results of each application update can be visualized, which is convenient for developers to check the difference information and update information.
[0089] The description file compression device generated based on Protobuf.js provided by the present invention is described below. The description file compression device generated based on Protobuf.js described below and the description file compression method generated based on Protobuf.js described above can refer to each other.
[0090] like Figure 3 As shown, the present invention also provides a description file compression device generated based on Protobuf.js, comprising:
[0091] A first acquisition module is used to acquire a target resource configuration and a target compression configuration of a target project;
[0092] A filtering module, used to filter out a target proto file from the proto file of the target project according to the target resource configuration;
[0093] A first generation module is used to call Protobuf.js to generate a first json description file according to the target proto file;
[0094] A second acquisition module is used to create a file writable stream and acquire a specified RPC function name and a specified description structure name from a project file of the target project according to the target compression configuration;
[0095] A third acquisition module is used to acquire corresponding structure data from the first JSON description file according to the specified RPC function name and the specified description structure name;
[0096] The second generation module is used to write the specified RPC function name, the specified description structure name and the structure data into the file writable stream, generate a second json description file, and determine the second json description file as a target compressed file.
[0097] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4As shown, the electronic device may include: a processor (processor) 410, a communication interface (Communications Interface) 420, a memory (memory) 430 and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440. The processor 410 can call the logic instructions in the memory 430 to execute the description file compression method generated based on Protobuf.js, which includes: obtaining the target resource configuration and target compression configuration of the target project; filtering the target proto file from the proto file of the target project according to the target resource configuration; calling Protobuf.js to generate a first json description file according to the target proto file; creating a file writable stream, and according to the target compression configuration, obtaining the specified RPC function name and the specified description structure name from the project file of the target project; according to the specified RPC function name and the specified description structure name, obtaining the corresponding structure data from the first json description file; writing the specified RPC function name, the specified description structure name and the structure data into the file writable stream to generate a second json description file, and determining the second json description file as the target compressed file.
[0098] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or 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 invention. 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 disk or an optical disk.
[0099] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the description file compression method generated based on Protobuf.js provided by the above methods, and the method includes: obtaining the target resource configuration and target compression configuration of the target project; filtering out the target proto file from the proto file of the target project according to the target resource configuration; calling Protobuf.js to generate a first json description file according to the target proto file; creating a file writable stream, and according to the target compression configuration, obtaining a specified RPC function name and a specified description structure name from the project file of the target project; according to the specified RPC function name and the specified description structure name, obtaining corresponding structural data from the first json description file; writing the specified RPC function name, the specified description structure name and the structural data into the file writable stream to generate a second json description file, and determining the second json description file as the target compressed file.
[0100] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the description file compression method generated based on Protobuf.js provided by the above methods, the method comprising: obtaining a target resource configuration and a target compression configuration of a target project; filtering out a target proto file from the proto file of the target project according to the target resource configuration; calling Protobuf.js to generate a first json description file according to the target proto file; creating a file writable stream, and obtaining a specified RPC function name and a specified description structure name from the project file of the target project according to the target compression configuration; obtaining corresponding structural data from the first json description file according to the specified RPC function name and the specified description structure name; writing the specified RPC function name, the specified description structure name and the structural data into the file writable stream to generate a second json description file, and determining the second json description file as the target compressed file.
[0101] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0102] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0103] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A description file compression method generated based on Protobuf.js, characterized in that: include: Get the target resource configuration and target compression configuration of the target project; According to the target resource configuration, filter out the target proto file from the proto file of the target project; Call Protobuf.js to generate a first json description file according to the target proto file; Create a file writable stream, and obtain a specified RPC function name and a specified description structure name from a project file of the target project according to the target compression configuration; According to the specified RPC function name and the specified description structure name, obtain corresponding structure data from the first json description file; The specified RPC function name, the specified description structure name and the structure data are written into the file writable stream to generate a second json description file, and the second json description file is determined as a target compressed file.
2. The description file compression method generated based on Protobuf.js according to claim 1, characterized in that: After writing the specified RPC function name, the specified description structure name and the structure data into the file writable stream to generate a second json description file, and determining the second json description file as the target compressed file, the method further includes: End the file writable stream and delete the first json description file.
3. The description file compression method generated based on Protobuf.js according to claim 1, characterized in that: After calling Protobuf.js and generating a first json description file according to the target proto file, the method further includes: Query whether there is a third json description file according to the compressed file address of the target project, wherein the third json description file is the compressed file saved last time; If yes, read and save the last compressed data of the third JSON description file; After acquiring corresponding structure data from the first json description file according to the specified RPC function name and the specified description structure name, the method further includes: Performing data difference calculation on the structure data and the last compressed data to obtain a data difference result; A difference record file is generated according to the data difference result.
4. The description file compression method generated based on Protobuf.js according to claim 3, characterized in that: Before calculating the data difference between the structure data and the last compressed data to obtain the data difference result, the method includes: Determining whether the last compressed data is complete; If yes, executing the step of calculating the data difference between the structure data and the last compressed data to obtain the data difference result; If not, the structural data is determined as newly added data, and a difference record file is generated according to the structural data.
5. The description file compression method generated based on Protobuf.js according to claim 4, characterized in that: Also includes: The difference record file is uploaded to the application server to implement incremental update of the application.
6. The description file compression method generated based on Protobuf.js according to any one of claims 3 to 5, characterized in that: The difference record file includes: a difference data part, file difference information, and update time information.
7. The description file compression method generated based on Protobuf.js according to claim 1, characterized in that: After obtaining corresponding structure data from the first json description file according to the specified RPC function name and the specified description structure name, the method further comprises: Check whether the specified RPC function name and the specified description structure name in the structure data are missing; If yes, generate and upload error information; If not, execute the step of writing the specified RPC function name, the specified description structure name and the structure data into the file writable stream to generate a second json description file, and determine the second json description file as the target compressed file.
8. A description file compression device generated based on Protobuf.js, characterized in that: include: A first acquisition module is used to acquire a target resource configuration and a target compression configuration of a target project; A filtering module, used to filter out a target proto file from the proto file of the target project according to the target resource configuration; A first generation module is used to call Protobuf.js to generate a first json description file according to the target proto file; A second acquisition module is used to create a file writable stream and acquire a specified RPC function name and a specified description structure name from a project file of the target project according to the target compression configuration; A third acquisition module is used to acquire corresponding structure data from the first JSON description file according to the specified RPC function name and the specified description structure name; The second generation module is used to write the specified RPC function name, the specified description structure name and the structure data into the file writable stream, generate a second json description file, and determine the second json description file as a target compressed file.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the description file compression method generated based on Protobuf.js as described in any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the description file compression method generated based on Protobuf.js as described in any one of claims 1 to 7 is implemented.