CN110704055B - Interface preposition optimization method and device, electronic equipment and storage medium - Google Patents

Interface preposition optimization method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN110704055B
CN110704055B CN201910843969.8A CN201910843969A CN110704055B CN 110704055 B CN110704055 B CN 110704055B CN 201910843969 A CN201910843969 A CN 201910843969A CN 110704055 B CN110704055 B CN 110704055B
Authority
CN
China
Prior art keywords
request
interface
code
network
related parameters
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910843969.8A
Other languages
Chinese (zh)
Other versions
CN110704055A (en
Inventor
杨寓钦
陈奇
王忆天
王琳
董思文
徐娇娇
刘兰超
方谦翔
钟炎
孔俊超
孔繁丽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Sankuai Online Technology Co Ltd
Original Assignee
Beijing Sankuai Online Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Sankuai Online Technology Co Ltd filed Critical Beijing Sankuai Online Technology Co Ltd
Priority to CN201910843969.8A priority Critical patent/CN110704055B/en
Publication of CN110704055A publication Critical patent/CN110704055A/en
Application granted granted Critical
Publication of CN110704055B publication Critical patent/CN110704055B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the application discloses an optimization method and device for interface preposition, electronic equipment and a storage medium, wherein the method comprises the following steps: in the compiling stage of the object code, acquiring an interface address and related parameters of a first network request in an HTML page of the object code; substituting the interface address and the related parameters into an interface request preposed code template to generate an interface request preposed code; inserting an interface request prepositive code into a position in front of a page script in an HTML page; in the HTML page operation stage, executing the interface request preposed code and the page script in parallel, and acquiring the request result and the request state of the execution interface request preposed code; and intercepting a network interface request which is initiated by the HTML page and accords with the front interface, and returning a request result and a request state to the HTML page. The embodiment of the disclosure realizes the access automation of the interface preposition, liberates the manpower required when the access interface is preposed, and improves the optimization efficiency of the interface preposition.

Description

Interface preposition optimization method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to an interface front-end optimization method and apparatus, an electronic device, and a storage medium.
Background
The interface preposition request is a front-end performance optimization scheme, and is used for carrying out data interface network request before loading related dependent resources on a page, so that the data interface network request and other resource loading are carried out simultaneously, network channel resources of a browser are fully utilized, and the page content display speed is optimized.
In the prior art, the access mode of interface pre-optimization is that developers manually comb the logic of each page, manually modify codes, and access a network request scheme into the page, so that the original flow of the page is changed.
In the access mode of the existing optimization scheme, repeated work is required for developers to access one page, certain manpower is consumed, and the efficiency is low.
Disclosure of Invention
The embodiment of the application provides an interface preposed optimization method and device, electronic equipment and a storage medium, which are beneficial to saving manpower and improving optimization efficiency.
In order to solve the above problem, in a first aspect, an embodiment of the present application provides an interface pre-stage optimization method, including:
in the compiling stage of the object code, acquiring an interface address and related parameters of a first network request in a hypertext markup language (HTML) page of the object code;
substituting the interface address and the related parameters into an interface request prefix code template to generate an interface request prefix code corresponding to the first network request;
inserting the interface request prepositive code into the position before a page script in an HTML document corresponding to the HTML page;
in the HTML page operation stage, the interface request preposed code and the page script are executed in parallel, and the request result and the request state of the interface request preposed code are obtained;
intercepting a network interface request which is initiated by the HTML page and accords with a front interface, and returning the request result and the request state to the HTML page.
Optionally, before intercepting the network interface request that conforms to the front interface and is initiated by the HTML page, the method further includes:
intercepting a current network interface request initiated by the HTML page, and acquiring an interface address and related parameters of the current network interface request;
matching the interface address and the related parameters of the current network interface request with the interface address and the related parameters of the first network request;
and if the interface address and the related parameters of the current network interface request are successfully matched with the interface address and the related parameters of the first network request, determining that the current network interface request is a network interface request conforming to a front interface.
Optionally, after the matching of the interface address and the related parameter of the current network interface request with the interface address and the related parameter of the first network request, the method further includes:
and if the interface address and the related parameters of the current network interface request are unsuccessfully matched with the interface address and the related parameters of the first network request, sending the current network interface request to a back end, acquiring request data, and returning the request data to the HTML page.
Optionally, in the HTML page operation stage, executing the interface request prefix code and the page script in parallel, and obtaining a request result and a request state of the interface request prefix code, where the method includes:
in the HTML page operation stage, executing the interface request preposed code to initiate the first network request to the rear end through a first channel resource of a browser, and acquiring a request result and a request state;
and executing the page script to request corresponding data from the back end through other channel resources of the browser.
Optionally, the obtaining, in the compiling stage of the object code, an interface address and related parameters of a first network request in an HTML page of the object code includes:
in the compiling stage of the object code, converting the object code into an abstract syntax tree;
and retrieving the abstract syntax tree, and determining an interface address and related parameters of the first network request in the HTML page.
Optionally, after the returning the request result and the request status to the HTML page, the method further includes:
and after the HTML page receives the request result and the request state, assembling the HTML page by using the request result or processing exception according to the request state.
In a second aspect, an embodiment of the present application provides an interface-preposed optimization apparatus, including:
the request parameter acquisition module is used for acquiring an interface address and related parameters of a first network request in an HTML page of the object code at the compiling stage of the object code;
a prefix code generation module, configured to substitute the interface address and the related parameter into an interface request prefix code template, and generate an interface request prefix code corresponding to the first network request;
the code insertion module is used for inserting the interface request prepositive code into the position before the page script in the HTML document corresponding to the HTML page;
the parallel execution module is used for executing the interface request preposed code and the page script in parallel in the HTML page operation stage and acquiring a request result and a request state of the interface request preposed code;
and the front request implementation module is used for intercepting a network interface request which is initiated by the HTML page and accords with a front interface, and returning the request result and the request state to the HTML page.
Optionally, the apparatus further comprises:
the request intercepting module is used for intercepting a current network interface request initiated by the HTML page and acquiring an interface address and related parameters of the current network interface request;
the request matching module is used for matching the interface address and the related parameters of the current network interface request with the interface address and the related parameters of the first network request;
and the front interface determining module is used for determining that the current network interface request is a network interface request conforming to a front interface if the interface address and the related parameters of the current network interface request are successfully matched with the interface address and the related parameters of the first network request.
Optionally, the apparatus further comprises:
and the normal request module is used for sending the current network interface request to the back end, acquiring request data and returning the request data to the HTML page if the interface address and the related parameters of the current network interface request are unsuccessfully matched with the interface address and the related parameters of the first network request.
Optionally, the parallel execution module includes:
the front request execution unit is used for executing the interface request front code to initiate the first network request to the rear end through a first channel resource of a browser in the HTML page operation stage and acquiring a request result and a request state;
and the page script execution unit is used for executing the page script to request corresponding data from the back end through other channel resources of the browser.
Optionally, the request parameter obtaining module includes:
the target code conversion unit is used for converting the target code into an abstract syntax tree in the compiling stage of the target code;
and the request parameter acquisition unit is used for retrieving the abstract syntax tree and determining the interface address and the related parameters of the first network request in the HTML page.
Optionally, the apparatus further comprises:
and the page processing module is used for assembling the TMHL page by using the request result or processing exception according to the request state after the HTML page receives the request result and the request state.
In a third aspect, an embodiment of the present application further discloses an electronic device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the method for optimizing the interface front-end according to the embodiment of the present application when executing the computer program.
In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the interface-advanced optimization method disclosed in the embodiments of the present application.
The interface address and the related parameters of the first network request in the HTML page of the object code are obtained in the compiling stage of the object code, the interface address and the related parameters are substituted into the interface request preposed code template to generate the interface request preposed code corresponding to the first network request, the interface request preposed code is inserted into the HTML document corresponding to the HTML page at the position before the page script, the interface request preposed code and the page script are executed in parallel in the HTML page running stage to obtain the request result and the request state for executing the interface request preposed code, the network interface request which is initiated by the HTML page and accords with the preposed interface is intercepted, and the request result and the request state are returned to the HTML page, the access automation of the interface preposition is realized, the manpower required when the access interface is preposed is liberated, and the optimization efficiency of the interface preposition is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart of an optimization method of an interface front-end according to a first embodiment of the present application;
FIG. 2 is a flow chart of the execution of a web interface request in a page in an embodiment of the present application;
fig. 3 is a schematic structural diagram of an interface-preposed optimization apparatus according to a second embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Example one
The method for optimizing the interface front end disclosed in this embodiment is applied to a page with a front end and a back end separated from each other, and performs processing at the front end, as shown in fig. 1, the method includes: step 110 to step 150.
Step 110, in the compiling stage of the object code, acquiring the interface address and the related parameters of the first network request in the HTML page of the object code.
And in the project compiling stage, retrieving the target code, carding page logic, screening network requests in each HTML (Hyper Text Markup Language) page of the target code, and acquiring an interface address and related parameters of a first network request in the HTML page. Wherein the related parameters include user information and service related parameters.
In an embodiment of the present application, the obtaining, in a compiling stage of an object code, an interface address and related parameters of a first network request in an HTML page of the object code includes:
in the compiling stage of the object code, converting the object code into an abstract syntax tree;
and retrieving the abstract syntax tree, and determining an interface address and related parameters of the first network request in the HTML page.
Wherein, the Abstract Syntax Tree (AST) is an Abstract representation of the Syntax structure of the source code, and it represents the Syntax structure of the programming language in the form of Tree, and each node on the Tree represents a structure in the source code.
In the compiling stage of the object code, the object code to be compiled is obtained, the object code is converted into an abstract syntax tree, the abstract syntax tree is retrieved, HTML pages in the object code are determined, the first network request in each HTML page is searched, and the interface address and the related parameters of the first network request are extracted. By converting the target code into the abstract syntax tree and then extracting the interface address and the related parameters of the first network request, the first network request can be quickly positioned and the corresponding interface address and the related parameters can be extracted, so that the processing speed is improved.
And step 120, substituting the interface address and the related parameters into an interface request prefix code template to generate an interface request prefix code corresponding to the first network request.
The interface request prefix code template is a preset universal template of the interface request prefix code.
After the interface address and the related parameters of the HTML page first network request are obtained, substituting the interface address and the related parameters of the HTML page first network request into the interface request preposed code template, combining the interface address and the related parameters of the first network request with the interface request preposed code template, and generating the interface request preposed code corresponding to the HTML page first network request.
Step 130, inserting the interface request front code into the position before the page script in the HTML document corresponding to the HTML page.
And in the stage of generating the HTML file by webpack packaging, inserting the interface request prepositive codes into the HTML file corresponding to the HTML page at the position before the page script, and packaging into the HTML file. The interface request prepositive code is inserted into the position before the page script, and the parallel execution of the interface request prepositive code and the page script can be realized by fully utilizing browser channel resources in the page running stage.
Step 140, in the HTML page operation phase, executing the interface request prefix code and the page script in parallel, and obtaining a request result and a request state of executing the interface request prefix code.
Wherein the request state comprises a request initiating state, a request waiting state, a request completing state or a request error state.
And in the HTML page operation stage, operating a corresponding HTML file, executing the interface request preposed code when the interface request preposed code is executed, generating an interface request preposed module, sending the first network interface request to a rear end through the interface request preposed module, and acquiring a request result and a request state. And after the first network request is sent to the back end, executing the page script and loading the related dependent resources to the back end request page. The interface request front module comprises an interface request unit and a network agent unit, the interface request unit is used for sending the first network interface request to the back end, and the network agent unit is used for acting the network module in the browser and intercepting the request initiated by the HTML page.
In an embodiment of the present application, in the HTML page operation phase, the interface request prefix code and the page script are executed in parallel, and the obtaining of the request result and the request state of the interface request prefix code includes:
in the HTML page operation stage, executing the interface request preposed code to initiate the first network request to the rear end through a first channel resource of a browser, and acquiring a request result and a request state;
and executing the page script to request corresponding data from the back end through other channel resources of the browser.
The browser comprises a plurality of browser channel resources and supports the simultaneous initiation of a plurality of requests, for example, the browser comprises 6 browser channel resources and can initiate 6 requests simultaneously.
Because the interface request prepositive code is positioned in front of the page script, the interface request prepositive code is executed before the page script in the HTML page operation stage, when the interface request prepositive code is executed, the first network request is sent to the back end through the first channel resource of the browser, and the request result and the request state returned by the back end are obtained. And after the interface requests the front code, executing the page script, requesting corresponding data to the back end through other channel resources except the first channel resource of the browser, and downloading the page and loading the related dependent resources. The channel resources of the browser are fully utilized, the parallel execution of the interface request preposed codes and the page scripts is realized, and the page content display speed can be optimized.
It should be noted that although the browser includes multiple browser channel resources, if the interface request prefix code is located behind the page script, parallel execution of the interface request prefix code and the page script cannot be achieved, because the interface request prefix code is located behind the page script, the page script is executed first, and the page script is executed, the page loading related dependent resources are downloaded, which requires a long time, and the execution of the page script blocks the execution of the following logic, so that the interface request prefix code and the page script cannot be executed in parallel.
Step 150, intercepting the network interface request which is initiated by the HTML page and accords with the preposed interface, and returning the request result and the request state to the HTML page.
Intercepting a network interface request initiated by an HTML page, and if the network interface request is a network interface request conforming to a front interface, returning a request result and a request state acquired when an interface request front code is executed to the HTML page so that the HTML page can use the request result and the request state.
For a page with a split front and back end, the existing loading method flow is as follows: requesting an HTML page, analyzing HTML by a browser, requesting page scripts such as CSS JS, executing a network interface request by JS, and assembling a page, requesting pictures and displaying a first screen by JS according to data. In the embodiment of the application, the interface address and the related parameters of the first network request in the HTML page are obtained in the code compiling stage, the interface request front code is generated, and the interface request front code is inserted into the position before the page script of the HTML document corresponding to the HTML page, so that the interface request front code and the page script can be executed in parallel in the page running stage, and the automatic access of the interface front is realized.
The interface preposed optimization method disclosed by the embodiment of the application acquires an interface address and related parameters of a first network request in an HTML page of a target code at a compiling stage of the target code, substitutes the interface address and the related parameters into an interface request preposed code template to generate an interface request preposed code corresponding to the first network request, inserts the interface request preposed code into a position before a page script in an HTML document corresponding to the HTML page, executes the interface request preposed code and the page script in parallel at an HTML page running stage to acquire a request result and a request state for executing the interface request preposed code, intercepts a network interface request which is initiated by the HTML page and accords with a preposed interface, and returns the request result and the request state to the HTML page to realize the access automation of the interface preposed, the manpower required when the access interface is preposed is liberated, and the optimization efficiency of the preposed interface is improved.
On the basis of the above technical solution, before intercepting the network interface request which is initiated by the HTML page and conforms to the front interface, the method further includes:
intercepting a current network interface request initiated by the HTML page, and acquiring an interface address and related parameters of the current network interface request;
matching the interface address and the related parameters of the current network interface request with the interface address and the related parameters of the first network request;
and if the interface address and the related parameters of the current network interface request are successfully matched with the interface address and the related parameters of the first network request, determining that the current network interface request is a network interface request conforming to a front interface.
Detecting each network interface request initiated to the back end by a HTML page through a network agent unit in an interface request preposition module, intercepting a current network interface request initiated to the back end by the HTML page, extracting an interface address and related parameters of the current network interface request, matching the interface address and related parameters of the intercepted current network interface request with the interface address and related parameters of a first network request, if the interface address and related parameters of the intercepted current network interface request are successfully matched with the interface address and related parameters of the first network request, namely the interface address and related parameters of the intercepted network interface request are the same as the interface address and the same parameters of the first network request, determining that the intercepted current network interface request is the network interface request conforming to the preposition interface, and then directly returning the request result and request state of the first network request to the HTML page, the front-end performance is optimized.
On the basis of the above technical solution, after the matching of the interface address and the related parameter of the current network interface request with the interface address and the related parameter of the first network request, the method further includes:
and if the interface address and the related parameters of the current network interface request are unsuccessfully matched with the interface address and the related parameters of the first network request, sending the current network interface request to a back end, acquiring request data, and returning the request data to the HTML page.
If the interface address and the related parameters of the intercepted current network interface request fail to be matched with the interface address and the related parameters of the first network request, the intercepted current network interface request is determined to be a network interface request which does not conform to the front interface, at the moment, the current network interface request is sent to the back end, request data is obtained from the back end, the request data is returned to the HTML page, and the HTML page can use the request data conveniently.
On the basis of the above technical solution, after the returning the request result and the request status to the HTML page, the method further includes:
and after the HTML page receives the request result and the request state, assembling the TMHL page by using the request result or processing exception according to the request state.
Because the interface request preposition module can return the result and the state of the preposition interface request to the HTML page without changing, the HTML page does not need to judge whether the request result comes from the network or the interface request preposition module, and the data can be normally used or abnormal can be processed without changing the processing flow of the data. The page code is not changed, the HTML page is subjected to imperceptible use interface preposed optimization through the interface request preposed module agent, the original flow of the page is not changed, and the risk of code change is reduced.
Fig. 2 is an execution flowchart of a network interface request in a page in an embodiment of the present application, and as shown in fig. 2, after a network interface request is initiated by a page, a network proxy unit in an interface request pre-processing module intercepts the network interface request initiated by the page, and the interface request pre-processing module matches an interface address and related parameters of the intercepted network interface request with a first network interface request, that is, an interface address and related parameters of a pre-processing interface, to determine whether the intercepted network interface request can use the pre-processing interface. If the judgment result is yes, returning the context reserved by the preposed interface request, namely returning the request result and the request state of the preposed interface request, replacing the context requested by the current network interface by the context of the preposed interface by the network agent unit in the interface request preposed module, and returning the context to the page, wherein the page has no perception on the context; if the judgment result is negative, the network interface request is normally requested, namely the network interface request is sent to the back end, the back end returns the result, the network agent unit of the interface request preposition module returns the request result returned by the back end to the page, and the page does not sense the request result. After the page receives the request result, the page does not need to judge whether the request result is from the network or the interface request preposition module, and the data can be normally used or abnormal processing can be carried out without changing the data processing flow of the page. The page code is not changed, the interface request preposed module agent enables the page to be perceptually used for preposed optimization, the original flow of the page is not changed, and the risk of code change is reduced. When the page requests, the context of the network request is established, the context of the network request comprises information such as the state of the request, the returned result and the like, when the page requests, the information is inherited, the request is continued on the basis of the previous preposed request when the request is not completed, and if the request is completed, the result of the preposed request is directly used, namely the context of the preposed interface is used for replacing the context of the current request.
Example two
The interface-preposed optimization apparatus disclosed in this embodiment is applied to a front-end and back-end separated page, as shown in fig. 3, the interface-preposed optimization apparatus 200 includes:
a request parameter obtaining module 210, configured to obtain, in a compiling stage of a target code, an interface address and related parameters of a first network request in an HTML page of the target code;
a prefix code generation module 220, configured to substitute the interface address and the relevant parameter into an interface request prefix code template, and generate an interface request prefix code corresponding to the first network request;
a code inserting module 230, configured to insert the interface request pre-code into a position before a page script in an HTML document corresponding to the HTML page;
a parallel execution module 240, configured to execute the interface request prefix code and the page script in parallel in the HTML page operation phase, and obtain a request result and a request state for executing the interface request prefix code;
and the front request implementation module 250 is configured to intercept a network interface request that is initiated by the HTML page and conforms to a front interface, and return the request result and the request state to the HTML page.
Optionally, the apparatus further comprises:
the request intercepting module is used for intercepting a current network interface request initiated by the HTML page and acquiring an interface address and related parameters of the current network interface request;
the request matching module is used for matching the interface address and the related parameters of the current network interface request with the interface address and the related parameters of the first network request;
and the front interface determining module is used for determining that the current network interface request is a network interface request conforming to a front interface if the interface address and the related parameters of the current network interface request are successfully matched with the interface address and the related parameters of the first network request.
Optionally, the apparatus further comprises:
and the normal request module is used for sending the current network interface request to the back end, acquiring request data and returning the request data to the HTML page if the interface address and the related parameters of the current network interface request are unsuccessfully matched with the interface address and the related parameters of the first network request.
Optionally, the parallel execution module includes:
the front request execution unit is used for executing the interface request front code to initiate the first network request to the rear end through a first channel resource of a browser in the HTML page operation stage and acquiring a request result and a request state;
and the page script execution unit is used for executing the page script to request corresponding data from the back end through other channel resources of the browser.
Optionally, the request parameter obtaining module includes:
the target code conversion unit is used for converting the target code into an abstract syntax tree in the compiling stage of the target code;
and the request parameter acquisition unit is used for retrieving the abstract syntax tree and determining the interface address and the related parameters of the first network request in the HTML page.
Optionally, the apparatus further comprises:
and the page processing module is used for assembling the TMHL page by using the request result or processing exception according to the request state after the HTML page receives the request result and the request state.
The interface-preposed optimization device provided in the embodiment of the present application is used to implement each step of the interface-preposed optimization method described in the first embodiment of the present application, and specific implementation manners of each module of the device refer to the corresponding step, which is not described herein again.
The interface preposed optimization device disclosed by the embodiment of the application acquires an interface address and related parameters of a first network request in an HTML page of a template code through a request parameter acquisition module in a compiling stage of a target code, a preposed code generation module substitutes the interface address and the related parameters into an interface request preposed code template to generate an interface request preposed code corresponding to the first network request, a code insertion module inserts the interface request preposed code into a position in front of a page script in an HTML document corresponding to the HTML page, a parallel execution module executes the interface request preposed code and the page script in parallel in an HTML page running stage to acquire a request result and a request state for executing the interface request preposed code, and a preposed request realization module intercepts a network interface request which is initiated by the HTML page and accords with the preposed interface, and the request result and the request state are returned to the HTML page, so that the access automation of the interface preposition is realized, the manpower required by the access interface preposition is liberated, and the optimization efficiency of the interface preposition is improved.
Correspondingly, the embodiment of the present application further discloses an electronic device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the computer program, the method for optimizing the interface front-end according to the first embodiment of the present application is implemented. The electronic device can be a PC, a mobile terminal, a personal digital assistant, a tablet computer and the like.
The embodiment of the present application also discloses a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the steps of the optimization method of the interface front-end according to the first embodiment of the present application.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The foregoing describes in detail an interface pre-optimization method, apparatus, electronic device, and storage medium provided in an embodiment of the present application, and a specific example is applied in the present application to explain the principle and implementation manner of the present application, and the description of the foregoing embodiment is only used to help understand the method and core ideas of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.

Claims (10)

1. An optimization method for interface front-end, comprising:
in the compiling stage of the object code, acquiring an interface address and related parameters of a first network request in a hypertext markup language (HTML) page of the object code;
substituting the interface address and the related parameters into an interface request prefix code template to generate an interface request prefix code corresponding to the first network request; the interface request preposed code template is a preset general template of the interface request preposed code;
inserting the interface request prepositive code into the position before a page script in an HTML document corresponding to the HTML page;
in the HTML page operation stage, the interface request preposed code and the page script are executed in parallel, and the request result and the request state of the interface request preposed code are obtained;
intercepting a network interface request which is initiated by the HTML page and accords with a front interface, and returning the request result and the request state to the HTML page.
2. The method of claim 1, wherein prior to intercepting the pre-interface compliant network interface request initiated by the HTML page, further comprising:
intercepting a current network interface request initiated by the HTML page, and acquiring an interface address and related parameters of the current network interface request;
matching the interface address and the related parameters of the current network interface request with the interface address and the related parameters of the first network request;
and if the interface address and the related parameters of the current network interface request are successfully matched with the interface address and the related parameters of the first network request, determining that the current network interface request is a network interface request conforming to a front interface.
3. The method according to claim 2, further comprising, after said matching the interface address and the related parameters of the current network interface request with the interface address and the related parameters of the first network request:
and if the interface address and the related parameters of the current network interface request are unsuccessfully matched with the interface address and the related parameters of the first network request, sending the current network interface request to a back end, acquiring request data, and returning the request data to the HTML page.
4. The method of claim 1, wherein the executing the interface request pre-code and the page script in parallel in the HTML page running stage to obtain the request result and the request status of the interface request pre-code comprises:
in the HTML page operation stage, executing the interface request preposed code to initiate the first network request to the rear end through a first channel resource of a browser, and acquiring a request result and a request state;
and executing the page script to request corresponding data from the back end through other channel resources of the browser.
5. The method of claim 1, wherein the obtaining, in the compiling stage of the object code, the interface address and the related parameters of the first network request in the HTML page of the object code comprises:
in the compiling stage of the object code, converting the object code into an abstract syntax tree;
and retrieving the abstract syntax tree, and determining an interface address and related parameters of the first network request in the HTML page.
6. The method of claim 1, after said returning said request result and said request status to said HTML page, further comprising:
and after the HTML page receives the request result and the request state, assembling the HTML page by using the request result or processing exception according to the request state.
7. An interface-advanced optimization apparatus, comprising:
the request parameter acquisition module is used for acquiring an interface address and related parameters of a first network request in an HTML page of the object code at the compiling stage of the object code;
a prefix code generation module, configured to substitute the interface address and the related parameter into an interface request prefix code template, and generate an interface request prefix code corresponding to the first network request; the interface request preposed code template is a preset general template of the interface request preposed code;
the code insertion module is used for inserting the interface request prepositive code into the position before the page script in the HTML document corresponding to the HTML page;
the parallel execution module is used for executing the interface request preposed code and the page script in parallel in the HTML page operation stage and acquiring a request result and a request state of the interface request preposed code;
and the front request implementation module is used for intercepting a network interface request which is initiated by the HTML page and accords with a front interface, and returning the request result and the request state to the HTML page.
8. The apparatus of claim 7, further comprising:
the request intercepting module is used for intercepting a current network interface request initiated by the HTML page and acquiring an interface address and related parameters of the current network interface request;
the request matching module is used for matching the interface address and the related parameters of the current network interface request with the interface address and the related parameters of the first network request;
and the front interface determining module is used for determining that the current network interface request is a network interface request conforming to a front interface if the interface address and the related parameters of the current network interface request are successfully matched with the interface address and the related parameters of the first network request.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method for optimizing an interface front end according to any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method for optimizing an interface front-end according to any one of claims 1 to 6.
CN201910843969.8A 2019-09-06 2019-09-06 Interface preposition optimization method and device, electronic equipment and storage medium Active CN110704055B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910843969.8A CN110704055B (en) 2019-09-06 2019-09-06 Interface preposition optimization method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910843969.8A CN110704055B (en) 2019-09-06 2019-09-06 Interface preposition optimization method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110704055A CN110704055A (en) 2020-01-17
CN110704055B true CN110704055B (en) 2020-11-13

Family

ID=69194449

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910843969.8A Active CN110704055B (en) 2019-09-06 2019-09-06 Interface preposition optimization method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110704055B (en)

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073686A (en) * 2010-12-24 2011-05-25 汉柏科技有限公司 Vertical dynamic loading method of page document and device thereof
CN103747094A (en) * 2014-01-21 2014-04-23 上海斐讯数据通信技术有限公司 Dynamic page data separation method
CN106648690B (en) * 2016-12-29 2020-04-07 北京恒华伟业科技股份有限公司 Automatic code generation method and device
CN107609156B (en) * 2017-09-26 2020-12-25 微梦创科网络科技(中国)有限公司 Page construction method and device
CN107959718B (en) * 2017-11-17 2020-10-02 西北工业大学 Micro-service architecture of enterprise-level application software in cloud computing environment
CN108628606B (en) * 2018-05-09 2021-08-03 烽火通信科技股份有限公司 Method and system for generating WEB network management application program of embedded equipment
CN109684586A (en) * 2018-11-21 2019-04-26 平安科技(深圳)有限公司 Page layout optimization display methods, device, computer equipment and storage medium
CN110196715A (en) * 2019-06-25 2019-09-03 上海仪电汽车电子系统有限公司 A kind of code generating system and method

Also Published As

Publication number Publication date
CN110704055A (en) 2020-01-17

Similar Documents

Publication Publication Date Title
CN110198247B (en) Interface test method and system
JP5225399B2 (en) Systems and methods for desktop application migration
US8078691B2 (en) Web page load time prediction and simulation
CN109144567B (en) Cross-platform webpage rendering method and device, server and storage medium
CN110858172A (en) Automatic test code generation method and device
CN106951270B (en) Code processing method, system and server
CN108984202B (en) Electronic resource sharing method and device and storage medium
CN110727429B (en) Front-end page generation method, device and equipment
CN109597618B (en) Program development method, program development device, computer device, and storage medium
CN108632361B (en) Webpage online method, server, system and storage medium
CN111679886A (en) Heterogeneous computing resource scheduling method, system, electronic device and storage medium
CN112988298B (en) Visual interface configuration method, visual interface configuration device, computer equipment and storage medium
CN111831384A (en) Language switching method and device, equipment and storage medium
CN110362317B (en) Code conversion method, device and storage medium
CN105068926A (en) Program test method and device thereof
CN111580821B (en) Script binding method and device, electronic equipment and computer readable storage medium
CN111310005A (en) Network request processing method and device, server and storage medium
CN116227505A (en) Internationalization file translation method, device, equipment and medium
CN111290996A (en) Document format conversion method, device, equipment and readable storage medium
JP6723976B2 (en) Test execution device and program
CN113535586A (en) Test environment switching method, device, equipment and readable storage medium
CN110704055B (en) Interface preposition optimization method and device, electronic equipment and storage medium
CN111240790B (en) Multi-language adaptation method, device, client and storage medium for application
CN112632419A (en) Domain name pre-resolution configuration method and device, computer equipment and storage medium
CN111061469A (en) WEB front-end source code generation method and device, storage medium and processor

Legal Events

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