Information processing method, device and storage medium
By automatically completing the domain name of the static resource address during the sub-application rendering process, the completion error problem caused by the lack of domain name of the static resource address in the prior art is solved, and the efficiency of the sub-application rendering is improved.
Patent Information
- Application Number
- CN202110673437.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-17
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2041-06-17
AI Technical Summary
In the prior art, when loading static resources of sub-applications in the base application, the lack of domain names of the static resource addresses leads to completion errors, reducing the efficiency of sub-application rendering and requiring manual completion of addresses.
Monitor the static resource attributes of dynamic elements during the rendering of sub-applications. If the static resource address does not contain a domain name, obtain the sub-application address of the sub-application, add its domain name to the static resource address, get the completed address, find and insert the static Resource information is applied to the base to form a micro front end.
By automatically completing the domain name of the static resource address, we ensure that the correct static resource information is obtained, which improves the efficiency of sub-application rendering and reduces manual intervention.
Smart Images

Figure CN113392351B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to an information processing method and device, and a storage medium. Background Art
[0002] Micro front-ends are divided into base applications and sub-applications. The base application is the main application, and those small applications integrated into the base application are called sub-applications.
[0003] In the prior art, when a base application loads the resources of a sub-application into its own page for rendering, a new element will be created. When the static resource address corresponding to the new element does not include a domain name, the static resource address is directly completed using the address domain name of the base application. Since the static resource address is inconsistent with the address domain name of the base application, directly completing the static resource address using the address domain name of the base application will result in an incorrect completed static resource address. The static resource information corresponding to the sub-application cannot be obtained based on the incorrect completed static resource address, and manual work is required to re-complete the static resource address, which reduces the efficiency of sub-application rendering. Summary of the invention
[0004] In order to solve the above technical problems, embodiments of the present invention hope to provide an information processing method and device, and a storage medium, which can improve the efficiency of sub-application rendering.
[0005] The technical solution of the present invention is achieved in this way:
[0006] The present invention provides an information processing method, which includes:
[0007] When a dynamic element is detected to be created during the rendering process of a sub-application, and the dynamic element has a static resource attribute, and the static resource address corresponding to the dynamic element does not include a domain name, obtain the sub-application address corresponding to the sub-application, and add the address domain name in the sub-application address to the static resource address to obtain the added static resource address;
[0008] The static resource information corresponding to the sub-application is searched through the added static resource address, and the static resource information is inserted into the base application corresponding to the sub-application to obtain the micro front-end corresponding to the sub-application.
[0009] The present application provides an information processing device, the device comprising:
[0010] an acquisition unit, configured to acquire a sub-application address corresponding to the sub-application when a dynamic element created in the rendering process of the sub-application is monitored, the dynamic element has a static resource attribute, and the static resource address corresponding to the dynamic element does not include a domain name;
[0011] A search unit, used to search for static resource information corresponding to the sub-application through the added static resource address;
[0012] An adding unit, used for adding the address domain name in the sub-application address to the static resource address to obtain the added static resource address;
[0013] An insertion unit is used to insert the static resource information into a base application corresponding to the sub-application to obtain a micro front-end corresponding to the sub-application.
[0014] The present application provides an information processing device, the device comprising:
[0015] A memory, a processor and a communication bus, wherein the memory communicates with the processor via the communication bus, and the memory stores an information processing program executable by the processor. When the information processing program is executed, the information processing method described above is executed by the processor.
[0016] An embodiment of the present application provides a storage medium having a computer program stored thereon, which is applied to an information processing device, and is characterized in that the computer program implements the above-mentioned information processing method when executed by a processor.
[0017] An embodiment of the present invention provides an information processing method, device, and storage medium. The information processing method includes: when a dynamic element created during the rendering process of a sub-application is monitored, and the dynamic element has a static resource attribute, and the static resource address corresponding to the dynamic element does not include a domain name, obtaining the sub-application address corresponding to the sub-application, and adding the address domain name in the sub-application address to the static resource address to obtain the added static resource address; through the added static resource address, searching for static resource information corresponding to the sub-application, and inserting the static resource information into the base application corresponding to the sub-application to obtain a micro front end corresponding to the sub-application. By adopting the above method to implement the scheme, when the information processing device monitors the dynamic elements created during the rendering process of the sub-application, by obtaining the sub-application address corresponding to the sub-application, when the dynamic element has static resource attributes and the static resource address corresponding to the dynamic element does not include a domain name, the information processing device can use the address domain name in the sub-application address to complete the static resource address and obtain the added static resource address. Since the address domain name of the sub-application address is the same as the domain name of the static resource address corresponding to the sub-application, the address domain name in the sub-application address is used to complete the static resource address, so that the information processing device can obtain the accurate added static resource address, so that the information processing device can obtain the static resource information corresponding to the sub-application at the added static resource address. The information processing device can obtain the micro-frontend corresponding to the sub-application based on the static resource information and the base application corresponding to the sub-application, thereby improving the efficiency of sub-application rendering. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 A flow chart of an information processing method provided in an embodiment of the present application;
[0019] Figure 2 An exemplary information processing method provided in the embodiment of the present application Figure 1 ;
[0020] Figure 3 An exemplary information processing method provided in the embodiment of the present application Figure 2 ;
[0021] Figure 4 An exemplary information processing method provided in the embodiment of the present application Figure 3 ;
[0022] Figure 5 A schematic diagram of the structure of an information processing device provided in an embodiment of the present application Figure 1 ;
[0023] Figure 6 A schematic diagram of the structure of an information processing device provided in an embodiment of the present application Figure 2 . DETAILED DESCRIPTION
[0024] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0025] Embodiment 1
[0026] The present application embodiment provides an information processing method, Figure 1 A flow chart of an information processing method provided in an embodiment of the present application, such as Figure 1 As shown, the information processing method may include:
[0027] S101. When a dynamic element is detected to be created during the rendering process of a sub-application, and the dynamic element has a static resource attribute, and the static resource address corresponding to the dynamic element does not include a domain name, obtain the sub-application address corresponding to the sub-application, and add the address domain name in the sub-application address to the static resource address to obtain the added static resource address.
[0028] An information processing method provided in an embodiment of the present application is suitable for a scenario in which an information processing device processes a rendering instruction of a sub-application.
[0029] In the embodiments of the present application, the information processing device can be implemented in various forms. For example, the information processing device described in the present application may include devices such as mobile phones, cameras, tablet computers, laptop computers, PDAs, portable media players (PMPs), navigation devices, wearable devices, smart bracelets, pedometers, and devices such as digital TVs, desktop computers, and servers.
[0030] In the embodiment of the present application, the dynamic element may be a picture element, a page element, a script element, a page jump element or a connection element, etc. The specific one may be determined according to the actual situation, and the embodiment of the present application does not limit this.
[0031] In the embodiment of the present application, static resource attributes can be used to describe the attributes of Cascading Style Sheets (CSS) static resources or to describe the attributes of JS (Javascript) static resources. Specifically, static resource attributes include: src (sparse representation-based classifier) attribute and hypertext reference (Hypertext Reference, href) attribute.
[0032] It should be noted that the static resource address can be the value of the static resource attribute of the sub-application. Specifically, the value of the static resource attribute of the sub-application may include the address domain name of the sub-application, or the value of the static resource attribute of the sub-application may not include the address domain name of the sub-application. In the case where the value of the static resource attribute of the sub-application may not include the address domain name of the sub-application, the information processing device can add the address domain name in the sub-application address to the static resource address to complete the domain name of the static resource address and obtain the added static resource address, so that the information processing device can obtain the static resource information corresponding to the sub-application according to the added static resource address.
[0033] In the embodiment of the present application, the sub-application address is specifically the Uniform Resource Locator (URL) address of the sub-application.
[0034] In an embodiment of the present application, a monitoring unit is configured in the information processing device to monitor the dynamic elements created by the sub-application during the rendering process.
[0035] In an embodiment of the present application, the information processing device is configured with an Element.prototype.setAttribute method for rewriting the attribute settings on the prototype chain of the element. The information processing device can also use the Element.prototype.setAttribute method to add the address domain name in the sub-application address to the static resource address when the method monitors that the dynamic element created during the rendering process has a static resource attribute and the static resource address corresponding to the dynamic element does not include a domain name, and obtains the added static resource address.
[0036] In an embodiment of the present application, when the information processing device monitors a dynamic element created during the rendering process of a sub-application, and the dynamic element has a static resource attribute, and the static resource address corresponding to the dynamic element includes a domain name, the information processing device uses the static resource address as the added static resource address.
[0037] In an embodiment of the present application, the static resource attributes include a first static resource attribute; the information processing device adds the address domain name in the sub-application address to the static resource address to obtain the added static resource address, including: when the dynamic element is a picture element, a page element or a script element, and the attribute of the dynamic element is the first static resource attribute, the information processing device obtains the first static resource address corresponding to the first static resource attribute from the static resource address; the information processing device adds the address domain name to the first static resource address to obtain the added first static resource address; and uses the added first static resource address as the added static resource address.
[0038] In the embodiment of the present application, the first static resource attribute is a src attribute. The image element may be an img element; the page element may be an iframe element; and the script element may be a script element.
[0039] In the embodiment of the present application, the first static resource address is the value of the first static resource attribute.
[0040] In an embodiment of the present application, the process in which the information processing device uses the first static resource address after being added as the static resource address after being added includes: the information processing device performs an attribute setting operation on the first static resource address after being added to obtain the set first static resource address; the information processing device uses the set first static resource address as the static resource address after being added.
[0041] It should be noted that the information processing device performs a property setting operation on the first static resource address after being added to obtain the set first static resource address. The information processing device can set the first static resource address after being added to a preset position of the dynamic element to obtain the set first static resource address.
[0042] In an embodiment of the present application, when the information processing device determines that the dynamic element is a picture element, a page element or a script element, and the attribute of the dynamic element is a first static resource attribute, and the first static resource address corresponding to the first static resource attribute includes a domain name, the information processing device directly sets the first static resource address at a preset position of the dynamic element, obtains the set first static resource address, and uses the set first static resource address as the added static resource address.
[0043] In an embodiment of the present application, the static resource attributes include a second static resource attribute; the information processing device adds the address domain name in the sub-application address to the static resource address to obtain the added static resource address, including: when the dynamic element is a page jump element or a connection element, and the attribute of the dynamic element is the second static resource attribute, the information processing device obtains the second static resource address corresponding to the second static resource attribute from the static resource address; the information processing device adds the address domain name to the second static resource address to obtain the added second static resource address; and uses the added second static resource address as the added static resource address.
[0044] In the embodiment of the present application, the second static resource attribute is the href attribute. The page jump element may be an a element; and the connection element may be a link element.
[0045] In the embodiment of the present application, the second static resource address is the value of the second static resource attribute.
[0046] In an embodiment of the present application, the process in which the information processing device uses the added second static resource address as the added static resource address includes: the information processing device performs a property setting operation on the added second static resource address to obtain the set second static resource address; the information processing device uses the set second static resource address as the added static resource address.
[0047] It should be noted that the information processing device performs a property setting operation on the added second static resource address to obtain the set second static resource address. The information processing device can set the added second static resource address at a preset position of the dynamic element to obtain the set second static resource address.
[0048] In an embodiment of the present application, when the information processing device determines that the dynamic element is a page jump element or a connection element, and the attribute of the dynamic element is a second static resource attribute, and the second static resource address corresponding to the second static resource attribute includes a domain name, the information processing device directly sets the second static resource address at a preset position of the dynamic element, obtains the set second static resource address, and uses the set second static resource address as the added static resource address.
[0049] S102. Use the added static resource address to search for the static resource information corresponding to the sub-application, and insert the static resource information into the base application corresponding to the sub-application to obtain the micro front-end corresponding to the sub-application.
[0050] In an embodiment of the present application, the information processing device adds the address domain name in the sub-application address to the static resource address. After obtaining the added static resource address, the information processing device searches for the static resource information corresponding to the sub-application through the added static resource address, and inserts the static resource information into the base application corresponding to the sub-application to obtain the micro front-end corresponding to the sub-application.
[0051] In an embodiment of the present application, the process in which the information processing device inserts static resource information into the base application corresponding to the sub-application to obtain a micro-frontend corresponding to the sub-application includes: the information processing device creates a first element and inserts the static resource information into the first element to obtain an updated first element; the information processing device inserts the updated first element into the base application to obtain a micro-frontend.
[0052] In the embodiment of the present application, the first element may be a style element; the first element may also be a segmentation mark element. Specifically, the segmentation mark element may be a div (division) element; the style element may be a style element.
[0053] It should be noted that if the first element is a div element, the information processing device can call document.createElement to create the div element.
[0054] In an embodiment of the present application, before the information processing device obtains the sub-application address corresponding to the sub-application, upon receiving the sub-application address corresponding to the sub-application, the information processing device creates an initial container element based on the sub-application address; the information processing device inserts the initial container element into the base application to obtain the container element; accordingly, the process of obtaining the sub-application address corresponding to the sub-application includes: the information processing device obtains the sub-application address from the container element; accordingly, the information processing device inserts the updated first element into the base application to obtain the micro-frontend, including: the information processing device inserts the updated first element into the container element to obtain the micro-frontend.
[0055] It should be noted that the container element may be a micro-app element, and the form of the container element may be:<micro-app name='app1'url='http: / / localhost:3000 / '> .
[0056] In an embodiment of the present application, the url in the micro-app element is the sub-application address corresponding to the sub-application, that is, the micro-app element is used to store the sub-application address corresponding to the sub-application.
[0057] In an embodiment of the present application, the information processing device may request the Hyper Text Markup Language (HTML) information of the sub-application according to the URL address in the micro-app element, wherein the HTML information is in the form of a string.
[0058] In an embodiment of the present application, after the information processing device obtains the html information of the sub-application, the information processing device can call the document.createElement method to create a div element, and then insert the html information into the div element through the innerHTML method, convert the html information into a DOM structure, and obtain a div tag containing the html information, that is, obtain a list of sub-elements of the DOM structure.
[0059] In an embodiment of the present application, after the information processing device obtains the sub-element list, the information processing device can process each element in the sub-element list. The processing process can be: first, the information processing device determines whether the first element is a picture element, a page element, or a script element and has a src attribute. If the condition is met, the information processing device further determines whether the address of the src attribute contains a domain name (containing a domain name means that the address starts with http, https, or / / ). If there is no domain name, the information processing device uses the url address to complete the src attribute address, and then the information processing device directly processes the next element. If the information processing device determines that the address of the src attribute contains a domain name, the information processing device directly processes the next element.
[0060] For example, if the address of the src attribute is / my-page / test.png, then the url address is used to complete the address of the src attribute, and the completed address of the src attribute is: http: / / localhost:3000 / my-page / test.png.
[0061] In the embodiment of the present application, if the information processing device determines that the first element is not a picture element, a page element, or a script element and does not have a src attribute, the information processing device further determines whether the first element is an a element and has an href attribute. If the condition is met, the information processing device further determines whether the address of the href attribute has a domain name. If there is no domain name, the information processing device uses the url address to complete the href attribute address, and then the information processing device directly processes the next element. If the information processing device determines that the href attribute address already has a domain name, the information processing device directly processes the next element.
[0062] In an embodiment of the present application, if the information processing device determines that the first element is not an a element and does not have an href attribute, the information processing device further determines whether the first element is a link element and has an href attribute. If the condition is met, the information processing device further determines whether the address of the href attribute contains a domain name. If there is no domain name, the information processing device uses the url address to complete the href address, and then uses the completed href address to request the css resource, performs regular matching on the obtained css content, completes the static resource address referenced in the css rule, creates a style element and replaces the link element, and then inserts the processed css content into the style element, completing the processing and replacement of the link element. If the address of the href attribute has a domain name, directly request the css resource pointed to by the href address, perform regular matching on the obtained css content, complete the static resource address referenced in the css rule, create a style element and replace the link element, and then insert the processed css content into the style element, completing the processing and replacement of the link element. The information processing device then processes the next element.
[0063] In the embodiment of the present application, if the information processing device determines that the first element is not a link element and does not have an href attribute, the information processing device further determines whether the first element is a style element. If the condition is met, the CSS content is obtained through textContent, and the CSS content is matched regularly, the static resource address referenced in the CSS is completed, and then the formatted CSS content is inserted into the style element to overwrite the original value. Then the information processing device processes the next element.
[0064] In the embodiment of the present application, if the information processing device determines that the first element is not a style element, the information processing device determines whether the first element has a child element. If there is no child element, the next element is directly processed. If there is a child element, the child element list of the child element is obtained, and each element in the child element list of the child element is processed. After that, the information processing device can obtain the formatted DOM structure, and then the information processing device inserts the formatted DOM structure into the micro-app element to complete the rendering process of the sub-application.
[0065] In an embodiment of the present application, the first element includes a style element; the information processing device inserts static resource information into the first element to obtain an updated first element, including: when the dynamic element is a connection element, the information processing device inserts the static resource information into the style element to obtain an updated style element; correspondingly, the information processing device inserts the updated first element into the base application to obtain a micro front end, including: the information processing device inserts the updated style element into the base application to obtain a micro front end.
[0066] In an embodiment of the present application, if the dynamic element is a connection element and the connection element has a second static resource attribute, the information processing device obtains the added static resource address corresponding to the connection element and finds the corresponding static resource information at the added static resource address. The information processing device performs regular matching on the static resource information and completes the domain name of the static resource address referenced in the static resource information. Thereafter, the information processing device creates a style element and inserts the static resource information into the created style element to obtain an updated style element. The information processing device then replaces the connection element with the updated style element and inserts the updated style element into the base application to obtain a micro front end.
[0067] In an embodiment of the present application, the second static resource address includes an original static resource address and a referenced static resource address; the information processing device adds the address domain name to the second static resource address to obtain the added second static resource address, including the information processing device adding the address domain name to the original static resource address to obtain the added original static resource address; the information processing device adds the address domain name to the referenced static resource address to obtain the added referenced static resource address; the information processing device uses the added original static resource address and the added referenced static resource address as the added second static resource address.
[0068] In the embodiment of the present application, the referenced static resource address may be the address of other static resources applied in the static resource information corresponding to the second static resource address.
[0069] In an embodiment of the present application, before the information processing device obtains the sub-application address corresponding to the sub-application, when the information processing device monitors the added element added by the client, the information processing device determines the attribute of the added element; when the added attribute of the added element is a preset attribute and the value of the added attribute is the preset attribute value, the information processing device determines that the added element is a dynamic element.
[0070] It should be noted that the preset attribute may be an ismicro attribute, and the preset attribute value may be true.
[0071] In an embodiment of the present application, dynamically added CSS static resources mainly have two forms: link elements and style elements. When the information processing device monitors the creation of these two elements or the insertion of these two elements into the page, the document.createElement method in the sub-application can be rewritten. The document.createElement method adds logic for setting the preset attributes and preset attribute values of the element when the element is created.
[0072] In the embodiment of the present application, the method for rewriting the Node prototype chain to add an element may be the Node.prototype.appendChild and Node.prototype.insertBefore methods. When an element is added, if the added attribute of the added element is a preset attribute, and the value of the added attribute is the preset attribute value, the information processing device determines that the added element is a dynamic element, and then the information processing device processes the dynamic element according to the information processing method configured in the information processing device, otherwise the information processing device does not process the added element.
[0073] In an embodiment of the present application, after the information processing device obtains the sub-application address corresponding to the sub-application, when the dynamic element is a first style element, the information processing device obtains the style static resource address corresponding to the first style element; the information processing device adds the address domain name to the style static resource address to obtain the added style static resource address; the information processing device searches for the style static resource information through the added style static resource address, and obtains the micro front end based on the style static resource information and the base application.
[0074] In an embodiment of the present application, if the dynamic element is a first style element and the first style element has a style static resource attribute, the information processing device obtains the added style static resource address corresponding to the first style element and finds the corresponding style static resource information at the added style static resource address through the textContent method. The information processing device performs regular matching on the style static resource information and completes the domain name of the static resource address referenced in the style static resource information. Thereafter, the information processing device inserts the static resource information into the first style element to obtain an updated first style element. After the information processing device formats the updated first style element into a string format, the updated first style element is inserted into the base application to obtain a micro front end.
[0075] Exemplarily, the present application embodiment provides an exemplary information processing method, such as Figure 2 As shown:
[0076] S1. When a dynamic element is detected to be created during the rendering process of a sub-application, and the dynamic element has a static resource attribute, and the static resource address corresponding to the dynamic element does not include a domain name, the information processing device obtains the sub-application address corresponding to the sub-application.
[0077] S2. When the dynamic element is a picture element, a page element or a script element, and the attribute of the dynamic element is a first static resource attribute, the information processing device obtains a first static resource address corresponding to the first static resource attribute from the static resource address.
[0078] It should be noted that the static resource attributes include the first static resource attributes.
[0079] S3. The information processing device adds the address domain name to the first static resource address to obtain the added first static resource address; and uses the added first static resource address as the added static resource address.
[0080] It should be noted that after the information processing device executes step S3, the information processing device may execute step S6.
[0081] S4. When the dynamic element is a page jump element or a connection element, and the attribute of the dynamic element is a second static resource attribute, the information processing device obtains a second static resource address corresponding to the second static resource attribute from the static resource address;
[0082] It should be noted that the static resource attribute includes the second static resource attribute.
[0083] It should be noted that after the information processing device executes step S1, the information processing device may execute step S2; after the information processing device executes step S1, the information processing device may also execute step S4.
[0084] S5. The information processing device adds the address domain name to the second static resource address to obtain the added second static resource address; and uses the added second static resource address as the added static resource address.
[0085] S6. The information processing device searches for static resource information corresponding to the sub-application through the added static resource address.
[0086] S7. The information processing device inserts the static resource information into the base application corresponding to the sub-application to obtain the micro-frontend corresponding to the sub-application.
[0087] Exemplarily, the present application embodiment provides an exemplary information processing method, such as Figure 3 As shown:
[0088] S10. When detecting an added element added by the client, the information processing device determines the attribute of the added element.
[0089] S11. When an added attribute of the added element is a preset attribute and a value of the added attribute is a preset attribute value, the information processing apparatus determines that the added element is a dynamic element.
[0090] S12. When a dynamic element is detected to be created during the rendering process of a sub-application, and the dynamic element has a static resource attribute, and the static resource address corresponding to the dynamic element does not include a domain name, the information processing device obtains the sub-application address corresponding to the sub-application.
[0091] S13. The information processing device adds the address domain name in the sub-application address to the static resource address to obtain the added static resource address.
[0092] S14. The information processing device searches for static resource information corresponding to the sub-application through the added static resource address.
[0093] S15. The information processing device creates a style element, and when the dynamic element is a connection element, inserts the static resource information into the style element to obtain an updated style element.
[0094] S16. The information processing device inserts the updated style elements into the base application to obtain a micro front end.
[0095] S17: When the dynamic element is a first style element, the information processing apparatus obtains a style static resource address corresponding to the first style element.
[0096] It should be noted that after the information processing device executes step S12, the information processing device can execute step 17; after the information processing device executes step S12, the information processing device can execute step 13.
[0097] S18. The information processing device adds the address domain name to the style static resource address to obtain the added style static resource address.
[0098] S19. The information processing device searches for the style static resource information through the added style static resource address, and obtains the micro front end based on the style static resource information and the base application.
[0099] Exemplarily, the present application embodiment provides an exemplary information processing method, such as Figure 4 As shown:
[0100] S20. Upon receiving the sub-application address corresponding to the sub-application, the information processing device creates an initial container element according to the sub-application address.
[0101] S21. The information processing device inserts the initial container element into the base application to obtain a container element.
[0102] S22. When a dynamic element is detected to be created during the rendering process of a sub-application, and the dynamic element has a static resource attribute and the static resource address corresponding to the dynamic element does not include a domain name, the information processing device obtains the sub-application address from the container element.
[0103] In the embodiment of the present application, the information processing device can request the html information of the sub-application according to the sub-application address in the container element. After the information processing device obtains the html information of the sub-application, the information processing device can call the document.createElement method to create a div element, and then insert the html information into the div element through the innerHTML method, convert the html information into a DOM structure, obtain a div tag containing the html information, and obtain a sub-element list of the DOM structure.
[0104] It should be noted that the dynamic element may also be an element in the child element list of the DOM structure.
[0105] S23. The information processing device adds the address domain name in the sub-application address to the static resource address to obtain the added static resource address.
[0106] In an embodiment of the present application, after the information processing device obtains the sub-element list, the information processing device can process each element in the sub-element list. The processing process can be: first, the information processing device determines whether the first element is a picture element, a page element, or a script element and has a src attribute. If the condition is met, the information processing device further determines whether the address of the src attribute contains a domain name. If there is no domain name, the information processing device adds the address domain name in the url address (sub-application address) to the src attribute address to obtain the added static resource address, and then the information processing device directly processes the next element. If the information processing device determines that the address of the src attribute contains a domain name, the information processing device directly processes the next element.
[0107] In the embodiment of the present application, if the information processing device determines that the first element is not a picture element, a page element, or a script element and does not have a src attribute, the information processing device further determines whether the first element is an a element and has an href attribute. If the condition is met, the information processing device further determines whether the address of the href attribute has a domain name. If there is no domain name, the information processing device adds the address domain name in the url address to the href attribute address to obtain the added static resource address, and then the information processing device directly processes the next element. If the information processing device determines that the href attribute address already has a domain name, the information processing device directly processes the next element.
[0108] In the embodiment of the present application, if the information processing device determines that the first element is not an a element and does not have an href attribute, the information processing device further determines whether the first element is a link element and has an href attribute. If the condition is met, the information processing device further determines whether the address of the href attribute has a domain name. If there is no domain name, the information processing device adds the address domain name in the url address to the address of the href attribute to obtain the added static resource address. If the address of the href attribute has a domain name, the information processing device processes the next element.
[0109] In the embodiment of the present application, if the information processing device determines that the first element is not a link element and does not have an href attribute, the information processing device further determines whether the first element is a style element. If the condition is met, the information processing device directly performs regular matching on the CSS content, adds the domain name to the static resource address referenced in the CSS, and obtains the added static resource address. Then the information processing device processes the next element.
[0110] In an embodiment of the present application, if the information processing device determines that the first element is not a style element either, the information processing device determines whether the first element has a child element. If there is no child element, the next element is directly processed. If there is a child element, the child element list of the child element is obtained, and each element in the child element list of the child element is processed.
[0111] S24. The information processing device searches for static resource information corresponding to the sub-application through the added static resource address.
[0112] In the embodiment of the present application, after the information processing device executes step S23, the information processing device can obtain the added static resource address, and then the information processing device can obtain the static resource information corresponding to the sub-application based on the added static resource address.
[0113] Exemplarily, if the information processing device obtains the completed href address, the information processing device can use the completed href address to request the css content to obtain the static resource information corresponding to the sub-application.
[0114] Exemplarily, if the first element is a style element, the information processing device directly obtains the css content through textContent at the static resource address to obtain the static resource information corresponding to the sub-application.
[0115] S25. The information processing device creates a first element and inserts the static resource information into the first element to obtain an updated first element.
[0116] In an embodiment of the present application, the first element may be a style element. If the information processing device determines whether the first element is a link element and has an href attribute and obtains the added static resource address (including the href attribute of the address domain name), the information processing device creates a style element and replaces the link element with the style element. The information processing device then inserts the processed css content into the style element to obtain the updated first element.
[0117] In an embodiment of the present application, if the first element is a style element, the information processing device may also directly use the style element as the first element. When the information processing device obtains the static resource information corresponding to the style element, the information processing device formats the static resource information into a string format, and inserts the static resource information (formatted CSS content) into the style element to overwrite the original value, thereby obtaining the updated first element.
[0118] S26. The information processing device inserts the updated first element into the container element to obtain a micro front end.
[0119] In an embodiment of the present application, after the information processing device executes steps S20-S25, the information processing device can obtain a formatted DOM structure, and then the information processing device inserts the formatted DOM structure into the micro-app element to complete the rendering process of the sub-application.
[0120] It can be understood that when the information processing device monitors the dynamic elements created during the rendering process of the sub-application, it obtains the sub-application address corresponding to the sub-application, so that when the dynamic element has static resource attributes and the static resource address corresponding to the dynamic element does not include a domain name, the information processing device can use the address domain name in the sub-application address to complete the static resource address and obtain the added static resource address. Since the address domain name of the sub-application address is the same as the domain name of the static resource address corresponding to the sub-application, the static resource address is completed using the address domain name in the sub-application address, so that the information processing device can obtain the accurate added static resource address, so that the information processing device can obtain the static resource information corresponding to the sub-application at the added static resource address. The information processing device can obtain the micro-frontend corresponding to the sub-application based on the static resource information and the base application corresponding to the sub-application, thereby improving the efficiency of sub-application rendering.
[0121] Embodiment 2
[0122] Based on the same inventive concept of the first embodiment, the embodiment of the present application provides an information processing device 1, corresponding to an information processing method; Figure 5 A schematic diagram of the structure of an information processing device provided in an embodiment of the present application Figure 1 , the information processing device 1 may include:
[0123] The acquisition unit 11 is used to acquire the sub-application address corresponding to the sub-application when a dynamic element created in the rendering process of the sub-application is monitored, the dynamic element has a static resource attribute, and the static resource address corresponding to the dynamic element does not include a domain name;
[0124] A search unit 12, used to search for static resource information corresponding to the sub-application through the added static resource address;
[0125] An adding unit 13, configured to add the address domain name in the sub-application address to the static resource address to obtain the added static resource address;
[0126] The insertion unit 14 is used to insert the static resource information into the base application corresponding to the sub-application to obtain the micro front-end corresponding to the sub-application.
[0127] In some embodiments of the present application, the static resource attribute includes a first static resource attribute;
[0128] The acquisition unit 11 is used for acquiring a first static resource address corresponding to the first static resource attribute from the static resource address when the dynamic element is a picture element, a page element or a script element and the attribute of the dynamic element is a first static resource attribute;
[0129] The adding unit 13 is used to add the address domain name to the first static resource address to obtain the added first static resource address; and use the added first static resource address as the added static resource address.
[0130] In some embodiments of the present application, the static resource attribute includes a second static resource attribute;
[0131] The acquisition unit 11 is used for acquiring a second static resource address corresponding to the second static resource attribute from the static resource address when the dynamic element is a page jump element or a connection element and the attribute of the dynamic element is a second static resource attribute;
[0132] The adding unit 13 is used to add the address domain name to the second static resource address to obtain the added second static resource address; and use the added second static resource address as the added static resource address.
[0133] In some embodiments of the present application, the apparatus further comprises a creating unit;
[0134] The creation unit is used to create a first element;
[0135] The insertion unit 14 is used to insert the static resource information into the first element to obtain an updated first element; and insert the updated first element into the base application to obtain the micro front end.
[0136] In some embodiments of the present application, the apparatus further comprises a determining unit;
[0137] The creation unit is configured to, upon receiving a sub-application address corresponding to the sub-application, create an initial container element according to the sub-application address;
[0138] The inserting unit 14 is used to insert the initial container element into the base application to obtain a container element;
[0139] Correspondingly, the acquisition unit 11 is used to acquire the sub-application address from the container element;
[0140] Correspondingly, the insertion unit 14 is used to insert the updated first element into the container element to obtain the micro front end.
[0141] In some embodiments of the present application, the first element includes a style element;
[0142] The inserting unit 14 is used to insert the static resource information into the style element to obtain an updated style element when the dynamic element is a connection element;
[0143] Correspondingly, the insertion unit 14 is used to insert the updated style element into the base application to obtain the micro front end.
[0144] In some embodiments of the present application, the second static resource address includes an original static resource address and a referenced static resource address;
[0145] The adding unit 13 is used to add the address domain name to the original static resource address to obtain the original static resource address after addition; add the address domain name to the referenced static resource address to obtain the referenced static resource address after addition; and use the original static resource address after addition and the referenced static resource address after addition as the second static resource address after addition.
[0146] In some embodiments of the present application, the apparatus further comprises a determining unit;
[0147] The determination unit is used to determine the attribute of the added element when monitoring the added element added by the client; and determine that the added element is the dynamic element when the added attribute of the added element is a preset attribute and the value of the added attribute is a preset attribute value.
[0148] In some embodiments of the present application, the acquisition unit 11 is used to acquire a style static resource address corresponding to the first style element when the dynamic element is a first style element;
[0149] The adding unit 13 is used to add the address domain name to the style static resource address to obtain the added style static resource address;
[0150] The search unit 12 is used to search for style static resource information through the added style static resource address, and obtain the micro front end based on the style static resource information and the base application.
[0151] It should be noted that, in actual applications, the above-mentioned acquisition unit 11, search unit 12, addition unit 13 and insertion unit 14 can be implemented by a processor 15 on the information processing device 1, specifically a CPU (Central Processing Unit), an MPU (Microprocessor Unit), a DSP (Digital Signal Processing) or a field programmable gate array (FPGA); the above-mentioned data storage can be implemented by a memory 16 on the information processing device 1.
[0152] The embodiment of the present invention further provides an information processing device 1, such as Figure 6 As shown, the information processing device 1 includes: a processor 15, a memory 16 and a communication bus 17. The memory 16 communicates with the processor 15 via the communication bus 17. The memory 16 stores a program executable by the processor 15. When the program is executed, the information processing method described above is executed by the processor 15.
[0153] In practical applications, the memory 16 may be a volatile memory, such as a random access memory (RAM); or a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk (HDD) or a solid-state drive (SSD); or a combination of the above types of memory, and provide instructions and data to the processor 15.
[0154] An embodiment of the present invention provides a computer-readable storage medium having a computer program thereon, and when the program is executed by the processor 15 , the information processing method as described above is implemented.
[0155] It can be understood that when the information processing device monitors the dynamic elements created during the rendering process of the sub-application, it obtains the sub-application address corresponding to the sub-application, so that when the dynamic element has static resource attributes and the static resource address corresponding to the dynamic element does not include a domain name, the information processing device can use the address domain name in the sub-application address to complete the static resource address and obtain the added static resource address. Since the address domain name of the sub-application address is the same as the domain name of the static resource address corresponding to the sub-application, the static resource address is completed using the address domain name in the sub-application address, so that the information processing device can obtain the accurate added static resource address, so that the information processing device can obtain the static resource information corresponding to the sub-application at the added static resource address. The information processing device can obtain the micro-frontend corresponding to the sub-application based on the static resource information and the base application corresponding to the sub-application, thereby improving the efficiency of sub-application rendering.
[0156] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0157] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0158] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0159] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0160] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention.
Claims
1. An information processing method, characterized in that: The method comprises: When a dynamic element created during the rendering process of a sub-application is monitored, and the dynamic element has a static resource attribute, and the static resource address corresponding to the dynamic element does not include a domain name, obtain the sub-application address corresponding to the sub-application and the type of the static resource attribute; determine the corresponding static resource address based on the type of the static resource attribute; add the address domain name in the sub-application address to the corresponding static resource address to obtain the added static resource address; wherein the static resource attribute represents the attribute of a picture element, a page element or a script element, or the static resource attribute represents the attribute of a page jump element or a connection element; The static resource information corresponding to the sub-application is searched through the added static resource address, and the static resource information is inserted into the base application corresponding to the sub-application to obtain the micro front-end corresponding to the sub-application.
2. The method according to claim 1, characterized in that The static resource attribute includes a first static resource attribute; the adding the address domain name in the sub-application address to the static resource address to obtain the added static resource address includes: When the dynamic element is a picture element, a page element or a script element, and the attribute of the dynamic element is a first static resource attribute, obtaining a first static resource address corresponding to the first static resource attribute from the static resource address; The address domain name is added to the first static resource address to obtain the added first static resource address; and the added first static resource address is used as the added static resource address.
3. The method according to claim 1, characterized in that The static resource attribute includes a second static resource attribute; the adding the address domain name in the sub-application address to the static resource address to obtain the added static resource address includes: When the dynamic element is a page jump element or a connection element, and the attribute of the dynamic element is a second static resource attribute, acquiring a second static resource address corresponding to the second static resource attribute from the static resource address; The address domain name is added to the second static resource address to obtain the added second static resource address; and the added second static resource address is used as the added static resource address.
4. The method according to claim 1, characterized in that: Inserting the static resource information into the base application corresponding to the sub-application to obtain the micro front-end corresponding to the sub-application includes: Creating a first element, and inserting the static resource information into the first element to obtain an updated first element; Inserting the updated first element into the base application to obtain the micro frontend.
5. The method according to claim 4, characterized in that Before obtaining the sub-application address corresponding to the sub-application, the method further includes: Upon receiving the sub-application address corresponding to the sub-application, creating an initial container element according to the sub-application address; Inserting the initial container element into the base application to obtain a container element; Correspondingly, obtaining the sub-application address corresponding to the sub-application includes: Obtain the sub-application address from the container element; Accordingly, inserting the updated first element into the base application to obtain the micro front end includes: Insert the updated first element into the container element to obtain the micro frontend.
6. The method according to claim 4, characterized in that The first element includes a style element; and the step of inserting the static resource information into the first element to obtain an updated first element includes: In the case where the dynamic element is a connection element, inserting the static resource information into the style element to obtain an updated style element; Accordingly, inserting the updated first element into the base application to obtain the micro front end includes: Insert the updated style element into the base application to obtain the micro frontend.
7. The method according to claim 3, characterized in that The second static resource address includes an original static resource address and a referenced static resource address; the adding the address domain name to the second static resource address to obtain the added second static resource address includes: Add the address domain name to the original static resource address to obtain the added original static resource address; Add the address domain name to the referenced static resource address to obtain the added referenced static resource address; The added original static resource address and the added referenced static resource address are used as the added second static resource address.
8. The method according to claim 1, characterized in that Before obtaining the sub-application address corresponding to the sub-application, the method further includes: In case of monitoring an additional element added by the client, determining the attribute of the additional element; In the case that the added attribute of the added element is a preset attribute and the value of the added attribute is a preset attribute value, it is determined that the added element is the dynamic element.
9. The method according to claim 1, characterized in that: After obtaining the sub-application address corresponding to the sub-application, the method further includes: In a case where the dynamic element is a first style element, obtaining a style static resource address corresponding to the first style element; Add the address domain name to the style static resource address to obtain the added style static resource address; The style static resource information is searched through the added style static resource address, and the micro front end is obtained based on the style static resource information and the base application.
10. An information processing device, characterized in that: The device comprises: An acquisition unit is used to acquire a sub-application address corresponding to the sub-application and a type of the static resource attribute when a dynamic element created in the rendering process of the sub-application is monitored, and the dynamic element has a static resource attribute, and the static resource address corresponding to the dynamic element does not include a domain name; determine the corresponding static resource address based on the type of the static resource attribute; wherein the static resource attribute represents an attribute of a picture element, a page element, or a script element, or the static resource attribute represents an attribute of a page jump element or a connection element; A search unit, used to search for static resource information corresponding to the sub-application through the added static resource address; An adding unit, used for adding the address domain name in the sub-application address to the corresponding static resource address to obtain the added static resource address; An insertion unit is used to insert the static resource information into a base application corresponding to the sub-application to obtain a micro front-end corresponding to the sub-application.
11. An information processing device, characterized in that: The device comprises: A memory, a processor and a communication bus, wherein the memory communicates with the processor via the communication bus, the memory stores an information processing program executable by the processor, and when the information processing program is executed, the method according to any one of claims 1 to 9 is performed by the processor.
12. A storage medium having a computer program stored thereon, applied to an information processing device, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Network data pre-fetching method and network data pre-fetching system
CN102591887A
Resource file loading method and device
CN104424239A