Data processing method and device, equipment and storage medium

By encapsulating the application program interface and data export specifications, the service data sharing between the server and the client is realized, solving the problem of data acquisition separately when rendering is combined, simplifying the development process and improving the rendering effect.

CN119127977APending Publication Date: 2024-12-13TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310693582.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-12
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

When using client rendering and server-side rendering, the business data of the server and client are usually obtained separately, resulting in cumbersome code development and lack of data sharing mechanism.

Method used

Through the encapsulation application program interface (API), data export specifications are defined, and unified calls to server-side and client user data files are realized. Asynclocalstorage and object wrapper share business data, and corresponding user data files are generated to ensure that they are in different operating environments. data shareability.

Benefits of technology

It realizes full-process business data sharing between the server and the client, simplifies code development, improves rendering effect, and provides a unified data access interface.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119127977A_ABST
    Figure CN119127977A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data processing method and device, equipment and a storage medium, which are used for realizing whole-course service data sharing between a server side and a client side. Comprising the steps that an application program interface is obtained through packaging, a data export specification of the application program interface is defined, the application program interface is used for calling a first user data file of a server side or a second user data file of a client side, and the data export specification is used for indicating an import environment for calling the first user data file or the second user data file; the first user data file and the second user data file have the same service data; loading the application program interface into a running environment, and obtaining the type of the running environment; when the type of the operation environment is a server-side operation environment, calling a first user data file through an application program interface; and when the type of the operating environment is the client operating environment, calling the second user data file through the application program interface. The technical scheme provided by the invention can be applied to the field of computers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a data processing method, device, equipment and storage medium. Background Art

[0002] The screen rendering of the application is divided into client-side rendering and server-side rendering. The process of client-side rendering is as follows: after the client sends a business request to the server, the server obtains an empty page without data rendering according to the client's business request and sends it to the client; the client obtains the empty string page and starts to execute the code in it from top to bottom. When the script contains request or rendering code, it will send another request to the server; when the server receives the second request from the client, it sends the response data to the client, and then the client renders again. The process of server-side rendering is as follows: the server receives the business request sent by the client, and then renders the page according to the business request, and directly returns the rendering result to the client.

[0003] These two rendering methods have their own advantages and disadvantages, so we consider combining client-side rendering with server-side rendering to achieve better rendering effects. However, in the process of combined use, the business data of the server and the business data of the client are usually obtained separately, which makes code development cumbersome.

[0004] Therefore, there is an urgent need for a data processing method that can enable the server and the client to share business data. Summary of the invention

[0005] The embodiments of the present application provide a data processing method, apparatus, device and storage medium for enabling a server and a client to share business data throughout the entire process.

[0006] In view of this, the present application provides, on the one hand, a data processing method, comprising: encapsulating an application interface and defining a data export specification of the application interface, wherein the application interface is used to call a first user data file on a server side or a second user data file on a client side, and the data export specification is used to indicate an import environment for calling the first user data file or the second user data file, and the first user data file and the second user data file have the same business data; loading the application interface into an operating environment and obtaining the type of the operating environment; when the type of the operating environment is a server-side operating environment, calling the first user data file through the application interface; when the type of the operating environment is a client-side operating environment, calling the second user data file through the application interface.

[0007] On the other hand, the present application provides a data processing device, including: a processing module, used to encapsulate an application program interface and define a data export specification of the application program interface, the application program interface is used to call a first user data file on a server or a second user data file on a client, the data export specification is used to indicate an import environment for calling the first user data file or the second user data file, the first user data file and the second user data file having the same business data;

[0008] A loading module, used to load the application interface into the operating environment and obtain the type of the operating environment;

[0009] The calling module is used to call the first user data file through the application interface when the operating environment is a server-side operating environment; and to call the second user data file through the application interface when the operating environment is a client-side operating environment.

[0010] In one possible design, in another implementation of another aspect of the embodiment of the present application, the device further includes:

[0011] The transceiver module is used to obtain the service data corresponding to the target service request;

[0012] A processing module, used to share the business data corresponding to the business request by using asynclocalstorage;

[0013] The execution code of the business data is packaged to generate the first user data file.

[0014] In one possible design, in another implementation of another aspect of the embodiment of the present application, the processing module is used to encapsulate the execution code of the business data using an object wrapper to generate the first user data file.

[0015] In one possible design, in another implementation of another aspect of the embodiment of the present application, the device further includes:

[0016] The transceiver module is used to obtain the service data corresponding to the target service request;

[0017] A processing module, used for sharing the business data corresponding to the business request by using global variables;

[0018] The execution code of the business data is packaged to generate the second user data file.

[0019] In one possible design, in another implementation of another aspect of the embodiment of the present application, the device further includes:

[0020] The transceiver module is used to obtain the service data corresponding to the target service request;

[0021] A processing module, used to share the business data corresponding to the business request by using asynclocalstorage;

[0022] The execution code of the business data is packaged to generate the second user data file.

[0023] In one possible design, in another implementation of another aspect of the embodiment of the present application, the processing module is used to encapsulate the execution code of the business data using an object wrapper to generate the second user data file.

[0024] In one possible design, in another implementation of another aspect of the embodiment of the present application, the processing module is used to encapsulate and obtain the useData application program interface.

[0025] In one possible design, in another implementation of another aspect of the embodiment of the present application, the processing module is used to name the function of the first user data file and the second user data file as useData.

