Method and device for dynamically updating components, electronic equipment and storage medium
Patent Information
- Application Number
- CN202210255467.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-15
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2042-03-15
AI Technical Summary
[0003]有鉴于此,本发明实施例提供一种组件动态更新的方法、装置、电子设备和存储介质,能够解决编译文件有时与应用不匹配,无法使组件进行动态更新,导致组件动态更新的效率较低的问题
[0041] One embodiment of the above invention has the following advantages or beneficial effects: In this embodiment, the update file is obtained by rewriting the source code of the component after updating it. The rewriting of the source code of the component is equivalent to establishing a bridge between the application and the update file, so that the updated parameters can be passed to the component through the rewritten update file to realize the dynamic update of the component. Therefore, after the dynamic update instruction of the component is triggered, the corresponding update file is obtained, the update file can be parsed to generate the expression tree corresponding to the component, and then based on the structure of the expression tree, the attribute values corresponding to each node can be obtained in sequence, which includes the parameters of the component update. Then, the updated component can be obtained by combining the attribute values corresponding to each node. In this way, the dynamic update of the component can be realized even when there is a mismatch between the update file and the application of the component, thus improving the efficiency of the dynamic update of the component.
Smart Images

Figure CN114594980B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for dynamic updating of components. Background Technology
[0002] Flutter components are frequently used in mobile application development to enable dynamic updates to application pages. In existing technologies, when a page needs updating, an updated compiled file can be dynamically downloaded. The Flutter component then replaces the updated compiled file and runs, achieving dynamic page updates. However, because update files developed for different platforms are not identical, and the compiled file sometimes doesn't match the application, dynamic updates of components become impossible, resulting in low efficiency. Summary of the Invention
[0003] In view of this, embodiments of the present invention provide a method, apparatus, electronic device, and storage medium for dynamic component updates, which can solve the problem that sometimes the compiled files are incompatible with the application, making it impossible to dynamically update the components and resulting in low efficiency of dynamic component updates.
[0004] To achieve the above objectives, according to one aspect of the present invention, a method for dynamically updating components is provided.
[0005] To achieve the above objectives, according to another aspect of the present invention, an apparatus for dynamically updating components is provided.
[0006] An apparatus for dynamically updating a component according to an embodiment of the present invention includes: in response to a dynamic update instruction of a component, obtaining a corresponding update file, wherein the update file is obtained by rewriting the source code of the component after updating; generating expressions corresponding to each node in the update file based on the update file to determine an expression tree corresponding to the component; and, based on the structure of the expression tree, sequentially obtaining attribute values corresponding to each node to combine the attribute values corresponding to each node to obtain and display the updated component.
[0007] In one embodiment, prior to responding to the dynamic update instruction, the method further includes:
[0008] Obtain the source code of the page corresponding to the component, and update the source code;
[0009] Generate a set of syntax tree node types for the updated source code, and rewrite the updated node functions in the set of syntax tree node types based on a data structure with a preset format to obtain the updated file;
[0010] Generate a version identifier corresponding to the updated file, and store the correspondence between the version identifier and the component identifier of the component.
[0011] In another embodiment, the process of rewriting the updated node functions in the syntax tree node type set based on a preset format data structure to obtain the updated file includes:
[0012] Based on a data structure with a preset format, the update node function in the set of syntax tree node types is rewritten to obtain the update file corresponding to the page;
[0013] Filter data structures whose type field values are preset values to generate update files for the components corresponding to the data structures.
[0014] In another embodiment, based on a preset data structure, rewriting the updated node functions in the syntax tree node type set includes:
[0015] Based on the map data structure, rewrite the node functions that update the set of node types in the syntax tree.
[0016] In yet another embodiment, based on the updated file, expressions corresponding to each node in the updated file are generated, including:
[0017] Query the target field values of each node in the updated file, and generate corresponding expressions for each node based on the expression types corresponding to the target field values.
[0018] In yet another embodiment, the method further includes:
[0019] In response to the display operation of the page corresponding to the component, the version identifier of the update file corresponding to the component identifier is obtained, so as to determine whether the version identifier is greater than the current version identifier of the component;
[0020] In response to the version identifier being greater than the current version identifier of the component, a dynamic update instruction for the component is triggered.
[0021] To achieve the above objectives, according to another aspect of the present invention, an apparatus for dynamically updating components is provided.
[0022] An apparatus for dynamically updating a component according to an embodiment of the present invention includes: a response unit, configured to respond to a dynamic update instruction of the component and obtain a corresponding update file, wherein the update file is obtained by rewriting the source code of the component after updating; a determination unit, configured to generate expressions corresponding to each node in the update file based on the update file, so as to determine the expression tree corresponding to the component; and an update unit, configured to obtain the attribute values corresponding to each node sequentially based on the structure of the expression tree, so as to combine the attribute values corresponding to each node to obtain the updated component and display it.
[0023] In one embodiment, the apparatus further includes:
[0024] An update unit is used to obtain the source code of the page corresponding to the component and update the source code;
[0025] The rewriting unit is used to generate a set of syntax tree node types for the updated source code, and rewrite the updated node functions in the set of syntax tree node types based on a preset data structure to obtain the updated file.
[0026] The storage unit is used to generate the version identifier corresponding to the update file and store the correspondence between the version identifier and the component identifier of the component.
[0027] In yet another embodiment, the rewriting unit is specifically used for:
[0028] Based on a data structure with a preset format, the update node function in the set of syntax tree node types is rewritten to obtain the update file corresponding to the page;
[0029] Filter data structures whose type field values are preset values to generate update files for the components corresponding to the data structures.
[0030] In yet another embodiment, the rewriting unit is specifically used for:
[0031] Based on the map data structure, rewrite the node functions that update the set of node types in the syntax tree.
[0032] In yet another embodiment, the determining unit is specifically used for:
[0033] Query the target field values of each node in the updated file, and generate corresponding expressions for each node based on the expression types corresponding to the target field values.
[0034] In yet another embodiment, the apparatus further includes:
[0035] The judgment unit is used to respond to the display operation of the page corresponding to the component, obtain the version identifier of the update file corresponding to the component identifier, and determine whether the version identifier is greater than the current version identifier of the component;
[0036] A triggering unit is configured to trigger a dynamic update instruction for the component in response to the version identifier being greater than the current version identifier of the component.
[0037] To achieve the above objectives, according to another aspect of the present invention, an electronic device is provided.
[0038] An electronic device according to an embodiment of the present invention includes: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the component dynamic update method provided in the embodiment of the present invention.
[0039] To achieve the above objectives, according to another aspect of the present invention, a computer-readable medium is provided.
[0040] An embodiment of the present invention provides a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method for dynamically updating components provided in the embodiment of the present invention.
[0041] One embodiment of the above invention has the following advantages or beneficial effects: In this embodiment, the update file is obtained by rewriting the source code of the component after updating it. The rewriting of the source code of the component is equivalent to establishing a bridge between the application and the update file, so that the updated parameters can be passed to the component through the rewritten update file to realize the dynamic update of the component. Therefore, after the dynamic update instruction of the component is triggered, the corresponding update file is obtained, the update file can be parsed to generate the expression tree corresponding to the component, and then based on the structure of the expression tree, the attribute values corresponding to each node can be obtained in sequence, which includes the parameters of the component update. Then, the updated component can be obtained by combining the attribute values corresponding to each node. In this way, the dynamic update of the component can be realized even when there is a mismatch between the update file and the application of the component, thus improving the efficiency of the dynamic update of the component.
[0042] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description
[0043] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:
[0044] Figure 1 This is a schematic diagram of the main process of a method for dynamic updating of components according to an embodiment of the present invention;
[0045] Figure 2 This is a schematic diagram of another main process of the component dynamic update method according to an embodiment of the present invention;
[0046] Figure 3 This is a schematic diagram of the main units of a device for dynamically updating components according to an embodiment of the present invention;
[0047] Figure 4 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;
[0048] Figure 5This is a schematic diagram of the structure of a computer system suitable for implementing embodiments of the present invention. Detailed Implementation
[0049] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0050] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.
[0051] This invention provides a component dynamic update system. The system may include a terminal device on which an application can be installed. The application's pages are implemented using components, such as Flutter components. When a page needs updating, the Flutter component can dynamically load the update file, thus achieving dynamic page updates. The component dynamic update system may also include a server-side component. The server-side component can store the update files of the Flutter components. When a page needs updating, the Flutter component can interact with the server-side component to dynamically load the update file from the server.
[0052] This invention provides a method for dynamically updating components, which can be executed by a terminal, such as... Figure 1 As shown, the method includes:
[0053] S101: Responding to the component's dynamic update command, obtain the corresponding update file.
[0054] The updated file is derived from rewriting the component's source code after updating it.
[0055] Updates to pages in an application typically involve style updates, such as changes to the page background, button text, decorative styles, text size, color, and font. Therefore, in this embodiment of the invention, component dynamic updates are equivalent to page style updates. During the application page development phase, a set of components that can be updated on the page is usually pre-configured in the source code, such as the top TitleBar, the entire page background, and specific buttons. These elements are usually wrapped using Flutter components. In this embodiment, the Flutter component can be a HotReloadWidget component, such as a custom HotReloadWidget component. Each element's corresponding HotReloadWidget component has a corresponding component identifier. The HotReloadWidget component can be used to obtain and process update files.
[0056] When a page needs updating, the page's source code can be obtained first, and the code in the HotReloadWidget component that needs updating can be modified, thus updating the component's corresponding source code. After the source code is updated, a set of syntax tree node types can be generated. Then, the updated node functions can be rewritten using this set of syntax tree node types to obtain the update file. After obtaining the update file, a version identifier corresponding to the update file can be generated, and the correspondence between the version identifier and the component's identifier can be stored to facilitate the retrieval of the update file. In this way, by rewriting the updated source code corresponding to the component, the update file corresponding to the component can be automatically obtained, and the update file can be retrieved through the established correspondence, thereby updating the component. This allows for dynamic updates of the component even when there is a mismatch between the update file and the component's application, improving the efficiency of dynamic component updates.
[0057] It should be noted that the source code updates in this step can be performed within the original IDE, and the updated source code can be previewed through the IDE to ensure it conforms to the style guidelines. Each element, method, and parameter in the source code can be considered a node. In this step, you can inherit from `GenneralizingAstVisitor` (a class for accessing AST (Abstract Syntax Tree) structure data). Based on the code logic in the source code, a set of syntax tree node types can be generated, including nodes that modify the code in the source code. For the source code, you can inherit from `SimpleAstVisitor` (a class for accessing AST structure data) to determine the updated node functions (such as the `visitNode` function) from the set of syntax tree node types. This involves modifying the node functions and then rewriting them, describing the node functions using a predefined data structure. In this embodiment of the invention, the data structure of the preset format can be specifically a map data structure. Therefore, the updated node functions in the syntax tree node type set can be rewritten based on the map data structure. Specifically, the map data structure can be in key-value format, such as {"type": "ReturnStatement", "argument": argument}. In this way, the rewritten node function can be directly determined by the value in each key-value format, which can quickly determine the content updated by the component and thus improve the efficiency of dynamic component updates.
[0058] Since updating the source code of a page may involve updating multiple elements, and each modified element may be wrapped by a different HotReloadWidget component, multiple HotReloadWidget components in the source code can be updated, and each HotReloadWidget component can complete its own dynamic update. Therefore, in this embodiment of the invention, the update file for each HotReloadWidget component can be stored separately. Specifically, this can be done by: rewriting the update node function in the syntax tree node type set based on a preset format data structure to obtain the update file corresponding to the page; and filtering data structures whose type field values are preset values to generate the update file for the component corresponding to the data structure. In this step, when updating a component, the source code of the page in the application can be updated first, and the update file of the page can be obtained by rewriting the update node function. Then, the update file of the component can be generated by using the type field value in the page's update file. This can ensure that the update file matches the application as much as possible, thereby improving the efficiency of dynamic component updates.
[0059] After updating the page's source code, a set of syntax tree node types can be obtained. Then, by rewriting the updated node functions within this set, the page's update file can be generated. Furthermore, the data structure (map data structure) of each HotReloadWidget component on the page can be filtered using the value of the `type` field. This data structure is then stored separately for each HotReloadWidget component, generating its update file. The default value of the `type` field can be set based on the scenario, such as being `HotReloadWidget`.
[0060] In this embodiment of the invention, when a page is opened and displayed in the application, the component corresponding to the page can first perform an update query to determine whether an update is needed based on the query results. If an update is determined to be needed, the component's dynamic update instruction can be triggered to execute the dynamic update; if an update is determined not to be needed, the component's dynamic update instruction will not be triggered, and the page will be displayed. Specifically, this can be performed as follows: in response to the display operation of the page corresponding to the component, the version identifier of the update file corresponding to the component identifier is obtained to determine whether the version identifier is greater than the component's current version identifier; in response to the version identifier being greater than the component's current version identifier, the component's dynamic update instruction is triggered.
[0061] The current version identifier can be the one currently stored by the component, and the component can update the current version identifier after each dynamic update. The update file can be stored on the server or the terminal device. The component can first obtain the version identifier of the update file from the server or the terminal, and then determine whether the obtained version identifier is greater than the component's current version identifier. If it is greater, the component needs a dynamic update; otherwise, it does not. After determining that the component needs a dynamic update, a dynamic update command can be triggered, and the corresponding update file for the component can be obtained. Thus, after the application is triggered to display, the version identifier can be used to determine whether a component update is needed, and a dynamic update command can be triggered after determining that an update is needed. This enables timely dynamic updates of components within the application, improving the timeliness of component updates.
[0062] S102: Based on the update file, generate the expression corresponding to each node in the update file to determine the expression tree corresponding to the component.
[0063] The update file includes node information for each node, such as node functions. Therefore, the corresponding expression for each node can be generated based on the update file. After obtaining the expression for each node, the expression tree corresponding to the component can be determined based on the inclusion relationship between nodes. The expression tree includes root nodes and child nodes. For example, a method can be a node and generate its corresponding expression. The input parameters, return value, and variable definitions included in the node function of the method can also be nodes and generate corresponding expressions. For this method, the expression corresponding to the method is the root node of the expression tree, and the nodes corresponding to the input parameters, return value, and variable definitions included in the node function of the method are all child nodes. In this way, the expression tree corresponding to the component can be obtained.
[0064] It should be noted that Expression includes various types, such as Identifier, NumericLiteral, and MethodDeclaration. In this embodiment of the invention, the corresponding expression type can be determined based on the target field value of each node in the update file, and then the expression corresponding to the node can be generated based on the corresponding expression type. The target field value represents the field value of the target field. The target field can be the field value of the type field in the component. The type field can include multiple types, such as: string type definition (StringLiteral) in the program, numeric type definition (NumericLiteral) in the program, function input parameter definition (ArgumentList) in the program, function method content definition (MethodDeclaration) in the program, function return content definition (ReturnStatement) in the program, variable declaration definition (VariableDeclaration) in the program, operation expression definition (BinaryExpression) in the program, and component definition (HotReloadWidget) in the program that supports dynamic updates.
[0065] Update files typically include information of different types and functions, such as numeric types, input parameters, etc. In order to facilitate more accurate parsing of update files, in this embodiment of the invention, a corresponding expression type is set for nodes with different information, and the corresponding expression type is represented by the field value of the target field. Therefore, in this step, the corresponding expression type can be determined by the target field value, and then the expression corresponding to each node can be generated, thereby improving the accuracy of expression generation and the accuracy of update file parsing.
[0066] S103: Based on the structure of the expression tree, the attribute values corresponding to each node are obtained sequentially, and the attribute values corresponding to each node are combined to obtain the updated component and display it.
[0067] The expression tree represents the containment relationships between nodes. Based on the structure of the expression data, the expressions are parsed sequentially to obtain the attribute values of the corresponding properties of each node. Parsing of the expression tree typically proceeds from the root node to the child nodes. For example, for the Text component, the attribute values of fields such as style, textAlign, and overflow are parsed from the root node first. Then, the expressions corresponding to each field, such as style, are parsed to obtain their respective attribute values. After parsing the attribute values of each node, these values can be combined to obtain the updated component, thus completing the dynamic update of the component and enabling page display and updates.
[0068] In this embodiment of the invention, the update file is obtained by rewriting the source code of the component after updating it. The rewriting of the component's source code after updating it is equivalent to establishing a bridge between the application and the update file, so that the updated parameters can be passed to the component through the rewritten update file, thereby realizing the dynamic update of the component. Therefore, after responding to the dynamic update instruction of the component, the corresponding update file is obtained. The update file can be parsed to generate the expression tree corresponding to the component. Then, based on the structure of the expression tree, the attribute values corresponding to each node can be obtained in sequence, which includes the parameters for component update. Then, the attribute values corresponding to each node can be combined to obtain the updated component. In this way, even when there is a mismatch between the update file and the application of the component, the dynamic update of the component can still be realized, thus improving the efficiency of the dynamic update of the component.
[0069] Taking a component dynamic update system including a server and a terminal as an example, the method of component dynamic update in this embodiment of the invention will be specifically described, such as... Figure 2 As shown, the method includes:
[0070] S201: The server retrieves the source code of the page corresponding to the component and updates the source code.
[0071] S202: The server generates a set of syntax tree node types for the updated source code, and rewrites the updated node functions in the set of syntax tree node types based on a preset data structure to obtain the updated file.
[0072] S203: The server generates version identifiers corresponding to the update files and stores the correspondence between version identifiers and component identifiers.
[0073] S204: In response to the display operation of the page corresponding to the component, the terminal obtains the version identifier of the update file corresponding to the component identifier from the server to determine whether the version identifier is greater than the current version identifier of the component.
[0074] S205: The terminal responds to the fact that the version identifier is greater than the current version identifier of the component, and triggers the dynamic update instruction of the component.
[0075] S206: The terminal responds to the component's dynamic update command, and the server obtains the corresponding update file.
[0076] S207: The terminal generates expressions corresponding to each node in the update file based on the update file, in order to determine the expression tree corresponding to the component.
[0077] S208: The terminal, based on the structure of the expression tree, sequentially obtains the attribute values corresponding to each node, combines the attribute values corresponding to each node, and obtains and displays the updated component.
[0078] It should be noted that the data processing principle in the embodiments of the present invention is the same as... Figure 1The data processing principle is the same in the embodiments shown, and will not be repeated here.
[0079] To address the problems existing in the prior art, embodiments of the present invention provide a device 300 for dynamic component updating, such as... Figure 3 As shown, the device 300 includes:
[0080] The response unit 301 is used to respond to the dynamic update instruction of the component and obtain the corresponding update file, wherein the update file is obtained by rewriting the source code of the component after updating;
[0081] The determining unit 302 is used to generate expressions corresponding to each node in the update file based on the update file, so as to determine the expression tree corresponding to the component;
[0082] The update unit 303 is used to sequentially obtain the attribute values corresponding to each node based on the structure of the expression tree, so as to combine the attribute values corresponding to each node to obtain the updated component and display it.
[0083] It should be understood that the manner in which embodiments of the present invention are implemented is different from the implementation method. Figure 2 The embodiments shown are the same and will not be described again here.
[0084] In one implementation of this invention, the update unit 303 is used to obtain the source code of the page corresponding to the component and update the source code; the device 300 further includes:
[0085] The rewriting unit is used to generate a set of syntax tree node types for the updated source code, and rewrite the updated node functions in the set of syntax tree node types based on a preset data structure to obtain the updated file.
[0086] The storage unit is used to generate the version identifier corresponding to the update file and store the correspondence between the version identifier and the component identifier of the component.
[0087] In yet another embodiment, the rewriting unit is specifically used for:
[0088] Based on a data structure with a preset format, the update node function in the set of syntax tree node types is rewritten to obtain the update file corresponding to the page;
[0089] Filter data structures whose type field values are preset values to generate update files for the components corresponding to the data structures.
[0090] In yet another embodiment, the rewriting unit is specifically used for:
[0091] Based on the map data structure, rewrite the node functions that update the set of node types in the syntax tree.
[0092] In yet another embodiment, the determining unit is specifically used for:
[0093] Query the target field values of each node in the updated file, and generate corresponding expressions for each node based on the expression types corresponding to the target field values.
[0094] In yet another embodiment, the device 300 further includes:
[0095] The judgment unit is used to respond to the display operation of the page corresponding to the component, obtain the version identifier of the update file corresponding to the component identifier, and determine whether the version identifier is greater than the current version identifier of the component;
[0096] A triggering unit is configured to trigger a dynamic update instruction for the component in response to the version identifier being greater than the current version identifier of the component.
[0097] It should be understood that the manner in which embodiments of the present invention are implemented is similar to... Figure 1 or Figure 2 The embodiments shown are the same and will not be described again here.
[0098] In this embodiment of the invention, the update file is obtained by rewriting the source code of the component after updating it. The rewriting of the component's source code after updating it is equivalent to establishing a bridge between the application and the update file, so that the updated parameters can be passed to the component through the rewritten update file, thereby realizing the dynamic update of the component. Therefore, after responding to the dynamic update instruction of the component, the corresponding update file is obtained. The update file can be parsed to generate the expression tree corresponding to the component. Then, based on the structure of the expression tree, the attribute values corresponding to each node can be obtained in sequence, which includes the parameters for component update. Then, the attribute values corresponding to each node can be combined to obtain the updated component. In this way, even when there is a mismatch between the update file and the application of the component, the dynamic update of the component can still be realized, thus improving the efficiency of the dynamic update of the component.
[0099] According to embodiments of the present invention, an electronic device and a readable storage medium are also provided.
[0100] An electronic device according to an embodiment of the present invention includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to cause the at least one processor to perform the component dynamic update method provided in the embodiment of the present invention.
[0101] Figure 4 An exemplary system architecture 400 is shown, in which the method or apparatus for dynamic component updating of embodiments of the present invention can be applied.
[0102] like Figure 4 As shown, system architecture 400 may include terminal devices 401, 402, and 403, a network 404, and a server 405. Network 404 serves as the medium for providing communication links between terminal devices 401, 402, and 403 and server 405. Network 404 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0103] Users can use terminal devices 401, 402, and 403 to interact with server 405 via network 404 to receive or send messages, etc. Various client applications can be installed on terminal devices 401, 402, and 403.
[0104] Terminal devices 401, 402, and 403 can be, but are not limited to, smartphones, tablets, laptops, and desktop computers, etc.
[0105] Server 405 can be a server that provides various services. The server can analyze and process data such as received product information query requests, and feed back the processing results (such as product information - just an example) to the terminal device.
[0106] It should be noted that the component dynamic update method provided in the embodiments of the present invention is generally executed by server 405, and correspondingly, the component dynamic update device is generally set in server 405.
[0107] It should be understood that Figure 4 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0108] The following is for reference. Figure 5 It shows a schematic diagram of the structure of a computer system 500 suitable for implementing embodiments of the present invention. Figure 5 The computer system shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.
[0109] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 502 or programs loaded from storage section 508 into random access memory (RAM) 503. The RAM 503 also stores various programs and data required for the operation of the system 500. The CPU 501, ROM 502, and RAM 503 are interconnected via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0110] The following components are connected to I / O interface 505: an input section 506 including a keyboard, mouse, etc.; an output section 507 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to I / O interface 505 as needed. A removable medium 511, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 510 as needed so that computer programs read from it can be installed into storage section 508 as needed.
[0111] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 509, and / or installed from removable medium 511. When the computer program is executed by central processing unit (CPU) 501, it performs the functions defined above in the system of this invention.
[0112] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0113] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a unit, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0114] The units described in the embodiments of the present invention can be implemented in software or hardware. The described units can also be located in a processor; for example, a processor can be described as including a response unit, a determination unit, and an update unit. The names of these units do not necessarily limit the specific unit; for example, a receiving unit can also be described as "a unit that performs the functions of a receiving unit."
[0115] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs that, when executed by the device, cause the device to perform the component dynamic update method provided by the present invention.
[0116] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for dynamically updating components, characterized in that, include: In response to a component's dynamic update instruction, the corresponding update file is obtained. The update file is obtained by rewriting the source code of the component after updating it. The process includes: generating a set of syntax tree node types after updating the page source code; rewriting the updated node functions in the set of syntax tree node types based on a preset data structure to obtain a page update file; generating an update file for the component through the field values of the type field in the page update file; generating a version identifier corresponding to the update file; and storing the correspondence between the version identifier and the component identifier of the component. Based on the update file, generate expressions corresponding to each node in the update file to determine the expression tree corresponding to the component; Based on the structure of the expression tree, the attribute values corresponding to each node are obtained sequentially, and the attribute values corresponding to each node are combined to obtain the updated component and display it, thereby realizing the dynamic updating of the component.
2. The method according to claim 1, characterized in that, The data structure based on the preset format rewrites the updated node functions in the set of syntax tree node types to obtain the updated file, including: Based on a data structure with a preset format, the update node function in the set of syntax tree node types is rewritten to obtain the update file corresponding to the page; Filter data structures whose type field values are preset values to generate update files for the components corresponding to the data structures.
3. The method according to claim 1 or 2, characterized in that, Based on a preset data structure, rewrite the update node functions in the set of syntax tree node types, including: Based on the map data structure, rewrite the node functions that update the set of node types in the syntax tree.
4. The method according to claim 1, characterized in that, Based on the updated file, generate expressions corresponding to each node in the updated file, including: Query the target field values of each node in the updated file, and generate corresponding expressions for each node based on the expression types corresponding to the target field values.
5. The method according to claim 1, characterized in that, The method further includes: In response to the display operation of the page corresponding to the component, the version identifier of the update file corresponding to the component identifier is obtained, so as to determine whether the version identifier is greater than the current version identifier of the component; In response to the version identifier being greater than the current version identifier of the component, a dynamic update instruction for the component is triggered.
6. A device for dynamically updating components, characterized in that, include: A response unit is used to respond to a component's dynamic update instruction and obtain the corresponding update file. The update file is obtained by rewriting the source code of the component after updating it. The process includes: generating a set of syntax tree node types after updating the page source code; rewriting the updated node functions in the set of syntax tree node types based on a preset data structure to obtain a page update file; generating an update file for the component through the field values of the type fields in the page update file; generating a version identifier corresponding to the update file; and storing the correspondence between the version identifier and the component identifier of the component. The determining unit is configured to generate expressions corresponding to each node in the update file based on the update file, so as to determine the expression tree corresponding to the component; The update unit is used to sequentially obtain the attribute values corresponding to each node based on the structure of the expression tree, combine the attribute values corresponding to each node to obtain the updated component and display it, thereby realizing the dynamic updating of the component.
7. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-5.
8. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Open source software defect data classification method and system based on abstract syntax tree
CN112181428A
Dynamic updating method and device of Flutter component, electronic equipment and storage medium
CN112667263A
Hook method and device for compiling period, equipment and storage medium
CN112799677A