Plugin Implementation Method, Electronic Device, and Storage Medium for Multi-Version Applications
By creating basic content distributors and sub-content distributors in multi-version application plug-ins, separating the functions to be updated from version judgment logic, solving the problems of large amount of code and poor readability in the existing technology, and improving the plug-in loading speed and reducing the code maintenance cost.
Patent Information
- Application Number
- CN202210181784.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-25
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2042-02-25
AI Technical Summary
When implementing multi-version application plug-ins in the prior art, it requires frequent version judgment, resulting in huge code volume, poor readability, and high maintenance costs.
By creating a basic content distributor and a sub-content distributor, the functions to be updated are logically separated from the version judgment logic, and the differences between application versions are extracted, and the sub-content distributors are distributed uniformly.
It reduces the amount of code in the plug-in that needs to judge the version multiple times, improves the plug-in loading speed, and reduces the code maintenance cost.
Smart Images

Figure CN114546457B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software technology, and particularly to a method for implementing a plug-in for multi-version applications, an electronic device, and a storage medium. Background Art
[0002] Pluginization is a solution for dynamically upgrading app functions, which can achieve the effect of updating some functions without upgrading the app, and users are unaware. However, considering that different clients use different versions of the app, the same plugin needs to be adapted to different versions of the app. As the number of app iterations increases, the number of app versions increases, and the adaptation work of the plugin also increases accordingly. When making modifications such as adding, deleting, or modifying some functions in the plugin, each version of the app to which the plugin is distributed must be taken into account. The prior art uses conditional statements such as if and else to make judgments at each place where version differentiation is required, and writes corresponding different processing statements according to different versions. For example, when the app version is judged to be version 1, the corresponding processing for version 1 is written; when the app version is judged to be version 2, the corresponding processing for version 2 is written, etc. When the plugin contains multiple different function modifications, each function needs to judge the version, resulting in a large amount of code in the plugin and extremely poor code readability. Summary of the Invention
[0003] In view of the above problems, the present invention is proposed to provide a method for implementing a plug-in for multi-version applications, an electronic device, and a storage medium that overcome the above problems or at least partially solve the above problems.
[0004] According to one aspect of the present invention, there is provided a method for implementing a plug-in for multi-version applications, which includes:
[0005] Create a basic content distributor, where the basic content distributor is created according to the classification of functions to be updated;
[0006] Based on the basic content distributor and multiple versions of the application, create respective sub-content distributors based on the differences between different versions;
[0007] Obtain the version of the application to be updated, and determine the sub-content distributor corresponding to the version, so as to execute the sub-content distributor in the plugin to update the plugin.
[0008] According to another aspect of the present invention, there is provided an electronic device, including: a processor, a memory, a communication interface, and a communication bus, and the processor, the memory, and the communication interface complete communication with each other through the communication bus;
[0009] The memory is used to store at least one executable instruction, and the executable instruction causes the processor to perform the following operations:
[0010] Create a basic content distributor, where the basic content distributor is created according to the classification of functions to be updated;
[0011] Based on the basic content distributor and multiple versions of the application, create respective sub-content distributors based on the differences between different versions;
[0012] Obtain the version of the application to be updated, determine the sub-content distributor corresponding to the version, so as to execute the sub-content distributor in the plugin for plugin update.
[0013] According to another aspect of the present invention, there is provided a computer storage medium storing at least one executable instruction, and the executable instruction causes the processor to perform the operations corresponding to the method for implementing a plugin of a multi-version application as described in any one of the above.
[0014] According to the method for implementing a plugin of a multi-version application, the electronic device and the storage medium provided by the present invention, by creating sub-content distributors for different versions, separating the differences between application versions and uniformly distributing them by the sub-content distributors, the plugin can be updated based on the sub-content distributors for different versions, improving the plugin loading speed, reducing the amount of code that needs to judge the version multiple times in the plugin, and reducing the code maintenance cost.
[0015] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable, the specific embodiments of the present invention are specifically given below. Brief Description of the Drawings
[0016] By reading the detailed description of the preferred embodiments below, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present invention. And throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:
[0017] Figure 1 Shows a schematic flowchart of a method for implementing a plugin of a multi-version application according to an embodiment of the present invention;
[0018] Figure 2 Shows a schematic flowchart of a method for implementing a plugin of a multi-version application according to another embodiment of the present invention;
[0019] Figure 3 Shows a schematic structural diagram of an electronic device according to an embodiment of the present invention. Detailed Description of the Embodiments
[0020] Embodiment 1
[0021] Figure 1The flowchart shows the implementation method of the plug-in for the multi-version application according to an embodiment of the present invention, as Figure 1 shown. The method includes the following steps:
[0022] Step S101: Create a basic content distributor.
[0023] When the plug-in upgrades the application App, it can update different functions. Considering that there are multiple versions of the application App and different users use different versions, the plug-in also needs to be adapted to multiple different versions, resulting in that in addition to the code of the function to be updated, the plug-in also needs to include the logical code for version judgment. Especially when there are multiple functions to be updated in the plug-in, the version needs to be judged in each function to be updated, and the version judgment logical code needs to be repeated multiple times, and the version judgment logical code is mixed with the code of the function to be updated, resulting in a large amount of code and a high cost of code maintenance.
[0024] In this embodiment, considering the above problems, a basic content distributor is created according to the classification of the functions to be updated. In the basic content distributor, the code of the function to be updated can be separated from the logical code for version judgment, so that the function to be updated only contains the code of the function to be updated, without including the logical code for version judgment in each function to be updated, with clear logic, strong code readability, and convenient for subsequent maintenance.
[0025] The basic content distributor is used to implement the functions to be updated. According to different functions to be updated, it can include, for example, a layout parameter distributor, a view distributor, a link jump distributor, etc. The layout parameter distributor is used to update the page layout. For example, for the book list page, the length and width parameters of the book cover can be set, etc.; the view distributor is used to update the page view, such as the page view is displayed in the n*m format, etc.; the link jump distributor is used to update different links, such as adding a jump link when there is no jump in the original page. The above are examples for illustration, and specific corresponding distributors are created according to the functions to be updated in the actual implementation.
[0026] Step S102: Based on the basic content distributor and multiple versions of the application, create respective sub-content distributors based on the differences between different versions.
[0027] For multiple existing versions of an application, in this embodiment, based on the differences between different versions, respective sub-content distributors are created for different versions. The sub-content distributors are created based on the basic content distributor, and the differential content of different versions is separately extracted into the sub-content distributors corresponding to each version. Specifically, for example, the basic content distributor can be implemented in ways such as interfaces and abstract classes. The sub-content distributors can inherit the basic content distributor through inheritance methods, and perform re-assignment of values, content rewriting, etc. on the differential content of each version. For example, the differential content of different versions: for app version 3.0, the book cover needs to be set to a right-angle display with a length of 102 dp and a width of 70 dp; for app version 3.0, the book cover needs to be set to a rounded corner with a length of 102 dp and a width of 70 dp; for app version 4.0, the book cover needs to be set to a rounded corner with a length of 80 dp, a width of 50 dp, and a shadow, etc. According to the differential content of different versions, it is separately implemented in the sub-content distributors corresponding to different versions. After the sub-content distributors inherit the basic content distributor, the length, width, and assignment of right angle / rounded corner / shadow are re-set for the differential content, or relevant methods are re-assigned, etc., to obtain the sub-content distributors corresponding to different versions. The sub-content distributors have separately implemented the differential content of different versions, and no longer need to judge the version, greatly reducing the amount of code, improving the readability of the code, and also reducing the code maintenance cost.
[0028] Step S103, obtain the version of the application to be updated, and determine the sub-content distributor corresponding to the version, so as to execute the sub-content distributor in the plugin for plugin update.
[0029] When the plugin is specifically executed, the version of the application to be updated currently on the client is obtained, and the sub-content distributor corresponding to this version is determined. In the plugin, only this sub-content distributor can be loaded for execution, improving the plugin loading speed and also avoiding problems such as a large amount of content being loaded and occupying storage space.
[0030] According to the plugin implementation method for multi-version applications provided by the present invention, by creating sub-content distributors for different versions, the differences between application versions are extracted and uniformly distributed by the sub-content distributors. The plugin can be updated based on the sub-content distributors of different versions, improving the plugin loading speed, reducing the amount of code that needs to judge the version multiple times in the plugin, and reducing the code maintenance cost.
[0031] Embodiment 2
[0032] Figure 2 Shows a schematic flowchart of a plugin implementation method for multi-version applications according to another embodiment of the present invention, as Figure 2 shown, the method includes the following steps:
[0033] Step S201, pre-configure multiple different versions of the application.
[0034] The application has multiple different versions, and the plugin needs to be adapted to different versions. Corresponding versions can be pre-configured. For example, int[] VERSIONS = new int[]{V300, V312, V350, V400}, and the version to be adapted when using the plugin can be configured.
[0035] Step S202, create a basic content dispatcher.
[0036] This step refers to the description of step S101 in Embodiment 1 and will not be elaborated here.
[0037] Step S203, inherit the basic content dispatcher and generate corresponding sub-content dispatchers for each version according to the differential content of different versions.
[0038] When generating the sub-content dispatcher, considering that among multiple versions of the application, there are cases where there is no differential content for certain functions such as layout parameters between some versions. At this time, the multiple versions can be classified by the functional differential content between the versions, and the multiple versions with the same functional content can be classified, such as being classified into the same specified version, without having to adapt each version one by one, reducing the code amount of the plugin and the number of subsequent sub-content dispatchers, etc.
[0039] Specifically, classification can be performed during version judgment:
[0040] switch(version){
[0041] case 300:
[0042] case 312:
[0043] viewParamsDispatcher = new ViewParamsDispatcher300();
[0044] break;
[0045] case 350:
[0046] viewParamsDispatcher = new ViewParamsDispatcher350();
[0047] break;
[0048] case 400:
[0049] viewParamsDispatcher = new ViewParamsDispatcher400();
[0050] break;
[0051] …
[0052] }
[0053] Among them, "version" refers to the version. When it is determined that the version is any version from 300 to 312, it is classified into the sub-content dispatcher that executes ViewParamsDispatcher300, and there is no need to generate a corresponding sub-content dispatcher for each intermediate version, saving the number of sub-content dispatchers. For versions with content of functional differences, such as version 350, version 400, etc., no differential classification is performed, and a corresponding sub-content dispatcher is generated for them. The above code is for illustrative purposes, and the specific implementation can be completed according to the implementation situation using any code language to write the corresponding code according to the description of this embodiment, which is not limited here.
[0054] The sub-content dispatchers corresponding to different versions can inherit the basic content dispatcher and reassign values or override content methods for the content of functional differences in their respective versions.
[0055] In step S204, obtain the version of the application to be updated for version judgment, determine the sub-content dispatcher corresponding to the version, and after instantiating the sub-content dispatcher, send the plugin for update.
[0056] After the plugin is sent to the application on the client, obtain the version of the application to be updated, and compare the version of the application to be updated with the classified versions configured in advance, so as to determine the sub-content dispatcher corresponding to the version. For example, obtain the version of the application to be updated on the client and compare it with multiple different versions of the application configured in advance. When comparing, compare in order from the highest version to the lowest version of the multiple versions of the application configured in advance. When the version of the application to be updated is greater than or equal to a certain version of the application configured in advance, such as version 350, determine that version 350 is the version of the corresponding sub-content dispatcher; if the version of the application to be updated is less than version 350, continue to compare it with other versions of the application configured in advance that are lower than version 350 until a certain version of the application configured in advance that is greater than or equal to is found, so as to determine the version of the corresponding sub-content dispatcher. The above is for illustrative purposes, and the specific implementation can be completed according to the implementation situation using any code language to write the corresponding code according to the description of this embodiment, which is not limited here.
[0057] After determining the corresponding version, as shown in the code in step S203, if the version of the application to be updated is 350, then the ViewParamsDispatcher350 in version 350 (case 350) is instantiated to distribute the plug-in for function update. There is no need to instantiate the sub-content dispatchers of other versions, which improves the plug-in loading speed. Without loading the sub-content dispatchers of other versions, it also reduces the storage space occupied by the client to store the plug-ins.
[0058] Furthermore, in this embodiment, the call entry of the plug-in is the basic content dispatcher. For example, if the basic content dispatcher is named baseDispatcher, directly call baseDispatcher.getViewParamsDispatcher().coverWidth. getViewParamsDispatcher().coverWidth is to obtain the broadband setting of the layout parameter dispatcher included in the basic dispatcher. By determining the version of the application to be updated, the layout parameter dispatcher of the sub-content dispatcher corresponding to the version, such as ViewParamsDispatcher350, is instantiated, and the width can be reassigned according to the different content of the version, and the broadband setting of the layout parameters in version 350 can be obtained, so as to realize the update of the layout parameters in version 350. The plug-in uniformly calls the basic content dispatcher, without having to make multiple judgments on the different functional difference content of different versions. The different version difference content is implemented in the sub-content dispatcher, which also separates the code of different versions, facilitating the code maintenance of each version, and greatly improving the readability and maintainability of the code.
[0059] According to the method for implementing a plug-in for multi-version applications provided by the present invention, multiple different versions of the application are pre-configured, and the difference classification is performed on multiple versions through the functional difference content between versions. Classifying multiple versions with the same functional content can reduce the code amount of the plug-in and the number of generated sub-content dispatchers. The plug-in uniformly calls the basic content dispatcher, reducing the judgment of different versions, greatly reducing the amount of code writing, and the different version difference content can be implemented in the sub-content dispatcher corresponding to each version, separating the code of each version, making the code of each version independent, with strong readability and convenient code maintenance.
[0060] Embodiment Three
[0061] Embodiment 3 of the present application provides a non-volatile computer storage medium, and the computer storage medium stores at least one executable instruction, and the computer executable instruction can execute the method for implementing a plug-in for multi-version applications in any of the above method embodiments.
[0062] The executable instruction can specifically be used to cause the processor to perform the following operations:
[0063] Create a basic content distributor, where the basic content distributor is created according to the classification of functions to be updated; according to the basic content distributor and multiple versions of the application, create respective sub-content distributors based on the differences between different versions; obtain the version of the application to be updated, and determine the sub-content distributor corresponding to the version, so as to execute the sub-content distributor in the plugin to update the plugin.
[0064] In an alternative embodiment, the executable instructions further cause the processor to perform the following operations: create a basic content distributor according to the function to be updated; where the basic content distributor includes a layout parameter distributor, a view distributor, and / or a link jump distributor; the basic content distributor is used to implement the function to be updated.
[0065] In an alternative embodiment, the executable instructions further cause the processor to perform the following operations: inherit the basic content distributor, and generate sub-content distributors corresponding to each version according to the differential content of different versions, where after inheriting the basic content distributor, the sub-content distributor reassigns and / or rewrites the differential content.
[0066] In an alternative embodiment, the executable instructions further cause the processor to perform the following operations: pre-configure multiple different versions of the application; classify the differences between multiple versions according to the differential function content between versions, classify the versions with the same function content, and create a sub-content distributor for the classified versions.
[0067] In an alternative embodiment, the executable instructions further cause the processor to perform the following operations: obtain the version of the application to be updated for version judgment, determine the sub-content distributor corresponding to the version; instantiate the sub-content distributor and then send it to the plugin for update.
[0068] Embodiment 4
[0069] Figure 3 Fig. shows a schematic structural diagram of an electronic device according to Embodiment 4 of the present invention. The specific embodiments of the present invention do not limit the specific implementation of the electronic device.
[0070] As Figure 3 shown, the electronic device may include: a processor 302, a communications interface 304, a memory 306, and a communication bus 308.
[0071] Wherein:
[0072] The processor 302, the communications interface 304, and the memory 306 communicate with each other through the communication bus 308.
[0073] A communication interface 304 for communicating with network elements of other devices such as clients or other servers.
[0074] A processor 302 for executing a program 310, which can specifically execute the relevant steps in the embodiments of the method for implementing a plug-in of the multi-version application described above.
[0075] Specifically, the program 310 may include program code, and the program code includes computer operation instructions.
[0076] The processor 302 may be a central processing unit (CPU), or a specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. One or more processors included in the server may be of the same type of processor, such as one or more CPUs; or they may be of different types of processors, such as one or more CPUs and one or more ASICs.
[0077] A memory 306 for storing the program 310. The memory 306 may include high-speed RAM memory and may also include non-volatile memory, such as at least one disk memory.
[0078] The program 310 is specifically configured to cause the processor 302 to perform the following operations:
[0079] Create a basic content distributor, where the basic content distributor is created according to the classification of functions to be updated; according to the basic content distributor and multiple versions of the application, create respective sub-content distributors based on the differences between different versions; obtain the version of the application to be updated, and determine the sub-content distributor corresponding to the version, so as to execute the sub-content distributor in the plug-in for plug-in update.
[0080] In an alternative embodiment, the program 310 is configured to cause the processor 302 to create a basic content distributor according to the function to be updated; wherein, the basic content distributor includes a layout parameter distributor, a view distributor, and / or a link jump distributor; and the basic content distributor is used to implement the function to be updated.
[0081] In an alternative embodiment, the program 310 is configured to cause the processor 302 to inherit the basic content distributor and generate sub-content distributors corresponding to each version according to the difference content of different versions. After inheriting the basic content distributor, the sub-content distributor reassigns and / or rewrites the difference content.
[0082] In an alternative embodiment, the program 310 is configured to cause the processor 302 to pre-configure multiple different versions of an application; classify the multiple versions according to the functional differences between the versions, classify the versions with the same functional content, and create a sub-content distributor for the classified versions.
[0083] In an alternative embodiment, the program 310 is configured to cause the processor 302 to obtain the version of the application to be updated for version judgment, determine the sub-content distributor corresponding to the version; instantiate the sub-content distributor and then distribute the plug-in for update.
[0084] For the specific implementation of each step in the program 310, reference may be made to the corresponding descriptions in the corresponding steps in the above-mentioned plug-in implementation embodiments of the multi-version application, which will not be elaborated here. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding process descriptions in the foregoing method embodiments, which will not be elaborated here.
[0085] Through the solution provided in this embodiment, by creating sub-content distributors for different versions, the differences between application versions are extracted and uniformly distributed by the sub-content distributors. The plug-in can be updated based on the sub-content distributors of different versions, which improves the plug-in loading speed, reduces the amount of code that needs to judge the version multiple times in the plug-in, and reduces the code maintenance cost.
[0086] In the specification provided here, a large number of specific details are described. However, it can be understood that the embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures, and technologies are not shown in detail so as not to obscure the understanding of this specification.
[0087] Similarly, it should be understood that, in order to streamline the present disclosure and assist in understanding one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be construed as reflecting the intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected by the claims, the inventive aspects lie in less than all the features of the preceding disclosed single embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into the detailed description, where each claim stands on its own as a separate embodiment of the present invention.
[0088] Those skilled in the art can understand that the modules in the devices in the embodiments can be adaptively changed and arranged in one or more devices different from those of the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and in addition, they can be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and / or processes or units are mutually exclusive, any combination can be adopted to combine all the features disclosed in this specification (including the accompanying claims, abstract and drawings) and all the processes or units of any method or device so disclosed. Unless otherwise explicitly stated, each feature disclosed in this specification (including the accompanying claims, abstract and drawings) can be replaced by an alternative feature that provides the same, equivalent or similar purpose.
[0089] In addition, those skilled in the art can understand that although some of the embodiments described herein include certain features included in other embodiments rather than other features, the combination of the features of different embodiments means that it is within the scope of the present invention and forms different embodiments. For example, in the claims, any one of the claimed embodiments can be used in any combination.
[0090] It should be noted that the above embodiments illustrate the present invention rather than limit the present invention, and those skilled in the art can design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in the claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention can be implemented by means of hardware including several different elements and by means of a suitably programmed computer. The use of the words first, second, and third, etc. does not denote any order. These words can be interpreted as names.
Claims
1. A method for implementing a plug-in for a multi-version application, which includes: Create a basic content dispatcher according to the function to be updated, wherein the basic content dispatcher is created according to the classification of the function to be updated; the basic content dispatcher includes a layout parameter dispatcher, a view dispatcher, and / or a link jump dispatcher; the basic content dispatcher is used to implement the function to be updated; Pre-configure multiple different versions of the application; Create respective sub-content dispatchers based on the differences between different versions according to the basic content dispatcher and the multiple versions of the application; Obtain the version of the application to be updated, determine the sub-content dispatcher corresponding to the version, so as to execute the sub-content dispatcher in the plug-in for plug-in update; wherein, the call entry of the plug-in is the basic content dispatcher; after the sub-content dispatcher is instantiated, the plug-in is sent for function update; The step of creating respective sub-content dispatchers based on the differences between different versions according to the basic content dispatcher and the multiple versions of the application further includes: Classify the differences of multiple versions according to the functional difference content between versions, classify the versions with the same functional content, and create sub-content dispatchers for the classified versions.
2. The method according to claim 1, wherein, The step of creating respective sub-content dispatchers based on the differences between different versions according to the basic content dispatcher and the multiple versions of the application is specifically: Inherit the basic content dispatcher, and generate sub-content dispatchers corresponding to each version according to the difference content of different versions. After inheriting the basic content dispatcher, the sub-content dispatcher reassigns and / or rewrites the difference content.
3. An electronic device, including: A processor, a memory, a communication interface, and a communication bus. The processor, the memory, and the communication interface complete communication with each other through the communication bus; The memory is used to store at least one executable instruction, and the executable instruction causes the processor to perform the following operations: Create a basic content dispatcher according to the function to be updated, wherein the basic content dispatcher is created according to the classification of the function to be updated; the basic content dispatcher includes a layout parameter dispatcher, a view dispatcher, and / or a link jump dispatcher; the basic content dispatcher is used to implement the function to be updated; Pre-configure multiple different versions of the application; Create respective sub-content dispatchers based on the differences between different versions according to the basic content dispatcher and the multiple versions of the application; Obtain the version of the application to be updated, determine the sub-content dispatcher corresponding to the version, so as to execute the sub-content dispatcher in the plug-in for plug-in update; wherein, the call entry of the plug-in is the basic content dispatcher; after the sub-content dispatcher is instantiated, the plug-in is sent for function update; The step of creating respective sub-content dispatchers based on the differences between different versions according to the basic content dispatcher and the multiple versions of the application further includes: Classify the differences of multiple versions according to the functional difference content between versions, classify the versions with the same functional content, and create sub-content dispatchers for the classified versions.
4. The electronic device according to claim 3, wherein the executable instructions further cause the processor to perform the following operations: Inherit the basic content distributor, and generate sub-content distributors corresponding to different versions according to the differential content of different versions, wherein, After inheriting the basic content distributor, the sub-content distributor reassigns and / or rewrites the differential content.
5. A computer storage medium, in which at least one executable instruction is stored, and the executable instruction causes the processor to perform operations corresponding to the plug-in implementation method of the multi-version application according to claim 1 or 2.
Citation Information
Patent Citations
Version updating method and device
CN113448602A