Page updating method and device, equipment, storage medium and product
By isolating the development service runtime environment of the front-end project and dynamically updating the module code using hot update messages, the issues of accuracy and real-time performance of the preview page are resolved, enabling partial updates that keep the page state unchanged during development.
Patent Information
- Application Number
- CN202510677168.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-23
- Publication Date
- 2026-11-24
AI Technical Summary
During front-end project development, the generated preview pages suffer from poor accuracy and real-time performance, especially due to rendering deviations caused by differences between development and production environments.
By isolating the runtime environments of development services corresponding to different front-end projects, and dynamically updating the module code of the target module using hot update messages, partial updates of the preview page can be achieved, maintaining consistency between the development and production environments.
This improves the accuracy and real-time performance of the preview page, avoids reloading the entire page, and ensures the accuracy and real-time performance of the preview page during the development process.
Smart Images

Figure CN123157201A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a page update method, a page update device, a computer device, a computer-readable storage medium, and a page update product. Background Technology
[0002] With advancements in scientific research, front-end development technology has developed rapidly. During front-end project development, it's necessary to continuously debug the source code based on project requirements and test results. During this debugging process, developers typically need to view preview pages generated from the debugged code to ensure the debugging effect. Research has found that, due to factors such as the development environment and compilation performance bottlenecks, the accuracy (e.g., rendering discrepancies between the front-end page generated in the development environment and the front-end page generated in the real environment) and real-time performance of preview pages generated during development are poor. Summary of the Invention
[0003] This application provides a page update method, apparatus, device, computer-readable storage medium, and product that can improve the accuracy and real-time performance of preview pages generated during the development process.
[0004] On one hand, embodiments of this application provide a page update method, including:
[0005] This displays a preview page of the front-end project, which is based on the project's source code.
[0006] Get the hot update message of the front-end project. The hot update message includes the module code of the target module. The target module is the module in the front-end project that needs to be updated. The hot update message is generated by the development service corresponding to the front-end project after detecting changes in the source code. The runtime environment of the development service corresponding to different front-end projects is isolated from each other.
[0007] By using the target module's code, the runtime modules of the front-end project are dynamically updated, and the updated results are obtained and displayed on the preview page.
[0008] In this embodiment, a preview page of the front-end project is displayed. The preview page is derived from the source code of the front-end project. A hot update message for the front-end project is obtained. This hot update message includes the module code of the target module that needs to be updated. The hot update message is generated by the development service corresponding to the front-end project after detecting changes in the source code. The runtime environments of the development services corresponding to different front-end projects are isolated from each other. By dynamically updating the runtime modules of the front-end project using the module code of the target module, the update result of the preview page is obtained and displayed. Therefore, by isolating the runtime environment of the development service corresponding to each front-end project and implementing dynamic module updates of the front-end project based on hot update messages, partial updates to the preview page can be performed while ensuring consistency between the development and production environments (keeping the preview page state unchanged without reloading the entire preview page), thereby improving the accuracy and real-time performance of the preview pages generated during the development process.
[0009] On one hand, embodiments of this application provide a page update method, including:
[0010] Retrieve the updated code and project identifier of the front-end project;
[0011] Based on the updated code, the source code of the front-end project is updated;
[0012] The hot update message for the front-end project is generated by the development service corresponding to the front-end project. The hot update message includes the module code of the target module, which is the module in the front-end project that needs to be updated. The module code is obtained based on the updated source code. The runtime environments of the development services corresponding to different front-end projects are isolated from each other.
[0013] A hot update message is returned to the client so that the client can display the updated result of the preview page of the front-end project based on the hot update message. The updated result of the preview page of the front-end project is obtained by dynamically updating the runtime module of the front-end project through the module code of the target module.
[0014] In this embodiment, the updated code and project identifier of the front-end project are obtained. Based on the updated code, the source code of the front-end project is updated. An update message for the front-end project is generated through the development service corresponding to the front-end project. The hot update message includes the module code of the target module, which is the module in the front-end project that needs to be updated. The module code is obtained based on the updated source code. The runtime environments of the development services corresponding to different front-end projects are isolated from each other. A hot update message is returned to the client so that the client can display the update result of the preview page of the front-end project based on the hot update message. The update result of the preview page of the front-end project is obtained by dynamically updating the runtime module of the front-end project through the module code of the target module. It can be seen that by isolating the runtime environment of the development service corresponding to each front-end project and realizing the dynamic update of the front-end project module based on the hot update message, partial updates of the preview page can be performed while ensuring consistency between the development environment and the production environment (keeping the preview page state unchanged without reloading the entire preview page), thereby improving the accuracy and real-time performance of the preview page generated during the development process.
[0015] On one hand, embodiments of this application provide a page updating device, which includes:
[0016] The display unit is used to display a preview page of the front-end project, which is based on the source code of the front-end project.
[0017] The acquisition unit is used to acquire hot update messages of the front-end project. The hot update message includes the module code of the target module, which is the module in the front-end project that needs to be updated. The hot update message is sent by the development service corresponding to the front-end project after detecting changes in the source code. The runtime environments of the development services corresponding to different front-end projects are isolated from each other.
[0018] The processing unit is used to dynamically update the runtime modules of the front-end project through the module code of the target module, and obtain and display the update results on the preview page.
[0019] In one implementation, the preview page of the front-end project is displayed in the canvas area of the first client, and the development service corresponding to the front-end project runs on the server; the processing unit is further configured to:
[0020] In response to component editing operations in the canvas area, generate the first update code;
[0021] Send the first update code to the server so that the server updates the source code based on the first update code.
[0022] In one implementation, the processing unit is configured to generate first update code in response to a component editing operation in the canvas area, specifically for:
[0023] In response to component editing operations in the canvas area, the abstract syntax tree of the front-end project is updated based on the component editing operations. The abstract syntax tree is generated based on the source code.
[0024] Based on the updated abstract syntax tree, the first updated code is generated.
[0025] In one implementation, the preview page of the front-end project is displayed in the first client, and at least two clients participate in the collaborative editing of the preview page of the front-end project, with the first client being included in the at least two clients;
[0026] The source code change was triggered by a second update code, which was generated based on component editing operations of a second client, which is any one of at least two clients other than the first client.
[0027] In one implementation, the development service corresponding to the front-end project runs on a local server; the processing unit is used to obtain the hot update message of the front-end project, specifically for:
[0028] Get the first updated code of the front-end project;
[0029] Based on the first updated code, the source code of the front-end project is updated to obtain the updated source code;
[0030] Through the development service corresponding to the front-end project, we can obtain the hot update message of the front-end project generated based on the updated source code.
[0031] In one implementation, the processing unit is configured to dynamically update the runtime module of the front-end project using the module code of the target module, and obtain and display the update result of the preview page, specifically for:
[0032] Get the module boundaries associated with the target module. The module boundaries are used to indicate the modules in the front-end project that have dependencies on the target module.
[0033] Based on the target module's code and boundaries, load the target module into the front-end project's runtime environment;
[0034] Based on the runtime environment after loading the target module, the update results of the preview page are displayed.
[0035] In one implementation, the processing unit is configured to display a preview page of the front-end project, specifically for:
[0036] Obtain the source code of the front-end project;
[0037] Send the source code to the server so that the server can start the development service corresponding to the front-end project based on the source code. The access port of the development service is different for different front-end projects.
[0038] Based on the page resources of the front-end project, a preview page of the front-end project is displayed. The page resources are provided by the development service based on the page resource request.
[0039] In one implementation, the processing unit is configured to display a preview page of the front-end project based on the page resources of the front-end project, specifically for:
[0040] Retrieve the Uniform Resource Locator (URL) of the front-end project returned by the server;
[0041] Send page resource requests to the development service corresponding to the front-end project using a Uniform Resource Locator;
[0042] Get the response information for page resource requests, including the page resources of the front-end project;
[0043] Render the page resources of the front-end project to obtain and display the preview page of the front-end project.
[0044] In one implementation, a preview page of the front-end project is displayed in the first client, and the hot update message is obtained from a channel of a full-duplex communication protocol, which is used to establish communication between the first client and the development service corresponding to the front-end project.
[0045] On one hand, embodiments of this application provide a page updating device, which includes:
[0046] The retrieval unit is used to retrieve the updated code and project identifier of the front-end project.
[0047] The processing unit is used to update the source code of the front-end project based on the updated code;
[0048] And it is used to generate hot update messages for front-end projects through the development services corresponding to the front-end projects. The hot update messages include the module code of the target module, which is the module in the front-end project that needs to be updated. The module code is obtained based on the updated source code. The runtime environments of the development services corresponding to different front-end projects are isolated from each other.
[0049] The sending unit is used to return a hot update message to the client, so that the client can display the update result of the preview page of the front-end project based on the hot update message. The update result of the preview page of the front-end project is obtained by dynamically updating the runtime module of the front-end project through the module code of the target module.
[0050] In one implementation, the process by which the processing unit generates a hot update message for the front-end project through the development service corresponding to the front-end project includes:
[0051] After detecting an update to the source code of the front-end project, the module code of the target module is generated through the development service corresponding to the front-end project;
[0052] The module boundaries associated with the target module are determined by the abstract syntax tree of the front-end project. The module boundaries are used to indicate the modules in the front-end project that have dependencies on the target module.
[0053] Based on module boundaries, update the dependencies between modules in the front-end project. These dependencies help the client load the target module into the runtime environment of the front-end project.
[0054] In one embodiment, the processing unit is further configured to:
[0055] Obtain the source code of the front-end project;
[0056] Assign an access port to the front-end project and start the corresponding development service based on the source code. The access port is used to access the development service corresponding to the front-end project. Different front-end projects have different access ports for their corresponding development services.
[0057] In response to a client's request for front-end project page resources, the front-end project's page resources are returned to the client through the corresponding development service.
[0058] In one implementation, the hot update message is transmitted via a channel using a full-duplex communication protocol; after starting the development service corresponding to the front-end project based on the source code, the processing unit is further configured to:
[0059] A connection is established between the development service corresponding to the front-end project and the client through a channel using a full-duplex communication protocol. The client is used to edit the preview page of the front-end project.
[0060] Accordingly, this application provides a computer device comprising:
[0061] Memory, which stores computer programs;
[0062] The processor is used to load computer programs to implement the page update method described above.
[0063] Accordingly, this application provides a computer-readable storage medium storing a computer program adapted to be loaded by a processor and executed by the above-described page update method.
[0064] Accordingly, this application provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the page update method described above.
[0065] In this embodiment, the client displays a preview page of the front-end project, which is derived from the front-end project's source code. The server obtains the updated code and project identifier of the front-end project. Based on the updated code, it updates the source code of the front-end project indicated by the project identifier. A hot update message for the front-end project is generated through the development service corresponding to the front-end project. The hot update message includes the module code of the target module, which is the module in the front-end project that needs to be updated. The module code is derived from the updated source code. The runtime environments of the development services corresponding to different front-end projects are isolated from each other, and hot update messages are returned to the client. The client obtains the hot update message of the front-end project and dynamically updates the runtime modules of the front-end project using the module code of the target module included in the hot update message, obtaining and displaying the updated result of the preview page. It can be seen that by isolating the runtime environment of the development service corresponding to each front-end project and implementing dynamic module updates of the front-end project based on hot update messages, partial updates of the preview page can be performed while ensuring consistency between the development and production environments (keeping the preview page state unchanged without reloading the entire preview page), thereby improving the accuracy and real-time performance of the preview pages generated during the development process. Attached Figure Description
[0066] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0067] Figure 1 An application scenario diagram illustrating a page update scheme provided in an embodiment of this application;
[0068] Figure 2 A flowchart illustrating a page update method provided in this application embodiment;
[0069] Figure 3a A schematic diagram of an abstract syntax tree provided for an embodiment of this application;
[0070] Figure 3b A schematic diagram of an editing page for a front-end project provided in an embodiment of this application;
[0071] Figure 3c This is a schematic diagram illustrating a hot update message acquisition method provided in an embodiment of this application.
[0072] Figure 3d This is another schematic diagram illustrating the acquisition of hot update messages provided in an embodiment of this application;
[0073] Figure 3e This is another schematic diagram illustrating the acquisition of hot update messages provided in an embodiment of this application;
[0074] Figure 3f A schematic diagram of a page update provided in an embodiment of this application;
[0075] Figure 4 A flowchart illustrating another page update method provided in this application embodiment;
[0076] Figure 5 A page update architecture diagram provided for embodiments of this application;
[0077] Figure 6 This is a schematic diagram of the structure of a page update device provided in an embodiment of this application;
[0078] Figure 7 This is a schematic diagram of another page update device provided in an embodiment of this application;
[0079] Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0080] It should be noted in advance that, in order to enable those skilled in the art to better understand the technical solutions proposed in the embodiments of this application, the embodiments of this application will be described clearly and completely in conjunction with one or more accompanying drawings. Furthermore, the various drawings shown in the embodiments of this application are merely illustrative examples; for example, the execution order of each step in the drawings can be adaptively adjusted according to the actual application scenario. In addition, in the embodiments of this application, the block diagrams shown in the various drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, or in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0081] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0082] It should be noted that "multiple" in this article refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0083] This application provides a page update scheme that can improve the accuracy and real-time performance of preview pages generated during the development process. Figure 1 An application scenario diagram of a page update scheme provided in an embodiment of this application is shown, such as... Figure 1 As shown, the application scenario of the page update scheme provided in this application includes a terminal device 101 and a server 102. The page update scheme provided in this application can be executed collaboratively by the terminal device 101 and the server 102. In one embodiment, the steps executed by the server 102 can also be executed by the server in the terminal device 101. In this case, the application scenario of the page update scheme may only include the terminal device 101, and all steps in the page update scheme provided in this application are executed by the terminal device 101. The terminal devices may include, but are not limited to: smartphones (such as Android phones, iOS phones, etc.), tablet computers, portable personal computers, mobile internet devices (MIDs), smart interactive devices, smart home appliances, vehicle terminals, wearable devices, etc., and this application embodiment does not limit them; the server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms, and this application embodiment does not limit them.
[0084] It should be noted that, Figure 1The number of terminal devices and servers is for illustrative purposes only and does not constitute an actual limitation of this application. Terminal device 101 and server 102 can be connected via wired or wireless means, and this application does not impose any restrictions on this.
[0085] The general process of the page update solution provided in this application is as follows:
[0086] (1) Terminal device 101 displays a preview page of the front-end project, which is based on the source code of the front-end project. In one embodiment, in response to the creation operation of the front-end project, terminal device 101 retrieves the source code of the front-end project and assigns a project identifier (such as a hash value) to the front-end project. In addition, terminal device 101 can also parse the source code of the front-end project according to the type of the front-end project (such as classification based on project framework) using the corresponding Abstract Syntax Tree (AST) parser to obtain the abstract syntax tree of the front-end project and establish a mapping relationship between the project identifier, the source code, and the abstract syntax tree. Then, terminal device 101 can send the source code and project identifier of the front-end project to server 102. After receiving the source code and project identifier of the front-end project, server 102, on the one hand, assigns an access interface to the front-end project (different access interfaces for different front-end projects), which can be implemented through a proxy gateway. On the other hand, it stores the source code of the front-end project and establishes a mapping relationship between the access interface, the source code storage path, and the project identifier. Next, server 102 starts the front-end project development service within the container (the runtime environment used to isolate the development service) and generates a Uniform Resource Locator (URL) for the front-end project. Furthermore, server 102 can establish communication between the development service and the client in terminal device 101 via a full-duplex communication protocol (WebSocket) channel. Server 102 sends the URL to terminal device 101, which then sends a page resource request to the development service using the URL. Based on the page resources returned by the development service, terminal device 101 renders a preview page of the front-end project, which can then be displayed on the client in terminal device 101.
[0087] (2) Server 102 obtains the updated code and project identifier of the front-end project, and updates the source code of the front-end project based on the updated code and project identifier (which can be used to determine the source code storage path of the front-end project). The updated code and project identifier of the front-end project can be sent by terminal device 101. In a collaborative editing scenario, the updated code and project identifier of the front-end project can also be sent by other collaborative editing participants besides terminal device 101. Accordingly, after detecting the source code update of the front-end project, the development service corresponding to the front-end project running on server 102 will generate a hot update message for the front-end project and return the hot update message to the client in terminal device 101 (e.g., via a websocket channel); wherein, the hot update message includes the module code of the target module in the front-end project, and the target module is the module in the front-end project that needs to be updated. The module code is obtained based on the updated source code; for example, the module code is obtained by compiling the updated source code.
[0088] (3) Terminal device 101 obtains a hot update message for the front-end project, and dynamically updates the runtime module of the front-end project using the module code of the target module in the hot update message (keeping the preview page state unchanged and not requiring reloading the entire preview page), obtaining and displaying the update result of the preview page of the front-end project. This update result can be specifically displayed in the client on terminal device 101. In one embodiment, terminal device 101 obtains the module boundary associated with the target module; wherein, the module boundary is used to indicate modules in the front-end project that have a dependency relationship with the target module. Then, based on the module code and module boundary of the target module, the target module is loaded into the runtime environment of the front-end project, and the update result of the preview page is displayed based on the runtime environment after loading the target module.
[0089] In this embodiment, the terminal device displays a preview page of the front-end project, which is derived from the source code of the front-end project. The server obtains the updated code and project identifier of the front-end project. Based on the updated code, it updates the source code of the front-end project indicated by the project identifier. A hot update message for the front-end project is generated through the development service corresponding to the front-end project. The hot update message includes the module code of the target module, which is the module in the front-end project that needs to be updated. The module code is derived from the updated source code. The runtime environments of the development services corresponding to different front-end projects are isolated from each other, and hot update messages are returned to the terminal device. The terminal device obtains the hot update message of the front-end project and dynamically updates the runtime modules of the front-end project using the module code of the target module included in the hot update message, obtaining and displaying the update result of the preview page. It can be seen that by isolating the runtime environment of the development service corresponding to each front-end project and implementing dynamic module updates of the front-end project based on hot update messages, partial updates of the preview page can be performed while ensuring consistency between the development and production environments (keeping the preview page state unchanged without reloading the entire preview page), thereby improving the accuracy and real-time performance of the preview pages generated during the development process.
[0090] Based on the above page update scheme, this application proposes a more detailed page update method. The page update method proposed in this application will be described in detail below with reference to the accompanying drawings.
[0091] Please see Figure 2 , Figure 2 A flowchart illustrating a page update method provided in this application embodiment, which can be executed by a computer device; for example, by... Figure 1 The terminal device 101 shown is executing.
[0092] like Figure 2 As shown, the page update method may include the following steps S201-S203:
[0093] S201. Display the preview page of the front-end project.
[0094] The preview page of a front-end project is derived from its source code. In one implementation, a computer device acquires the source code of the front-end project and provides it to a server or local server, enabling the server or local server to launch the development service corresponding to the front-end project based on the source code. Different front-end projects have different access ports for their development services, which can be uniquely identified by the project's identifier. The runtime environments of the development services for different front-end projects are isolated from each other (e.g., through containers). By isolating the runtime environments of the development services, a development environment consistent with the production environment can be configured for each front-end project, resolving rendering discrepancies caused by environmental differences.
[0095] After starting the development service corresponding to the front-end project, the computer device displays a preview page of the front-end project based on the project's page resources. These page resources are provided by the development service based on page resource requests. In one embodiment, the server or local server returns the access address (such as a Uniform Resource Locator) of the front-end project. After obtaining this address, the computer device sends a page resource request to the corresponding development service and retrieves the page resources from the response information. Once the page resources are obtained, the computer device renders them to obtain and display the preview page.
[0096] In another embodiment, after obtaining the source code of the front-end project, the computer device can perform abstract syntax tree parsing on the source code of the front-end project to obtain the abstract syntax tree of the front-end project. Figure 3a This is a schematic diagram of an abstract syntax tree provided for an embodiment of this application. For example... Figure 3a As shown, each node in the abstract syntax tree can correspond to an ES module in the front-end project. The connection between nodes can be used to indicate the dependency relationship between ES modules. For example, if node A is the parent node of node B, it means that module 2 corresponding to node B (directly) depends on module 1 corresponding to node A.
[0097] In another implementation, a preview page of the front-end project is displayed on a canvas on the client side. One or more components can also be displayed on the client side, and objects can edit the front-end project by dragging and dropping components (such as dragging a new component into the canvas or removing a component from the canvas). Figure 3b This is a schematic diagram of an editing page for a front-end project, provided as an embodiment of this application. Figure 3bAs shown, the front-end project editing page 301 includes a canvas area 3011, which displays a preview of the front-end project. The canvas area 3011 supports drag-and-drop editing to generate Vue / React components. The page editing effect of the front-end project can be displayed in real-time in iframe format within the canvas area 3011. In addition, the editing page 301 may also include an element selection bar 3012, a candidate element display area 3013, and an element configuration area 3014. The element selection bar 3012 is used to select the page elements to be edited (such as structures, variables, interfaces, dependencies, etc.). The candidate element display area 3013 is used to display candidate elements; for example, when "component" is selected in the element selection bar 3012, candidate components are displayed in the candidate element display area 3013. These subsequent components can be displayed in categories, and a search control can also be displayed in the candidate element display area 3013 to facilitate developers in quickly searching for the required components. The element configuration area 3014 can be used to further configure selected page elements. For example, if the selected page element is a component, the element configuration area 3014 can be used to configure the component's submission process, style, text, etc. In practical applications, developers can drag and drop candidate elements from the candidate element display area 3013 to the canvas area 3011 to edit the front-end project; in addition, the dragged candidate elements can be further configured through the element configuration area 3014.
[0098] S202, Get the hot update message of the front-end project.
[0099] The hot update message includes the module code of the target module, which is the (ES) module in the front-end project that needs to be updated. The hot update message is generated by the development service corresponding to the front-end project after detecting changes in the source code. In one embodiment, the preview page of the front-end project is displayed in the first client, and the hot update message is obtained from a full-duplex communication protocol (WebSocket) channel. The WebSocket channel is used to establish communication between the first client and the development service corresponding to the front-end project.
[0100] In one implementation, the development service corresponding to the front-end project runs on a server (such as a cloud server, remote server, etc.), and the preview page of the front-end project is displayed in the canvas area of a first client (such as a low-code development platform). In response to component editing operations in the canvas area, the computer device generates first update code. Component editing operations may include, but are not limited to, component addition operations, component configuration operations, and component deletion operations; component editing operations may also be a series of combined operations. For example, in a low-code development platform, component editing operations may include component drag-and-drop operations and configuration operations for dragged components. In one embodiment, in response to component editing operations in the canvas area, the computer device updates the abstract syntax tree of the front-end project based on the component editing operations, and generates first update code based on the updated abstract syntax tree. The computer device then sends the first update code to the server, causing the server to update the source code based on the first update code, and return a hot update message for the front-end project based on the updated source code. Figure 3c This is a schematic diagram illustrating a hot update message acquisition method provided in an embodiment of this application. Figure 3c As shown, the first update code of the front-end project is sent to the server by the computer device. This first update code can be generated by the computer device based on component editing operations in the canvas area. After receiving the first update code, the server updates the source code of the front-end project using the first update code and generates a hot update message. The server can then return this hot update message to the computer device via a WebSocket channel.
[0101] In another implementation, the development service corresponding to the front-end project runs on a local server, and the preview page of the front-end project is displayed in the canvas area of the first client (such as a low-code development platform). In response to component editing operations in the canvas area, the computer device generates first update code. Based on the first update code, the source code of the front-end project is updated to obtain the updated source code. Accordingly, after detecting an update to the source code of the front-end project, the development service corresponding to the front-end project generates a hot update message for the front-end project based on the updated source code. In one embodiment, the process by which the development service corresponding to the front-end project generates a hot update message for the front-end project based on the updated source code includes: generating module code (such as ES module code) for the target module based on the updated source code, and determining the module boundaries associated with the target module through the abstract syntax tree of the front-end project; wherein, the module boundaries are used to indicate modules in the front-end project that have dependencies on the target module. Then, based on the module boundaries, the dependencies between the various modules in the front-end project are updated, and the dependencies are used to assist the client in loading the target module into the runtime environment of the front-end project. Figure 3d This is another schematic diagram illustrating the acquisition of hot update messages provided in an embodiment of this application. For example... Figure 3dAs shown, the computer device includes a client and a local server (no additional server is required). After generating the first update code based on component editing operations in the canvas area, the computer device transmits the first update code to the local server. Upon receiving the first update code of the front-end project, the local server updates the source code of the front-end project using the first update code and generates a hot update message. The local server then returns this hot update message to the client via a WebSocket channel.
[0102] In another implementation, a preview page of the front-end project is displayed on a first client, and at least two clients participate in the collaborative editing of the preview page, with the first client being one of the participating clients. Changes to the front-end project's source code are triggered by a second update code, which is generated based on component editing operations on a second client, which is any client participating in the collaborative editing other than the first client. Figure 3e This is a schematic diagram illustrating another hot update message acquisition method provided in an embodiment of this application. For example... Figure 3e As shown, computer devices and other (computer) devices collaboratively edit the preview page of a front-end project. Other devices send a second update code for the front-end project to the server. This second update code can be generated by other devices based on component editing operations in their canvas area. The server receives the second update code from the other devices, updates the source code of the front-end project using the second update code, and generates a hot update message. The server then returns this hot update message to the computer devices and other devices via a WebSocket channel. At this point, from the computer device's perspective, even though the technical developers have not performed component editing operations, the preview page of the front-end project in the canvas area will still change based on the component editing operations of the other participants.
[0103] S203. By using the module code of the target module, dynamically update the runtime module of the front-end project, and obtain and display the update result on the preview page.
[0104] In one implementation, the computer device obtains the module boundaries associated with the target module; wherein the module boundaries are used to indicate modules in the front-end project that have dependencies on the target module. Then, based on the target module's code and module boundaries, the target module is loaded into the runtime environment of the front-end project, and based on the runtime environment after loading the target module, the updated results of the preview page are displayed.
[0105] Figure 3f This is a schematic diagram of a page update provided in an embodiment of this application. Figure 3f This demonstrates the page changes as developers edit the preview page of the front-end project (i.e., the page changes corresponding to steps S201-S203). For example... Figure 3f As shown, the editing page 302 of the front-end project includes a candidate button component 3021, a canvas area 3022, and a preview page of the front-end project displayed in the canvas area 3022. In response to a drag operation of the candidate button component 3021, the computer device performs a partial update display on a local area 3023 within the canvas area 3022 (keeping the area of the canvas area 3022 other than the local area 3023, and the state of the preview page, unchanged). Specifically, based on the drag operation of the candidate button component 3021, the computer device displays a button 3024 in the local area 3023, and can also display a button configuration area 3025 in the editing page 302. The button configuration area 3025 is used for further configuration of the button 3024 (such as configuring dependencies, text in the button, etc.).
[0106] In this embodiment, a preview page of the front-end project is displayed. The preview page is derived from the source code of the front-end project. A hot update message for the front-end project is obtained. This hot update message includes the module code of the target module that needs to be updated. The hot update message is generated by the development service corresponding to the front-end project after detecting changes in the source code. The runtime environments of the development services corresponding to different front-end projects are isolated from each other. By dynamically updating the runtime modules of the front-end project using the module code of the target module, the update result of the preview page is obtained and displayed. Therefore, by isolating the runtime environment of the development service corresponding to each front-end project and implementing dynamic module updates of the front-end project based on hot update messages, partial updates to the preview page can be performed while ensuring consistency between the development and production environments (keeping the preview page state unchanged without reloading the entire preview page), thereby improving the accuracy and real-time performance of the preview pages generated during the development process.
[0107] Please see Figure 4 , Figure 4 A flowchart illustrating another page update method provided in this application embodiment, which can be executed by a computer device; for example, by... Figure 1 The server 102 shown is executing.
[0108] like Figure 4 As shown, the page update method may include the following steps S401-S404:
[0109] S401. Obtain the updated code and project identifier of the front-end project.
[0110] The project identifier of a front-end project can be used to determine the storage path of the front-end project's source code and the access port of the front-end project. In one embodiment, the updated code of the front-end project is generated by the terminal device based on component editing operations in the canvas area, which displays a preview page of the front-end project.
[0111] In one implementation, before acquiring the updated code and project identifier of the front-end project, the computer device obtains the source code and project identifier of the front-end project. Next, the computer device assigns an access port to the front-end project and can establish a mapping relationship between the access port and the project identifier, allowing the gateway in the computer device to determine the access port of the front-end project based on the project identifier. After assigning the access port, the computer device starts the development service corresponding to the front-end project based on the source code. The access port can be used to access the development service corresponding to the front-end project. Different front-end projects have different access ports for their development services, and the runtime environments of the development services for different front-end projects are isolated from each other (e.g., through containers). By isolating the runtime environments of the development services, a development environment consistent with the production environment can be configured for each front-end project, resolving rendering deviation issues caused by environmental differences.
[0112] After starting the development service corresponding to the front-end project, the computer device can return a Uniform Resource Locator (URL) for the front-end project to the client. The client can then use this URL to send a page resource request to the development service to obtain the front-end project's page resources. In response to the client's page resource request, the computer device returns the front-end project's page resources to the client through the development service. After obtaining the page resources, the client renders them to obtain a preview page of the front-end project. Developers can then edit this preview page on the client; for example, they can edit components through drag-and-drop operations.
[0113] In one embodiment, after starting the development service corresponding to the front-end project based on the source code, the computer device can establish a connection between the development service corresponding to the front-end project and the client through a full-duplex communication protocol (WebSocket) channel.
[0114] S402. Update the source code of the front-end project based on the updated code.
[0115] In one implementation, the computer device determines the storage path of the source code of the front-end project through the project identifier of the front-end project, and updates the stored source code by updating the code.
[0116] S403. Generate hot update messages for the front-end project through the development service corresponding to the front-end project.
[0117] The hot update message includes the module code of the target module, which is the module in the front-end project that needs to be updated. The module code of the target module is obtained based on the updated source code.
[0118] In one implementation, the process by which a computer device generates a hot update message for a front-end project through a development service corresponding to the front-end project includes: upon detecting an update to the source code of the front-end project, on the one hand, generating module code for the target module through the development service corresponding to the front-end project; for example, the development service can analyze the updated source code, determine the parts that need incremental compilation, and then compile the parts that need incremental compilation to obtain the module code for the target module. On the other hand, determining the module boundaries associated with the target module through the abstract syntax tree of the front-end project, the module boundaries are used to indicate modules in the front-end project that have dependencies on the target module. Then, based on the module boundaries, updating the dependencies between the various modules in the front-end project; wherein, the dependencies are used to assist the client in loading the target module into the runtime environment of the front-end project.
[0119] S404. Return a hot update message to the client so that the client can display the update results of the preview page of the front-end project based on the hot update message.
[0120] The update result of the front-end project's preview page is obtained by the client dynamically updating the runtime module of the front-end project through the target module's module code. For details on how the client displays the update result of the front-end project's preview page based on hot update messages, please refer to [link to documentation / reference]. Figure 2 The implementation methods of steps S202 and S203 will not be described in detail here.
[0121] Figure 5 This is a page update architecture diagram provided for an embodiment of this application. For example... Figure 5As shown, a new front-end project is first created in the client (e.g., a low-code editor). The source code of this front-end project (React / Vue) can be pulled from the code repository. The client assigns a unique project identifier (e.g., a hash value) to each front-end project. Then, the editor can use different AST parsers based on the project framework to perform AST parsing on the front-end project's source code, obtaining the front-end project's abstract syntax tree. A mapping relationship can be established between the project identifier, source code, and the front-end project's abstract syntax tree. Next, the client transmits the front-end project's project identifier and source code as parameters to the server (or local server); for example, this can be done through the server's exposed `init http` interface. Upon receiving the initialization request, the server mainly performs the following steps: on one hand, it allocates an idle access port for the front-end project, establishes and stores the mapping relationship between the front-end project's project identifier and the access port. On the other hand, it stores the front-end project's source code locally on the server, establishes and stores the mapping relationship between the front-end project's project identifier and the server's storage path. Finally, the server can start the front-end project's development service within the container (e.g., via `vite`), which can be accessed through the allocated access port. The development service mainly implements: (1) compiling the source code of the front-end project and starting the front-end project; (2) establishing a connection with the client through the WebSocket channel; (3) detecting code updates in the front-end project in real time. After detecting an update to the source code of the front-end project, it will hot-update and compile the front-end project in real time and transmit the hot-update message through the WebSocket channel. After starting the development service, the server can generate an access address (such as a public URL) for the front-end project and transmit the access address back to the client as an interface response. The proxy gateway will record the project identifier and access address of the front-end project, as well as the mapping relationship between the WebSocket channel and the access address. When the editor accesses the development service through the access address, the proxy gateway will automatically forward the request to the corresponding development service or WebSocket channel according to the mapping relationship.
[0122] After the client accesses the development service via the access address, it can display a preview page of the front-end project in an embedded iframe based on the page resources returned by the development service. This iframe serves as the editor's canvas area, where all visual editing interactions of the front-end project take place. When the editor detects a component editing operation (such as dragging a component in the canvas area), it can parse the operation using the AST dynamic parsing engine, generate updated code for the front-end project, and transmit the updated code and the front-end project's identifier as parameters to the server (e.g., the server's update HTTP interface). Upon receiving the updated code and the front-end project's identifier, the proxy gateway can determine the storage path of the front-end project's source code based on the identifier and update the source code accordingly. After detecting an update to the front-end project's source code, the front-end project's development service automatically performs a hot-reload dynamic compilation and transmits the hot-reload message via a WebSocket channel. Upon receiving the WebSocket hot-reload message, the client dynamically updates the front-end project's runtime module using the target module's code, obtaining and displaying the updated preview page.
[0123] In this embodiment, the updated code and project identifier of the front-end project are obtained. Based on the updated code, the source code of the front-end project is updated. An update message for the front-end project is generated through the development service corresponding to the front-end project. The hot update message includes the module code of the target module, which is the module in the front-end project that needs to be updated. The module code is obtained based on the updated source code. The runtime environments of the development services corresponding to different front-end projects are isolated from each other. A hot update message is returned to the client so that the client can display the update result of the preview page of the front-end project based on the hot update message. The update result of the preview page of the front-end project is obtained by dynamically updating the runtime module of the front-end project through the module code of the target module. It can be seen that by isolating the runtime environment of the development service corresponding to each front-end project and realizing the dynamic update of the front-end project module based on the hot update message, partial updates of the preview page can be performed while ensuring consistency between the development environment and the production environment (keeping the preview page state unchanged without reloading the entire preview page), thereby improving the accuracy and real-time performance of the preview page generated during the development process.
[0124] The methods of the embodiments of this application have been described in detail above. In order to facilitate better implementation of the above solutions of the embodiments of this application, the apparatus of the embodiments of this application is provided below.
[0125] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of a page update device provided in an embodiment of this application. Figure 6The page update device shown can be mounted in a computer device, which may specifically be a terminal device. Figure 6 The page update device shown can be used to perform the above. Figure 2 Some or all of the functionality described in the method embodiments. Please refer to [link / reference]. Figure 6 The page update device includes:
[0126] Display unit 601 is used to display a preview page of the front-end project, which is obtained based on the source code of the front-end project;
[0127] The acquisition unit 602 is used to acquire the hot update message of the front-end project. The hot update message includes the module code of the target module. The target module is the module in the front-end project that needs to be updated. The hot update message is generated by the development service corresponding to the front-end project after detecting changes in the source code. The running environments of the development services corresponding to different front-end projects are isolated from each other.
[0128] The processing unit 603 is used to dynamically update the runtime module of the front-end project through the module code of the target module, and obtain the update result and display it on the preview page through the display unit 601.
[0129] In one implementation, the preview page of the front-end project is displayed in the canvas area of the first client, and the development service corresponding to the front-end project runs on the server; the processing unit 603 is further configured to:
[0130] In response to component editing operations in the canvas area, generate the first update code;
[0131] Send the first update code to the server so that the server updates the source code based on the first update code.
[0132] In one implementation, the processing unit 603 is configured to generate first update code in response to a component editing operation in the canvas area, specifically for:
[0133] In response to component editing operations in the canvas area, the abstract syntax tree of the front-end project is updated based on the component editing operations. The abstract syntax tree is generated based on the source code.
[0134] Based on the updated abstract syntax tree, the first updated code is generated.
[0135] In one implementation, the preview page of the front-end project is displayed in the first client, and at least two clients participate in the collaborative editing of the preview page of the front-end project, with the first client being included in the at least two clients;
[0136] The source code change was triggered by a second update code, which was generated based on component editing operations of a second client, which is any one of at least two clients other than the first client.
[0137] In one implementation, the development service corresponding to the front-end project runs on a local server; the processing unit 603 is used to obtain the hot update message of the front-end project, specifically for:
[0138] Get the first updated code of the front-end project;
[0139] Based on the first updated code, the source code of the front-end project is updated to obtain the updated source code;
[0140] Through the development service corresponding to the front-end project, we can obtain the hot update message of the front-end project generated based on the updated source code.
[0141] In one implementation, the processing unit 603 is configured to dynamically update the runtime module of the front-end project using the module code of the target module, and obtain and display the update result of the preview page, specifically for:
[0142] Get the module boundaries associated with the target module. The module boundaries are used to indicate the modules in the front-end project that have dependencies on the target module.
[0143] Based on the target module's code and boundaries, load the target module into the front-end project's runtime environment;
[0144] Based on the runtime environment after loading the target module, the update results of the preview page are displayed.
[0145] In one embodiment, the processing unit 603 is configured to display a preview page of the front-end project, specifically for:
[0146] Obtain the source code of the front-end project;
[0147] Send the source code to the server so that the server can start the development service corresponding to the front-end project based on the source code. The access port of the development service is different for different front-end projects.
[0148] Based on the page resources of the front-end project, a preview page of the front-end project is displayed. The page resources are provided by the development service based on the page resource request.
[0149] In one implementation, the processing unit 603 is configured to display a preview page of the front-end project based on the page resources of the front-end project, specifically for:
[0150] Retrieve the Uniform Resource Locator (URL) of the front-end project returned by the server;
[0151] Send page resource requests to the development service corresponding to the front-end project using a Uniform Resource Locator;
[0152] Get the response information for page resource requests, including the page resources of the front-end project;
[0153] Render the page resources of the front-end project to obtain and display the preview page of the front-end project.
[0154] In one implementation, a preview page of the front-end project is displayed in the first client, and the hot update message is obtained from a channel of a full-duplex communication protocol, which is used to establish communication between the first client and the development service corresponding to the front-end project.
[0155] According to one embodiment of this application, Figure 2 The steps involved in the page update method shown can be derived from... Figure 6 The page update is performed by individual units in the illustrated page update device. For example, Figure 2 Step S201 shown can be performed by Figure 6 The display unit 601 shown executes the step S202, which can be performed by... Figure 6 The acquisition unit 602 shown is executed, and step S203 can be performed by... Figure 6 The processing unit 603 shown executes. Figure 6 The various units in the page update apparatus shown can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effects of the embodiments of this application. The above units are based on logical function division. In practical applications, the function of one unit can be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the page update apparatus may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.
[0156] According to another embodiment of this application, a general-purpose computing device, such as a computer device including processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM), can perform operations such as... Figure 2 The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 6 The page updating apparatus shown herein, and the page updating method for implementing embodiments of this application, are described. A computer program may be recorded on, for example, a computer-readable recording medium, loaded onto the aforementioned computing device via the computer-readable recording medium, and executed therein.
[0157] Based on the same inventive concept, the principle and beneficial effects of the page update device provided in the embodiments of this application are similar to the principle and beneficial effects of the page update method in the embodiments of this application. For details, please refer to the principle and beneficial effects of the method implementation. For the sake of brevity, these will not be repeated here.
[0158] Please see Figure 7 , Figure 7 This is a schematic diagram of another page update device provided in an embodiment of this application. Figure 7 The page update device shown can be mounted in a computer device, specifically a server. Figure 7 The page update device shown can be used to perform the above. Figure 4 Some or all of the functionality described in the method embodiments. Please refer to [link / reference]. Figure 7 The page update device includes:
[0159] Acquisition unit 701 is used to acquire the updated code of the front-end project and the project identifier of the front-end project;
[0160] Processing unit 702 is used to update the source code of the front-end project based on the updated code;
[0161] And it is used to generate hot update messages for front-end projects through the development services corresponding to the front-end projects. The hot update messages include the module code of the target module, which is the module in the front-end project that needs to be updated. The module code is obtained based on the updated source code. The runtime environments of the development services corresponding to different front-end projects are isolated from each other.
[0162] The sending unit 703 is used to return a hot update message to the client so that the client can display the update result of the preview page of the front-end project based on the hot update message. The update result of the preview page of the front-end project is obtained by dynamically updating the runtime module of the front-end project through the module code of the target module.
[0163] In one implementation, the process by which the processing unit 702 generates a hot update message for the front-end project through the development service corresponding to the front-end project includes:
[0164] After detecting an update to the source code of the front-end project, the module code of the target module is generated through the development service corresponding to the front-end project;
[0165] The module boundaries associated with the target module are determined by the abstract syntax tree of the front-end project. The module boundaries are used to indicate the modules in the front-end project that have dependencies on the target module.
[0166] Based on module boundaries, update the dependencies between modules in the front-end project. These dependencies help the client load the target module into the runtime environment of the front-end project.
[0167] In one embodiment, the processing unit 702 is further configured to:
[0168] Obtain the source code of the front-end project;
[0169] Assign an access port to the front-end project and start the corresponding development service based on the source code. The access port is used to access the development service corresponding to the front-end project. Different front-end projects have different access ports for their corresponding development services.
[0170] In response to a client's request for front-end project page resources, the front-end project's page resources are returned to the client through the corresponding development service.
[0171] In one implementation, the hot update message is transmitted via a channel using a full-duplex communication protocol; after starting the development service corresponding to the front-end project based on the source code, the processing unit 702 is further configured to:
[0172] A connection is established between the development service corresponding to the front-end project and the client through a channel using a full-duplex communication protocol. The client is used to edit the preview page of the front-end project.
[0173] According to one embodiment of this application, Figure 4 The steps involved in the page update method shown can be derived from... Figure 7 The page update is performed by individual units in the illustrated page update device. For example, Figure 4 Step S401 shown can be performed by Figure 7 The acquisition unit 701 shown is executed, and steps S402 and S403 can be performed by... Figure 7 The processing unit 702 shown executes the step S404, which can be performed by... Figure 7 The sending unit 703 shown is executed. Figure 7 The various units in the page update apparatus shown can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effects of the embodiments of this application. The above units are based on logical function division. In practical applications, the function of one unit can be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the page update apparatus may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.
[0174] According to another embodiment of this application, a general-purpose computing device, such as a computer device including processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM), can perform operations such as... Figure 4 The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 7 The page updating apparatus shown herein, and the page updating method for implementing embodiments of this application, are described. A computer program may be recorded on, for example, a computer-readable recording medium, loaded onto the aforementioned computing device via the computer-readable recording medium, and executed therein.
[0175] Based on the same inventive concept, the principle and beneficial effects of the page update device provided in the embodiments of this application are similar to the principle and beneficial effects of the page update method in the embodiments of this application. For details, please refer to the principle and beneficial effects of the method implementation. For the sake of brevity, these will not be repeated here.
[0176] Please see Figure 8 , Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The computer device may be a terminal device or a server. Figure 8 As shown, the computer device includes at least a processor 801, a communication interface 802, and a memory 803. The processor 801, communication interface 802, and memory 803 can be connected via a bus or other means. The processor 801 (or Central Processing Unit, CPU) is the computing and control core of the computer device. It can parse various instructions within the computer device and process various data. For example, the CPU can parse power-on / off commands issued by an object to the computer device and control the computer device to perform power-on / off operations; it can also transmit various interactive data between internal structures of the computer device, and so on. The communication interface 802 may optionally include standard wired interfaces or wireless interfaces (such as Wi-Fi, mobile communication interfaces, etc.), and can be used to send and receive data under the control of the processor 801; the communication interface 802 can also be used for data transmission and interaction within the computer device. The memory 803 is the storage device in the computer device, used to store programs and data. It can be understood that the memory 803 here can include the computer device's built-in memory, or it can include extended memory supported by the computer device. The memory 803 provides storage space for storing the operating system of the computer device, which may include, but is not limited to, Android, iOS, Windows Phone, etc. This application does not limit this.
[0177] This application embodiment also provides a computer-readable storage medium (Memory), which is a memory device in a computer device used to store programs and data. It is understood that the computer-readable storage medium here can include both the built-in storage medium in the computer device and extended storage media supported by the computer device. The computer-readable storage medium provides storage space that stores the processing system of the computer device. Furthermore, the storage space also stores computer programs suitable for loading and execution by the processor 801. It should be noted that the computer-readable storage medium here can be high-speed RAM memory or non-volatile memory, such as at least one disk storage device; optionally, it can also be at least one computer-readable storage medium located remotely from the aforementioned processor.
[0178] In one embodiment, processor 801 performs the following operations by running a computer program stored in memory 803:
[0179] This displays a preview page of the front-end project, which is based on the project's source code.
[0180] Get the hot update message of the front-end project. The hot update message includes the module code of the target module. The target module is the module in the front-end project that needs to be updated. The hot update message is generated by the development service corresponding to the front-end project after detecting changes in the source code. The runtime environment of the development service corresponding to different front-end projects is isolated from each other.
[0181] By using the target module's code, the runtime modules of the front-end project are dynamically updated, and the updated results are obtained and displayed on the preview page.
[0182] As an optional embodiment, the preview page of the front-end project is displayed in the canvas area of the first client, and the development service corresponding to the front-end project runs on the server; the processor 801 also performs the following operations by running the computer program in the memory 803:
[0183] In response to component editing operations in the canvas area, generate the first update code;
[0184] Send the first update code to the server so that the server updates the source code based on the first update code.
[0185] As an optional embodiment, the processor 801 generates the first update code in response to a component editing operation in the canvas area, specifically in the following embodiment:
[0186] In response to component editing operations in the canvas area, the abstract syntax tree of the front-end project is updated based on the component editing operations. The abstract syntax tree is generated based on the source code.
[0187] Based on the updated abstract syntax tree, the first updated code is generated.
[0188] As an optional embodiment, the preview page of the front-end project is displayed in the first client, and at least two clients participate in the collaborative editing of the preview page of the front-end project, with the first client being included in at least two clients;
[0189] The source code change was triggered by a second update code, which was generated based on component editing operations of a second client, which is any one of at least two clients other than the first client.
[0190] As an optional implementation, the development service corresponding to the front-end project runs on a local server; the specific implementation of the processor 801 obtaining the hot update message of the front-end project is as follows:
[0191] Get the first updated code of the front-end project;
[0192] Based on the first updated code, the source code of the front-end project is updated to obtain the updated source code;
[0193] Through the development service corresponding to the front-end project, we can obtain the hot update message of the front-end project generated based on the updated source code.
[0194] As an optional embodiment, the processor 801 dynamically updates the runtime module of the front-end project through the module code of the target module to obtain and display the update result of the preview page. A specific embodiment of this is as follows:
[0195] Get the module boundaries associated with the target module. The module boundaries are used to indicate the modules in the front-end project that have dependencies on the target module.
[0196] Based on the target module's code and boundaries, load the target module into the front-end project's runtime environment;
[0197] Based on the runtime environment after loading the target module, the update results of the preview page are displayed.
[0198] As an optional embodiment, the processor 801 displays a preview page of the front-end project in the following specific embodiment:
[0199] Obtain the source code of the front-end project;
[0200] Send the source code to the server so that the server can start the development service corresponding to the front-end project based on the source code. The access port of the development service is different for different front-end projects.
[0201] Based on the page resources of the front-end project, a preview page of the front-end project is displayed. The page resources are provided by the development service based on the page resource request.
[0202] As an optional embodiment, the processor 801 displays a preview page of the front-end project based on the page resources of the front-end project. A specific embodiment of this is as follows:
[0203] Retrieve the Uniform Resource Locator (URL) of the front-end project returned by the server;
[0204] Send page resource requests to the development service corresponding to the front-end project using a Uniform Resource Locator;
[0205] Get the response information for page resource requests, including the page resources of the front-end project;
[0206] Render the page resources of the front-end project to obtain and display the preview page of the front-end project.
[0207] As an optional embodiment, the preview page of the front-end project is displayed in the first client, and the hot update message is obtained from the channel of the full-duplex communication protocol. The channel of the full-duplex communication protocol is used to establish communication between the first client and the development service corresponding to the front-end project.
[0208] In another embodiment, processor 801 performs the following operations by running a computer program stored in memory 803:
[0209] Retrieve the updated code and project identifier of the front-end project;
[0210] Based on the updated code, the source code of the front-end project is updated;
[0211] The hot update message for the front-end project is generated by the development service corresponding to the front-end project. The hot update message includes the module code of the target module, which is the module in the front-end project that needs to be updated. The module code is obtained based on the updated source code. The runtime environments of the development services corresponding to different front-end projects are isolated from each other.
[0212] A hot update message is returned to the client so that the client can display the updated result of the preview page of the front-end project based on the hot update message. The updated result of the preview page of the front-end project is obtained by dynamically updating the runtime module of the front-end project through the module code of the target module.
[0213] As an optional embodiment, the process by which the processor 801 generates a hot update message for the front-end project through the development service corresponding to the front-end project includes:
[0214] After detecting an update to the source code of the front-end project, the module code of the target module is generated through the development service corresponding to the front-end project;
[0215] The module boundaries associated with the target module are determined by the abstract syntax tree of the front-end project. The module boundaries are used to indicate the modules in the front-end project that have dependencies on the target module.
[0216] Based on module boundaries, update the dependencies between modules in the front-end project. These dependencies help the client load the target module into the runtime environment of the front-end project.
[0217] As an optional embodiment, the processor 801, by running a computer program in the memory 803, also performs the following operations:
[0218] Obtain the source code of the front-end project;
[0219] Assign an access port to the front-end project and start the corresponding development service based on the source code. The access port is used to access the development service corresponding to the front-end project. Different front-end projects have different access ports for their corresponding development services.
[0220] In response to a client's request for front-end project page resources, the front-end project's page resources are returned to the client through the corresponding development service.
[0221] As an optional embodiment, the hot update message is transmitted through a channel of a full-duplex communication protocol; after starting the development service corresponding to the front-end project based on the source code, the processor 801 also performs the following operations by running the computer program in the memory 803:
[0222] A connection is established between the development service corresponding to the front-end project and the client through a channel using a full-duplex communication protocol. The client is used to edit the preview page of the front-end project.
[0223] Based on the same inventive concept, the principle and beneficial effects of the computer device provided in the embodiments of this application in solving the problem are similar to the principle and beneficial effects of the page update method in the embodiments of this application in solving the problem. Please refer to the principle and beneficial effects of the implementation of the method. For the sake of brevity, they will not be repeated here.
[0224] This application also provides a computer-readable storage medium storing a computer program adapted to be loaded by a processor and to execute the page update method described in the above method embodiments.
[0225] This application also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the page update method described above.
[0226] The steps in the method of this application embodiment can be adjusted, combined, or deleted according to actual needs.
[0227] The modules in the device of this application embodiment can be merged, divided, and deleted according to actual needs.
[0228] In the embodiments of this application, the term "module" or "unit" refers to a computer program or part of a computer program with a predetermined function, which works together with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0229] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc.
[0230] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Those skilled in the art will understand that all or part of the processes for implementing the above embodiments and equivalent variations made in accordance with the claims of this application are still within the scope of this application.
Claims
1. A page update method, characterized in that, The method includes: Displays a preview page of the front-end project, which is derived from the source code of the front-end project; Obtain the hot update message of the front-end project. The hot update message includes the module code of the target module. The target module is the module in the front-end project that needs to be updated. The hot update message is generated by the development service corresponding to the front-end project after detecting the source code change. The running environments of the development services corresponding to different front-end projects are isolated from each other. The runtime module of the front-end project is dynamically updated using the module code of the target module, and the update result of the preview page is obtained and displayed.
2. The method as described in claim 1, characterized in that, The preview page of the front-end project is displayed in the canvas area of the first client, and the development service corresponding to the front-end project runs on the server. The method further includes: In response to component editing operations in the canvas area, generate first update code; The first update code is sent to the server so that the server updates the source code based on the first update code.
3. The method as described in claim 2, characterized in that, The first update code generated in response to component editing operations in the canvas area includes: In response to a component editing operation in the canvas area, the abstract syntax tree of the front-end project is updated based on the component editing operation, the abstract syntax tree being generated based on the source code; Based on the updated abstract syntax tree, the first updated code is generated.
4. The method as described in claim 1, characterized in that, The preview page of the front-end project is displayed in the first client, and at least two clients participate in the collaborative editing of the preview page of the front-end project, with the first client being included in the at least two clients; The change in the source code was triggered by a second update code, which was generated based on a component editing operation of a second client, which is any one of the at least two clients other than the first client.
5. The method as described in claim 1, characterized in that, The development service corresponding to the front-end project runs on a local server. The step of obtaining the hot update message of the front-end project includes: Obtain the first updated code of the aforementioned front-end project; Based on the first updated code, the source code of the front-end project is updated to obtain the updated source code; The hot update message for the front-end project is obtained through the development service corresponding to the front-end project, which is generated based on the updated source code.
6. The method as described in claim 1, characterized in that, The step of dynamically updating the runtime module of the front-end project through the module code of the target module to obtain and display the update result of the preview page includes: Obtain the module boundary associated with the target module, whereby the module boundary indicates the modules in the front-end project that have a dependency relationship with the target module; Based on the module code and the module boundaries of the target module, the target module is loaded into the runtime environment of the front-end project; Based on the runtime environment after loading the target module, the update results of the preview page are displayed.
7. The method as described in claim 1, characterized in that, The preview page for the display front-end project includes: Obtain the source code of the front-end project; Send the source code to the server so that the server can start the development service corresponding to the front-end project based on the source code. The access port of the development service corresponding to different front-end projects is different. Based on the page resources of the front-end project, a preview page of the front-end project is displayed, wherein the page resources are provided by the development service based on a page resource request.
8. The method as described in claim 7, characterized in that, The step of displaying a preview page of the front-end project based on its page resources includes: Obtain the Uniform Resource Locator (URL) of the front-end project returned by the server; The page resource request is sent to the development service corresponding to the front-end project through the Uniform Resource Locator; Obtain the response information for the page resource request, wherein the response information includes the page resources of the front-end project; The page resources of the front-end project are rendered to obtain and display a preview page of the front-end project.
9. The method as described in claim 1, characterized in that, The preview page of the front-end project is displayed in the first client. The hot update message is obtained from the channel of the full-duplex communication protocol. The channel of the full-duplex communication protocol is used to establish communication between the first client and the development service corresponding to the front-end project.
10. A page update method, characterized in that, The method includes: Obtain the updated code of the front-end project and the project identifier of the front-end project; Based on the updated code, the source code of the front-end project is updated; The hot update message of the front-end project is generated by the development service corresponding to the front-end project. The hot update message includes the module code of the target module, which is the module in the front-end project that needs to be updated. The module code is obtained based on the updated source code. The running environments of the development services corresponding to different front-end projects are isolated from each other. The hot update message is returned to the client so that the client can display the update result of the preview page of the front-end project based on the hot update message. The update result of the preview page of the front-end project is obtained by dynamically updating the runtime module of the front-end project through the module code of the target module.
11. The method as described in claim 10, characterized in that, The process of generating the hot update message for the front-end project through the development service corresponding to the front-end project includes: After detecting an update to the source code of the front-end project, the module code of the target module is generated through the development service corresponding to the front-end project; The module boundaries associated with the target module are determined by the abstract syntax tree of the front-end project. The module boundaries are used to indicate the modules in the front-end project that have dependencies on the target module. Based on the module boundaries, the dependencies between modules in the front-end project are updated. These dependencies are used to assist the client in loading the target module into the runtime environment of the front-end project.
12. The method as described in claim 10, characterized in that, The method further includes: Obtain the source code of the front-end project; An access port is assigned to the front-end project, and the development service corresponding to the front-end project is started based on the source code. The access port is used to access the development service corresponding to the front-end project. Different front-end projects have different access ports for their corresponding development services. In response to a client's request for page resources of the front-end project, the page resources of the front-end project are returned to the client through the development service corresponding to the front-end project.
13. The method as described in claim 12, characterized in that, The hot update message is transmitted via a full-duplex communication protocol channel; after starting the development service corresponding to the front-end project based on the source code, the method further includes: A connection is established between the development service corresponding to the front-end project and the client through the channel of the full-duplex communication protocol. The client is used to edit the preview page of the front-end project.
14. A page updating device, characterized in that, The page update device includes: A display unit is used to display a preview page of a front-end project, the preview page being derived from the source code of the front-end project; The acquisition unit is used to acquire a hot update message for the front-end project. The hot update message includes the module code of the target module, which is the module in the front-end project that needs to be updated. The hot update message is generated by the development service corresponding to the front-end project after detecting the source code change. The running environments of the development services corresponding to different front-end projects are isolated from each other. The processing unit is used to dynamically update the runtime module of the front-end project through the module code of the target module, and obtain and display the update result of the preview page.
15. A page updating device, characterized in that, The page update device includes: The acquisition unit is used to acquire the updated code of the front-end project and the project identifier of the front-end project. A processing unit is configured to update the source code of the front-end project based on the updated code; And a hot update message for generating the front-end project through the development service corresponding to the front-end project, the hot update message including the module code of the target module, the target module being the module in the front-end project that needs to be updated, the module code being obtained based on the updated source code, and the runtime environment of the development service corresponding to different front-end projects being isolated from each other; The sending unit is used to return the hot update message to the client so that the client can display the update result of the preview page of the front-end project based on the hot update message. The update result of the preview page of the front-end project is obtained by dynamically updating the runtime module of the front-end project through the module code of the target module.
16. A computer device, characterized in that, include: A memory, wherein a computer program is stored; A processor is configured to load the computer program to implement the page update method as described in any one of claims 1-9; or, to load the computer program to implement the page update method as described in any one of claims 10-13.
17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded by a processor and executed as described in any one of claims 1-9; or, adapted to be loaded by a processor and executed as described in any one of claims 10-13.
18. A computer program product, characterized in that, The computer program product includes a computer program adapted to be loaded by a processor and execute the page update method as described in any one of claims 1-9; or, adapted to be loaded by a processor and execute the page update method as described in any one of claims 10-13.
