Front-end-based request processing method and device, terminal and storage medium

Through preset scripts, the Ajax request method of the front-end project is logically processed and redefined, combined with Esbuild and package management tools, the problem of global modification of the front-end framework in project iteration is solved, and the unified processing of the request method and efficient resource construction is realized. Improved security and maintainability.

CN118916055AActive Publication Date: 2024-11-08PING AN BANK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411060002.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-02
Publication Date
2024-11-08
Estimated Expiration
2044-08-02

AI Technical Summary

Technical Problem

When existing front-end frameworks are iterated, especially when global modifications are required such as security verification logic or buried system integration, they cannot be directly defined globally, resulting in waste of resources and runtime errors.

Method used

The Ajax request method is logically processed through advanced functions of preset scripts, including encryption and decryption and embedding of buried point information, redefining the request method, and using Esbuild and package management tools to build library function files to achieve unified object generation and efficient resource generation Build.

Benefits of technology

It realizes unified processing, security enhancement and efficient construction of Ajax requests, reduces the complexity of code maintenance and resource loading, and improves the maintainability and scalability of code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916055A_ABST
    Figure CN118916055A_ABST
Patent Text Reader

Abstract

The invention provides a request processing method and device based on a front end, a terminal and a storage medium. The method comprises the following steps: acquiring a request method for updating a front-end item; all Ajax methods in the request method are logically processed through a preset high-order function of a preset script, the processed request method is obtained, and the preset high-order function comprises a first preset function and a second preset function; the processed request method is redefined through the preset script, and the request method after object unification is obtained; constructing the request method after the object unification to generate a corresponding library function file; through unified processing, security enhancement and efficient construction processes for Ajax requests, security processing of request parameters, efficient construction and loading of resources and dynamic function extension are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, and in particular to a front-end-based request processing method, device, terminal and storage medium. Background Art

[0002] In the current Internet front-end development field, component-based development models and rich ecosystems based on front-end frameworks such as Vue and React have become the choice of many projects. In order to compile complex project structures into browser-recognizable code, developers generally use packaging tools such as Webpack and Rollup to integrate, compress, and optimize various resources, and ultimately generate bundle files that are easy to deploy.

[0003] When a project needs to be iterated, especially when the entire project or a large number of pages need to be functionally adjusted, it is necessary to add unified security verification logic to all Ajax requests, or integrate a new tracking system to collect user behavior data. However, many applications based on mature front-end frameworks do not directly expose global entry points for developers to make such global modifications, especially when the front-end framework itself is highly encapsulated or the project structure is complex. This can only be solved by using the plugin of the webpack tool, which needs to be concretized to each page for processing through the plugin. There is a problem of repeated definition of global methods, which leads to resource waste and even runtime errors. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to provide a front-end-based request processing method, device, terminal and storage medium to solve the technical problem that the existing request method definition cannot be directly globally defined and is prone to repeated definition.

[0005] In a first aspect, the present invention provides a front-end-based request processing method, comprising:

[0006] Get the request method used to update the front-end project;

[0007] Performing logical processing on all Ajax methods in the request method through a preset high-order function of a preset script to obtain a processed request method, wherein the preset high-order function includes a first preset function and a second preset function;

[0008] Redefine the processed request method through the preset script to obtain the request method after the unified object;

[0009] The request method after the unified object is constructed to generate a corresponding library function file.

[0010] In an optional embodiment, the method further comprises:

[0011] Obtaining an initialization request for the front-end project;

[0012] Inject the preset script into the front-end project.

[0013] In an optional implementation, the logical processing of all Ajax methods in the request method by the preset high-order function of the preset script to obtain the processed request method includes:

[0014] The input parameter and the output parameter of the request method are encrypted and decrypted respectively by the first preset function to obtain the corresponding processed request method;

[0015] The embedding point information is embedded through the second preset function to obtain the corresponding processed request method.

[0016] In an optional implementation manner, constructing the request method after unifying the object includes:

[0017] The request method after the unified object is constructed by using the Esbuild packaging tool.

[0018] In an optional embodiment, the method further comprises:

[0019] Execute the preset build task according to the library function file through the preset package management tool to obtain the corresponding build result;

[0020] The build result is loaded into the front-end project as a static resource.

[0021] In an optional implementation, executing the construction task according to the library function file by using a preset package management tool includes:

[0022] The preset construction task of the library function file is executed using the front script of the preset package management tool.

[0023] In a second aspect, the present invention provides a request processing device based on a front end, the device comprising:

[0024] The acquisition module is used to obtain the request method for updating the front-end project;

[0025] Processing module: used for performing logic processing on all Ajax methods in the request method through a preset high-order function of a preset script to obtain a processed request method, wherein the preset high-order function includes a first preset function and a second preset function;

[0026] A definition module, used to redefine the processed request method through the preset script to obtain a unified request method;

[0027] The construction module is used to construct the request method after the unified object to generate a corresponding library function file.

[0028] In an optional embodiment, the processing module includes:

[0029] A processing unit, configured to encrypt and decrypt the input parameter and the output parameter of the request method respectively through the first preset function to obtain a corresponding processed request method;

[0030] Embedding unit: used to embed the tracking point information through the second preset function to obtain the corresponding processed request method.

[0031] In a third aspect, the present invention provides a terminal, comprising a memory and a processor, wherein the memory stores a front-end-based request processing program, and the front-end-based request processing program executes the front-end-based request processing method described in the aforementioned embodiment when the processor is running.

[0032] In a fourth aspect, the present invention provides a computer storage medium, wherein the computer storage medium stores a front-end-based request processing program, and when the front-end-based request processing program runs on a processor, it executes the front-end-based request processing method described in the aforementioned embodiment.

[0033] The present invention adopts the above technical solution to achieve the following effects:

[0034] The present invention obtains a request method for updating a front-end project; performs logical processing on all Ajax methods in the request method through a preset high-order function of a preset script to obtain a processed request method, wherein the preset high-order function includes a first preset function and a second preset function; redefines the processed request method through the preset script to obtain a unified object request method; constructs the unified object request method to generate a corresponding library function file; the present invention realizes secure processing of request parameters, efficient construction and loading of resources, and dynamic function expansion through unified processing, security enhancement and efficient construction process for Ajax requests. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments of the present invention are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0036] Figure 1A schematic diagram of a process flow of a front-end-based request processing method provided by an embodiment of the present invention;

[0037] Figure 2 is another flow chart of a front-end-based request processing method provided by an embodiment of the present invention;

[0038] Figure 3 It is another flow chart of a front-end-based request processing method provided by an embodiment of the present invention;

[0039] Figure 4 It is another flow chart of a front-end-based request processing method provided by an embodiment of the present invention;

[0040] Figure 5 It is a structural diagram of a front-end-based request processing device provided by an embodiment of the present invention;

[0041] Figure 6 It is a schematic diagram of the structure of a terminal provided by an embodiment of the present invention.

[0042] Icons: 500-front-end based request processing device; 501-acquisition module; 502-processing module; 503-definition module; 504-construction module; 600-terminal; 601-processor; 602-transceiver;

[0043] 603-Memory. DETAILED DESCRIPTION

[0044] The technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.

[0045] The components of the present invention generally described and shown in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0046] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.

[0047] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.

[0048] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present invention belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present invention.

[0049] At present, obtaining users' vital signs data through wearable devices on the market is relatively direct and complicated, which is not only not conducive to users directly discovering data anomalies and changes, but also unable to provide easy-to-understand result analysis and early warnings.

[0050] In response to the above technical problems, an embodiment of the present invention provides a front-end-based request processing method, device, terminal and storage medium, aiming to solve the technical problem that the existing request method definition cannot be directly defined globally and is prone to repeated definition.

[0051] Example 1

[0052] like Figure 1 As described above, the embodiment of the present invention provides a front-end-based request processing method, including steps S100 to S400, and each step is described below.

[0053] Step S100, obtaining a request method for updating a front-end project.

[0054] In this embodiment, the front-end-based request processing method is applied to a terminal, and the terminal includes but is not limited to: computers and mobile terminals and other devices; the terminal is provided with a training migration platform for front-end-based request processing.

[0055] Preferably, the front-end project can be a front-end framework project such as Vue, React, etc. that has a series of preset code libraries, components and guide collections, or a non-front-end project that does not rely on mature frameworks and directly uses native Web technologies (HTML, CSS, JavaScript) for page construction and interactive logic implementation. The request method includes the request method that needs to be updated for all single-page or multi-page applications in the front-end project, where the update includes but is not limited to update operations such as obtaining data, updating data or submitting forms.

[0056] In this embodiment, in the front-end project development, when the project development needs to make an update request, a request method for updating the front-end project is obtained. Preferably, the front-end project uses Ajax requests to implement update requests. Therefore, the main thing is to obtain the Ajax request for updating the front-end project, thereby optimizing the request processing.

[0057] like Figure 2 As described above, S100 obtains a request method for updating a front-end project, and previously includes the following steps:

[0058] Step S500, obtaining an initialization request for the front-end project.

[0059] Step S600, injecting the preset script into the front-end project.

[0060] Preferably, when the front-end project is being developed, an initialization request during the development process is obtained, so that a preset script is injected into the front-end project, providing a pre-task for subsequent updates and realizing independent expansion of functions.

[0061] In this embodiment, by obtaining the initialization request of the front-end project under development, the script is injected into the front-end project to provide front-end loading and improve the optimization efficiency.

[0062] Step S200, performing logical processing on all Ajax methods in the request method through a preset high-order function of a preset script to obtain a processed request method, wherein the preset high-order function includes a first preset function and a second preset function.

[0063] Preferably, the preset script executes a custom method in the script through the _ajaxBefore function, mainly referring to the _ajaxBefore function that uniformly preprocesses Ajax requests in the front-end project, and enhances or controls the behavior of the request by inserting a custom logic method. The preset high-order function is a high-order function used to enhance or modify the Ajax request method, which can realize the logical processing of the request, wherein the first preset function refers to a high-order function used for encryption and decryption operations on request parameters (input parameters) and response data (output parameters), and the second preset function refers to a high-order function used to embed embedded point information, which respectively represent processing logic at different levels. By combining the preset high-order functions, all Ajax methods in the request method are logically processed, including encryption and decryption of input and output parameters, injection of embedded point information and other logical processing, to obtain the processed request method, thereby efficiently responding to complex request processing logic and realizing the unification and enhancement of the request method. In this embodiment, the preferred logical processing is encryption and decryption of input and output parameters, injection of embedded point information and other logical processing.

[0064] In this embodiment, redefining all Ajax methods by presetting high-order functions can be achieved by loading the following custom functions into the presetting script:

[0065] const_ajaxBefore=function(callback)

[0066] {return async(...args)=>

[0067] {await callback(...args)

[0068] this(...args)}}

[0069] The preset script is loaded when the project is initialized. By executing the preset function and the custom function in the high-order function _ajaxBefore, the Ajax request method performs logical processing such as encryption and decryption of input and output parameters and injection of embedded point information, thereby redefining all Ajax objects.

[0070] In this embodiment, the _ajaxBefore function is used as a preset hook to provide a centralized way to manage and enhance Ajax requests. Then, by customizing the method in the _ajaxBefore function, encryption and decryption operations of request parameters (input parameters) and response data (output parameters) and / or embedding of tracking point information are implemented, thereby simplifying development work and ensuring the comprehensiveness and consistency of data collection.

[0071] like Figure 3 As shown, specifically, in an implementation of this embodiment, step S200 includes the following:

[0072] Step S210, encrypting and decrypting the input parameter and output parameter of the request method respectively through the first preset function to obtain the corresponding processed request method;

[0073] Step S220, embedding the tracking point information through the second preset function to obtain the corresponding processed request method.

[0074] In this embodiment, the first preset function is a function used for encryption and decryption operations in the preset script, and the second preset function is a function used to embed the buried point information in the preset script. The encryption and decryption operations of the request parameters (input parameters) and the response data (output parameters) are implemented through the first preset function, which is usually used to protect sensitive information, such as user credentials, financial transaction data, etc. For example, sensitive data in the request body can be encrypted before sending the request to ensure that the data is not easily stolen during the transmission process; at the same time, after receiving the response, the data is decrypted so that the application can use the data safely. Then the buried point information is embedded through the second preset function. The buried point refers to inserting code at the key position of the application to collect user behavior data for subsequent analysis of user habits, optimization of product functions, etc. Embedding the buried point information means that before each Ajax request is initiated, some tracking codes or specific parameters are automatically added to record the context information of the request, such as the request URL, timestamp, user ID, etc., so as to protect the security of the request data, and effectively collect and analyze the interaction data between the user and the application, thereby optimizing the user experience and application performance.

[0075] Step S300, redefine the processed request method through the preset script to obtain the request method after the unified object.

[0076] In this embodiment, redefining the processed request method refers to modifying the global Ajax object through a preset script, that is, modifying the global window.$.ajax object, and specifically executing the _ajaxBefore function to ensure that each Ajax request is processed by the logic of the preset script, thereby uniformly redefining each Ajax request to obtain the request method after the unified object, which not only enhances the security and functionality of the front-end project request, but also simplifies code maintenance through unified processing logic, realizes the unification and enhancement of the request method, and improves the maintainability and extensibility of the code.

[0077] Step S400, constructing the request method after unifying the object to generate a corresponding library function file.

[0078] In this embodiment, the construction operation refers to packaging the request method after the unified object into a browser-compatible file in order to ensure that the browser environment can correctly load and execute the request method after being processed by the preset script unified object, thereby handling the dependencies of different method specifications and ensuring the compatibility and maintainability of the code.

[0079] Specifically, in an implementation of this embodiment, step S400 includes the following:

[0080] Step S410: construct the request method after unifying the objects by using the Esbuild packaging tool.

[0081] As a preferred method, the lightweight packaging tool Esbuild is used to output the request method after the unified object, so as to realize the independence and efficiency of the packaging construction, thereby providing a pre-task for generating the corresponding library function file and realizing the independent expansion of the function.

[0082] Because the global singleton mode is used, it is guaranteed that the resource will not be injected repeatedly and will only be executed when ajax is loaded. In the single page mode shown in the figure below, page1, page2...pageN all use the same window.$.ajax. The injection of global functions makes the script purer and more efficient, avoiding the side effects caused by multiple loading.

[0083] In this embodiment, since the use of preset high-order functions to process the Ajax request method requires the introduction of new dependencies (such as libraries that comply with the ESM or CommonJS specifications) to assist in processing these business logics, when the business logic processing relies on libraries that comply with the ESM (ECMAScript module) specifications or the CommonJS specifications, direct use in the browser environment may encounter compatibility issues. Therefore, the Node package management tool is used to package the introduced new dependencies together with the processed Ajax request method into a single file that is compatible with the current project environment (whether ESM or CommonJS), thereby ensuring the normal operation of the code. The Esbuild fast build packaging tool is used to package the request method after the unified object into a file compatible with different browsers, which can further improve the code's running efficiency and loading speed while ensuring the compatibility of the code.

[0084] like Figure 4 As shown, specifically, in an implementation of this embodiment, step S400 also includes the following:

[0085] Step S420, executing a preset construction task according to the library function file through a preset package management tool to obtain a corresponding construction result.

[0086] Step S430: Load the construction result into the front-end project as a static resource.

[0087] Preferably, the preset package management tool includes but is not limited to utilizing Node's package management tool npm.

[0088] In this embodiment, a preset package management tool is used to perform preset build tasks, specifically parsing the project configuration file, identifying the required library function files and their dependencies, and executing the build tasks based on the parsing results, thereby maximizing performance and loading speed, simplifying the integration process of third-party libraries or custom library function files in the front-end project, and ensuring resource consistency and optimal performance through standardized build processes, thereby solving efficiency and quality issues in front-end resource management and build integration, and promoting the advancement of front-end development technology.

[0089] Specifically, in an implementation of this embodiment, step S420 includes the following:

[0090] Step S421, using the front script of the preset package management tool to execute the preset construction task of the library function file.

[0091] Preferably, the prescript prescript of the Node package management tool npm is used to execute the building task of the library function file, and the building task refers to building the library function file according to the library function file, the project type into which the library function file is loaded, and the corresponding project environment.

[0092] In this embodiment, the Ajax request method after the unified object is effectively integrated into the project through the package management tool of npm, ensuring the high performance, compatibility and maintenance convenience of the code, thereby achieving no changes to the business layer logic code, and being able to achieve unified processing of all request methods without leaving the original front-end project construction process, while ensuring the independence and efficiency of the functions. Not only does it reduce the intrusion into the existing code, but it also achieves the effects of low-code processing, backward compatibility, and elegant upgrades, and ensures that the Ajax request method after the unified object is built and deployed with the project, improving the organization and maintainability of the code.