[0026] In one possible design, in another implementation of another aspect of the embodiment of the present application, the processing module is used to define the data export specification of the application interface in package.json, and the first field is defined in the package.json for exporting the first user data file, and the second field is defined for exporting the second user data file.

[0027] In one possible design, in another implementation of another aspect of the embodiment of the present application, the calling module is used to read the first field and call the first user data file through the application interface.

[0028] In one possible design, in another implementation of another aspect of the embodiment of the present application, the calling module is used to read the second field and call the second user data file through the application interface.

[0029] In one possible design, in another implementation of another aspect of the embodiment of the present application, the calling module is used to export the compilation type corresponding to the first user data file or the second user data file through the application interface.

[0030] Another aspect of the present application provides a computer device, including: a memory, a processor, and a bus system;

[0031] Wherein, the memory is used to store programs;

[0032] The processor is used to execute the program in the memory, and the processor is used to execute the above-mentioned methods according to the instructions in the program code;

[0033] The bus system is used to connect the memory and the processor so that the memory and the processor can communicate with each other.

[0034] Another aspect of the present application provides a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer is enabled to execute the above-mentioned methods.

[0035] Another aspect of the present application provides a computer program product or a computer program, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided by the above aspects.

[0036] It can be seen from the above technical solution that the embodiment of the present application has the following advantages: the user data file on the server side or the user data file on the client side can be called through an application program interface, so that developers can share the user data files on the server side and the client side through an application program interface. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A schematic diagram of the architecture of the communication system in the embodiment of the present application

[0038] Figure 2 This is a schematic diagram of an embodiment of a data processing method in an embodiment of the present application;

[0039] Figure 2a A code schematic diagram of exposing an application program interface in a data processing method in an embodiment of the present application;

[0040] Figure 2b A code schematic diagram of defining two different user data files in the data processing method in the embodiment of the present application;

[0041] Figure 2c A code schematic diagram of a data export specification defining an application program interface in a data processing method in an embodiment of the present application;

[0042] Figure 2d A code schematic diagram of encapsulating an application program interface as a third-party module in a data processing method in an embodiment of the present application;

[0043] Figure 3 This is a schematic diagram of an embodiment of sharing business data on the server side in the data processing method in the embodiment of the present application;

[0044] Figure 3a This is a schematic diagram of an embodiment of using asynclocalstorage to share business data in a data processing method in an embodiment of the present application;

[0045] Figure 3b A schematic diagram of an embodiment of encapsulating and generating a first user data file in a data processing method in an embodiment of the present application;

[0046] Figure 4 This is a schematic diagram of an embodiment of a client sharing business data in a data processing method in an embodiment of the present application;

[0047] Figure 5 This is a schematic diagram of an embodiment of a client sharing business data in a data processing method in an embodiment of the present application;

[0048] Figure 5a This is a schematic diagram of an embodiment of using global variables to share business data in a data processing method in an embodiment of the present application;

[0049] Figure 6 A processing flow diagram of a data processing method in an embodiment of the present application;

[0050] Figure 7 This is a schematic diagram of an embodiment of a data processing device in an embodiment of the present application;

[0051] Figure 7a This is another schematic diagram of an embodiment of a data processing device in an embodiment of the present application;

[0052] Figure 8 This is another schematic diagram of an embodiment of a data processing device in an embodiment of the present application;

[0053] Fig. 9 FIG. 2 is a schematic diagram of another embodiment of a data processing device in an embodiment of the present application. DETAILED DESCRIPTION

[0054] The embodiments of the present application provide a data processing method, apparatus, device and storage medium for enabling a server and a client to share business data throughout the entire process.

[0055] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "corresponding to" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0056] The screen rendering of the application is divided into client-side rendering and server-side rendering. Among them, the process of client-side rendering is as follows: after the client sends a business request to the server, the server obtains an empty page without data rendering according to the client's business request and sends it to the client; the client obtains the empty string page and starts to execute the code from top to bottom. When the script has a request or rendering code, it will make another request to the server; the server receives the second request from the client and sends the response data to the client, and then the client renders again. The process of server-side rendering is as follows: the server receives the business request sent by the client, and then renders the page according to the business request, and directly returns the rendering result to the client. These two rendering methods have their own advantages and disadvantages, so it is considered to combine client-side rendering with server-side rendering to achieve better rendering effect. In the process of combined use, the business data of the server and the business data of the client are usually obtained separately, which leads to cumbersome code development. Therefore, there is an urgent need for a data processing method that allows the server and the client to share business data.

[0057] In order to solve the above problems, the present application provides the following technical solutions: encapsulate an application interface and define a data export specification of the application interface, the application interface is used to call the first user data file of the server or the second user data file of the client, the data export specification is used to indicate the import environment for calling the first user data file or the second user data file, the first user data file and the second user data file have the same business data; load the application interface into the operating environment and obtain the type of the operating environment; when the type of the operating environment is the server-side operating environment, call the first user data file through the application interface; when the type of the operating environment is the client-side operating environment, call the second user data file through the application interface. In this way, the user data file of the server or the user data file of the client can be called through one application interface, so that developers can share the user data files of the server and the client through one application interface.

[0058] For ease of understanding, some of the terms used in this application are described below:

[0059] Asynchronous: Each task has one or more callback functions. After the previous task is completed, the callback function is executed instead of the next task. The next task is executed without waiting for the previous task to be completed. Therefore, the execution order of the program is inconsistent with the order of task arrangement.

