Component-based picture resource integration method and device, equipment and storage medium
By generating global resource mapping tables and classified reading codes, the naming conflicts and configuration path errors in image resource management in component development are solved, and the accurate loading and display of image resources during component merging is achieved.
Patent Information
- Application Number
- CN202510588882.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-08-15
AI Technical Summary
In component development, there are naming conflicts and configuration path errors in image resource management when component merging, resulting in inaccurate reference of image resources by the application and affecting the user experience.
By traversing the component's root directory, obtaining configuration files and image resource directories, generating global resource mapping tables and classification reading codes, analyzing component relationship lists, and using classification reading code to integrate binary libraries and resource packages to ensure the correct loading of image resources.
It solves the problem of image resource naming conflicts and configuration path errors, improves the accuracy of image resource reference, and ensures that the application can load and display pictures correctly.
Smart Images

Figure CN120492025A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image detection technology, and in particular to a component-based image resource integration method, device, equipment and storage medium. Background Art
[0002] Component-based development is an architectural pattern that breaks large applications into multiple independent, reusable components (or modules). Each component is responsible for a specific function and can be independently developed, tested, and deployed. This development model is particularly popular in the financial industry, where it improves development efficiency, reduces maintenance costs, and makes applications more flexible and scalable.
[0003] While componentization brings many benefits to software development, in practice, when software projects enter the integration phase and need to merge these components into a complete application, they still face many challenges. These issues are particularly prominent in the development of financial applications. In the field of financial technology, component-based development is also widely used. For example, consider the "Service App," an intelligent financial management application developed by a financial technology company. This application is composed of multiple independently developed components, each responsible for a different business function:
[0004] Component A: Account management, including login, registration, profile editing and other functions.
[0005] Component B: Transaction management, including the purchase and sale of financial products such as stocks and funds.
[0006] Component C: Financial statements, including the display of income, expenditure, assets and other data.
[0007] Component D: Customer Service, including online customer service, FAQs, etc.
[0008] When these components are merged into a "service app", developers need to manually configure the image resource path for each component. Due to conflicts in the naming of image resources between different components and the different management methods of image resources by developers of each component, many problems arise when referencing these image resources in the application, such as image failure and display errors.
[0009] Component-based development is also widely used in the healthcare field. For example, a health management application called "Health Assistant" developed by a medical technology company consists of the following components:
[0010] Component E: User health record management, including user basic information, medical records, physical examination reports and other functions.
[0011] Component F: Online consultation, including real-time communication between users and doctors, appointment registration and other functions.
[0012] Component G: Health data analysis, including analysis and display of exercise data, sleep data, and diet data.
[0013] Component H: Health information push, including health science articles, disease prevention knowledge, etc.
[0014] When merging these components into the "Health Assistant" app, the same issue arises with image resource management. For example, component E and component F might both contain an image file named "logo.png," but with different content. If developers incorrectly configure the image resource path, the app might display incorrect images, impacting the user experience.
[0015] Therefore, how to improve the accuracy of image resources referenced by various components in applications is a technical problem that needs to be solved urgently. Summary of the Invention
[0016] In view of the above, it is necessary to provide a component-based image resource integration method, which aims to avoid naming conflicts, configuration path errors and resource reference problems of image resources in component merging, and improve the accuracy of referencing image resources.
[0017] In a first aspect, a component-based image resource integration method is provided, comprising:
[0018] Receive a request to integrate image resources of a target application, traverse the root directory of each component of the target application according to the request, and obtain the configuration file and image resource directory corresponding to each component;
[0019] Extract the image name, image type, and image path of each image file from the image resource directory, create a global resource mapping table based on the image names, image types, and image paths of all image files, and generate a classified reading code for loading each image file based on the global resource mapping table;
[0020] Parse the configuration file corresponding to each component to obtain the component name, component path, dependency relationship, and reference attributes of the image files contained in each component; and generate a component relationship list between each component and other components based on the component name, component path, dependency relationship, and reference attributes of the image files contained in each component;
[0021] Execute predefined compilation commands on each component according to the component relationship list to obtain the binary library and resource package of each component, and use the classification reading code to integrate the binary libraries and resources of all components into the target application.
[0022] In a second aspect, a component-based image resource integration device is provided, comprising:
[0023] An acquisition module is configured to receive a request for integrating image resources of a target application, traverse the root directory of each component of the target application according to the request, and obtain the configuration file and image resource directory corresponding to each component;
[0024] A creation module is used to extract the image name, image type and image path of each image file from the image resource directory, create a global resource mapping table based on the image name, image type and image path of all image files, and generate a classification reading code for loading each image file based on the global resource mapping table;
[0025] A parsing module is used to parse the configuration file corresponding to each component to obtain the component name, component path, dependency relationship and reference attributes of the image files contained in each component, and generate a component relationship list between each component and other components based on the component name, component path, dependency relationship and reference attributes of the image files contained in each component;
[0026] The merging module is used to execute a predefined compilation command on each component according to the component relationship list to obtain the binary library and resource package of each component, and use the classification reading code to integrate the binary libraries and resources of all components into the target application.
[0027] In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned component-based image resource integration method when executing the computer program.
[0028] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned component-based image resource integration method are implemented.
[0029] Compared with the existing technology, the present invention automatically generates a set of classification reading codes for unified image resource access logic based on the image resource information of each component, and uses the classification reading code for each image file to ensure that the image resource names within the component are the same and can be loaded correctly.
[0030] Compile commands are executed for each component based on the component relationship list to generate binary libraries and resource packages. Classification reading code is used to integrate the binary libraries and resources into components of the target application. Whenever a new component is added or the image resources of an existing component change, the classification reading code can be rerun to automatically generate the latest image resource access logic, ensuring that the target application can correctly reference image resources.
[0031] This solves the problems of naming conflicts and configuration path errors of image resources that occur when applications reference image resources in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 1 is a schematic diagram of an application environment of a component-based image resource integration method according to an embodiment of the present invention;
[0033] Figure 2 A schematic diagram of a process flow of a component-based image resource integration method provided by one embodiment of the present invention;
[0034] Figure 3 A schematic diagram of a module of a component-based image resource integration device provided by an embodiment of the present invention;
[0035] Figure 4 A schematic diagram of the structure of a computer device according to an embodiment of the present invention;
[0036] Figure 5 FIG. 2 is another structural diagram of a computer device according to an embodiment of the present invention.
[0037] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0039] It should be noted that the descriptions of "first", "second", etc. in the present invention are for descriptive purposes only and should not be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include at least one of such features. In addition, the technical solutions between the various embodiments can be combined with each other, but this must be based on the fact that they can be implemented by ordinary technicians in this field. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0040] The component-based image resource integration method provided by the embodiment of the present invention can be applied in Figure 1In an application environment, the client communicates with the server through a network. After receiving a request from the client for integrating the image resources of the target application, the server can traverse the root directory of each component of the target application according to the request to obtain the configuration file and image resource directory corresponding to each component; extract the image name, image type and image path of each image file from the image resource directory, create a global resource mapping table according to the image name, image type and image path of all image files, and generate a classification reading code for loading each image file according to the global resource mapping table; parse the configuration file corresponding to each component to obtain the component name, component path, dependency relationship and reference attributes of the image files contained in each component, and generate a component relationship list between each component and other components according to the component name, component path, dependency relationship and reference attributes of the image files contained in each component; execute a predefined compilation command on each component according to the component relationship list to obtain the binary library and resource package of each component, and use the classification reading code to integrate the binary libraries and resources of all components into the target application. The present invention is aimed at the fields of financial enterprises, medical health, market analysis and engineering design. It uses a preset script file (Ruby script file) to automatically generate a set of classification reading codes for unified image resource access logic according to the image resource information of each component. The classification reading code is used to ensure that even if the image resource names inside the component are the same, they can be loaded correctly. According to the component relationship list, the compilation command is executed for each component to generate a binary library and resource package. The classification reading code is used to integrate the binary library and resources into the components of the target application. Whenever a new component is added or the image resources of an existing component change, the classification reading code can be re-run to automatically generate the latest image resource access logic to ensure that the target application can quickly adapt to market changes and improve the accuracy of referencing image resources. Among them, the client can be but is not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices. The server can be implemented with an independent server or a server cluster composed of multiple servers. The present invention is described in detail below through specific embodiments.
[0041] Reference Figure 2 FIG. 1 is a flow chart of a component-based image resource integration method according to an embodiment of the present invention. The method is executed by a device.
[0042] In this embodiment, the component-based image resource integration method includes:
[0043] S1. Receive a request for integrating image resources of a target application, traverse the root directory of each component of the target application according to the request, and obtain a configuration file and image resource directory corresponding to each component.
[0044] In this embodiment, when merging multiple independently developed components into a complete target application, a request to merge the components into the target application is sent to the server through the client. According to the request, the root directory of each component of the target application is traversed, and the configuration file and image resource directory of each component are obtained from the root directory, which can ensure that the configuration information and image resources of each component can be correctly processed in the subsequent merging process.
[0045] Components refer to a large application (target application) that is split into multiple independent, reusable small modules or components.
[0046] The target application is a complete application that combines the aforementioned independently developed components (or modules). It is a collection of these components that forms a complete, coherent software product. For example, if a server receives a request that includes the root directory path of each component, the server iterates over each component in the component_roots dictionary to obtain its root directory path.
[0047] In this paper, we use the financial scenario as an example: a financial enterprise is developing a financial application "Service App", which consists of the following components:
[0048] Component A: Account management, including login, registration, profile editing and other functions.
[0049] Component B: Transaction management, including the purchase and sale of financial products such as stocks and funds.
[0050] Component C: Financial statements, including the display of income, expenditure, assets and other data.
[0051] Component D: Customer Service, including online customer service, FAQs, etc.
[0052] The server receives a request to merge components A, B, C, and D into a "service app", traverses the root directory of each component of the target application according to the request, and obtains the configuration file and image resource directory path from the root directory.
[0053] In step S1, by traversing the root directory of each component of the target application according to the request, the configuration file and image resource directory of each component can be fully obtained, ensuring that no important resources of any component are missed during the merging process, thereby ensuring that the final generated target application is complete and fully functional.
[0054] S2. Extract the picture name, picture type and picture path of each picture file from the picture resource directory, create a global resource mapping table based on the picture name, picture type and picture path of all picture files, and generate a classified reading code for loading each picture file based on the global resource mapping table.
[0055] In this embodiment, a preset script file is used to traverse the image resource directory of each component to extract relevant information of each image file, including the image name, image type and image path.
[0056] The preset script file is pre-written and can be a batch script, Python script or any other suitable scripting language. In the present invention, Ruby script is preferably used as the preset script file.
[0057] The script will traverse the image resource directory of each component. For example, the image resource directory path of component A is / path / to / componentA / res / images. It will extract the following information from each image file:
[0058] Image Name: The name of the image file, for example, login_button.png.
[0059] Image type: The type of image file, such as png.
[0060] Image path: The full path of the image file, for example, / path / to / componentA / res / images / login_button.png.
[0061] Create an empty data structure (such as a dictionary or hash table) as the initial resource mapping table, add the image name, image type, and image path of each image file obtained through traversal to the initial resource mapping table to obtain a global resource mapping table. The global resource mapping table can be a dictionary or hash table, where the key is the unique identifier of the image file (for example, a combination of the image name and path), and the value is the detailed information of the image file (name, type, path).
[0062] According to the image name, image type and image path of each image file in the global resource mapping table, the classification standard of the image resource is determined. According to each image classification standard, the preset reading function library is queried to obtain the classification reading function corresponding to each image classification standard. The generated classification reading functions are combined into a reading code file to obtain the classification reading code.
[0063] The purpose of the classified read code is to generate corresponding read functions based on criteria such as image type or usage. For example, you can generate a common read function for all button images and another read function for all icon images. These read functions are combined into a read code file to ensure that all image resources can be correctly loaded and displayed in the target application.
[0064] Imagine a medical technology company developing a health management app called "Health Assistant." The app consists of multiple independently developed components, each responsible for a different business function:
[0065] Component E: User health record management, including user basic information, medical records, physical examination reports and other functions.
[0066] Component F: Online consultation, including real-time communication between users and doctors, appointment registration and other functions.
[0067] Component G: Health data analysis, including analysis and display of exercise data, sleep data, and diet data.
[0068] Component H: Health information push, including health science articles, disease prevention knowledge, etc.
[0069] Traverse the image resource directory of each component to obtain the image resource directory of each component, which is used to store image files related to the component. These image files are icons, charts, user avatars, etc. in the user interface. For example: the image resource directory of component E is / path / to / componentE / res / images, which contains user avatars, medical record icons, etc. The image resource directory of component F is / path / to / componentF / res / images, which contains doctor avatars, appointment button icons, etc. The image resource directory of component G is / path / to / componentG / res / images, which contains health data charts, sports data icons, etc. The image resource directory of component H is / path / to / componentH / res / images, which contains thumbnails of health information, application logos, etc.
[0070] In one embodiment, creating a global resource mapping table based on the picture names, picture types, and picture paths of all picture files includes:
[0071] Create an empty data structure as the initial resource mapping table;
[0072] Add the image name, image type, and image path of each image file obtained through traversal to the corresponding location item in the initial resource mapping table;
[0073] An association relationship between the picture name, picture type and picture path of each picture file is established in the initial resource mapping table to obtain the global resource mapping table.
[0074] Choose a suitable data structure to store image resource information. Common choices are dictionaries or hash tables because they provide fast lookup and insertion operations. You can create an empty dictionary as the initial resource mapping table.
[0075] Use a pre-set script file to traverse the image resource directory of each component, extract the image name, image type, and image path of each image file from the image resource directory, and add the extracted information of each image file to the initial resource mapping table to obtain the global resource mapping table. Select an appropriate key-value pair in the global resource mapping table to store this information, for example, using the image's unique identifier (such as a combination of the image name and path) as the key and the image's detailed information as the value.
[0076] In component-based development, the present invention creates and uses a global resource mapping table, which plays several important roles:
[0077] 1. Image files with the same name may appear in multiple components. For example, two components may have a file named logo.png, but the content is different. A global resource map can be used to generate a unique identifier for each image file (for example, a combination of the component name and the image name) to avoid naming conflicts. For example, ComponentA / logo.png and ComponentB / logo.png can be stored as different key-value pairs.
[0078] 2. When merging multiple components, you need to ensure that all image resources are correctly referenced and managed. The global resource map provides a centralized place to manage all image resources, allowing you to easily view and manage the information of each image file, including name, type, and path.
[0079] 3. In large applications, the number of image resources may be very large, and directly loading all resources may cause performance issues. The global resource map can be used to optimize resource loading strategies. For example, image resources can be loaded dynamically as needed instead of loading all resources at once. In addition, the global resource map can be used to quickly find and load specific image files, improving loading efficiency.
[0080] In one embodiment, generating a classification reading code for loading each image file according to the global resource mapping table includes:
[0081] Setting classification standards according to the picture name, picture type and picture path of each picture file in the global resource mapping table to obtain multiple picture classification standards;
[0082] According to each image classification standard, the preset reading function library is searched to obtain the classification reading function corresponding to each image classification standard;
[0083] The various classification reading functions are combined to obtain a function set, and the function set is converted into a code in a preset format to obtain the classification reading code.
[0084] According to the image name, image type and image path of each image file in the global resource mapping table, identify the common characteristics of the image name, image type and image path, and set classification standards based on the common characteristics. For example, set the first image classification standard based on the prefix or suffix of the image name, set the second image classification standard based on the image type, set the third image classification standard based on the image path, set the fourth image classification standard based on the component source (for example, from component A, component B, etc.), and set the fifth image classification standard based on the purpose of the image (for example, button image, icon image, background image, etc.).
[0085] According to the determined classification standard, the preset reading function library is searched to find the classification reading function corresponding to each classification standard. The reading function library is a pre-prepared library containing various types of classification reading functions.
[0086] A categorized read function is specifically designed to read and process image resources by category. In component-based development, categorized read functions are used to read and load corresponding image resources from a global resource map based on image type, usage, or other classification criteria. This allows for more efficient management and use of image resources, ensuring that images are correctly loaded and displayed in the target application.
[0087] All classification standards and their corresponding reading functions are combined into a function set, and the function set is converted into code in a preset format (for example, CommonJS module format, ES6 module format, Python or Python), ensuring that the code can correctly load and process image resources under each classification standard, thereby effectively generating classification reading code and realizing efficient management and loading of image resources.
[0088] In component-based development, the present invention has several important functions by using classification to read code:
[0089] 1. Classified loading code can efficiently manage and load different types of image resources. For example, by classifying image resources according to type, purpose, and other criteria, the classified loading code can quickly find and load the required image resources, avoiding the inefficient operation of traversing all resources.
[0090] 2. Classified read code makes the code more structured and modular. For example, by encapsulating the read logic in a classified read function, the code becomes clearer and easier to understand. When the read logic needs to be modified or expanded, only the corresponding classified read function needs to be modified, without changing the entire code base.
[0091] 3. Classified read code supports dynamic loading of image resources. For example, in large applications, loading all image resources at once may cause performance issues. By using classified read code, specific categories of image resources can be dynamically loaded as needed, improving application startup speed and operating efficiency.
[0092] In step S2, the classified reading code generates corresponding reading functions based on criteria such as image type and purpose, ensuring efficient management and loading of image resources in the target application. Even if image files with the same name exist in different components, they can still be loaded correctly. The global resource mapping table generates unique identifiers for each image file, and the classified reading code uses these unique identifiers to load images, thus avoiding naming conflicts.
[0093] S3. Parse the configuration file corresponding to each component to obtain the component name, component path, dependency relationship and reference attributes of the image files contained in each component. Based on the component name, component path, dependency relationship and reference attributes of the image files contained in each component, generate a component relationship list between each component and other components.
[0094] In this embodiment, each component has a configuration file (e.g., config.json), which contains the following information:
[0095] Component Name: A unique identifier for the component.
[0096] Component path: The root directory path of the component.
[0097] Dependencies: The names of other components that the component depends on.
[0098] Each component contains an image file reference attribute: This is the specific reference method or identifier for the image resource used within the component. Reference attributes appear in the component's source code, configuration files, or stylesheets and are used to specify which image resource to load or display. Reference attributes can include information such as the image ID or key, image path, image name, image type, image size, and image resolution.
[0099] Extract the component name, path, dependencies, and image file reference properties from each component's configuration file. Store the extracted component information in a suitable data structure, such as a dictionary or list.
[0100] Based on the extracted component information, a component relationship list is generated between each component and other components. The component relationship list contains the name of each component and the names of other components it depends on. This helps ensure the correct dependencies and order of each component when building the target application.
[0101] Continuing with the example of the healthcare scenario above, component-based development and dependency management are very important in the healthcare field. For example:
[0102] Component E (User Health Record Management): Depends on Component G (Health Data Analysis) because the user's health record may need to display some health data analysis results. Component F (Online Consultation): Depends on Component E (User Health Record Management) because doctors may need to review the user's health record during a consultation. Component H (Health Information Push): Depends on Component E (User Health Record Management) because the pushed health information may require personalized recommendations based on the user's health record.
[0103] By generating a list of component relationships between each component and other components in this way, the development team can efficiently manage and integrate the various components to ensure the functional integrity and user experience of the "Health Assistant" application.
[0104] In one embodiment, parsing the configuration file corresponding to each component to obtain the component name, component path, dependency relationship, and reference attributes of the image files contained in each component includes:
[0105] Parse the configuration file of each component and convert the parsed configuration file into the preset data structure;
[0106] The component name, component path, dependency relationship and reference attributes of the image file included in each component are extracted from the preset data structure.
[0107] Convert the parsed configuration file content into a preset data structure, such as a dictionary or object. This preset data structure can easily store and access the information in the configuration file.
[0108] Extract the component name, path, dependencies, and reference properties of the image files contained in each component from the converted data structure.
[0109] By extracting the component name and path, you can ensure that each component is correctly referenced when building the target application. The component name is a unique identifier for the component, and the path is the component's location in the file system. This information is essential for the build and integration process. The dependencies between components are critical to ensuring the correct operation of the application. By extracting the dependencies of each component, you can generate a component relationship list, clearly identifying the components each component depends on. This helps ensure that all dependent components are correctly loaded and configured during the build and deployment process, avoiding build failures or runtime errors caused by incorrect dependencies.
[0110] By extracting the reference properties (such as name and path) of the image files contained in each component, a component relationship list can be generated. This allows for optimization of resource loading strategies. For example, specific categories of image resources can be dynamically loaded instead of loading all resources at once, thereby improving application startup speed and operational efficiency.
[0111] In one embodiment, generating a component relationship list between each component and other components based on the component name, component path, dependency, and reference attributes of the image file contained in each component includes:
[0112] Create an empty initial list, and add the component name, the component path, the dependency, and the reference attribute to the corresponding position item in the initial list;
[0113] Establishing associations among the component names, component paths, dependencies, and reference attributes in the initial list;
[0114] The associated initial list is converted into a file in a preset format to obtain a component relationship list between each component and other components.
[0115] Create an empty initial list and add the component name, component path, dependency, and reference properties to the corresponding positional items in the initial list. Associate the component name, component path, dependency, and reference properties in the initial list, and convert the associated initial list into a file in a pre-defined format, such as JSON. JSON is a lightweight data exchange format that is easy to read and write, and also easy for machines to parse and generate.
[0116] Output the converted JSON data to a file and generate a list of component relationships between each component and other components.
[0117] In component-based development, the component relationship list plays several important roles in the present invention:
[0118] 1. The component relationship list can track the dependencies between components. For example, through the component relationship list, you can clearly see which other components each component depends on, which helps to ensure that all dependent components are loaded and configured correctly during the build and deployment process.
[0119] 2. The component relationship list ensures that components are loaded in the correct order when building the target application. For example, during the build process, dependencies determine the order in which components are loaded. For example, if component A depends on component B, component B must be loaded before component A. The component relationship list provides information about these dependencies, ensuring that the build tool can load components in the correct order.
[0120] 3. The component relationship list helps optimize resource loading and management. For example, by understanding the dependencies between components, you can optimize resource loading strategies. You can prioritize loading core components and their dependent resources, thereby improving application startup speed and performance.
[0121] S4. Execute a predefined compilation command on each component according to the component relationship list to obtain a binary library and resource package of each component, and use the classification reading code to integrate the binary libraries and resources of all components into the target application.
[0122] In this embodiment, the component name, component path and dependency relationship in the component relationship list are used to execute a predefined compilation command for each component. The compilation command includes steps such as compiling the source code of each component, packaging resource files, etc., to generate a binary library and resource package for each component.
[0123] A binary library is a pre-compiled file that can be linked and used directly by other programs or libraries. A binary library contains pre-compiled code and data that can be loaded and used at runtime without recompiling the source code.
[0124] A resource package is a collection of files containing various non-code resources required by an application. These resources include images, audio, video, configuration files, localized strings, and more. Resource packages are crucial in software development because they help developers separate resource files from source code, improving project organization and maintainability.
[0125] After compilation is complete, each component generates a binary library (such as a .so file) and a resource package (such as a directory containing images, configuration files, etc.). These binary libraries and resource packages are the files required for the component to run in the target application.
[0126] Use the classification reading code to integrate the generated binary library and resources into the target application. The classification reading code is responsible for loading and managing resources according to the resource classification standards (such as image type and purpose), ensuring that the resources are used correctly in the target application.
[0127] Continuing with the financial scenario above, let's assume a financial enterprise is developing a comprehensive financial services application called a "Service App." This application consists of multiple independently developed components, each responsible for a different business function. To ensure the "Service App" can smoothly integrate these components and resolve issues like image resource naming conflicts and configuration path errors during the integration process, the following implementation steps are required:
[0128] Component A: Account management, including login, registration, profile editing and other functions.
[0129] Component B: Transaction management, including the purchase and sale of financial products such as stocks and funds.
[0130] Component C: Financial statements, including the display of income, expenditure, assets and other data.
[0131] Component D: Customer Service, including online customer service, FAQs, etc.
[0132] When the development team decides to merge these four components into a "service app," they send a merge request to the server. Upon receiving the request, they begin traversing the root directory of each component of the target application, obtaining each component's configuration file (e.g., config.json) and image resource directory (e.g., / res / images / ).
[0133] Use a pre-set script file (such as a Ruby script) to traverse the image resource directory of each component, extract the name, type, and path of each image file, and create a global resource map. For example, for an image file named login_button.png in component A, add its information to the global resource map to ensure that even if there is a file named login_button.png in other components, it can be distinguished by different paths.
[0134] Next, the component configuration file is parsed to extract the component name, path, dependencies, and image file reference properties. A component relationship list is generated based on this information to ensure that all component dependencies are correctly handled when building the "service app." For example, if component B depends on component A, the component relationship list will clearly indicate this, ensuring that component A is loaded before component B during the build process.
[0135] Finally, predefined compilation commands are executed for each component based on the component relationship list to generate each component's binary library (such as a .so file) and resource package (such as a directory containing images, configuration files, etc.). These binary libraries and resources are integrated into the "Service App" using the previously generated classification reading code. The classification reading code is responsible for loading and managing resources based on image classification standards (such as type and purpose), ensuring that all image resources are displayed correctly in the "Service App."
[0136] In one embodiment, executing a predefined compilation command on each component according to the component relationship list to obtain a binary library and resource package of each component includes:
[0137] Extracting the component name, component path and dependency relationship of each component from the component relationship list;
[0138] Determine the compilation order of each component based on dependencies;
[0139] The component path of each component is mapped and associated with the root directory of the corresponding component. According to the mapping association and the component name, a predefined compilation command is executed on each component in the compilation order to generate a binary library and resource package for each component.
[0140] Extract the component name, component path, and dependencies of each component from the component relationship list. The component name, component path, and dependencies are the basis for subsequent compilation and integration.
[0141] The compilation order of each component is determined based on the dependencies between components. The compilation order ensures that all dependent components have been compiled before compiling a component.
[0142] Map the component path of each component to the root directory of the corresponding component. Mapping helps to correctly find the source code and resource files of each component during the compilation process.
[0143] Based on the mapping association and component name, the predefined compilation command is executed for each component in the compilation order. The compilation command includes steps such as compiling source code and packaging resource files to generate a binary library and resource package for each component.
[0144] In one embodiment, the utilizing the classified read code to integrate binary libraries and resources of all components into the target application includes:
[0145] Loading the classification reading code into the root directory of the target application;
[0146] Create a binary library directory and a resource package directory of the target application in the root directory of the target application;
[0147] The loaded classification reading code is used to copy the binary library of each component to the binary library directory, and to copy the resource package of each component to the resource package directory.
[0148] Copy or move the code file of the classification reading code (for example, read_resources.py) to the root directory of the target application to ensure that the classification reading code can be accessed and used in the target application.
[0149] Create two directories in the target application's root directory: one for storing binary libraries and the other for storing resource bundles. For example, create a lib directory for storing binary libraries and a res directory for storing resource bundles.
[0150] Use the classified reading code to copy the binary library of each component to the binary library directory. Use the classified reading code to copy the resource bundle of each component to the resource bundle directory. During the merging process, the classified reading code removes duplicate resource bundles, reduces the size of the target application, speeds up the loading of the application, and improves the user experience. Specifically, the resource bundle of each component is copied to the res directory. During the copying process, the classified reading code checks whether the resource bundle already exists. If so, the file is skipped to avoid duplicate copying. Hash values or other unique identifiers are used to detect the duplication of resource bundles. For example, the MD5 hash value of each resource bundle is calculated. If a resource bundle with the same hash value is found, it is considered a duplicate resource bundle and the copying is skipped.
[0151] In steps S1-S4, the present invention uses a preset script file to automatically generate a set of unified classification reading codes for image resource access logic based on the image resource information of each component. The classification reading codes are used to ensure that the image resource names within the components are the same and can be loaded correctly.
[0152] Compile commands are executed for each component based on the component relationship list to generate binary libraries and resource packages. Classification reading code is used to integrate the binary libraries and resources into components of the target application. Whenever a new component is added or the image resources of an existing component change, the classification reading code can be re-run to automatically generate the latest image resource access logic, ensuring that the target application can quickly adapt to market changes.
[0153] This solves the problems of naming conflicts and configuration path errors of image resources that occur when applications reference image resources in the prior art.
[0154] like Figure 3 FIG. 1 is a module diagram of a component-based image resource integration device provided by an embodiment of the present invention.
[0155] The component-based image resource integration device 100 described in the present invention can be installed in a device. Depending on the functionality implemented, the component-based image resource integration device 100 may include an acquisition module 110, a creation module 120, a parsing module 130, and a merging module 140. A module, also referred to as a unit, is a series of computer program segments that can be executed by a device processor and perform a fixed function, and is stored in the device's memory.
[0156] In this embodiment, the functions of each module / unit are as follows:
[0157] The acquisition module 110 is configured to receive a request for integrating image resources of a target application, traverse the root directory of each component of the target application according to the request, and obtain a configuration file and image resource directory corresponding to each component;
[0158] A creation module 120 is configured to extract the image name, image type, and image path of each image file from the image resource directory, create a global resource mapping table based on the image names, image types, and image paths of all image files, and generate a classification read code for loading each image file based on the global resource mapping table;
[0159] The parsing module 130 is configured to parse the configuration file corresponding to each component to obtain the component name, component path, dependency relationship, and reference attributes of the image files contained in each component, and generate a component relationship list between each component and other components based on the component name, component path, dependency relationship, and reference attributes of the image files contained in each component;
[0160] The merging module 140 is used to execute a predefined compilation command on each component according to the component relationship list to obtain the binary library and resource package of each component, and use the classification reading code to integrate the binary libraries and resources of all components into the target application.
[0161] In one embodiment, the creation module 120 is specifically configured to:
[0162] Create an empty data structure as the initial resource mapping table;
[0163] Add the image name, image type, and image path of each image file obtained through traversal to the corresponding location item in the initial resource mapping table;
[0164] An association relationship between the picture name, picture type and picture path of each picture file is established in the initial resource mapping table to obtain the global resource mapping table.
[0165] In one embodiment, the creation module 120 is specifically configured to:
[0166] Setting classification standards according to the picture name, picture type and picture path of each picture file in the global resource mapping table to obtain multiple picture classification standards;
[0167] According to each image classification standard, the preset reading function library is searched to obtain the classification reading function corresponding to each image classification standard;
[0168] The various classification reading functions are combined to obtain a function set, and the function set is converted into a code in a preset format to obtain the classification reading code.
[0169] In one embodiment, the parsing module 130 is specifically configured to:
[0170] Parse the configuration file of each component and convert the parsed configuration file into the preset data structure;
[0171] The component name, component path, dependency relationship and reference attributes of the image file included in each component are extracted from the preset data structure.
[0172] In one embodiment, the parsing module 130 is specifically configured to:
[0173] Create an empty initial list, and add the component name, the component path, the dependency, and the reference attribute to the corresponding position item in the initial list;
[0174] Establishing associations among the component names, component paths, dependencies, and reference attributes in the initial list;
[0175] The associated initial list is converted into a file in a preset format to obtain a component relationship list between each component and other components.
[0176] In one embodiment, the merging module 140 is specifically configured to:
[0177] Extracting the component name, component path and dependency relationship of each component from the component relationship list;
[0178] Determine the compilation order of each component based on dependencies;
[0179] The component path of each component is mapped and associated with the root directory of the corresponding component. According to the mapping association and the component name, a predefined compilation command is executed on each component in the compilation order to generate a binary library and resource package for each component.
[0180] In one embodiment, the merging module 140 is specifically configured to:
[0181] Loading the classification reading code into the root directory of the target application;
[0182] Create a binary library directory and a resource package directory of the target application in the root directory of the target application;
[0183] The loaded classification reading code is used to copy the binary library of each component to the binary library directory, and to copy the resource package of each component to the resource package directory.
[0184] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, it implements the functions or steps on the server side of a form filling method.
[0185] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, memory, network interface, display screen, and input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements the functions or steps on the client side of a form filling method.
[0186] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are performed:
[0187] Receive a request to integrate image resources of a target application, traverse the root directory of each component of the target application according to the request, and obtain the configuration file and image resource directory corresponding to each component;
[0188] Extract the image name, image type, and image path of each image file from the image resource directory, create a global resource mapping table based on the image names, image types, and image paths of all image files, and generate a classified reading code for loading each image file based on the global resource mapping table;
[0189] Parse the configuration file corresponding to each component to obtain the component name, component path, dependency relationship, and reference attributes of the image files contained in each component; and generate a component relationship list between each component and other components based on the component name, component path, dependency relationship, and reference attributes of the image files contained in each component;
[0190] Execute predefined compilation commands on each component according to the component relationship list to obtain the binary library and resource package of each component, and use the classification reading code to integrate the binary libraries and resources of all components into the target application.
[0191] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can be found in the relevant descriptions of the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0192] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0193] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0194] The above-described embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. If any software tools or components other than those of the company appear in the application embodiments, they are merely used for illustration and do not represent actual use. Although the present invention has been described in detail with reference to the above-mentioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above-mentioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A component-based image resource integration method, characterized in that: The method comprises: Receive a request to integrate image resources of a target application, traverse the root directory of each component of the target application according to the request, and obtain the configuration file and image resource directory corresponding to each component; Extract the image name, image type, and image path of each image file from the image resource directory, create a global resource mapping table based on the image names, image types, and image paths of all image files, and generate a classified reading code for loading each image file based on the global resource mapping table; Parse the configuration file corresponding to each component to obtain the component name, component path, dependency relationship, and reference attributes of the image files contained in each component; and generate a component relationship list between each component and other components based on the component name, component path, dependency relationship, and reference attributes of the image files contained in each component; Execute predefined compilation commands on each component according to the component relationship list to obtain the binary library and resource package of each component, and use the classification reading code to integrate the binary libraries and resources of all components into the target application.
2. The component-based image resource integration method according to claim 1, wherein: The global resource mapping table is created based on the image names, image types, and image paths of all image files, including: Create an empty data structure as the initial resource mapping table; Add the image name, image type, and image path of each image file obtained through traversal to the corresponding location item in the initial resource mapping table; An association relationship between the picture name, picture type and picture path of each picture file is established in the initial resource mapping table to obtain the global resource mapping table.
3. The component-based image resource integration method according to claim 1, wherein: The generating of the classification reading code for loading each image file according to the global resource mapping table includes: Setting classification standards according to the picture name, picture type and picture path of each picture file in the global resource mapping table to obtain multiple picture classification standards; According to each image classification standard, the preset reading function library is searched to obtain the classification reading function corresponding to each image classification standard; The various classification reading functions are combined to obtain a function set, and the function set is converted into a code in a preset format to obtain the classification reading code.
4. The component-based image resource integration method according to claim 1, wherein: The configuration file corresponding to each component is parsed to obtain the component name, component path, dependency relationship and reference properties of the image files contained in each component, including: Parse the configuration file of each component and convert the parsed configuration file into the preset data structure; The component name, component path, dependency relationship and reference attributes of the image file included in each component are extracted from the preset data structure.
5. The component-based image resource integration method according to claim 1, wherein: The generating of a component relationship list between each component and other components according to the component name, component path, dependency, and reference attributes of the image files contained in each component includes: Create an empty initial list, and add the component name, the component path, the dependency, and the reference attribute to the corresponding position item in the initial list; Establishing associations among the component names, component paths, dependencies, and reference attributes in the initial list; The associated initial list is converted into a file in a preset format to obtain a component relationship list between each component and other components.
6. The component-based image resource integration method according to claim 1, wherein: The step of executing a predefined compilation command on each component according to the component relationship list to obtain a binary library and resource package for each component includes: Extracting the component name, component path and dependency relationship of each component from the component relationship list; Determine the compilation order of each component based on dependencies; The component path of each component is mapped and associated with the root directory of the corresponding component. According to the mapping association and the component name, a predefined compilation command is executed on each component in the compilation order to generate a binary library and resource package for each component.
7. The component-based image resource integration method according to claim 1, wherein: The method of utilizing the classified reading code to integrate the binary libraries and resources of all components into the target application includes: Loading the classification reading code into the root directory of the target application; Create a binary library directory and a resource package directory of the target application in the root directory of the target application; The loaded classification reading code is used to copy the binary library of each component to the binary library directory, and to copy the resource package of each component to the resource package directory.
8. A component-based image resource integration device, characterized in that: The device comprises: An acquisition module is configured to receive a request for integrating image resources of a target application, traverse the root directory of each component of the target application according to the request, and obtain the configuration file and image resource directory corresponding to each component; A creation module is used to extract the image name, image type and image path of each image file from the image resource directory, create a global resource mapping table based on the image name, image type and image path of all image files, and generate a classification reading code for loading each image file based on the global resource mapping table; A parsing module is used to parse the configuration file corresponding to each component to obtain the component name, component path, dependency relationship and reference attributes of the image files contained in each component, and generate a component relationship list between each component and other components based on the component name, component path, dependency relationship and reference attributes of the image files contained in each component; The merging module is used to execute a predefined compilation command on each component according to the component relationship list to obtain the binary library and resource package of each component, and use the classification reading code to integrate the binary libraries and resources of all components into the target application.
9. A device, characterized in that The device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a component-based image resource integration program that can be executed by the at least one processor, and the component-based image resource integration program is executed by the at least one processor so that the at least one processor can execute the component-based image resource integration method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a component-based image resource integration program, and the component-based image resource integration program can be executed by one or more processors to implement the component-based image resource integration method according to any one of claims 1 to 7.