CN114594980A - Method and device for dynamically updating component, electronic equipment and storage medium - Google Patents

Method and device for dynamically updating component, electronic equipment and storage medium Download PDF

Info

Publication number
CN114594980A
CN114594980A CN202210255467.5A CN202210255467A CN114594980A CN 114594980 A CN114594980 A CN 114594980A CN 202210255467 A CN202210255467 A CN 202210255467A CN 114594980 A CN114594980 A CN 114594980A
Authority
CN
China
Prior art keywords
component
updated
file
updating
node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210255467.5A
Other languages
Chinese (zh)
Inventor
康伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202210255467.5A priority Critical patent/CN114594980A/en
Publication of CN114594980A publication Critical patent/CN114594980A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/656Updates while running
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/51Source to source
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a device for dynamically updating a component, electronic equipment and a storage medium, and relates to the technical field of computers. One embodiment of the method comprises: responding to a dynamic updating instruction of the component, and acquiring a corresponding updating file, wherein the updating file is obtained by rewriting the updated source code of the component; generating an expression corresponding to each node in the update file based on the update file so as to determine an expression tree corresponding to the component; and sequentially acquiring attribute values corresponding to the nodes based on the structure of the expression tree so as to combine the attribute values corresponding to the nodes to obtain and display the updated component. The method and the device can solve the problem that the efficiency of dynamic updating of the component is low because the compiled file is not matched with the application sometimes and the component cannot be dynamically updated.

Description