[0093] In one implementation of this embodiment, the specific implementation steps in the front-end project can be: first, redefine the global Ajax request method by presetting a high-order function, the preset script is loaded when the front-end project is initialized, and the custom method is executed in the _ajaxBefore function. The custom method includes logical processing such as encryption and decryption of input and output parameters, injection of embedded point information, and finally redefines the Ajax object on the global window. Among them, when encountering the dependency of the ESM specification or the dependency of the CommonJS specification during the logical processing, the library function is packaged and built by using the fast and lightweight packaging tool Esbuild to generate ajax.bundle.js. Esbuild has built-in code compression and can generate efficient production environment code without additional tools. It is simple to configure and realizes the independence and efficiency of the function. The preset script provides a pre-task for generating ajax.bundle.js, realizing the independent expansion of the function. Because the global singleton mode is used, it is guaranteed that the resources will not be injected repeatedly and are only executed when Ajax is loaded, making the script purer and more efficient, avoiding the side effects caused by multiple loading. Finally, the pre-hook prescript of Node's package management tool-npm is used to execute the construction task of the library function. The construction task will be completed before the main construction process of the front-end project is executed, and finally it is loaded as a static resource after the Ajax request method is loaded. Since the solution of the present invention is completed outside the original framework project construction process, when all single-page or multi-page applications request ajax, the corresponding injected resources are only loaded once, that is, ajax.bundle.js. And it will not involve changes in the business layer logic code. In this way, it can achieve unified processing of all request methods without the original framework project construction process, while ensuring the independence and efficiency of the functions. Reduce the impact of intervention on existing codes.

[0094] The present invention adopts the above technical solution to achieve the following effects:

[0095] The present invention obtains a request method for updating a front-end project; performs logical processing on all Ajax methods in the request method through a preset high-order function of a preset script to obtain a processed request method, wherein the preset high-order function includes a first preset function and a second preset function; redefines the processed request method through the preset script to obtain a unified object request method; constructs the unified object request method to generate a corresponding library function file; the present invention realizes secure processing of request parameters, efficient construction and loading of resources, and dynamic function expansion through unified processing, security enhancement and efficient construction process for Ajax requests.

[0096] Example 2

[0097] In addition, the present application provides a request processing device 500 based on the front end, and its functional module diagram is as follows: Figure 5 As shown, the front-end-based request processing device 500 includes:

[0098] An acquisition module 501 is used to acquire a request method for asynchronously updating a front-end project;

[0099] Processing module 502: used to perform logic processing on all Ajax methods in the request method through a preset high-order function of a preset script to obtain a processed request method, wherein the preset high-order function includes a first preset function and a second preset function;

[0100] A definition module 503, configured to redefine the processed request method through the preset script to obtain a unified request method;

[0101] The construction module 504 is used to construct the request method after the unified object to generate a corresponding library function file.

[0102] Specifically, in an implementation of this embodiment, the processing module 502 includes:

[0103] A processing unit, configured to encrypt and decrypt the input parameter and the output parameter of the request method respectively through the first preset function to obtain a corresponding processed request method;

[0104] Embedding unit: used to embed the tracking point information through the second preset function to obtain the corresponding processed request method.

[0105] The front-end-based request processing device 500 provided in this embodiment can implement a front-end-based request processing method provided in Embodiment 1, and will not be described again here to avoid repetition.

[0106] Example 3

[0107] In addition, an embodiment of the present application provides a terminal, including a memory and a processor, wherein the memory stores a front-end-based request processing program, and when the front-end-based request processing program runs on the processor, it executes the front-end-based request processing method provided in Example 1.

[0108] For details, see Figure 6The terminal 600 includes: a transceiver 602, a bus interface and a processor 601, wherein the processor 601 is used to: obtain a request method for updating a front-end project; perform logical processing on all Ajax methods in the request method through a preset high-order function of a preset script to obtain a processed request method, wherein the preset high-order function includes a first preset function and a second preset function; redefine the processed request method through the preset script to obtain a unified object request method; construct the unified object request method to generate a corresponding library function file.

[0109] In one implementation, the processor 601 is further configured to: obtain an initialization request for the front-end project; and inject the preset script into the front-end project.

[0110] In one embodiment, the processor 601 is also used to: encrypt and decrypt the input parameters and output parameters of the request method respectively through the first preset function to obtain the corresponding processed request method; embed the embedding point information through the second preset function to obtain the corresponding processed request method.

[0111] In one implementation, the processor 601 is further configured to: construct the request method after unifying the object by using an Esbuild packaging tool.

[0112] In one embodiment, the processor 601 is further used to: execute a preset build task according to the library function file through a preset package management tool to obtain a corresponding build result; and load the build result into the front-end project as a static resource.

[0113] In one implementation, the processor 601 is further configured to: execute the preset construction task of the library function file using a front script of the preset package management tool.