[0060] asynclocalstorage: A capability provided by the Node.js language to track complete request information in asynchronous methods. Among them, the two most important functions are as follows: asyncLocalStorage.run(store, callback): saves the data store and makes it available in the callback (including the sub-functions inside the callback). asyncLocalStorage.get(store): gets the store data saved by the run method.

[0061] Object wrapper: A mechanism for converting primitive data types into objects. It makes primitive data types have the characteristics of objects, that is, it changes from primitive data types to reference data types. At this time, the primitive data type can also be called using the object calling method. Using object wrappers can make the code more flexible, convenient, and easy to read. The object wrapping methods it provides can include the following:

[0062] valueOf() method: Converts a string to a value of the corresponding primitive data type or object wrapper type.

[0063] parseInt() method: Converts a string to an int value.

[0064] toString() method: Converts an object to a string.

[0065] equals() method: Compares whether two objects are equal.

[0066] compareTo() method: Compares the size relationship of two objects.

[0067] intValue() method: Converts an object to a value of type int.

[0068] doubleValue() method: Converts an object to a double value.

[0069] booleanValue() method: Converts an object to a boolean value.

[0070] Application Program Interface (API): It is a set of definitions, programs and protocols. Its main function is to provide a common set of functions to enable mutual communication between computer software. Through the API interface, specific functions can be implemented without knowing its internal implementation details. The API interface can be understood as a kind of encapsulation of a specific service, which encapsulates the service and provides it to others for calling, so that many functions do not need to be redeveloped. API allows organizations to extend the use of their own software and data to applications and data that do not belong to them. This brings a series of benefits, such as cost savings, time savings, and enhanced functionality.

[0071] Server-side rendering: It is essentially string concatenation. After the client initiates a request, the server embeds the result of the data query in Hypertext Markup Language (html), and then sends the entire package to the client for rendering. There will only be one request.

[0072] Client rendering: It is essentially string concatenation. After the client initiates a request, the server returns the html page, which also contains js (JavaScript) executable files and Cascading Style Sheets (CSS) style files. When the page is returned, the js executable file is executed again to obtain data resources from the server and render them on the html page. There will be at least two requests. Among them, the CSS is a computer language used to express the style of files such as HTML or Extensible Markup Language (XML) (a subset of the standard generalized markup language). CSS can not only modify web pages statically, but also dynamically format the elements of the web pages in conjunction with various scripting languages. js is a lightweight, interpreted or just-in-time compiled programming language with function priority. JavaScript is a dynamic scripting language based on prototype programming and multiple paradigms, and supports object-oriented, imperative, declarative, and functional programming paradigms.

[0073] Global variables: A variable that can be accessed and modified throughout the entire program. Different programming languages ​​have different ways of declaring and using global variables. For example, in Python, you can declare a global variable anywhere in a module. Java does not have the concept of global variables, but you can use a class's public static variables to simulate the role of global variables, because such public class static variables can be accessed anywhere by any other class. In Go, global variables refer to capitalized exported variables declared at the top level of the package, so that this variable can be accessed and modified in any corner of the entire Go program. Based on its definition, global variables can be accessed anywhere in the program. Whether in a function, method, loop body, or deeply indented conditional statement block, global variables can be directly accessed. At the same time, due to the easy access feature, global variables are often used to share data between different parts of the program, such as configuration item data, command line flags (cmd flag), etc. Because the life cycle of a global variable is the same as the entire life cycle of the program, it will not be destroyed because of the end of the function call, nor will it be GCed, and it can always exist and maintain its value. Similarly, because global variables are easy to access, this means that global variables may be directly accessed or modified everywhere. Changing a global variable at any location may affect another function that uses it in an unexpected way.

[0074] By running the data processing solution provided in the embodiment of the present application, the electronic device can realize that the server and the client can share business data throughout the process. That is, the electronic device itself can be improved to realize that the server and the client can share business data throughout the process. It is applicable to various application scenarios. For example, data rendering scenarios of various applications.

[0075] See also Figure 1 , Figure 1It is an optional architecture diagram under an application scenario of the data processing solution provided by the embodiment of the present application. In order to realize and support a data processing solution, the terminal device 100 is connected to the server 300 through the network 200, and the server 300 is connected to the database 400. The network 200 can be a wide area network or a local area network, or a combination of the two. The client for implementing the data processing solution is deployed on the terminal device 100, wherein the client can be run on the terminal device 100 in the form of a browser, or can be run on the terminal device 100 in the form of an independent application (application, APP), etc. The specific presentation form of the client is not limited here. The server 300 involved in this application can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal device 100 can be a smart phone, a tablet computer, a laptop, a PDA, a personal computer, a smart TV, a smart watch, a vehicle-mounted device, a wearable device, etc., but is not limited thereto. The terminal device 100 and the server 300 can be directly or indirectly connected through the network 200 by wired or wireless communication, and this application does not limit this. The number of servers 300 and terminal devices 100 is also not limited. The solution provided in this application can be completed independently by the terminal device 100, or by the server 300, or by the terminal device 100 and the server 300 in cooperation, and this application does not make specific limitations. Among them, the database 400, in short, can be regarded as an electronic filing cabinet-a place for storing electronic files, and users can add, query, update, delete, and other operations on the data in the file. The so-called "database" is a collection of data that is stored together in a certain way, can be shared with multiple users, has as little redundancy as possible, and is independent of the application program. A database management system (DBMS) is a computer software system designed for managing databases, generally with basic functions such as storage, interception, security, and backup.Database management systems can be classified according to the database models they support, such as relational, Extensible Markup Language (XML); or according to the types of computers they support, such as server clusters, mobile phones; or according to the query language used, such as Structured Query Language (SQL), XQuery; or according to performance impulse focus, such as maximum scale, maximum operating speed; or other classification methods. Regardless of the classification method used, some DBMSs can cross categories, for example, supporting multiple query languages ​​at the same time. In the present application, the database 400 can be used to store a first user data file and a second user data file. Of course, the storage location of the first user data file and the second user data file is not limited to the database, for example, it can also be stored in the terminal device 100, the blockchain or the distributed file system of the server 300.