Method and device for dynamically updating component, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for dynamically updating a component, an electronic device, and a storage medium.
Background
The Flutter component is often used in application development of mobile terminals to enable dynamic updates of application pages. In the prior art, when a page needs to be updated, an updated compiled file can be dynamically downloaded, and a Flutter component operates after replacing the updated compiled file, so that the page is dynamically updated. However, since the update files developed by different platforms are not the same, and the compiled file is sometimes not matched with the application, the component cannot be dynamically updated, and the efficiency of dynamically updating the component is low.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for dynamically updating a component, an electronic device, and a storage medium, which can solve the problem that a compiled file sometimes does not match an application, and a component cannot be dynamically updated, so that the efficiency of dynamically updating the component is low.
To achieve the above object, according to an aspect of an embodiment of the present invention, a method for dynamically updating a component is provided.
To achieve the above object, according to another aspect of the embodiments of the present invention, an apparatus for dynamically updating components is provided.
The device for dynamically updating the components of the embodiment of the invention comprises: responding to a dynamic updating instruction of the component, and acquiring a corresponding updating file, wherein the updating file is obtained by rewriting a source code of the component after updating; generating an expression corresponding to each node in the update file based on the update file to determine an expression tree corresponding to the component; and sequentially acquiring attribute values corresponding to the nodes based on the structure of the expression tree so as to combine the attribute values corresponding to the nodes to obtain and display the updated component.
In one embodiment, before said responding to the dynamic update instruction, further comprising:
acquiring a source code of a page corresponding to the component, and updating the source code;
generating a syntax tree node type set of the updated source code, and rewriting updated node functions in the syntax tree node type set by using a data structure based on a preset format to obtain an updated file;
and generating a version identification corresponding to the updated file, and storing the corresponding relation between the version identification and the component identification of the component.
In another embodiment, the rewriting the updated node function in the syntax tree node type set based on the data structure in the preset format to obtain the updated file includes:
rewriting the updated node function in the syntax tree node type set based on a data structure with a preset format to obtain an updated file corresponding to the page;
and screening a data structure with a preset value as a type field value to generate an update file of a component corresponding to the data structure.
In another embodiment, the rewriting of the updated node function in the syntax tree node type set based on a data structure in a preset format includes:
rewriting the updated node function in the syntax tree node type set based on the map data structure.
In another embodiment, generating an expression corresponding to each node in the update file based on the update file includes:
and querying the target field value of each node in the update file to generate an expression corresponding to each node based on the expression type corresponding to the target field value.
In yet another embodiment, the method further comprises:
responding to the display operation of the page corresponding to the component, and acquiring the version identification of the updated file corresponding to the component identification so as to judge whether the version identification is larger than the current version identification of the component;
and triggering a dynamic updating instruction of the component in response to the version identification being larger than the current version identification of the component.
To achieve the above object, according to another aspect of the embodiments of the present invention, an apparatus for dynamically updating components is provided.
The device for dynamically updating the components in the embodiment of the invention comprises: the response unit is used for responding to a dynamic update instruction of the component and acquiring a corresponding update file, wherein the update file is obtained by rewriting the updated source code of the component; the determining unit is used for generating expressions corresponding to all nodes in the update file based on the update file so as to determine an expression tree corresponding to the component; and the updating unit is used for sequentially acquiring the attribute values corresponding to the nodes based on the structure of the expression tree so as to combine the attribute values corresponding to the nodes to obtain an updated assembly and display the updated assembly.
In one embodiment, the apparatus further comprises:
the updating unit is used for acquiring a source code of the page corresponding to the component and updating the source code;
the rewriting unit is used for generating a syntax tree node type set of the updated source code, and rewriting the updated node function in the syntax tree node type set based on a data structure in a preset format to obtain the updated file;
and the storage unit is used for generating a version identifier corresponding to the update file and storing the corresponding relation between the version identifier and the component identifier of the component.
In another embodiment, the rewrite unit is specifically configured to:
rewriting the updated node function in the syntax tree node type set based on a data structure with a preset format to obtain an updated file corresponding to the page;
and screening a data structure with the type field value as a preset value to generate an update file of a component corresponding to the data structure.
In another embodiment, the rewrite unit is specifically configured to:
rewriting the updated node function in the syntax tree node type set based on the map data structure.
In another embodiment, the determining unit is specifically configured to:
and inquiring the target field value of each node in the update file so as to generate an expression corresponding to each node based on the expression type corresponding to the target field value.
In yet another embodiment, the apparatus further comprises:
the judging unit is used for responding to the display operation of the page corresponding to the component, acquiring the version identification of the update file corresponding to the component identification, and judging whether the version identification is larger than the current version identification of the component or not;
and the triggering unit is used for triggering a dynamic updating instruction of the component in response to the version identification being larger than the current version identification of the component.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided an electronic apparatus.
An electronic device according to an embodiment of the present invention includes: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the method for dynamically updating the components provided by the embodiment of the invention.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided a computer-readable medium.
A computer-readable medium of an embodiment of the present invention stores thereon a computer program, which when executed by a processor implements a method for dynamically updating a component provided by an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: in the embodiment of the invention, the update file is obtained by rewriting the updated source code of the component, the rewriting of the updated source code of the component is equivalent to establishing a bridge between the application and the update file, the updated parameters are transmitted to the component through the rewritten update file to realize the dynamic update of the component, therefore, after the dynamic update instruction of the response component is triggered, the corresponding update file is obtained, the update file can be analyzed to generate the expression tree corresponding to the component, then based on the structure of the expression tree, the attribute value corresponding to each node can be obtained in turn, namely, the updated parameters of the components are included, and the updated components can be obtained by combining the attribute values corresponding to the nodes, therefore, when the updated file is not matched with the application of the component, the dynamic update of the component can be realized, and the efficiency of the dynamic update of the component is improved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of one major flow of a method for dynamic update of components, according to an embodiment of the invention;
FIG. 2 is a schematic diagram of yet another major flow of a method for dynamic update of components according to an embodiment of the invention;
FIG. 3 is a schematic diagram of the main elements of an apparatus for dynamic update of components, according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
FIG. 5 is a schematic block diagram of a computer system suitable for use in implementing embodiments of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments and features of the embodiments may be combined with each other without conflict.
The embodiment of the invention provides a system for dynamically updating a component, which can comprise a terminal device, wherein an application can be installed in the terminal device, and a page of the application is realized through the component, such as a Flutter component. When the page needs to be updated, the Flutter component can dynamically load the update file to realize the dynamic update of the page. The dynamic component updating system can further comprise a server, the server can be used for storing an update file of the Flutter component, and when the page needs to be updated, the Flutter component can dynamically load the update file from the server through interaction with the server.
An embodiment of the present invention provides a method for dynamically updating a component, where the method may be executed by a terminal, and as shown in fig. 1, the method includes:
s101: and responding to the dynamic updating instruction of the component, and acquiring a corresponding updating file.
Wherein, the update file is obtained by rewriting the updated source code of the component.
The updating of the page in the application is usually updating of the style, for example, updating of elements such as the background of the page, the text of the button, the decoration style, the size of the text, the color, the font, and the like, so in the embodiment of the present invention, the component is dynamically updated to be the updating of the page style. In a development stage of an application page, a component set which can be used for updating in a page, such as elements of a top TitleBar, a whole page background, a certain button and the like, are usually configured in advance in a source code, and the elements are usually wrapped by using a Flutter component.
When the page needs to be updated, the source code of the page can be obtained first, and the code in the HotReloadWidget component which needs to be updated in the source code is modified, that is, the source code corresponding to the component is updated. After the source code is updated, a syntax tree node type set in the source code can be generated, and then the updated node function is rewritten through the syntax tree node type set to obtain an updated file. After the update file is obtained, the version identifier corresponding to the update file can be generated, and the corresponding relation between the version identifier and the component identifier of the component is stored, so that the update file can be conveniently obtained. Therefore, the updated file corresponding to the component can be automatically obtained by rewriting the updated source code corresponding to the component, and the updated file is acquired by the established corresponding relation, so that the component is updated, the dynamic update of the component can be realized when the updated file is not matched with the application of the component, and the efficiency of the dynamic update of the component is improved.
It should be noted that the update to the source code in this step can be performed in the original IDE, and whether the updated source code conforms to the style specification is previewed through the IDE. Each element, method, and parameter in the source code may be used as a node, in this step, a gennerralinzingastvisitor (a class for accessing AST (Abstract Syntax Tree) structure data) may be inherited, and a Syntax Tree node type set may be generated based on code logic in the source code, where the Syntax Tree node type set includes nodes for modifying code in the source code. For the source code, a SimpleAstVisitor (a class for accessing AST structure data) in the source code may be inherited, so as to determine, from the syntax tree node type set, a node function (e.g., visitNode function) updated in the syntax tree node type set, that is, a node function corresponding to a modified node, and then rewrite the node function, that is, describe the node function by a data structure in a preset format. In this embodiment of the present invention, the data structure in the preset format may specifically be a map data structure, so that the node function updated in the syntax tree node type set may be rewritten based on the map data structure, and specifically, the map data structure may specifically be in a key-value (key-value) format, such as { "type": "Return State", "alignment": therefore, the rewritten node function can be directly determined through the value in each key value format, that is, the updated content of the component can be quickly determined, and the efficiency of dynamic update of the component can be further improved.
Since the source code update to the page may be an update to multiple elements, and each modified element may also be wrapped by a different HotReloadWidget component, it may be possible to update multiple HotReloadWidget components in the source code, and each HotReloadWidget component may perform its own dynamic update. Therefore, in the embodiment of the present invention, the update file of each HotReloadWidget component may be stored separately, and specifically, the update file may be executed as: rewriting updated node functions in the node type set of the syntax tree based on a data structure with a preset format to obtain an updated file corresponding to the page; and screening the data structure with the preset value as the type field value to generate an update file of the component corresponding to the data structure. In this step, when the component is updated, the source code of the page in the application can be updated first, then the updated node function can be rewritten to obtain the updated file of the page, and then the updated file of the component is generated through the type field value in the updated file of the page, so that the updated file and the application can be matched with each other as much as possible, and the updating efficiency of the dynamic component can be improved.
After the source code of the page is updated, a node type set of the syntax tree can be obtained, then after the node function updated in the node type set of the syntax tree is rewritten, an update file of the page can be obtained, and then the data structure of each HotRoadWidget component in the page, namely a map data structure, can be screened out through the field value of the type field in the component, and then the data structure of each HotRoadWidget component is stored independently, so that the update file of the component is generated. The preset value of the type field may be set based on a scene, for example, the preset value may be hotraloadwidget.
In the embodiment of the invention, when the page is opened and displayed in the application, the component corresponding to the page can be updated and inquired firstly, and whether the updating is needed or not is judged by updating the inquiry result. If the updating is needed, a dynamic updating instruction of the component can be triggered to execute dynamic updating firstly; and if the updating is not needed, the dynamic updating instruction of the component is not triggered, and the page display is carried out. Specifically, the following may be implemented: responding to the display operation of the page corresponding to the component, and acquiring the version identification of the updated file corresponding to the component identification so as to judge whether the version identification is larger than the current version identification of the component; and triggering a dynamic updating instruction of the component in response to the version identification being larger than the current version identification of the component.
The current version identifier may be currently stored by the component, and the component may update the current version identifier after each dynamic update. The update file can be stored in 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 judge whether the obtained version identifier is larger than the current version identifier of the component, if so, the component needs to be dynamically updated; if not, the component is not required to be dynamically updated. After the component is determined to need to be dynamically updated, a dynamic update instruction can be triggered, and then an update file corresponding to the component can be obtained. Therefore, after the application is triggered to display operation, whether the component needs to be updated or not can be determined through the version identifier, and a dynamic update instruction is triggered after the update is determined to be needed, so that timely dynamic update of the component in the application can be realized, and the timeliness of updating the component is improved.
S102: and generating an expression corresponding to each node in the update file based on the update file so as to determine an expression tree corresponding to the component.
The update file includes node information of each node, such as a node function, so that a corresponding Expression of each node, that is, an Expression of each node, may be generated based on the update file. After the expression of each node is obtained, an expression tree corresponding to the component may be determined based on the inclusion relationship between the nodes, where the expression tree includes a root node and child nodes, for example, a method may be used as one node and may be produced as its corresponding expression, and the input parameter, the return value, the variable definition included in the node function, and the like of the method may also be used as one node and generate a corresponding expression.
It should be noted that the Expression includes multiple types, such as Identifier, numeric live, method declaration, and the like, and in the embodiment of the present invention, the corresponding Expression type may be determined based on the target field value of each node in the update file, and then the Expression corresponding to the node is generated based on the corresponding Expression type. The target field value represents a field value of a target field, the target field may be a field value of a type field in the component, and the type field may include a plurality of fields, such as: the definition of a string type in a program (StringLiteral), the definition of a number type in a program (NumericLiteral), the argument definition of a function in a program (ArgumentList), the content definition of a function method in a program (MethodDeclaration), the function return content definition in a program (returnstate), the variable declaration definition in a program (variable declaration), the operational expression definition in a program (BinaryExpression), and the component definition in a program (hotropeadwidget) that supports dynamic update.
In the embodiment of the invention, corresponding expression types are set for nodes of different information, and the corresponding expression types are represented by field values of target fields, so that the corresponding expression types can be determined through the target field values in the step, and then the corresponding expressions of the nodes are generated, thereby improving the accuracy of the generation of the expressions and the accuracy of the analysis of the updated files.
S103: and sequentially acquiring attribute values corresponding to the nodes based on the structure of the expression tree so as to combine the attribute values corresponding to the nodes to obtain and display the updated component.
The expression tree represents the inclusion relationship among the nodes, the expressions are analyzed in sequence based on the structure of expression data, the attribute values of the attributes corresponding to the nodes can be obtained, and the analysis of the expression tree is generally performed in the sequence from the root node to the child nodes. For example, for a Text component, the attribute values of the fields such as style, textAlign, overflow and the like can be analyzed from the root node, and then the expressions corresponding to the fields such as style and the like are analyzed, so as to obtain the corresponding attribute values respectively. And then, after the attribute values of all the nodes are analyzed, the attribute values can be combined to obtain the finished updated component, so that the dynamic update of the component is finished, the page display can be carried out, and the page update is realized.
In the embodiment of the invention, the update file is obtained by rewriting the updated source code of the component, the rewriting of the updated source code of the component is equivalent to establishing a bridge between the application and the update file, the updated parameters are transmitted to the component through the rewritten update file to realize the dynamic update of the component, therefore, after the dynamic update instruction of the response component is triggered, the corresponding update file is obtained, the update file can be analyzed to generate the expression tree corresponding to the component, then based on the structure of the expression tree, the attribute value corresponding to each node can be obtained in turn, namely, the updated parameters of the components are included, and the updated components can be obtained by combining the attribute values corresponding to the nodes, therefore, when the updated file is not matched with the application of the component, the dynamic update of the component can be realized, and the efficiency of the dynamic update of the component is improved.
Taking an example that a component dynamic update system includes a server and a terminal, a method for dynamically updating a component in the embodiment of the present invention is specifically described, as shown in fig. 2, the method includes:
s201: and the server side acquires the source code of the page corresponding to the component and updates the source code.
S202: and the server generates a syntax tree node type set of the updated source code, and rewrites the updated node function in the syntax tree node type set based on a data structure in a preset format to obtain an updated file.
S203: and the server generates a version identifier corresponding to the update file, and stores the corresponding relation between the version identifier and the component identifier of the component.
S204: and the terminal responds to the display operation of the page corresponding to the component, and acquires the version identification of the updated file corresponding to the component identification from the server so as to judge whether the version identification is larger than the current version identification of the component.
S205: and the terminal triggers a dynamic updating instruction of the component in response to the version identification being larger than the current version identification of the component.
S206: and the terminal responds to the dynamic updating instruction of the component, and the server side acquires the corresponding updating file.
S207: and the terminal generates an expression corresponding to each node in the update file based on the update file so as to determine an expression tree corresponding to the component.
S208: and the terminal sequentially acquires the attribute values corresponding to the nodes based on the structure of the expression tree so as to combine the attribute values corresponding to the nodes to obtain and display the updated component.
It should be noted that the principle of data processing in the embodiment of the present invention is the same as that in the embodiment shown in fig. 1, and is not described herein again.
In order to solve the problems in the prior art, an embodiment of the present invention provides an apparatus 300 for dynamically updating components, as shown in fig. 3, the apparatus 300 includes:
a response unit 301, configured to respond to a dynamic update instruction of a component, and obtain a corresponding update file, where the update file is obtained by rewriting a source code of the component after updating;
a determining unit 302, configured to generate, based on the update file, an expression corresponding to each node in the update file, so as to determine an expression tree corresponding to the component;
an updating unit 303, configured to sequentially obtain 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, obtain an updated component, and display the updated component.
It should be understood that the manner of implementing the embodiment of the present invention is the same as the manner of implementing the embodiment shown in fig. 2, and the description thereof is omitted.
In an implementation manner of the embodiment of the present invention, the updating unit 303 is configured to obtain a source code of a page corresponding to the component, and update the source code; the apparatus 300 further comprises:
the rewriting unit is used for generating a syntax tree node type set of the updated source code, and rewriting the updated node function in the syntax tree node type set based on a data structure in a preset format to obtain the updated file;
and the storage unit is used for generating a version identifier corresponding to the update file and storing the corresponding relation between the version identifier and the component identifier of the component.
In another embodiment, the rewrite unit is specifically configured to:
rewriting the updated node function in the syntax tree node type set based on a data structure with a preset format to obtain an updated file corresponding to the page;
and screening a data structure with the type field value as a preset value to generate an update file of a component corresponding to the data structure.
In another embodiment, the rewriting unit is specifically configured to:
rewriting the updated node function in the syntax tree node type set based on the map data structure.
In another embodiment, the determining unit is specifically configured to:
and inquiring the target field value of each node in the update file so as to generate an expression corresponding to each node based on the expression type corresponding to the target field value.
In yet another embodiment, the apparatus 300 further comprises:
the judging unit is used for responding to the display operation of the page corresponding to the component, acquiring the version identification of the update file corresponding to the component identification, and judging whether the version identification is larger than the current version identification of the component or not;
and the triggering unit is used for responding to the version identification larger than the current version identification of the component and triggering a dynamic updating instruction of the component.
It should be understood that the embodiment of the present invention is implemented in the same manner as the embodiment shown in fig. 1 or fig. 2, and is not described herein again.
In the embodiment of the invention, the update file is obtained by rewriting the updated source code of the component, the rewriting of the updated source code of the component is equivalent to establishing a bridge between the application and the update file, the updated parameters are transmitted to the component through the rewritten update file to realize the dynamic update of the component, therefore, after the dynamic update instruction of the response component is triggered, the corresponding update file is obtained, the update file can be analyzed to generate the expression tree corresponding to the component, then based on the structure of the expression tree, the attribute value corresponding to each node can be obtained in turn, namely, the updated parameters of the components are included, and the updated components can be obtained by combining the attribute values corresponding to the nodes, therefore, when the updated file is not matched with the application of the component, the dynamic update of the component can be realized, and the efficiency of the dynamic update of the component is improved.
According to an embodiment of the present invention, an electronic device and a readable storage medium are also provided.
The electronic device of the embodiment of the invention comprises: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the processor, and the instructions are executed by the at least one processor to cause the at least one processor to perform the method for dynamically updating the components provided by the embodiment of the present invention.
Fig. 4 illustrates an exemplary system architecture 400 to which the method for component dynamic update or the apparatus for component dynamic update of embodiments of the present invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like. Various client applications may be installed on the terminal devices 401, 402, 403.
The terminal devices 401, 402, 403 may be, but are not limited to, smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 405 may be a server that provides various services, and the server may analyze and process data such as a received product information query request, and feed back a processing result (for example, product information — just an example) to the terminal device.
It should be noted that the method for dynamically updating the components provided by the embodiment of the present invention is generally performed by the server 405, and accordingly, the device for dynamically updating the components is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, a block diagram of a computer system 500 suitable for use in implementing embodiments of the present invention is shown. The computer system illustrated in FIG. 5 is only an example and should not impose any limitations on the scope of use or functionality of embodiments of the invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures 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 the flowchart or block diagrams may represent a unit, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present invention may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a response unit, a determination unit, and an update unit. Where the names of these elements do not in some cases constitute a limitation of the element itself, for example, a receiving element may also be described as "an element of the function of the receiving element".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to perform the method for dynamically updating components provided by the present invention.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for dynamic update of a component, comprising:
responding to a dynamic updating instruction of the component, and acquiring a corresponding updating file, wherein the updating file is obtained by rewriting a source code of the component after updating;
generating an expression corresponding to each node in the update file based on the update file to determine an expression tree corresponding to the component;
and sequentially acquiring attribute values corresponding to the nodes based on the structure of the expression tree so as to combine the attribute values corresponding to the nodes to obtain and display the updated component.
2. The method of claim 1, prior to said responding to the dynamically updated instruction, further comprising:
acquiring a source code of a page corresponding to the component, and updating the source code;
generating a syntax tree node type set of the updated source code, and rewriting updated node functions in the syntax tree node type set by using a data structure based on a preset format to obtain an updated file;
and generating a version identification corresponding to the updated file, and storing the corresponding relation between the version identification and the component identification of the component.
3. The method according to claim 2, wherein the rewriting the updated node function in the syntax tree node type set based on the data structure in the preset format to obtain the updated file comprises:
rewriting updated node functions in the syntax tree node type set based on a data structure with a preset format to obtain an updated file corresponding to the page;
and screening a data structure with the type field value as a preset value to generate an update file of a component corresponding to the data structure.
4. The method according to claim 2 or 3, wherein rewriting the updated node function in the syntax tree node type set based on a data structure in a preset format comprises:
rewriting the updated node function in the syntax tree node type set based on the map data structure.
5. The method of claim 1, wherein generating the expression corresponding to each node in the update file based on the update file comprises:
and inquiring the target field value of each node in the update file so as to generate an expression corresponding to each node based on the expression type corresponding to the target field value.
6. The method of claim 1, further comprising:
responding to the display operation of the page corresponding to the component, and acquiring the version identification of the updated file corresponding to the component identification to judge whether the version identification is larger than the current version identification of the component;
and triggering a dynamic updating instruction of the component in response to the version identification being larger than the current version identification of the component.
7. An apparatus for dynamically updating components, comprising:
the response unit is used for responding to a dynamic update instruction of the component and acquiring a corresponding update file, wherein the update file is obtained by rewriting the updated source code of the component;
the determining unit is used for generating expressions corresponding to all nodes in the update file based on the update file so as to determine an expression tree corresponding to the component;
and the updating unit is used for sequentially acquiring the attribute values corresponding to the nodes based on the structure of the expression tree so as to combine the attribute values corresponding to the nodes to obtain and display the updated component.
8. The apparatus of claim 7, further comprising:
the updating unit is used for acquiring a source code of the page corresponding to the component and updating the source code;
the rewriting unit is used for generating a syntax tree node type set of the updated source code, and rewriting the updated node function in the syntax tree node type set based on a data structure in a preset format to obtain the updated file;
and the storage unit is used for generating a version identifier corresponding to the update file and storing the corresponding relation between the version identifier and the component identifier of the component.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN202210255467.5A 2022-03-15 2022-03-15 Method and device for dynamically updating component, electronic equipment and storage medium Pending CN114594980A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210255467.5A CN114594980A (en) 2022-03-15 2022-03-15 Method and device for dynamically updating component, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210255467.5A CN114594980A (en) 2022-03-15 2022-03-15 Method and device for dynamically updating component, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114594980A true CN114594980A (en) 2022-06-07

Family

ID=81809764

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210255467.5A Pending CN114594980A (en) 2022-03-15 2022-03-15 Method and device for dynamically updating component, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114594980A (en)

Similar Documents

Publication Publication Date Title
CN109062563B (en) Method and device for generating page
US9916140B2 (en) Method of generating end-to-end web application from tooling
CN110895471A (en) Installation package generation method, device, medium and electronic equipment
CN110555030A (en) SQL statement processing method and device
CN110780874B (en) Method and device for generating information
CN113760324A (en) Method and device for constructing micro front-end application
CN113238740B (en) Code generation method, code generation device, storage medium and electronic device
CN110109983B (en) Method and device for operating Redis database
CN114035879A (en) Page theme color changing method and device, electronic equipment and computer readable medium
CN113760276A (en) Method and device for generating page code
CN113536748A (en) Method and device for generating chart data
CN109254778B (en) Method and apparatus for deploying an information flow system
CN112947900A (en) Web application development method and device, server and development terminal
CN116048517A (en) API (application program interface) generating method, system and device based on B/S (browser/Server) architecture application system
CN112579151A (en) Method and device for generating model file
CN114625373A (en) Application conversion method and device, electronic equipment and storage medium
US20220284371A1 (en) Method, device and medium for a business function page
CN114594980A (en) Method and device for dynamically updating component, electronic equipment and storage medium
CN112130860B (en) JSON object analysis method and device, electronic equipment and storage medium
CN114880020A (en) Software development kit management method, related device and computer program product
CN114661402A (en) Interface rendering method and device, electronic equipment and computer readable medium
CN112099841A (en) Method and system for generating configuration file
CN112306984A (en) Data source routing method and device
CN112882698A (en) Development environment generation method and device, computer storage medium and electronic device
CN110858240A (en) Front-end module loading method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination