A page preview method and device for running a Web project
By dynamically generating and parsing front-end code using SPA frameworks, the method and device address the delay in client-side page previews, facilitating real-time viewing of front-end page modifications.
Patent Information
- Application Number
- CN202111414566.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-25
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2041-11-25
AI Technical Summary
Existing low-code/zero-code technologies in software development require server-side compilation and compression, leading to prolonged delays in client-side page previews, which hinders real-time viewing of front-end page modifications.
Implementing a method and device that dynamically generate and parse front-end code on the server and client sides using Single-Page Application (SPA) frameworks, allowing real-time preview by throttling compilation and enabling immediate client-side page rendering.
Enables real-time preview of front-end page modifications by dynamically generating and parsing front-end code, improving user experience in scenarios requiring immediate feedback.
Smart Images

Figure CN114117275B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software development technology, and in particular to a page preview method and device for running a Web project. Background Art
[0002] As the process of enterprise informatization accelerates, the market demand for application development will far exceed the production capacity of information companies. To fill this production gap, low-code / zero-code technology is currently a feasible solution.
[0003] At present, the technical solutions selected to implement low-code / zero-code technology mostly use the method of generating front-end code based on data analysis and model building. However, in order to pursue readability and customizability, the front-end code generated by the data analysis and model building also needs to be compiled and compressed, just like writing code in the traditional mode. Since the client is only responsible for displaying the page, the client cannot preview the front-end page when the server-side compilation and compression are completed.
[0004] However, as the front-end engineering code increases, compilation and compression take longer and longer. The client can only preview the front-end page when the server completes compilation, compression and dynamic rendering. This is not a good user experience in scenarios where the effect of modifying the front-end page needs to be viewed in real time. Summary of the invention
[0005] The embodiments of the present application provide a page preview method and device for running a Web project, which is used to solve the problem that the client can only preview the front-end page when the server completes compilation, compression and dynamic rendering. This does not provide a good user experience in the scenario where the effect of modifying the front-end page needs to be viewed in real time.
[0006] The present application embodiment adopts the following technical solutions:
[0007] On the one hand, an embodiment of the present application provides a page preview method for running a Web project, the method comprising: a server determines a first single-page application SPA front-end framework of a web app, determines application function requirement information of the web app in the first SPA front-end framework, and dynamically generates compiled front-end code from the application function requirement information; the front-end code is sent to a client, so that when the client runs the front-end code, a second SPA front-end framework of the web app is generated by dynamically parsing the front-end code, and a front-end page to be previewed is automatically parsed based on the second SPA front-end framework.
[0008] In one example, the dynamic generation of compiled front-end code from the application function requirement information specifically includes: determining dynamic code logic and dynamic code rules in the code compilation tool webpack; generating list data in the lazy list lazyRoutes according to the application function requirement information; reading the list data through the webpack, and dynamically parsing the list data according to the dynamic code logic and dynamic code rules; compiling the parsed list data to generate the compiled front-end code.
[0009] In one example, after automatically parsing the front-end page to be previewed based on the second SPA front-end framework, the method also includes: the server determines the changed content of the front-end code; generates a hash value of the changed content; determines the change notification information based on the changed content and the hash value; and pushes the change notification information to the client.
[0010] On the other hand, an embodiment of the present application provides another page preview method for running a Web project, the method comprising: a client obtains a front-end code from a server; wherein the front-end code determines a first single-page application SPA front-end framework of the webapp through the server, determines application function requirement information of the web app in the first SPA front-end framework, and dynamically generates compiled front-end code from the application function requirement information; when running the front-end code, a second SPA front-end framework of the web app is generated by dynamically parsing the front-end code, and based on the second SPA front-end framework, the front-end page to be previewed is automatically parsed.
[0011] In one example, the method of generating a second SPA front-end framework of the web app by dynamically parsing the front-end code specifically includes: determining a hypertext markup language HTML template; parsing the string of the HTML template character by character through a regular expression to determine element nodes and corresponding node information on the element nodes; performing template syntax analysis on the node information to determine an abstract syntax tree AST node to generate a corresponding AST tree; determining a function for rendering an interface of the AST tree in a browser environment; and dynamically parsing the front-end code through the function to generate a second SPA front-end framework of the web app.
[0012] In one example, the front-end page to be previewed is automatically parsed based on the second SPA front-end framework, specifically including: obtaining a page loading request based on the user's operation; parsing the page loading request, and determining the component type and the front-end code of the component corresponding to the page loading request in the second SPA front-end framework; loading the component to the corresponding area according to the component type and the front-end code of the component, and presenting a rendering page corresponding to the page loading request.
[0013] In one example, the resource data in the second SPA front-end framework is split into blocks; wherein the resource data of each block respectively loads the front-end code corresponding to different components; the loading of the components to the corresponding areas according to the component types and the front-end codes of the components specifically includes: independently loading the components to the corresponding areas according to the component types and the front-end codes of the components.
[0014] In one example, after automatically parsing the front-end page to be previewed based on the second SPA front-end framework, the method also includes: sending a request to the server to obtain a manifest file corresponding to the changed content of the front-end code; obtaining the changed content from the manifest file; and updating the second SPA front-end framework by dynamically parsing the changed content.
[0015] On the other hand, an embodiment of the present application provides a page preview device for running a Web project, which is applied to a server, and includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can: determine a first single-page application SPA front-end framework of a web app, determine application function requirement information of the web app in the first SPA front-end framework, and dynamically generate compiled front-end code from the application function requirement information; send the front-end code to a client, so that when the client runs the front-end code, it generates a second SPA front-end framework of the web app by dynamically parsing the front-end code, and automatically parses the front-end page to be previewed based on the second SPA front-end framework.
[0016] On the other hand, an embodiment of the present application provides another page preview device for running a Web project, which is applied to a client, and includes: obtaining a front-end code from a server; wherein the front-end code determines a first single-page application SPA front-end framework of the webapp through the server, determines application function requirement information of the web app in the first SPA front-end framework, and dynamically generates compiled front-end code from the application function requirement information; when running the front-end code, a second SPA front-end framework of the web app is generated by dynamically parsing the front-end code, and based on the second SPA front-end framework, the front-end page to be previewed is automatically parsed.
[0017] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
[0018] In the embodiment of the present application, the server determines the application function requirement information of the web app in the first SPA front-end framework, dynamically generates compiled front-end code based on the application function requirement information, and can package and compile the front-end code based on the demand to achieve the effect of throttling. When the client runs the front-end code, the second SPA front-end framework of the web app is generated by dynamically parsing the front-end code, which can automatically parse the front-end page to be previewed, realize real-time preview of the front-end page, and bring a better experience to users. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solution of the present application, some embodiments of the present application will be described in detail below in conjunction with the accompanying drawings, in which:
[0020] Figure 1 A schematic diagram of a flow chart of a page preview method for running a Web project provided in an embodiment of the present application;
[0021] Figure 2 A schematic diagram of another method for previewing a page of a Web project provided in an embodiment of the present application;
[0022] Figure 3 A schematic diagram of the structure of a page preview device for running a Web project provided in an embodiment of the present application;
[0023] Figure 4 A schematic diagram of the structure of another page preview device for running a Web project provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0025] Some embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0026] Figure 1 A flow chart of a page preview method for running a Web project provided in an embodiment of the present application. The method can be applied to different business fields, such as Internet financial business field, e-commerce business field, instant messaging business field, game business field, official business field, etc. Certain input parameters or intermediate results in the process allow manual intervention and adjustment to help improve accuracy.
[0027] Figure 1 The process in may include the following steps:
[0028] S101: The server determines the first SPA front-end framework of the web app.
[0029] Among them, web app refers to an application that runs on the Internet and standard browsers and is developed based on web page technology to implement specific functions. The Single Page Application (SPA) front-end framework is used to load a single HTML page and dynamically update the page when the user interacts with the application.
[0030] It should be noted that the server may be a single device or a system consisting of multiple devices, that is, a distributed server, and this application does not make any specific limitation on this.
[0031] S102: Determine application function requirement information of the web app in the first SPA front-end framework, and dynamically generate compiled front-end code based on the application function requirement information.
[0032] Among them, a large proportion of web app development is currently based on the SPA front-end framework, which is divided into pages of different modules through Route. The mainstream front-end frameworks are all in this vein. In order to throttle before compiling the code, the embodiment of the present application pre-selects the application function requirement information of the web app, and then packages the code based on the requirement information. The loader in the front-end webpack can complete this task, so that the output code is processed by the loader and the processing is completed before the code is compiled.
[0033] It should be noted that webpack is a module bundler. Webpack is a code compilation tool with entry, exit, loader and plug-in.
[0034] Specifically, the server determines the dynamic code logic and dynamic code rules in the code compilation tool webpack. Then, the list data in the lazy list lazyRoutes is generated according to the application function requirement information. Then, the list data is read in through webpack and dynamically parsed according to the dynamic code logic and dynamic code rules. Finally, the parsed list data is compiled to generate the compiled front-end code.
[0035] For example, set the dynamic code rule module rule to webpack, enforce to pre, and generate dynamic code logic for layRouteLoader.js. Webpack will read the list data of lazyRoutes.js, dynamically parse the list data through layRouteLoader.js and module rule, and then dynamically generate compiled front-end code back to lazyRoutes.js.
[0036] S103: Send the front-end code to the client, so that when the client runs the front-end code, it generates a second SPA front-end framework of the web app by dynamically parsing the front-end code, and automatically parses the front-end page to be previewed based on the second SPA front-end framework.
[0037] In some embodiments of the present application, the current front-end framework generally processes HTML by converting it into a Render function during compilation. The embodiments of the present application implement a technical solution for dynamically parsing the front-end code, that is, when the client runs the front-end code, it generates a second SPA front-end framework for the web app by dynamically parsing the front-end code.
[0038] Furthermore, since the front-end page to be previewed may not meet the requirements, the developer needs to change the front-end code to effectively ensure the accuracy of the analysis, thereby optimizing the speed of dynamic analysis of the front-end code.
[0039] Specifically, the server determines the changes in the front-end code. Then, a hash value of the changes is generated. Then, the change notification information is determined based on the changes and the hash value. Finally, the change notification information is pushed to the client, so that the client obtains the changes in the front-end code from the server and updates the second SPA front-end framework.
[0040] For example, a websocket is established between the client and the server to update the changes of the front-end code in real time. Since a websocket connection is established between the client and the server, when the front-end code is changed, the server will push a message to the browser in the client. The message contains the hash value generated after the front-end code is changed. Based on the hash value, the client obtains the changed content of the front-end code from the server and updates the second SPA front-end framework.
[0041] It should be noted that although the embodiments of the present application are based on Figure 1 Steps S101 to S103 are described in sequence, but this does not mean that steps S101 to S103 must be performed in a strict order. Figure 1 The order shown in the figure is to introduce and explain step S101 to step S103 in sequence, in order to facilitate those skilled in the art to understand the technical solution of the embodiment of the present application. In other words, in the embodiment of the present application, the order between step S101 to step S103 can be appropriately adjusted according to actual needs.
[0042] pass Figure 1 The method determines the application function requirement information of the web app in the first SPA front-end framework, dynamically generates compiled front-end code from the application function requirement information, can package and compile the front-end code based on the demand, and achieve the effect of throttling. When the front-end code is running, the second SPA front-end framework of the web app is generated by dynamically parsing the front-end code, which can automatically parse the front-end page to be previewed, and realize the real-time preview of the front-end page, that is, after the server is started, the client can preview the front-end page in real time.
[0043] Based on the above description, the compilation method of running a Web project is described in detail from the client's perspective. Figure 2 As shown, Figure 2 A flowchart of another page preview method for running a Web project provided in an embodiment of the present application.
[0044] Figure 2 The process in may include the following steps:
[0045] S201: The client obtains the front-end code from the server; wherein the front-end code determines the first SPA front-end framework of the webapp through the server, determines the application function requirement information of the webapp in the first SPA front-end framework, and dynamically generates compiled front-end code from the application function requirement information.
[0046] S202: When the front-end code is running, a second SPA front-end framework of the web app is generated by dynamically parsing the front-end code.
[0047] In some embodiments of the present application, in order to generate a second SPA front-end framework of a web app by dynamically parsing the front-end code, a library that can be run in a client browser environment and implements similar functions compiled on the server side is pre-built.
[0048] Specifically, the client determines an HTML template, parses the string of the HTML template character by character through a regular expression, and determines an element node and corresponding node information on the element node. For example, the node information includes instructions, attributes, event binding, and the like.
[0049] Then, the template syntax analysis is performed on the node information, such as if branches, for loops, interpolation expressions, slots, etc., which are processed into AST nodes, and finally a complete AST tree is generated.
[0050] Then, determine the function of the AST tree to render the interface in the browser environment. Finally, dynamically parse the front-end code through the function to generate the second SPA front-end framework of the web app.
[0051] S203: Based on the second SPA front-end framework, automatically parse the front-end page to be previewed.
[0052] In some embodiments of the present application, on the basis that the client can automatically parse the front-end page to be previewed, the client obtains a page loading request based on the user's operation, such as clicking a preview control, and then parses the page loading request. Then, in the second SPA front-end framework, the component type corresponding to the page loading request and the front-end code of the component are determined. Finally, according to the component type and the front-end code of the component, the component is loaded into the corresponding area, and finally the rendering page corresponding to the page loading request is presented.
[0053] Furthermore, when loading components on a page, in order to avoid slow loading caused by a single resource being too large, the resource data in the second SPA front-end framework is split into blocks in advance; wherein, the resource data of each block loads the front-end code corresponding to different components respectively, so that components can be independently loaded into corresponding areas according to the component type and the front-end code of the component, thereby realizing on-demand loading of components.
[0054] In some embodiments of the present application, when the client obtains the change notification information pushed by the server, it sends a request to the server through ajax based on the hash value identification to obtain the manifest file corresponding to the changed content of the front-end code, wherein the mainfest file contains the rebuilt hash value. Then, the changed content is obtained from the manifest file, and the second SPA front-end framework is updated by dynamically parsing the changed content.
[0055] pass Figure 2 The method determines the application function requirement information of the web app in the first SPA front-end framework, dynamically generates compiled front-end code from the application function requirement information, can package and compile the front-end code based on the demand, and achieve the effect of throttling; and when the front-end code is running, the second SPA front-end framework of the web app is generated by dynamically parsing the front-end code, which can automatically parse the front-end page to be previewed, and realize the real-time preview of the front-end page.
[0056] It should be noted that although the embodiments of the present application are based on Figure 2 Steps S201 to S203 are described in sequence, but this does not mean that steps S201 to S203 must be performed in a strict order. Figure 2 The order shown in the figure introduces and explains step S201 to step S203 in sequence to facilitate those skilled in the art to understand the technical solution of the embodiment of the present application. In other words, in the embodiment of the present application, the order between step S201 to step S203 can be appropriately adjusted according to actual needs.
[0057] Based on the same idea, some embodiments of the present application also provide devices and non-volatile computer storage media corresponding to the above methods.
[0058] Figure 3 The embodiment of the present application provides the corresponding Figure 1 A schematic diagram of a structure of a page preview device for running a Web project equipped with the above-mentioned page preview method for running a Web project, the device includes:
[0059] at least one processor; and,
[0060] a memory communicatively connected to the at least one processor; wherein,
[0061] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
[0062] Determine the first single-page application SPA front-end framework for web apps;
[0063] Determine application function requirement information of the web app in the first SPA front-end framework, and dynamically generate compiled front-end code from the application function requirement information;
[0064] The front-end code is sent to the client, so that when the client runs the front-end code, the second SPA front-end framework of the web app is generated by dynamically parsing the front-end code, and the front-end page to be previewed is automatically parsed based on the second SPA front-end framework.
[0065] Some embodiments of the present application provide corresponding Figure 1 A compiled non-volatile computer storage medium for running a Web project stores computer executable instructions, wherein the computer executable instructions are configured as follows:
[0066] Determine the first single-page application SPA front-end framework for web apps;
[0067] Determine application function requirement information of the web app in the first SPA front-end framework, and dynamically generate compiled front-end code from the application function requirement information;
[0068] The front-end code is sent to the client, so that when the client runs the front-end code, the second SPA front-end framework of the web app is generated by dynamically parsing the front-end code, and the front-end page to be previewed is automatically parsed based on the second SPA front-end framework.
[0069] Figure 4 The embodiment of the present application provides the corresponding Figure 2 A schematic diagram of a structure of a page preview device for running a Web project equipped with the above-mentioned page preview method for running a Web project, the device includes:
[0070] at least one processor; and,
[0071] a memory communicatively connected to the at least one processor; wherein,
[0072] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
[0073] Acquire the front-end code from the server; wherein the front-end code is obtained by determining a first single-page application SPA front-end framework of the web app through the server, determining application function requirement information of the web app in the first SPA front-end framework, and dynamically generating compiled front-end code from the application function requirement information;
[0074] When the front-end code is run, a second SPA front-end framework of the web app is generated by dynamically parsing the front-end code;
[0075] Based on the second SPA front-end framework, the front-end page to be previewed is automatically parsed.
[0076] Some embodiments of the present application provide corresponding Figure 2 A compiled non-volatile computer storage medium for running a Web project stores computer executable instructions, wherein the computer executable instructions are configured as follows:
[0077] Acquire the front-end code from the server; wherein the front-end code is obtained by determining a first single-page application SPA front-end framework of the web app through the server, determining application function requirement information of the web app in the first SPA front-end framework, and dynamically generating compiled front-end code from the application function requirement information;
[0078] When the front-end code is run, a second SPA front-end framework of the web app is generated by dynamically parsing the front-end code;
[0079] Based on the second SPA front-end framework, the front-end page to be previewed is automatically parsed.
[0080] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0081] The devices and media provided in the embodiments of the present application correspond one-to-one to the methods. Therefore, the devices and media also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0082] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0083] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0084] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0085] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0086] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0087] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0088] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0089] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0090] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the technical principle of the present application should all fall within the protection scope of the present application.
Claims
1. A page preview method for running a Web project, characterized in that: The method comprises: The server side determines the first single page application SPA front-end framework of the web app; Determine application function requirement information of the web app in the first SPA front-end framework, and dynamically generate compiled front-end code from the application function requirement information; Send the front-end code to the client, so that when the client runs the front-end code, the second SPA front-end framework of the web app is generated by dynamically parsing the front-end code, and the front-end page to be previewed is automatically parsed based on the second SPA front-end framework; pre-build a library that can be run in the client browser environment and realizes similar functions compiled on the server; The dynamically generating and compiling the front-end code from the application function requirement information specifically includes: In the code compilation tool webpack, determine the dynamic code logic and dynamic code rules; Generate list data in the lazyRoutes list according to the application function requirement information; Read the list data through the webpack, and dynamically parse the list data according to the dynamic code logic and dynamic code rules; Compiling the parsed list data to generate the compiled front-end code; After automatically parsing the front-end page to be previewed based on the second SPA front-end framework, the method further includes: The server determines the changed content of the front-end code; Generate a hash value of the changed content; Determine change notification information according to the change content and the hash value; Pushing the change notification information to the client; The client sends a request to the server to obtain the manifest file corresponding to the changed content of the front-end code; Obtain the changed content from the manifest file; The second SPA front-end framework is updated by dynamically parsing the changed content.
2. A page preview method for running a Web project, characterized in that: The method comprises: The client obtains the front-end code from the server; wherein the front-end code is obtained by determining a first single-page application SPA front-end framework of the webapp through the server, determining application function requirement information of the web app in the first SPA front-end framework, and dynamically generating compiled front-end code from the application function requirement information; When the front-end code is run, a second SPA front-end framework of the web app is generated by dynamically parsing the front-end code; Based on the second SPA front-end framework, the front-end page to be previewed is automatically parsed; a library that can be run in the client browser environment and implements similar functions compiled on the server is pre-built; After automatically parsing the front-end page to be previewed based on the second SPA front-end framework, the method further includes: Send a request to the server to obtain the manifest file corresponding to the changed content of the front-end code; Obtain the changed content from the manifest file; Updating the second SPA front-end framework by dynamically parsing the changed content; Among them, the server determines the dynamic code logic and dynamic code rules in the code compilation tool webpack; Generate list data in the lazyRoutes list according to the application function requirement information; Read the list data through the webpack, and dynamically parse the list data according to the dynamic code logic and dynamic code rules; Compiling the parsed list data to generate the compiled front-end code; Wherein, the server determines the content of the change of the front-end code; Generate a hash value of the changed content; Determine change notification information according to the change content and the hash value; Push the change notification information to the client.
3. The method according to claim 2, characterized in that The generating of the second SPA front-end framework of the web app by dynamically parsing the front-end code specifically includes: Determine the Hypertext Markup Language HTML template; Parsing the string of the HTML template character by character by using a regular expression to determine an element node and the node information corresponding to the element node; Performing template syntax analysis on the node information to determine an abstract syntax tree AST node to generate a corresponding AST tree; Determine the function of rendering the interface of the AST tree in the browser environment; The front-end code is dynamically parsed by the function to generate a second SPA front-end framework of the web app.
4. The method according to claim 2, characterized in that: The automatic parsing of the front-end page to be previewed based on the second SPA front-end framework specifically includes: Get page loading requests based on user operations; Parsing the page loading request, and determining the component type and the front-end code of the component corresponding to the page loading request in the second SPA front-end framework; The component is loaded into a corresponding area according to the component type and the front-end code of the component, and a rendering page corresponding to the page loading request is presented.
5. The method according to claim 4, characterized in that Split the resource data in the second SPA front-end framework into blocks; wherein the resource data of each block loads the front-end code corresponding to different components respectively; The step of loading the component into a corresponding area according to the component type and the front-end code of the component specifically includes: According to the component type and the front-end code of the component, the component is independently loaded into the corresponding area.
6. A page preview device for running a Web project, characterized in that: Applied to the server, including: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Determine the first single-page application SPA front-end framework for web apps; Determine application function requirement information of the web app in the first SPA front-end framework, and dynamically generate compiled front-end code from the application function requirement information; Send the front-end code to the client, so that when the client runs the front-end code, the second SPA front-end framework of the web app is generated by dynamically parsing the front-end code, and the front-end page to be previewed is automatically parsed based on the second SPA front-end framework; pre-build a library that can be run in the client browser environment and realizes similar functions compiled on the server; The dynamically generating and compiling the front-end code from the application function requirement information specifically includes: In the code compilation tool webpack, determine the dynamic code logic and dynamic code rules; Generate list data in the lazyRoutes list according to the application function requirement information; Read the list data through the webpack, and dynamically parse the list data according to the dynamic code logic and dynamic code rules; Compiling the parsed list data to generate the compiled front-end code; After automatically parsing the front-end page to be previewed based on the second SPA front-end framework, the method further includes: The server determines the changed content of the front-end code; Generate a hash value of the changed content; Determine change notification information according to the change content and the hash value; Pushing the change notification information to the client; The client sends a request to the server to obtain the manifest file corresponding to the changed content of the front-end code; Obtain the changed content from the manifest file; The second SPA front-end framework is updated by dynamically parsing the changed content.
7. A page preview device for running a Web project, characterized in that: Applied to the client, including: Acquire the front-end code from the server; wherein the front-end code is obtained by determining a first single-page application SPA front-end framework of the web app through the server, determining application function requirement information of the web app in the first SPA front-end framework, and dynamically generating compiled front-end code from the application function requirement information; When the front-end code is run, a second SPA front-end framework of the web app is generated by dynamically parsing the front-end code; Based on the second SPA front-end framework, the front-end page to be previewed is automatically parsed; a library that can be run in the client browser environment and implements similar functions compiled on the server is pre-built; After automatically parsing the front-end page to be previewed based on the second SPA front-end framework, the method further includes: Send a request to the server to obtain the manifest file corresponding to the changed content of the front-end code; Obtain the changed content from the manifest file; Updating the second SPA front-end framework by dynamically parsing the changed content; Among them, the server determines the dynamic code logic and dynamic code rules in the code compilation tool webpack; Generate list data in the lazyRoutes list according to the application function requirement information; Read the list data through the webpack, and dynamically parse the list data according to the dynamic code logic and dynamic code rules; Compiling the parsed list data to generate the compiled front-end code; Wherein, the server determines the content of the change of the front-end code; Generate a hash value of the changed content; Determine change notification information according to the change content and the hash value; Push the change notification information to the client.