[0076] It is understandable that in the specific implementation of this application, business data and other related data are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0077] Combined with the above introduction, the data processing method in this application will be introduced below. Please refer to Figure 2 , an embodiment of the data processing method in the embodiment of the present application includes:

[0078] 201. Encapsulate an application program interface and define a data export specification of the application program interface, wherein the application program interface is used to call a first user data file on a server or a second user data file on a client, and the data export specification is used to indicate an import environment for calling the first user data file or the second user data file, and the first user data file and the second user data file have the same business data.

[0079] In order to realize business data sharing between the client and the server, the data processing device encapsulates the user data files of the client and the user data files of the server to obtain an application program interface for data calling, and defines data export specifications of the application program interface for the user data files of the client and the user data files of the server.

[0080] In an exemplary embodiment, the application program interface can be Figure 2a The code shown is exposed to the developer.

[0081] It should be understood that, in this embodiment, the first user data file is a code file obtained by encapsulating the execution code based on the business data of the server, and the second user data file is a code file obtained by encapsulating the execution code based on the business data of the client. That is, when the first user data file or the second user data file is called through the application interface, the execution code of the business data of the server or the client can be directly called.

[0082] Optionally, the application program interface may be defined as a useData application program interface, so that the first user data file or the second user data file can be called at any location.

[0083] Based on the useData application program interface, the first user data file and the second user data file can be named as the same data function during the encoding process, wherein the data function is named useData.

[0084] At the same time, in this embodiment, when defining the data export specification, the data processing device can adopt the following technical solution: that is, in package.json, define the corresponding field for the first user data file as the first field, and define the corresponding field for the second user data file as the second field. Then, based on the execution of the first field and the second field, determine whether to call the first user data file or the second user data file.

[0085] In an exemplary solution, the first user data file is defined as a server folder, and the server folder is stored in the implementation function of the server. The second user data file is defined as a client folder, and the client folder is stored in the implementation function of the client. At this time, both the implementation function of the server and the implementation function of the client are named useData. An exemplary code can be as follows Figure 2b As shown, the types.ts file is used to export the compilation type of the server-side and client-side code files. In this way, only one compilation type is returned to the developer, but the developer can perform different code compilation operations according to the different user data files actually called. At the same time, the developer does not know the code implementation details of each operating environment, but can directly call the relevant code data, thereby enhancing the usability of the solution.

[0086] After defining different folders, you can define the data export specifications for each folder in package.json. Figure 2cAs shown, in the server-side operating environment, the esports.node field will be read, that is, the server folder will be directly called, and the code in the server folder will be executed to realize the sharing capability of the server-side business data. In the client-side operating environment, the browser field will be read, that is, the client folder will be directly called, and the code in the client folder will be executed to realize the sharing capability of the client-side business data.

[0087] 202. Load the application interface into a running environment, and obtain the type of the running environment.

[0088] The data processing device loads the application interface into the operating environment, and at this time the data processing device can also detect the operating environment to obtain the type of the operating environment. In this embodiment, the type of the operating environment is a server-side operating environment or a client-side operating environment.

[0089] In an exemplary solution, the application interface is encapsulated into a third module (i.e., utils), and then the code for loading the application interface can be as follows: Figure 2d shown.

[0090] 203. When the type of the operating environment is a server-side operating environment, call the first user data file through the application interface.

[0091] When it is determined that the type of the operating environment is a server-side operating environment, the data processing device can read the first field corresponding to the first user data file on the server side, then call the first user data file, and execute the code under the first user data file to realize the sharing capability of business data on the server side.

[0092] In an exemplary embodiment, if the first field is set as Figure 2b As shown, the data processing device will read the esports.node field, that is, directly call the server folder and execute the code under the server folder to realize the sharing capability of business data on the server side.

[0093] 204. When the type of the operating environment is a client operating environment, the second user data file is called through the application interface.

[0094] When it is determined that the type of the operating environment is a client operating environment, the data processing device can read the second field corresponding to the second user data file of the client, then call the second user data file, and execute the code under the second user data file to realize the sharing capability of business data on the client.

[0095] In an exemplary embodiment, if the second field is set as Figure 2b As shown, the data processing device will read the esports.node field, that is, directly call the server folder and execute the code under the server folder to realize the sharing capability of business data on the server side.

[0096] It is understandable that before encapsulating the application interface, the data processing device may also perform shared processing on the service data of the server side, and the specific operation may be as follows: Figure 3 As shown, an embodiment of a method for processing service data on the server side in the present application includes:

[0097] 301. Obtain business data corresponding to the target business request.

[0098] The data processing device obtains service data corresponding to the target service request.

[0099] In this embodiment, the target business request can be a data request for a web page. For example, on a shopping platform, a user clicks to enter a merchant's store homepage. At this time, after the user clicks the control, the data processing device generates the target business request in response to the click operation. At this time, the target business request is used to request all business data of the store homepage (such as JS execution data, CSS files, etc.). Alternatively, the user directly enters the address of a web page through the search bar of the browser and clicks to enter. The data processing device can generate the target business request in response to the click operation. At this time, the target business request is used to request all business data of the store homepage (such as JS execution data, CSS files, etc.).

[0100] 302. Use asynclocalstorage to share the business data corresponding to the business request.

[0101] After acquiring the business data, the data processing device shares the business data using asynclocalstorage, that is, all subsequent execution codes of the business request are run in the asynclocalstorage, so that the correct business data can be acquired at any location and at any time in the code.

[0102] In an exemplary solution, the code for the data processing device to share the service data through the asynclocalstorage can be as follows: Figure 3a As shown, asyncLocalStorage.run(userData,()=>) is used to indicate that the business data is obtained within the scope of asyncLocalStorage.

[0103] 303. Encapsulate the execution code of the business data to generate the first user data file.

[0104] The data processing device uses the object wrapper to encapsulate the execution code of the business data, thereby obtaining the first user data file.

[0105] In an exemplary solution, when the data processing device encapsulates the first user data file, its specific encapsulation code may be as follows: Figure 3b As shown, run:asyncfunction(store:AppStore, callback(args?:unknown)=>StorageReturnVal) is used to indicate the encapsulation of the run method. At this time, the developer only needs to pass in data and the callback function to automatically execute the first user data file.

[0106] Similarly, before encapsulating the application interface, the data processing device can also perform shared processing on the client's business data. The specific operation can be as follows: Figure 4 As shown, an embodiment of a method for processing service data of a client in the present application includes:

[0107] 401. Obtain business data corresponding to the target business request.

[0108] The data processing device obtains service data corresponding to the target service request.

[0109] In this embodiment, the target business request can be a data request for a web page. For example, on a shopping platform, a user clicks to enter a merchant's store homepage. At this time, after the user clicks the control, the data processing device generates the target business request in response to the click operation. At this time, the target business request is used to request all business data of the store homepage (such as JS execution data, CSS files, etc.). Alternatively, the user directly enters the address of a web page through the search bar of the browser and clicks to enter. The data processing device can generate the target business request in response to the click operation. At this time, the target business request is used to request all business data of the store homepage (such as JS execution data, CSS files, etc.).

[0110] 402. Use asynclocalstorage to share the business data corresponding to the business request.

[0111] After acquiring the business data, the data processing device shares the business data using asynclocalstorage, that is, all subsequent execution codes of the business request are run in the asynclocalstorage, so that the correct business data can be acquired at any location and at any time in the code.

[0112] In an exemplary solution, when the data processing device encapsulates the second user data file, its specific encapsulation code may be as follows: Figure 3b As shown, run:asyncfunction(store:AppStore, callback(args?:unknown)=>StorageReturnVal) is used to indicate the encapsulation of the run method. At this time, the developer only needs to pass in data and the callback function to automatically execute the second user data file.

[0113] 403. Encapsulate the execution code of the service data to generate the second user data file.

[0114] The data processing device uses the object wrapper to encapsulate the execution code of the business data, thereby obtaining the first user data file.

[0115] In this embodiment, the data processing device encapsulates the code file generating the second user data file and the Figure 3 The scheme shown is similar and will not be described in detail here.

[0116] In another implementation, Figure 5 As shown, an embodiment of a method for processing service data of a client in the present application includes:

[0117] 501. Obtain business data corresponding to the target business request.

[0118] The data processing device obtains service data corresponding to the target service request.

[0119] In this embodiment, the target business request can be a data request for a web page. For example, on a shopping platform, a user clicks to enter a merchant's store homepage. At this time, after the user clicks the control, the data processing device generates the target business request in response to the click operation. At this time, the target business request is used to request all business data of the store homepage (such as JS execution data, CSS files, etc.). Alternatively, the user directly enters the address of a web page through the search bar of the browser and clicks to enter. The data processing device can generate the target business request in response to the click operation. At this time, the target business request is used to request all business data of the store homepage (such as JS execution data, CSS files, etc.).

[0120] 502. Use global variables to share the business data corresponding to the business request.

[0121] After the data processing device obtains the business data, since there is only one user on the client sending a business request, in order to reduce the complexity of the code, the business data can be shared using global variables, so that the correct business data can be obtained at any location and at any time in the code.

[0122] In an exemplary solution, the code of the data processing device using global variables to share the service data can be as follows: Figure 5a As shown, a global variable is defined as global.user, and then the user directly calls the global variable when executing a business request.

[0123] 503. Encapsulate the execution code of the service data to generate the second user data file.

[0124] The data processing device uses the object wrapper to encapsulate the execution code of the business data, thereby obtaining the first user data file.

[0125] In this embodiment, the data processing device encapsulates the code file generating the second user data file and the Figure 3 The scheme shown is similar and will not be described in detail here.

[0126] The data processing method of the present application is described below with a specific flowchart. Figure 6 As shown:

[0127] After the user initiates a business request, the business request can be sent to the server and the client at the same time, and then the server and the client also use the useData interface to obtain the corresponding business data; the server uses asynclocalstorage to share the business data, and then uses useData to encapsulate the business data and the execution code of the business data to generate the server folder, and then defines its export specification through the defined node field; the client uses global variables to share the business data, and then uses useData to encapsulate the business data and the execution code of the business data to generate the client folder, and then defines its export specification through the defined browser field; finally, the corresponding application interface is encapsulated for the server folder and the client folder, and a utils module is generated, thereby enhancing the usability of the application interface.

[0128] The data processing device in this application is described in detail below. Figure 7 , Figure 7 This is a schematic diagram of an embodiment of a data processing device in an embodiment of the present application. The data processing device 20 includes:

[0129] The processing module 201 is used to encapsulate an application program interface and define a data export specification of the application program interface, wherein the application program interface is used to call a first user data file on the server side or a second user data file on the client side, and the data export specification is used to indicate an import environment for calling the first user data file or the second user data file, and the first user data file and the second user data file have the same business data;

[0130] A loading module 202, used to load the application interface into the operating environment and obtain the type of the operating environment;

[0131] The calling module 203 is used to call the first user data file through the application interface when the operating environment is a server-side operating environment; and to call the second user data file through the application interface when the operating environment is a client-side operating environment.

[0132] In an embodiment of the present application, a data processing device is provided. By using the above device, a user data file on the server side or a user data file on the client side can be called through an application program interface, so that developers can share user data files on the server side and the client side through an application program interface.

[0133] Optionally, in the above Figure 7 Based on the corresponding embodiments, Figure 7a As shown, in another embodiment of the data processing device 20 provided in the embodiment of the present application,

[0134] The transceiver module 204 is used to obtain the service data corresponding to the target service request;

[0135] Processing module 201, used to share the business data corresponding to the business request by using asynclocalstorage;

[0136] The execution code of the business data is packaged to generate the first user data file.

[0137] In an embodiment of the present application, a data processing device is provided. The device is used to isolate each scope in the server using asynclocalstorage, so that the business data corresponding to each business request will not be polluted, thereby ensuring that there will be no problem with server-side data sharing.

[0138] Optionally, in the above Figure 7a On the basis of the corresponding embodiment, in another embodiment of the data processing device 20 provided in the embodiment of the present application, the processing module 201 is used to encapsulate the execution code of the business data by using the object wrapper to generate the first user data file.

[0139] In an embodiment of the present application, a data processing device is provided. Using the above device, the first user data file uses an object wrapper to encapsulate the execution code of the business data, thereby obtaining the first user data file, so that the basic type in the execution code can be packaged as an object type, making the code more convenient, flexible and easy to read.

[0140] Optionally, in the above Figure 7a On the basis of the corresponding embodiment, in another embodiment of the data processing device 20 provided in the embodiment of the present application,

[0141] The transceiver module 204 is used to obtain the service data corresponding to the target service request;

[0142] Processing module 201, used to share the business data corresponding to the business request by using global variables;

[0143] The execution code of the business data is packaged to generate the second user data file.

[0144] In an embodiment of the present application, a data processing device is provided. By using the above device, the business data corresponding to each business request in the client is shared using global variables, which makes the code simpler without affecting the pollution of the business data.

[0145] Optionally, in the above Figure 7a On the basis of the corresponding embodiment, in another embodiment of the data processing device 20 provided in the embodiment of the present application,

[0146] The transceiver module 204 is used to obtain the service data corresponding to the target service request;

[0147] Processing module 201, used to share the business data corresponding to the business request by using asynclocalstorage;

[0148] The execution code of the business data is packaged to generate the second user data file.

[0149] In an embodiment of the present application, a data processing device is provided. The device is used to isolate each scope in the client using asynclocalstorage, so that the business data corresponding to each business request will not be polluted, thereby ensuring that there will be no problem with client data sharing.

[0150] Optionally, in the above Figure 7a On the basis of the corresponding embodiment, in another embodiment of the data processing device 20 provided in the embodiment of the present application, the processing module 201 is used to encapsulate the execution code of the business data by using the object wrapper to generate the second user data file.

[0151] In the embodiment of the present application, a data processing device is provided. Using the above device, the second user data file uses an object wrapper to encapsulate the execution code of the business data, thereby obtaining the second user data file, so that the basic type in the execution code can be packaged as an object type, thereby making the code more convenient, flexible and easy to read.

[0152] Optionally, in the above Figure 7a On the basis of the corresponding embodiment, in another embodiment of the data processing device 20 provided in the embodiment of the present application, the processing module 201 is used to encapsulate and obtain the useData application program interface.

[0153] In an embodiment of the present application, a data processing device is provided. By adopting the above device, the data function can be better called using the useData API.

[0154] Optionally, in the above Figure 7a On the basis of the corresponding embodiment, in another embodiment of the data processing device 20 provided in the embodiment of the present application,

[0155] The processing module 201 is used to name the function of the first user data file and the second user data file as useData.

[0156] In an embodiment of the present application, a data processing device is provided. By using the above device, a function name is used to name user data files from two sources respectively, so that developers can call user data files from different sources through one function, thereby realizing full data sharing between the client and the server.

[0157] Optionally, in the above Figure 7a On the basis of the corresponding embodiment, in another embodiment of the data processing device 20 provided in the embodiment of the present application,

[0158] The processing module 201 is used to define the data export specification of the application interface in package.json, wherein the first field is defined in the package.json to export the first user data file, and the second field is defined to export the second user data file.