[0114] In the embodiment of the present invention, the terminal 600 further includes a memory 603. Figure 6 In the embodiment, the bus architecture may include any number of interconnected buses and bridges, specifically linking various circuits of one or more processors represented by processor 601 and memory represented by memory 603. The bus architecture may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface. The transceiver 602 may be a plurality of components, i.e., including a transmitter and a receiver, providing a unit for communicating with various other devices on a transmission medium. The processor 601 is responsible for managing the bus architecture and general processing, and the memory 603 may store data used by the processor 601 when performing operations.

[0115] The terminal 600 provided in the embodiment of the present invention can execute the steps of the front-end-based request processing method provided in the above method embodiment 1, which will not be described again here to avoid repetition.

[0116] The terminal provided in this embodiment obtains a request method for updating a front-end project; performs logical processing on all Ajax methods in the request method through a preset high-order function of a preset script to obtain a processed request method, wherein the preset high-order function includes a first preset function and a second preset function; redefines the processed request method through the preset script to obtain a unified object request method; constructs the unified object request method to generate a corresponding library function file, and realizes secure processing of request parameters, efficient construction and loading of resources, and dynamic function expansion through unified processing, security enhancement and efficient construction process for Ajax requests.

[0117] Example 4

[0118] The present application also provides a computer storage medium, which stores a front-end-based request processing program. When the front-end-based request processing program is executed by a processor, a front-end-based request processing method provided in Example 1 is implemented.

[0119] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0120] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0121] Furthermore, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0122] It should be noted that if the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.

[0123] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0124] The above description is only an embodiment of the present invention and is not intended to limit the protection scope of the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A request processing method based on a front end, characterized in that: include: Get the request method used to update the front-end project; Performing logical processing on all Ajax methods in the request method through a preset high-order function of a preset script to obtain a processed request method, wherein the preset high-order function includes a first preset function and a second preset function; Redefine the processed request method through the preset script to obtain the request method after the unified object; The request method after the unified object is constructed to generate a corresponding library function file.

2. The front-end-based request processing method according to claim 1, characterized in that: The method also includes: Obtaining an initialization request for the front-end project; Inject the preset script into the front-end project.

3. The front-end-based request processing method according to claim 2, characterized in that: The method of performing logical processing on all Ajax methods in the request method by using the preset high-order function of the preset script to obtain the processed request method includes: The input parameter and the output parameter of the request method are encrypted and decrypted respectively by the first preset function to obtain the corresponding processed request method; The embedding point information is embedded through the second preset function to obtain the corresponding processed request method.

4. The front-end-based request processing method according to claim 2, characterized in that: The request method after unifying the object is constructed, including: The request method after the unified object is constructed by using the Esbuild packaging tool.

5. The front-end-based request processing method according to claim 4, characterized in that: The method further comprises: Execute the preset build task according to the library function file through the preset package management tool to obtain the corresponding build result; The build result is loaded into the front-end project as a static resource.

6. The front-end-based request processing method according to claim 5, characterized in that: The executing the construction task according to the library function file by using the preset package management tool includes: The preset construction task of the library function file is executed using the front script of the preset package management tool.

7. A request processing device based on a front end, characterized in that: The device comprises: The acquisition module is used to obtain the request method for updating the front-end project; Processing module: used for performing logic processing on all Ajax methods in the request method through a preset high-order function of a preset script to obtain a processed request method, wherein the preset high-order function includes a first preset function and a second preset function; A definition module, used to redefine the processed request method through the preset script to obtain a unified request method; The construction module is used to construct the request method after the unified object to generate a corresponding library function file.

8. The front-end-based request processing device according to claim 7, characterized in that: The processing module comprises: A processing unit, configured to encrypt and decrypt the input parameter and the output parameter of the request method respectively through the first preset function to obtain a corresponding processed request method; Embedding unit: used to embed the tracking point information through the second preset function to obtain the corresponding processed request method.

9. A terminal, characterized in that: It includes a memory and a processor, wherein the memory stores a front-end-based request processing program, and the front-end-based request processing program executes the front-end-based request processing method described in any one of claims 1 to 6 when the processor is running.

10. A computer storage medium, characterized in that: The computer storage medium stores a front-end-based request processing program, and when the front-end-based request processing program is run on a processor, the front-end-based request processing method according to any one of claims 1 to 6 is executed.

Citation Information

Patent Citations

  • Ajax request merging processing method, system and device and storage medium

    CN113641512A

  • Providing globalization functionalities for javascript applications

    US20080082965A1