Packaging optimization method, interface generation method, device and storage medium
By dividing the SDK system into functional components and deleting unreferenced code and dependent packages, an optimized packaging file is generated, which solves the problem of long loading time and resource constraints of the SDK system on embedded devices, and achieves efficient on-demand loading and Improved stability.
Patent Information
- Application Number
- CN202410937425.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-07-12
AI Technical Summary
When deploying SDK systems, existing technologies face problems such as limited resources, heavy data processing burden, long loading time, and high development complexity, especially on embedded devices and especially in intelligent conversational robot applications.
By dividing the software development tool kit into multiple functional components, deleting unreferenced code and dependent packages, and generating optimized packaging files, on-demand loading is achieved, reducing device burden and file size.
It optimizes the loading time and device burden of the SDK system, improves the resource utilization and system stability of embedded devices, and reduces development complexity.
Smart Images

Figure CN118466971B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and specifically relates to a packaging optimization method, an interface generation method, a device and a storage medium. Background Art
[0002] In order to realize certain application functions on the platform, a Software Development Kit (SDK) system is generally deployed on the platform to realize the functions of the SDK system.
[0003] Generally, to implement the functions of the SDK system on the platform, it is necessary to package the various components in the SDK system in advance and load the packaged file. However, the file generally has a large amount of data, resulting in a long loading time and a large data processing burden on the device where the platform is located. Summary of the invention
[0004] The present application proposes a packaging optimization method, an interface generation method, a device and a storage medium, which can solve the technical problems that the loading time of files is too long when the current function is implemented, and it will cause a relatively large data processing burden on the device where the platform is located.
[0005] The first embodiment of the present application proposes a packaging optimization method, including:
[0006] Dividing the software development kit into multiple functional components based on functional codes in the software development kit;
[0007] Deleting unreferenced codes corresponding to the multiple functional components based on the import configuration file and the export configuration file to obtain multiple target functional components;
[0008] Deleting at least one dependent package from multiple dependent packages of the software development kit to obtain at least one target dependent package;
[0009] A packaging file is generated based on the multiple target functional components and the at least one target dependent package.
[0010] The embodiment of the second aspect of the present application provides a packaging optimization device, including:
[0011] A partitioning module, used for partitioning the software development kit into a plurality of functional components based on functional codes in the software development kit;
[0012] A deletion module, used for deleting unreferenced codes corresponding to the plurality of functional components based on the import configuration file and the export configuration file, to obtain a plurality of target functional components;
[0013] The deleting module is further used to delete at least one dependent package from the multiple dependent packages of the software development kit to obtain at least one target dependent package;
[0014] A generation module is used to generate a packaging file based on the multiple target functional components and the at least one target dependent package.
[0015] The third aspect of the present application provides an interface generation method, including:
[0016] Decompress the obtained compressed file to obtain a packaged file;
[0017] Rendering the initial functional component in the packaged file to generate a display interface corresponding to the initial functional component;
[0018] In response to at least one import operation on the display interface, obtaining, from the packaged file, an import function component corresponding to the at least one import operation;
[0019] Render at least one of the introduced functional components to generate a target interface.
[0020] The fourth aspect of the present application provides an interface generation device, including:
[0021] The decompression module is used to decompress the obtained compressed file to obtain a packaged file;
[0022] A rendering module, used to render the initial functional components in the packaged file and generate a display interface corresponding to the initial functional components;
[0023] An acquisition module, configured to, in response to at least one import operation on the display interface, obtain, from the package file, an import function component corresponding to the at least one import operation;
[0024] A generation module is used to render at least one of the introduced functional components to generate a target interface.
[0025] An embodiment of the fifth aspect of the present application provides a computing device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in the first aspect or the third aspect above.
[0026] The embodiment of the sixth aspect of the present application provides a computer-readable storage medium on which a computer program is stored, and the program is executed by a processor to implement the method described in the first aspect or the third aspect above.
[0027] The technical solution provided in the embodiments of the present application has at least the following technical effects or advantages:
[0028] In an embodiment of the present application, firstly, the software development kit is divided into multiple functional components based on the functional code in the software development kit; based on the import configuration file and the export configuration file, the unreferenced codes corresponding to the multiple functional components are deleted to obtain multiple target functional components; at least one dependent package is deleted from the multiple dependent packages of the software development kit to obtain at least one target dependent package; and a package file is generated based on the multiple target functional components and at least one target dependent package. The embodiment of the present application can optimize the size of the package file by segmenting the functional components in the software development kit so as to realize on-demand loading in loading the package file, reduce the loading pressure of the device, clear the unreferenced codes in the functional components, and delete the dependent packages in the software development kit.
[0029] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0031] Figure 1 A flow chart of a packaging optimization method provided by an embodiment of the present application is shown;
[0032] Figure 2 A flow chart of a packaging optimization method provided by an embodiment of the present application is shown;
[0033] Figure 3 A flow chart of an interface generation method provided by an embodiment of the present application is shown;
[0034] Figure 4 A schematic diagram of an interface provided by an embodiment of the present application is shown;
[0035] Figure 5 Another interface schematic diagram provided by an embodiment of the present application is shown;
[0036] Figure 6 A schematic diagram of the structure of a packaging optimization device provided by an embodiment of the present application is shown;
[0037] Figure 7 A schematic diagram of the structure of an interface generation device provided by an embodiment of the present application is shown;
[0038] Figure 8A schematic diagram of the structure of a computing device provided by an embodiment of the present application is shown;
[0039] Fig. 9 A schematic diagram of a storage medium provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0040] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0041] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should have the common meanings understood by technicians in the field to which this application belongs.
[0042] Based on the above background technology, with the rapid development of artificial intelligence technology, SDK systems, as an embedded function implementation tool, have shown broad application prospects in many fields. However, some SDK systems may be subject to some restrictions during deployment. For example, intelligent conversational robots, as an important tool for human-computer interaction, have shown broad application prospects in many fields. However, deploying intelligent conversational robots on embedded devices faces a series of unique challenges. These devices are often resource-constrained (such as limited computing power and storage space) and need to run stably in a low-power environment.
[0043] In order to solve the problem of limited resources, the SDK system can be deployed to the cloud server to realize the corresponding functions. Although cloud deployment can make full use of powerful computing resources, it increases data transmission delays, privacy leakage risks and dependence on the network, which is not suitable for application scenarios with high requirements for real-time response and offline operation. In addition, the existing embedded dialogue systems are often not highly integrated, and developers need to integrate multiple components (such as speech recognition, natural language processing, dialogue management, etc.) by themselves, which not only increases the difficulty and cycle of development, but also easily leads to system stability problems.
[0044] Based on this, the present application proposes a packaging optimization method, an interface generation method, a device and a storage medium, by dividing the software development kit into multiple functional components based on the functional code in the software development kit; deleting the unreferenced codes corresponding to the multiple functional components based on the import configuration file and the export configuration file to obtain multiple target functional components; deleting at least one dependent package from the multiple dependent packages of the software development kit to obtain at least one target dependent package; generating a packaging file based on multiple target functional components and at least one target dependent package. The embodiment of the present application can optimize the size of the packaging file by segmenting the functional components in the software development kit so as to realize on-demand loading when loading the packaging file, reduce the loading pressure of the device, clear the unreferenced codes in the functional components, and delete the dependent packages in the software development kit.
[0045] The packaging optimization method or interface generation method of the present application can be executed by a computing device, and the computing device can be a server, such as one server, multiple servers, a server cluster, a cloud computing platform, etc. Optionally, the computing device can also be a terminal device, such as a mobile phone, a tablet computer, a game console, a portable computer, a desktop computer, an advertising machine, an all-in-one machine, etc. The present application does not limit the device type and number of the computing device.
[0046] A packaging optimization method proposed according to an embodiment of the present application is described below in conjunction with the accompanying drawings.
[0047] See also Figure 1 , the method specifically comprises the following steps:
[0048] S101. Divide a software development kit into multiple functional components based on functional codes in the software development kit.
[0049] Generally, before releasing an SDK, it is necessary to package the SDK so that the packaged files can be compressed, tested, and released.
[0050] In some embodiments, the SDK can be packaged using a packaging tool, where the packaging tool can be webpack.
[0051] Among them, the function code of the software development kit is used to implement multiple functions corresponding to the software development kit, and the multiple functions include: core functions, auxiliary functions and common functions, etc. The multiple functions are nested in the software development kit to ensure that the corresponding multiple functions are implemented under the premise of normal operation of the software development kit.
[0052] In order to reduce the dependency between various functional components, the functional code may be segmented first, that is, the functional code may be segmented according to multiple functions to obtain multiple functional components after segmentation.
[0053] Among them, the code splitting function can be enabled through the configuration file of the packaging tool through the corresponding configuration options. For example, the corresponding configuration options can be configured through webpack.config.js to split the functional code and divide the software development kit into multiple functional components.
[0054] For example, the function implemented by the above SDK system is intelligent dialogue, and the SDK can be divided into multiple core functions, multiple auxiliary functions and multiple common functions. Among them, the core functions may include: natural language understanding, dialogue management and natural language generation, etc., the auxiliary functions may include: speech to text, knowledge graph and database access and multimodal support, etc., and the common functions may include logging, debugging tools, security authentication, permission management, performance optimization and caching strategy, etc.
[0055] The multiple functional components have independent responsibilities and boundaries, and the interface of each functional component can be defined so that data can be exchanged between the functional components.
[0056] S102: Deleting unreferenced codes corresponding to a plurality of functional components based on the import configuration file and the export configuration file to obtain a plurality of target functional components.
[0057] The software development kit is divided into multiple functional components, and a configuration file is required to determine the import positions and export positions corresponding to each of the multiple functional components to achieve the corresponding functions.
[0058] The import configuration file and the export configuration file may be pre-configured in the packaging tool, and the import and export relationships of the codes in the multiple functional components may be determined through the import configuration file and the export configuration file, so as to determine which codes are unreferenced codes.
[0059] In some embodiments, unreferenced codes corresponding to multiple functional components are deleted based on an import configuration file and an export configuration file, including: traversing the import configuration file and the export configuration file to determine multiple import code blocks of the import configuration file and multiple export code blocks of the export configuration file; determining at least one code block in the multiple export code blocks that does not exist in the multiple import code blocks as unreferenced code corresponding to the multiple functional components, the unreferenced code including code corresponding to at least one functional component in the multiple functional components, code corresponding to a static file, and code corresponding to at least one sub-function in the multiple functional components; deleting the unreferenced code.
[0060] The imported code blocks and exported code blocks may be code blocks corresponding to functions, code blocks corresponding to static files, and so on.
[0061] The code block corresponding to a function may be a code block corresponding to any of the multiple core functions, multiple auxiliary functions, and multiple common functions, or a code block corresponding to any sub-function included in any function. For example, the core function conversation management includes multiple sub-functions, namely: session modification, session details, session record, and session list. Therefore, the code block corresponding to a function may be a code block corresponding to the conversation management function, or a code block corresponding to at least one of the functions of session modification, session details, session record, and session list.
[0062] In some embodiments, the import configuration file and the export configuration file can be traversed to determine the code of the import configuration file and the code blocks of the export configuration file. If it is determined that a code block exists in the export configuration file but does not exist in the import configuration file, then the part of the code block is determined as unreferenced code and the unreferenced code is deleted.
[0063] S103: Delete at least one dependent package from multiple dependent packages of the software development kit to obtain at least one target dependent package.
[0064] Software development kits generally reference some dependency packages to implement their core, auxiliary or public functions. Among multiple dependency packages, there may be some common and infrequently changed dependency packages, which can be externalized and implemented through interface calls. Therefore, even if these dependency packages are deleted, it will not affect the implementation of the functions and can reduce the size of the package file.
[0065] In some embodiments, at least one dependency package is deleted from multiple dependency packages of a software development kit to obtain at least one target dependency package, including: determining at least one external dependency package corresponding to a keyword from multiple dependency packages through a keyword query method; deleting at least one external dependency package from multiple dependency packages to obtain at least one target dependency package.
[0066] In some embodiments, all dependency packages in the SDK can be obtained. In a Python project, the pip list command can be used to list all dependency packages and their versions installed in the current project. In a JavaScript project, the npm list or npm ls command can be used to list all dependency packages and their versions installed in the current project.
[0067] Furthermore, you can query the keywords in the configuration file to determine the external dependency packages that need to be deleted. The keywords can be externals and pip uninstall.
[0068] Among them, using the keyword pip uninstall to determine the external dependency packages that need to be deleted can be implemented as: pipuninstall+dependency package name, that is, multiple deletion statements are required to delete multiple external dependency packages, such as pipuninstall package_name, that is, to delete the dependency package named package_name.
[0069] Using the keyword externals to determine the external dependency packages that need to be deleted can be implemented as follows: where externals is a configuration item in the configuration file, and at least one dependency package that needs to be deleted can be configured in this configuration item, such as externals: {
[0070] 'vue': 'Vue', / / means that when you import Vue from 'vue' in the code, Webpack will not package the Vue library, but expect Vue to be available as a global variable.
[0071] 'axios': 'axios',
[0072] 'vue-router': 'VueRouter',
[0073] 'vuex': 'Vuex',
[0074] 'html2canvas': 'html2canvas', / / 'axios', 'vue-router', 'vuex', 'html2canvas': Similarly, these libraries will also be considered external dependencies and will not be packaged into the final bundle
[0075] 'lodash': '' / / lodash is configured as an empty string, which means that when import _from 'lodash' in the code, Webpack will not package lodash into the bundle, because the lodash library is expected to be available in the global environment
[0076] }
[0077] The above code means deleting the dependent packages named Vue, 'axios', 'vue-router', 'vuex', 'html2canvas' and lodash.
[0078] In some embodiments, after deleting at least one external dependency package, the dependency package needs to be introduced into the configuration file through CDN or other means.
[0079] <script src="https: / / cdn.jsdelivr.net / npm / lodash@4.17.21 / lodash.min.js">< / script> / / Introduce version 4.17.21 of the lodash library into the HTML page.
[0080] The above code introduces the dependency package named lodash through CDN.
[0081] S104: Generate a packaging file based on multiple target functional components and at least one target dependency package.
[0082] In some embodiments, a packaging file is generated based on multiple target functional components and at least one target dependency package, including: generating sub-packaging files corresponding to each of the multiple target functional components and at least one target dependency package; configuring the reference relationship corresponding to each sub-packaging file; and generating a packaging file based on the reference relationship and each sub-packaging file.
[0083] The reference relationship may be that in the process of realizing the function of the package file or after realizing the function of the sub-package file, the functions of other sub-package files need to be supported. Therefore, the reference relationship of each sub-package file can be configured in the configuration file of the packaging tool to realize the function of each sub-package file.
[0084] In order to reduce the dependencies between various functional components, each target functional component and each dependent package can be packaged separately to generate multiple packages, and the packaging file can be generated by configuring the interaction between multiple packages.
[0085] The embodiment of the present application provides a packaging optimization method. In the embodiment of the present application, the software development kit is first divided into multiple functional components based on the functional code in the software development kit; the unreferenced codes corresponding to the multiple functional components are deleted based on the import configuration file and the export configuration file to obtain multiple target functional components; at least one dependent package is deleted from the multiple dependent packages of the software development kit to obtain at least one target dependent package; and a packaging file is generated based on the multiple target functional components and at least one target dependent package. The embodiment of the present application can optimize the size of the packaging file by segmenting the functional components in the software development kit so as to realize on-demand loading in loading the packaging file, reduce the loading pressure of the device, clear the unreferenced codes in the functional components, and delete the dependent packages in the software development kit.
[0086] In some embodiments, a software development kit is divided into multiple functional components based on the function code in the software development kit, including: determining a target function code to be divided in the function code; extracting a first function code corresponding to a common function in the target function code; dividing the first function code according to the function and division rules to obtain multiple common function components, the division rules including at least one of the maximum data amount of the divided components and the minimum data amount of the divided components; dividing the second function code according to the function and division rules to obtain multiple core function components and multiple auxiliary function components, the second function code being the code in the target function code except the first function code.
[0087] The packaging tool can determine how to split the code block based on the splitting options, where the splitting options are generally optimization objects, and the splitting options generally include the types of the split code blocks, including 'all', 'async', 'initial', that is, all types, asynchronous loading types, and initial loading types, that is, the target function code to be divided can be determined based on the type of code to be split. The target function code can be all function codes, asynchronously loaded function codes, or initially loaded function codes.
[0088] As mentioned above, there are codes corresponding to common functions in the target function code. Therefore, the codes corresponding to the common functions can be extracted preferentially, and the first function code can be divided according to the division rules and functions, wherein the division rules include at least one of the maximum data volume threshold of the divided component and the minimum data volume threshold of the divided component, that is, the divided functional component cannot be greater than the maximum data volume threshold and cannot be less than the minimum data volume threshold.
[0089] Furthermore, the codes in the target function code except the first function code are divided according to the division rules and functions to obtain multiple core function components and multiple auxiliary function components.
[0090] In some embodiments, the functional code can be first segmented to obtain multiple core functional components and multiple auxiliary functional components. Further, it is determined whether the same common functions exist in the multiple core functional components and the multiple auxiliary functional components. If so, the code corresponding to the common function is segmented to obtain multiple common functional components.
[0091] The embodiment of the present application has obtained multiple core functional components, multiple auxiliary functional components and multiple common functional components by dividing the functional codes. By componentizing the functions, on-demand loading of functional components can be achieved when loading the SDK. Compared with the traditional packaging method, which usually packages all dependencies and business codes into one or a few large files and requires users to download the entire package when accessing for the first time, the time for the first load is reduced and the loading pressure of the loading device is reduced.
[0092] In some embodiments, the method further comprises:
[0093] The packaged file is encrypted and compressed according to the compression rules to generate a compressed file. The compression rules include file type, minimum data size of the compressed file, minimum compression ratio and whether to delete at least one of the packaged files; the file format corresponding to the compressed file is configured on the server side; the compressed file is transmitted to the server side according to the file format so that the business side can obtain the compressed file from the server side.
[0094] Among them, an efficient compression algorithm can be used to compress and encrypt the packaged file.
[0095] Compression rules can be configured in the configuration file to compress the packaged files, where file types can include: .js, .css, .html, etc. The packaged files will be compressed only when they are larger than the minimum data size of the compressed files, and when they are larger than the minimum compression ratio, the packaged files will be compressed. The compression rules will also determine whether to delete the packaged files after the compressed files are generated.
[0096] Before transmitting the compressed file, you need to configure the file format corresponding to the compressed file on the server. Assuming that the file format of the compressed file is .gz, the corresponding configuration code can be:
[0097] http {
[0098] # Enable gzip compression
[0099] gzip on; / / Enable the gzip compression function on the server side;
[0100] gzip_vary on; / / Add Vary: Accept-Encoding to the response header to tell the proxy server to cache different versions of the response content according to the Accept-Encoding header in the request to ensure that different users get the content version that suits them;
[0101] gzip_min length 1k; / / Set the response content length to be gzip compressed only when it exceeds 1k, avoiding compressing smaller files to avoid increasing processing overhead;
[0102] gzip buffers 4 16k; The buffer size configured for gzip compression is 16k, and a maximum of 4 buffers are used;
[0103] gzip_comp_level 6; sets the gzip compression level to 6, which is a medium compression ratio level that can significantly reduce the file size without consuming too much server CPU resources;
[0104] gzip types text / plain text / css application / json application / javascripttext / xml application / xml application / xml+rss text / javascript;gzip_proxied any;gzip_disable "MSIE [1-6]\."; / / Specifies the MIME types that need to be gzip compressed, including text files, style sheets, scripts, and various XML format files;
[0105] server {
[0106] location / {
[0107] # If the requested file has a file ending in .gz with the same name, the .gz file will be returned directly gzip_staticon; if the requested file has a .gz compressed file with the same name, the compressed file will be returned directly instead of dynamically compressing the original file;
[0108] }
[0109] }
[0110] }.
[0111] The embodiment of the present application improves the security of packaged file transmission by encrypting and compressing the packaged files, and compressing the packaged files has the advantages of reducing storage space and network transmission overhead, accelerating web page loading speed, supporting multiple browsers, and being transparent.
[0112] After the compressed file is generated, it is necessary to test and provide feedback on the compressed file. Therefore, the embodiment of the present application provides an automated packaging and testing process using continuous integration and continuous deployment tools to ensure that each build can achieve the best packaging effect. Through continuous monitoring and feedback mechanisms, problems that occur during the packaging process can be discovered and resolved in a timely manner.
[0113] Specifically:
[0114] 1) Configure a code repository (such as Git) to manage front-end source code.
[0115] 2) Set up automated build tasks in the continuous integration tool, with the trigger condition being the update of the code repository.
[0116] 3) Integrate code analysis, dependency management, incremental packaging, compression optimization and other steps into the build task.
[0117] 4) Configure a caching mechanism to store and reuse unchanged files.
[0118] 5) Use parallel processing technology to speed up the packaging process.
[0119] 6) Set up real-time monitoring and feedback mechanisms to ensure the transparency and optimizability of the packaging process.
[0120] After the test is completed, the corresponding compressed file can be obtained. Further, the compressed file can be published so that the business end can obtain the corresponding compressed file.
[0121] In order to fully describe the above packaging process, the present application embodiment provides a flowchart of a packaging method, such as Figure 2 As shown, the method comprises the following steps:
[0122] S201. Segment the function code in the SDK to obtain multiple core function components, multiple auxiliary function components and multiple common function components.
[0123] Specifically, how to split the code blocks using the split options of the configuration file in the packaging tool, where the split options are generally optimization objects, and the split options generally include the types of the split code blocks, including 'all', 'async', 'initial', that is, all types, asynchronous loading types, and initial loading types, that is, the target function code to be divided can be determined based on the type of code to be split. The target function code can be all function codes, asynchronously loaded function codes, or initially loaded function codes.
[0124] S202: Perform a tree shaking operation on the multiple segmented functional components to obtain multiple target functional components.
[0125] The import configuration file and the export configuration file can be traversed to determine the code of the import configuration file and the code block of the export configuration file. If it is determined that a code block exists in the export configuration file but does not exist in the import configuration file, the part of the code block is determined as unreferenced code and deleted.
[0126] S203. Delete at least one dependent package to obtain at least one target dependent package.
[0127] You can query the keywords in the configuration file to determine the external dependency packages that need to be deleted. The keywords can be externals and pip uninstall. The deleted external dependency packages can be loaded through externalization methods such as CDN.
[0128] S204: Encrypt and compress the packaged file formed by at least one target dependency package and multiple target functional components according to the compression rules.
[0129] Compression rules can be configured in the configuration file to compress and encrypt the packaged file. The compression rules include at least one of the file type, the minimum data size of the compressed file, the minimum compression ratio, and whether to delete the packaged file.
[0130] S205. Perform continuous integration and continuous deployment on packaged files.
[0131] Specifically:
[0132] 1) Configure a code repository (such as Git) to manage front-end source code.
[0133] 2) Set up automated build tasks in the continuous integration tool, with the trigger condition being the update of the code repository.
[0134] 3) Integrate code analysis, dependency management, incremental packaging, compression optimization and other steps into the build task.
[0135] 4) Configure a caching mechanism to store and reuse unchanged files.
[0136] 5) Use parallel processing technology to speed up the packaging process.
[0137] 6) Set up real-time monitoring and feedback mechanisms to ensure the transparency and optimizability of the packaging process.
[0138] The following describes an interface generation method proposed according to an embodiment of the present application in conjunction with the accompanying drawings. The method is applied to a business end and includes the following steps:
[0139] S301, decompressing the obtained compressed file to obtain a packaged file.
[0140] The corresponding compressed file and the decompression key corresponding to the compressed file can be downloaded from the compressed file publishing platform, and the compressed file can be decompressed based on the decompression key to obtain the corresponding packaged file.
[0141] S302: Render the initial functional component in the packaged file to generate a display interface corresponding to the initial functional component.
[0142] Among them, the initial functional component can be specified in the configuration file in the package file or be the default functional component of the package file. For example, the initial functional component corresponding to the package file for intelligent conversation can be the functional component corresponding to conversation management, that is, display the corresponding initial dialog box and default prompt messages, etc.
[0143] In some embodiments, the initial functional component can be determined by importing a configuration file. For example, the imported configuration file includes: import SmartVoice from '@ecogpt / smark-voice-sdk ', that is, the business side first loads the functional component named SmartVoice, and the location of this functional component is @ecogpt / smark-voice-sdk. That is, the display interface corresponding to the SmartVoice functional component can be loaded.
[0144] S303. In response to at least one introduction operation on the display interface, obtain at least one introduced functional component corresponding to each of the at least one introduction operation from the package file.
[0145] Among them, the display interface can include introduction controls for other functional components. In response to a touch operation on the introduction control, the imported configuration file can be dynamically updated, and the functional component corresponding to the updated imported configuration file can be obtained from the package file.
[0146] Render at least one introduced functional component to generate a target interface.
[0147] Furthermore, render the introduced functional components to generate the final interface.
[0148] In some embodiments, the rendering process can be implemented through the following code:
[0149] <SmartVoice ref="smartVoice" / / This attribute defines the reference name of the component as "smartVoice";
[0150] :configs="ecogptConfigs" / / This attribute configs is bound to the ecogptConfigs variable;
[0151] :serverUrls=" serverUrls " / / This attribute serverUrls is also bound to the serverUrls variable; / >
[0152] Among them, the parameter table in the above code is shown in Table 1:
[0153]
[0154] Table 1
[0155] The properties corresponding to the parameter ecogptConfigs are shown in Table 2:
[0156]
[0157] Table 2
[0158] The properties corresponding to the parameter serverUrls are shown in Table 3:
[0159]
[0160] Table 3
[0161] The display interface is rendered according to the values of the parameters in Table 2 in the configuration file and the dependent packages obtained by the parameters in Table 3.
[0162] Figure 4 This is a schematic diagram of the interface corresponding to loading the initial functional component in an embodiment of the present application, such as Figure 4 As shown, the function implemented by the SDK is intelligent dialogue, and the initial functional component loaded is the functional component corresponding to the dialogue management. By loading the initial functional component, the following is obtained: Figure 4 The display interface shown includes the model "XX model" corresponding to the intelligent dialogue, the initial dialog box, and the default prompt: Try asking me this: Where is the capital of China?
[0163] In addition, the display interface also includes the introduction control " ", in response to the triggering operation of the introduced control, obtain the functional component of the introduced control, and load the functional component, wherein the functional component is the functional component corresponding to the scene function, and display as shown Figure 5 The target display interface shown in the figure includes Figure 5 In addition to the content of the display interface, the scenarios of the intelligent dialogue search are also displayed, including: economy, politics, military, entertainment, society, education and technology.
[0164] The embodiment of the present application obtains a corresponding packaged file by decompressing a componentized compressed file. Since the packaged file is a componentized packaged file, the initial functional component can be loaded to render and display the corresponding display interface, and other functional components of the packaged file can be obtained and rendered in response to the introduction operation of the display interface to generate a target display interface, thereby realizing on-demand loading of functional components and reducing the pressure of initial loading of the packaged file.
[0165] In some embodiments, the method further comprises:
[0166] Receiving a configuration operation for a target interface, and acquiring configuration data corresponding to the configuration operation, wherein the configuration data includes at least one of static data of a functional component corresponding to the target interface and update data for the functional component corresponding to the target interface;
[0167] Update the target interface according to the configuration data.
[0168] Among them, the server is also configured with an SDK database, which stores configuration data corresponding to the packaged files. The SDK database can also store identifiers corresponding to the configuration data. The business end can obtain the corresponding configuration data from the SDK database of the server by receiving the corresponding data identifier. The configuration data can be static data, such as pictures, texts, etc., and can also be update data for functional components, such as version update data for functional components.
[0169] The embodiment of the present application stores the update data of the functional components on the server side, and when there is an update, the corresponding update data can be sent to the business side through the acquisition operation of the business side, so as to implement the update of the functional components.
[0170] The present application also provides a packaging optimization device, which is used to execute the packaging optimization method provided in any of the above embodiments. Figure 6 As shown, the device includes: a division module 601, a deletion module 602 and a generation module 603.
[0171] A division module 601 is used to divide the software development kit into multiple functional components based on the functional codes in the software development kit;
[0172] A deleting module 602 is used to delete unreferenced codes corresponding to the multiple functional components based on the import configuration file and the export configuration file to obtain multiple target functional components;
[0173] The deleting module 602 is further used to delete at least one dependent package from the multiple dependent packages of the software development kit to obtain at least one target dependent package;
[0174] The generation module 603 is used to generate a packaging file based on the multiple target functional components and the at least one target dependency package.
[0175] In an embodiment of the present application, firstly, the software development kit is divided into multiple functional components based on the functional code in the software development kit; based on the import configuration file and the export configuration file, the unreferenced codes corresponding to the multiple functional components are deleted to obtain multiple target functional components; at least one dependent package is deleted from the multiple dependent packages of the software development kit to obtain at least one target dependent package; and a package file is generated based on the multiple target functional components and at least one target dependent package. The embodiment of the present application can optimize the size of the package file by segmenting the functional components in the software development kit so as to realize on-demand loading in loading the package file, reduce the loading pressure of the device, clear the unreferenced codes in the functional components, and delete the dependent packages in the software development kit.
[0176] In some embodiments, the division module 601 is specifically used to:
[0177] Determining a divided target function code in the function code;
[0178] Extracting a first function code corresponding to a common function in the target function code;
[0179] Divide the first function code according to functions and division rules to obtain a plurality of common function components, wherein the division rules include at least one of a maximum data volume of the divided components and a minimum data volume of the divided components;
[0180] The second function code is divided according to the function and the division rule to obtain multiple core function components and multiple auxiliary function components, and the second function code is the code in the target function code except the first function code.
[0181] In some embodiments, the deletion module 602 is specifically configured to:
[0182] Traversing the import configuration file and the export configuration file, determining a plurality of import code blocks of the import configuration file and a plurality of export code blocks of the export configuration file;
[0183] Determine at least one code block among the multiple exported code blocks that does not exist in the multiple imported code blocks as unreferenced code corresponding to multiple functional components, wherein the unreferenced code includes code corresponding to at least one functional component among the multiple functional components, code corresponding to a static file, and code corresponding to at least one sub-function among the multiple functional components;
[0184] Delete the unreferenced code.
[0185] In some embodiments, the deletion module 602 is further specifically configured to:
[0186] Determine at least one external dependency package corresponding to the keyword from multiple dependency packages by keyword query;
[0187] The at least one external dependent package is deleted from the multiple dependent packages to obtain at least one target dependent package.
[0188] In some embodiments, the generating module 603 is specifically used to:
[0189] Generate sub-package files corresponding to the multiple target functional components and the at least one target dependency package respectively;
[0190] Configure the reference relationship corresponding to each sub-package file;
[0191] A package file is generated based on the reference relationship and each sub-package file.
[0192] In some embodiments, the above apparatus further includes a compression module, a configuration module and a transmission module:
[0193] A compression module, used to encrypt and compress the packaged file according to a compression rule to generate a compressed file, wherein the compression rule includes at least one of a file type, a minimum data volume of a compressed file, a minimum compression ratio, and whether to delete the packaged file;
[0194] A configuration module, used to configure the file format corresponding to the compressed file on the server side;
[0195] The transmission module is used to transmit the compressed file to the server according to the file format, so that the service end can obtain the compressed file from the server.
[0196] The present application also provides an interface generation device, which is used to execute the packaging optimization method provided in any of the above embodiments. Figure 7 As shown, the device includes: a decompression module 710, a rendering module 720, an acquisition module 730 and a generation module 740.
[0197] The decompression module 710 is used to decompress the obtained compressed file to obtain a packaged file;
[0198] A rendering module 720, configured to render the initial functional components in the packaged file and generate a display interface corresponding to the initial functional components;
[0199] An acquisition module 730 is used for acquiring, in response to at least one import operation on the display interface, an import function component corresponding to the at least one import operation from the package file;
[0200] The generation module 740 is used to render at least one of the introduced functional components to generate a target interface.
[0201] The embodiment of the present application obtains a corresponding packaged file by decompressing a componentized compressed file. Since the packaged file is a componentized packaged file, the initial functional component can be loaded to render and display the corresponding display interface, and other functional components of the packaged file can be obtained and rendered in response to the introduction operation of the display interface to generate a target display interface, thereby realizing on-demand loading of functional components and reducing the pressure of initial loading of the packaged file.
[0202] In some embodiments, the above-mentioned apparatus further includes: a receiving module and an updating module;
[0203] A receiving module, configured to receive a configuration operation for a target interface, and obtain configuration data corresponding to the configuration operation, wherein the configuration data includes at least one of static data of a functional component corresponding to the target interface and update data of a functional component corresponding to the target interface;
[0204] An updating module is used to update the target interface according to the configuration data.
[0205] The present application also provides a computing device to execute the above-mentioned packaging optimization method. Figure 8 It shows a schematic diagram of a computing device provided by some embodiments of the present application. Figure 8 As shown, the computing device 7 includes: a processor 700, a memory 701, a bus 702 and a communication interface 703, and the processor 700, the communication interface 703 and the memory 701 are connected via the bus 702; the memory 701 stores a computer program that can be run on the processor 700, and when the processor 700 runs the computer program, it executes the packaging optimization method or the interface generation method provided in any of the aforementioned embodiments of the present application.
[0206] The memory 701 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the device network element and at least one other network element is realized through at least one communication interface 703 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.
[0207] The bus 702 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory 701 is used to store programs, and the processor 700 executes the program after receiving an execution instruction. The packing optimization method disclosed in any implementation of the aforementioned embodiment of the present application may be applied to the processor 700, or implemented by the processor 700.
[0208] The processor 700 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 700. The above processor 700 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a readily available programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 701, and the processor 700 reads the information in the memory 701 and completes the steps of the above method in combination with its hardware.
[0209] The computing device provided in the embodiment of the present application and the packaging optimization method or interface generation method provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented therein.
[0210] The present application also provides a computer-readable storage medium corresponding to the packaging optimization method provided in the above embodiment. Fig. 9 The computer-readable storage medium shown is a CD 30 on which a computer program (ie, a program product) is stored. When the computer program is run by a processor, it executes the packaging optimization method or interface generation method provided by any of the aforementioned embodiments.
[0211] It should be noted that examples of computer-readable storage media may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical or magnetic storage media, which are not listed here one by one.
[0212] The computer-readable storage medium provided in the above-mentioned embodiments of the present application and the packaging optimization method provided in the embodiments of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the application programs stored therein.
[0213] It should be noted that:
[0214] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known structures and technologies are not shown in detail so as not to obscure the understanding of this description.
[0215] Similarly, it should be understood that in order to streamline the present application and help understand one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present application, the various features of the present application are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be interpreted as reflecting the following schematic diagram: the claimed application requires more features than the features clearly stated in each claim. More specifically, as reflected in the claims below, the inventive aspects are less than all the features of the single embodiment disclosed above. Therefore, the claims following the specific embodiment are hereby expressly incorporated into the specific embodiment, wherein each claim itself serves as a separate embodiment of the present application.
[0216] In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present application and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.
[0217] The above are only preferred specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application 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 packaging optimization method, characterized in that: include: Dividing the software development kit into multiple functional components based on functional codes in the software development kit; Deleting unreferenced codes corresponding to the plurality of functional components based on the import configuration file and the export configuration file to obtain a plurality of target functional components; The deleting the unreferenced codes corresponding to the multiple functional components based on the import configuration file and the export configuration file includes: Traversing the import configuration file and the export configuration file, determining a plurality of import code blocks of the import configuration file and a plurality of export code blocks of the export configuration file; Determine at least one code block among the multiple exported code blocks that does not exist in the multiple imported code blocks as unreferenced code corresponding to multiple functional components, wherein the unreferenced code includes code corresponding to at least one functional component among the multiple functional components, code corresponding to a static file, and code corresponding to at least one sub-function among the multiple functional components; Delete the unreferenced code; Deleting at least one dependent package from multiple dependent packages of the software development kit to obtain at least one target dependent package; Generate a packaging file based on the multiple target functional components and the at least one target dependency package; The software development kit is divided into multiple functional components based on the functional codes in the software development kit, including: Determining a divided target function code in the function code; Extracting a first function code corresponding to a common function in the target function code; Divide the first function code according to functions and division rules to obtain a plurality of common function components, wherein the division rules include at least one of a maximum data volume of the divided components and a minimum data volume of the divided components; The second function code is divided according to the functions and the division rules to obtain multiple core function components and multiple auxiliary function components, and the second function code is the code in the target function code except the first function code.
2. The method according to claim 1, characterized in that The deleting at least one dependent package from the multiple dependent packages of the software development kit to obtain at least one target dependent package includes: Determine at least one external dependency package corresponding to the keyword from multiple dependency packages by keyword query; The at least one external dependent package is deleted from the multiple dependent packages to obtain at least one target dependent package.
3. The method according to claim 1, characterized in that The generating a packaging file based on the multiple target functional components and the at least one target dependency package includes: Generate sub-package files corresponding to the multiple target functional components and the at least one target dependency package respectively; Configure the reference relationship corresponding to each sub-package file; A package file is generated based on the reference relationship and each sub-package file.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Encrypt and compress the packaged file according to a compression rule to generate a compressed file, wherein the compression rule includes at least one of a file type, a minimum data volume of a compressed file, a minimum compression ratio, and whether to delete the packaged file; Configuring the file format corresponding to the compressed file on the server side; The compressed file is transmitted to the server according to the file format so that the service end can obtain the compressed file from the server.
5. An interface generation method, characterized in that: The method applied to any one of claims 1 to 4, comprising: Decompress the obtained compressed file to obtain a packaged file; Rendering the initial functional component in the packaged file to generate a display interface corresponding to the initial functional component; In response to at least one import operation on the display interface, obtaining, from the packaged file, an import function component corresponding to the at least one import operation; Render at least one of the introduced functional components to generate a target interface.
6. The method according to claim 5, characterized in that The method further comprises: Receiving a configuration operation for a target interface, and acquiring configuration data corresponding to the configuration operation, wherein the configuration data includes at least one of static data of a functional component corresponding to the target interface and update data for the functional component corresponding to the target interface; The target interface is updated according to the configuration data.
7. A computing device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: The processor runs the computer program to implement the method according to any one of claims 1 to 6.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the method according to any one of claims 1 to 6.