[0159] In an embodiment of the present application, a data processing device is provided. By using the above device, two different fields are used to distinguish the first user data file and the second user data file, so as to import the same user data file in different operating environments, so that the developer can call the data files of the server and the client without feeling.

[0160] Optionally, in the above Figure 7aOn the basis of the corresponding embodiment, in another embodiment of the data processing device 20 provided in the embodiment of the present application,

[0161] The calling module 203 is used to read the first field and call the first user data file through the application interface.

[0162] In an embodiment of the present application, a data processing device is provided. By using the above device, two different fields are used to distinguish the first user data file and the second user data file, so as to import the same user data file in different operating environments, so that the developer can call the data files of the server and the client without feeling.

[0163] Optionally, in the above Figure 7a On the basis of the corresponding embodiment, in another embodiment of the data processing device 20 provided in the embodiment of the present application,

[0164] The calling module 203 is used to read the second field and call the second user data file through the application interface.

[0165] In an embodiment of the present application, a data processing device is provided. By using the above device, two different fields are used to distinguish the first user data file and the second user data file, so as to import the same user data file in different operating environments, so that the developer can call the data files of the server and the client without feeling.

[0166] Optionally, in the above Figure 7a On the basis of the corresponding embodiment, in another embodiment of the data processing device 20 provided in the embodiment of the present application, the calling module 203 is used to export the compilation type corresponding to the first user data file or the second user data file through the application interface.

[0167] In an embodiment of the present application, a data processing device is provided. Using the above device, in an embodiment of the present application, a data processing device is provided. Using the above device, two different compilation types are used to distinguish the first user data file and the second user data file, so as to import different compilation types of user data files in different operating environments, so that developers can call the data files of the server and the client without feeling.

[0168] The data processing device provided in this application can be used in a server, see Figure 8 , Figure 8: is a schematic diagram of a server structure provided in an embodiment of the present application. The server 300 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 322 (for example, one or more processors) and memory 332, and one or more storage media 330 (for example, one or more mass storage devices) storing application programs 342 or data 344. Among them, the memory 332 and the storage medium 330 can be short-term storage or permanent storage. The program stored in the storage medium 330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 322 can be configured to communicate with the storage medium 330 to execute a series of instruction operations in the storage medium 330 on the server 300.

[0169] The server 300 may also include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input and output interfaces 358, and / or one or more operating systems 341, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0170] The steps performed by the server in the above embodiment can be based on the Figure 8 The server structure shown.

[0171] The data processing device provided in this application can be used in terminal equipment. Fig. 9 For the sake of convenience, only the parts related to the embodiments of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiments of the present application. In the embodiments of the present application, the terminal device is a smart phone as an example for explanation:

[0172] Fig. 9 The block diagram shows a partial structure of a smart phone related to the terminal device provided in the embodiment of the present application. Fig. 9 The smart phone includes: a radio frequency (RF) circuit 410, a memory 420, an input unit 430, a display unit 440, a sensor 450, an audio circuit 460, a wireless fidelity (WiFi) module 470, a processor 480, and a power supply 490. Those skilled in the art will appreciate that Fig. 9 The structure of the smartphone shown in the figure does not constitute a limitation of the smartphone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0173] Combine the following Fig. 9 A detailed introduction to the various components of a smartphone:

[0174] The RF circuit 410 can be used for receiving and sending signals during the process of sending and receiving information or making calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 480 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit 410 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF circuit 410 can also communicate with the network and other devices through wireless communication. The above-mentioned wireless communication can use any communication standard or protocol, including but not limited to the global system of mobile communication (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), long term evolution (LTE), email, short messaging service (SMS), etc.

[0175] The memory 420 can be used to store software programs and modules. The processor 480 executes various functional applications and data processing of the smartphone by running the software programs and modules stored in the memory 420. The memory 420 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the smartphone (such as audio data, a phone book, etc.), etc. In addition, the memory 420 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0176] The input unit 430 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the smart phone. Specifically, the input unit 430 may include a touch panel 431 and other input devices 432. The touch panel 431, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 431 or near the touch panel 431 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 431 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 480, and can receive and execute commands sent by the processor 480. In addition, the touch panel 431 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 431, the input unit 430 may also include other input devices 432. Specifically, other input devices 432 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.

[0177] The display unit 440 can be used to display information input by the user or information provided to the user and various menus of the smartphone. The display unit 440 may include a display panel 441. Optionally, the display panel 441 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like. Further, the touch panel 431 may cover the display panel 441. When the touch panel 431 detects a touch operation on or near it, it is transmitted to the processor 480 to determine the type of touch event. Subsequently, the processor 480 provides a corresponding visual output on the display panel 441 according to the type of touch event. Although in Fig. 9 In the embodiment, the touch panel 431 and the display panel 441 are used as two independent components to implement the input and output functions of the smartphone, but in some embodiments, the touch panel 431 and the display panel 441 can be integrated to implement the input and output functions of the smartphone.

[0178] The smartphone may also include at least one sensor 450, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 441 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 441 and / or the backlight when the smartphone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the smartphone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in smartphones, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.

[0179] The audio circuit 460, the speaker 461, and the microphone 462 can provide an audio interface between the user and the smartphone. The audio circuit 460 can transmit the received audio data to the speaker 461 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 462 converts the collected sound signal into an electrical signal, which is received by the audio circuit 460 and converted into audio data, and then the audio data is output to the processor 480 for processing, and then sent to another smartphone through the RF circuit 410, or the audio data is output to the memory 420 for further processing.

[0180] WiFi is a short-range wireless transmission technology. Smartphones can help users send and receive emails, browse web pages, and access streaming media through WiFi module 470, which provides users with wireless broadband Internet access. Fig. 9 A WiFi module 470 is shown, but it is understandable that it is not an essential component of the smartphone and can be omitted as needed without changing the essence of the invention.

[0181] Processor 480 is the control center of the smartphone, which uses various interfaces and lines to connect various parts of the entire smartphone, and executes various functions of the smartphone and processes data by running or executing software programs and / or modules stored in memory 420, and calling data stored in memory 420, thereby monitoring the smartphone as a whole. Optionally, processor 480 may include one or more processing units; optionally, processor 480 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into processor 480.

[0182] The smart phone also includes a power source 490 (such as a battery) for supplying power to various components. Optionally, the power source can be logically connected to the processor 480 through a power management system, thereby managing functions such as charging, discharging, and power consumption management through the power management system.

[0183] Although not shown, the smartphone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.

[0184] The steps performed by the terminal device in the above embodiment can be based on the Fig. 9 The terminal device structure shown.

[0185] A computer-readable storage medium is also provided in an embodiment of the present application. The computer-readable storage medium stores a computer program, which, when executed on a computer, enables the computer to execute the methods described in the aforementioned embodiments.

[0186] The present application also provides a computer program product including a program, which, when executed on a computer, enables the computer to execute the methods described in the aforementioned embodiments.

[0187] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0188] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, 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, such as 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 an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0189] 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.

[0190] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0191] If the integrated unit is implemented in the form of a software functional unit 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 application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable 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 application. 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 code.

[0192] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A data processing method, characterized in that: include: encapsulate to obtain an application program interface, and define a data export specification of the application program interface, wherein the application program interface is used to call a first user data file on a server or a second user data file on a client, and the data export specification is used to indicate an import environment for calling the first user data file or the second user data file, and the first user data file and the second user data file have the same business data; Loading the application program interface into an operating environment and obtaining a type of the operating environment; When the type of the operating environment is a server-side operating environment, calling the first user data file through the application program interface; When the type of the operating environment is a client operating environment, the second user data file is called through the application program interface.

2. The method according to claim 1, characterized in that Before encapsulating to obtain the application program interface, the method further includes: Obtain the business data corresponding to the target business request; Use asynclocalstorage to share the business data corresponding to the business request; The execution code of the business data is encapsulated to generate the first user data file.

3. The method according to claim 2, characterized in that The step of packaging the execution code of the service data to generate the first user data file comprises: The execution code of the business data is encapsulated by using an object wrapper to generate the first user data file.

4. The method according to claim 1, characterized in that: Before encapsulating to obtain the application program interface, the method further includes: Obtain the business data corresponding to the target business request; Using global variables to share the business data corresponding to the business request; The execution code of the business data is packaged to generate the second user data file.

5. The method according to claim 1, characterized in that Before encapsulating to obtain the application program interface, the method further includes: Obtain the business data corresponding to the target business request; Use asynclocalstorage to share the business data corresponding to the business request; The execution code of the business data is packaged to generate the second user data file.

6. The method according to claim 4 or 5, characterized in that: The step of packaging the execution code data of the service data to generate the second user data file comprises: The execution code of the business data is encapsulated by using an object wrapper to generate the second user data file.

7. The method according to any one of claims 1 to 5, characterized in that The encapsulated application program interface includes: Encapsulates the useData API.

8. The method according to claim 7, characterized in that The method further comprises: The function name of naming the first user data file and the second user data file is useData.

9. The method according to any one of claims 1 to 5, characterized in that The data export specification defining the application program interface includes: The data export specification of the application program interface is defined in package.json, wherein a first field is defined in the package.json for exporting the first user data file, and a second field is defined for exporting the second user data file.

10. The method according to claim 9, characterized in that Calling the first user data file through the application program interface includes: The first field is read, and the first user data file is called through the application program interface.

11. The method according to claim 9, characterized in that Calling the second user data file through the application program interface includes: The second field is read, and the second user data file is called through the application program interface.

12. The method according to any one of claims 1 to 5, 8, 10 to 11, characterized in that The method further comprises: The compilation type corresponding to the first user data file or the second user data file is exported through the application program interface.

13. A data processing device, characterized in that: include: a processing module, configured to encapsulate an application program interface and define a data export specification of the application program interface, wherein the application program interface is used to call a first user data file on a server or a second user data file on a client, and the data export specification is used to indicate an import environment for calling the first user data file or the second user data file, and the first user data file and the second user data file have the same business data; A loading module, used to load the application program interface into the operating environment and obtain the type of the operating environment; A calling module, used for calling the first user data file through the application program interface when the type of the operating environment is a server-side operating environment; When the type of the operating environment is a client operating environment, the second user data file is called through the application program interface.

14. A computer device, characterized in that: include: Memory, processor, and bus system; Wherein, the memory is used to store programs; The processor is used to execute the program in the memory, and the processor is used to execute the method according to any one of claims 1 to 12 according to the instructions in the program code; The bus system is used to connect the memory and the processor so that the memory and the processor can communicate with each other.

15. A computer-readable storage medium comprising instructions, which, when executed on a computer, causes the computer to perform the method according to any one of claims 1 to 12.