CN111679828B - Data processing method and device, electronic equipment and storage medium - Google Patents

Data processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111679828B
CN111679828B CN202010451846.2A CN202010451846A CN111679828B CN 111679828 B CN111679828 B CN 111679828B CN 202010451846 A CN202010451846 A CN 202010451846A CN 111679828 B CN111679828 B CN 111679828B
Authority
CN
China
Prior art keywords
javascript
client
page element
javascript code
user operation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010451846.2A
Other languages
Chinese (zh)
Other versions
CN111679828A (en
Inventor
刘明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Taikang Asset Management Co ltd
Taikang Insurance Group Co Ltd
Original Assignee
Taikang Asset Management Co ltd
Taikang Insurance Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Taikang Asset Management Co ltd, Taikang Insurance Group Co Ltd filed Critical Taikang Asset Management Co ltd
Priority to CN202010451846.2A priority Critical patent/CN111679828B/en
Publication of CN111679828A publication Critical patent/CN111679828A/en
Application granted granted Critical
Publication of CN111679828B publication Critical patent/CN111679828B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the application provides a data processing method and device, electronic equipment and storage medium, wherein the method comprises the following steps: when a JavaScript code sent by the server is received, establishing a binding relationship between the JavaScript code and a preset user operation event; responding to the trigger of the user operation event, executing the JavaScript code by adopting the JavaScript analyzer to obtain a first operation instruction; by adopting the first operation instruction, system call is carried out in an operation system where the client is located, dynamic deployment of service logic codes in a server is realized, overlong deployment period caused by steps such as compiling, packaging and the like is avoided, the same service logic can be executed in different clients by using the same JavaScript codes, repeated development of the service logic codes is avoided, and development efficiency is improved.

Description

Data processing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to a data processing method and apparatus, an electronic device, and a storage medium.
Background
With the rapid development and popularization of mobile terminal technology, market demands of mobile terminal applications are expanding, and operation platforms of mobile terminal applications are various, such as iOS operating systems of apple companies and Android operating systems of google companies.
In the prior art, because the programming languages of the iOS and the android are different, when the mobile terminal application development is performed, aiming at the same service content or service logic in the mobile application, technical developers need to write codes of the iOS and the android mobile operation systems respectively, after compiling the codes, the codes can be packed to generate a mobile terminal application installation package and be distributed to an application store, and after downloading, the mobile terminal application installation package can be installed to a mobile phone of a user for execution.
However, in this method, a technical developer is required to have mobile application development skills of both the iOS and the android platform, and develop two codes for the same service logic respectively, so that the development efficiency is extremely low, for example, after the technical developer develops the code of the iOS platform, the technical developer is also required to develop a code of the android platform with the same function. And after development, the code can be finally operated on the mobile terminal after a series of processes such as compiling, packaging, publishing, downloading and installing, and the like, so that the deployment period is longer.
Disclosure of Invention
In view of the foregoing, a method and apparatus for data processing, an electronic device, a storage medium, and a computer program product are provided to overcome or at least partially solve the foregoing, including:
the data processing method is applied to a client, the client is in communication connection with a server, the client is provided with a JavaScript parser, and the server stores JavaScript codes; the JavaScript code comprises a business logic code of the client, and the client is an android client or an iOS client; the method comprises the following steps:
when a JavaScript code sent by the server is received, establishing a binding relationship between the JavaScript code and a preset user operation event;
responding to the trigger of the user operation event, executing the JavaScript code by adopting the JavaScript analyzer to obtain a first operation instruction;
and adopting the first operation instruction to carry out system call in an operation system where the client is located.
Optionally, the first operation instruction includes a callback function identifier, and the method further includes:
receiving the callback function identification sent by the operating system; the callback function identification is sent after the operating system makes a system call corresponding to the first operation instruction;
Determining a callback function corresponding to the callback function identifier in the JavaScript code;
and executing the callback function by adopting the JavaScript parser to obtain a second operation instruction.
Optionally, the JavaScript code includes one or more sets of candidate JavaScript codes, the preset user operation event includes one or more preset user operation events, and the establishing a binding relationship between the JavaScript code and the preset user operation event includes:
determining candidate UI components corresponding to one or more preset user operation events and first page element identifiers corresponding to the candidate UI components;
acquiring corresponding second page element identifiers from the one or more groups of candidate JavaScript codes;
when the second page element identifier is matched with the first page element identifier, storing the corresponding relation between the candidate JavaScript code and the first page element identifier in a preset event mapping table.
Optionally, the executing the JavaScript code by using the JavaScript parser to obtain a first operation instruction, including:
determining a target UI component corresponding to the user operation event and a third page element identifier corresponding to the target UI component;
In the event mapping table, determining that the candidate JavaScript code corresponding to the third page element identifier is a target JavaScript code;
and executing the target JavaScript code by adopting the JavaScript parser to obtain a first operation instruction.
Optionally, the determining the target UI component corresponding to the user operation event and the third page element identifier corresponding to the target UI component includes:
determining a triggered UI component corresponding to the user operation event and a page element identifier corresponding to the triggered UI component;
when the page element identifier corresponding to the triggered UI component is determined to have the corresponding candidate JavaScript code in the event mapping table, the triggered UI component is determined to be a target UI component, and the page element identifier corresponding to the triggered UI component is determined to be a third page element identifier.
Optionally, before the step of establishing a binding relationship between the JavaScript code and a preset user operation event when receiving the JavaScript code sent by the server, the method further includes:
when a client is started, acquiring a resource file address;
and acquiring JavaScript codes from the server by adopting the resource file address.
Optionally, the step of obtaining the resource file address includes:
determining a preset page template description file, and acquiring a resource file address from the page template description file;
the page template description file comprises a plurality of resource file addresses, and the step of acquiring JavaScript codes from the server side by adopting the resource file addresses comprises the following steps:
acquiring a plurality of groups of codes to be spliced corresponding to the plurality of resource file addresses from the server by adopting the plurality of resource file addresses;
and splicing the plurality of groups of codes to be spliced to generate JavaScript codes.
The data processing device is applied to a client, the client is in communication connection with a server, the client is provided with a JavaScript parser, and the server stores JavaScript codes; the JavaScript code comprises a business logic code of the client, and the client is an android client or an iOS client; the device comprises:
the user operation event binding module is used for establishing a binding relation between the JavaScript code and a preset user operation event when receiving the JavaScript code sent by the server;
The user operation event response module is used for responding to the trigger of the user operation event and executing the JavaScript code by adopting the JavaScript analyzer to obtain a first operation instruction;
and the system call module is used for carrying out system call in an operating system where the client is positioned by adopting the first operation instruction.
An electronic device comprising a processor, a memory and a computer program stored on the memory and capable of running on the processor, which computer program, when being executed by the processor, carries out the steps of the method of data processing as described above.
A computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of a method of data processing as described above.
The embodiment of the application has the following advantages:
in the embodiment of the application, when the JavaScript code sent by the server is received, the binding relation between the JavaScript code and the preset user operation event is established, the JavaScript analyzer is adopted to execute the JavaScript code in response to the trigger of the user operation event to obtain the first operation instruction, and the first operation instruction is adopted to carry out system call in the operating system where the client is positioned, so that the dynamic deployment of the business logic code in the server is realized, the overlong deployment period caused by steps such as compiling and packaging is avoided, and the same business logic can be executed in different clients by using the same JavaScript code, thereby avoiding repeated development of the business logic code and improving the development efficiency.
Drawings
In order to more clearly illustrate the technical solutions of the present application, the drawings that are needed in the description of the present application will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort to a person skilled in the art.
FIG. 1 is a flow chart of steps of a method for data processing according to an embodiment of the present application;
FIG. 2 is a flow chart of steps of another method for data processing according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a user interface provided by an embodiment of the present application;
fig. 4 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present application.
Detailed Description
In order that the above-recited objects, features and advantages of the present application will become more readily apparent, a more particular description of the application will be rendered by reference to the appended drawings and appended detailed description. It will be apparent that the described embodiments are some, but not all, embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Referring to fig. 1, a flowchart illustrating steps of a method for processing data according to an embodiment of the present application may be applied to a client, where the client may be communicatively connected to a server, and the client may be provided with a JavaScript parser, where the parser may be configured to parse JavaScript codes, and the server may store JavaScript codes, where the JavaScript codes may include service logic codes of the client.
Wherein, the client may be an android client or an iOS client. In the android platform, the client may be a client developed using Java language; in the iOS platform, the client may be a client developed in the Objective-C language.
Specifically, the method comprises the following steps:
step 101, when a JavaScript code sent by the server is received, establishing a binding relationship between the JavaScript code and a preset user operation event;
in a specific implementation, the client may send a resource acquisition request to the server. After receiving the resource acquisition request, the server may send JavaScript code to the client.
When receiving the JavaScript code sent by the server, the client can establish a binding relationship between the JavaScript code and a preset user operation event, wherein the preset user operation event can comprise a user clicking a UI control in an interface.
In practical application, aiming at clients with the same service content, service logic needs to be written in an Objective-C language and a Java language respectively so as to run the clients in different platforms, however, the development efficiency of the method is low, and based on the method, javaScript codes can be introduced.
JavaScript may be a lightweight, interpreted or just-in-time compiled programming language with functional preference, as well as a dynamic scripting language based on prototype programming, multiple paradigms.
In the embodiment of the application, a JavaScript parser built in an android client or an iOS client can be adopted to execute JavaScript codes. By adopting JavaScript to write the business logic codes, the purpose of writing the business logic in a cross-platform manner can be achieved, so that the same business logic codes can be executed in the iOS platform and the android at the same time, technical developers do not need to repeatedly write the business logic codes, and development efficiency is improved.
In an example, the business logic may also be described by writing a page through HTML5, embedding JavaScript code, and then loading the HTML5 page through WebView embedded in the mobile terminal, executing the JavaScript code therein.
Step 102, responding to the trigger of the user operation event, and executing the JavaScript code by adopting the JavaScript analyzer to obtain a first operation instruction;
in the running process of the client, whether a preset user operation event is triggered or not can be detected, when the user operation event is triggered, the client can execute JavaScript codes by adopting a JavaScript parser in response to the triggering of the user operation event, and a first operation instruction is obtained.
And step 103, adopting the first operation instruction to perform system call in an operation system where the client is located.
After the first operation instruction is acquired, system call can be performed in an operating system where the client is located.
Specifically, the operating system can be developed through native codes (codes written in the Objective-C language and the Java language), and has basic functions of calling the functions of the mobile terminal device, requesting a network, managing user events, refreshing pages, popup dialog boxes and the like.
When executing the JavaScript code, the client can generate a call request for calling the basic function through the JavaScript analyzer, package the request into a first operation instruction, store the first operation instruction into an instruction queue in the memory of the JavaScript analyzer, and the operating system can acquire the first operation instruction to be executed from the instruction queue, and after the execution is finished, continue to acquire the next operation instruction from the instruction queue until all the operation instructions are finished.
In practical application, as the JavaScript code can be applied to the iOS platform or the android platform, the specific context environment of the original code in the operating system can not be known under the condition that the operating system of the practical application can not be determined; moreover, for security reasons, the JavaScript parser does not directly display the objected-C or Java object in the execution environment of the JavaScript code, so as to prevent the JavaScript code from acquiring excessive execution rights, which threatens the security of the operating system, such as reflecting operations (accessing, detecting and modifying the behavior of the program or the program state). This results in a method that cannot directly call either Objective-C or Java objects through JavaScript code.
In the embodiment of the application, the operating system reads the instruction from the instruction queue by executing the JavaScript code to generate the operating instruction, thereby achieving the purpose of calling the built-in function of the operating system and coordinating the interaction between the JavaScript code and the operating system of the mobile terminal.
In one example, an operation instruction may be added to an instruction queue to call a base function by:
in an embodiment of the present application, the first operation instruction may include a callback function identifier, and the method may further include the following steps:
S1, receiving the callback function identification sent by the operating system; the callback function identification is sent after the operating system makes a system call corresponding to the first operation instruction;
in the process of executing the JavaScript code and obtaining the first operation instruction, a callback function identifier (CallbackID) can be added in the first operation instruction, then the first operation instruction is stored in an instruction queue, and system call is performed in an operating system, wherein the callback function identifier can map a corresponding callback function in a memory of a JavaScript parser.
After executing the system call corresponding to the first operation instruction, the operating system can send the callback function identifier in the first operation instruction to the client, so that the client can receive the callback function identifier sent by the operating system.
In one example, the callback function mapping dictionary may be created in JavaScript parser memory using the following code:
var callbacks={};
in another example, the callback function identification may be generated as follows:
var callbackId=plugin+"_"+generateCallbackId();
in another example, a callback function may be created as follows:
in an example, the mapping relationship between the callback function and the callback function identifier may be added to the callback function mapping dictionary in the following manner:
callbacks[callbackId]=callback;
Generating a first operation instruction by adding a callback function identifier into the first operation instruction, wherein the first operation instruction comprises the following steps of:
var command=json. Stringify ({ "plug in": "alert", "callback": callback id, "args": "hello |" })
enqueue_call_native(command);
S2, determining a callback function corresponding to the callback function identifier in the JavaScript code;
after receiving the callback function identifier, the client can determine a callback function corresponding to the callback function identifier in the JavaScript code.
And S3, executing the callback function by adopting the JavaScript parser to obtain a second operation instruction.
After determining the callback function, the callback function can be executed by adopting a JavaScript parser to obtain a second operation instruction.
In the embodiment of the application, when the JavaScript code sent by the server is received, the binding relation between the JavaScript code and the preset user operation event is established, the JavaScript analyzer is adopted to execute the JavaScript code in response to the trigger of the user operation event to obtain the first operation instruction, and the first operation instruction is adopted to carry out system call in the operating system where the client is positioned, so that the dynamic deployment of the business logic code in the server is realized, the overlong deployment period caused by steps such as compiling and packaging is avoided, and the same business logic can be executed in different clients by using the same JavaScript code, thereby avoiding repeated development of the business logic code and improving the development efficiency.
Referring to fig. 2, a flowchart illustrating steps of another method for processing data according to an embodiment of the present application may be applied to a client, which may be an android client or an iOS client. The client can be in communication connection with the server, the client can be provided with a JavaScript parser which can be used for parsing JavaScript codes, the JavaScript codes can be stored in the server, and the JavaScript codes can comprise business logic codes of the client.
Specifically, the method comprises the following steps:
step 201, when a client is started, acquiring a resource file address;
as an example, the resource file address may be a URL (Uniform Resource Locator ) by which the resource address in the server may be uniquely identified.
In practical application, when the client is started, the resource file address can be acquired.
In an embodiment of the present application, the step of obtaining the address of the resource file may include the following sub-steps:
and determining a preset page template description file, and acquiring a resource file address from the page template description file.
Specifically, the client may be configured with a template parsing engine, and the client may pre-store a page template description file, such as an HTML file, in a local resource or server. And when the client is started or in the running process, a preset page template description file can be acquired.
In the page template description file, the resource file address can be defined by a "< script >" tag, and after the client determines the page template description file, the template analysis engine can analyze the page template description file, and the resource file address is obtained from the content defined by the < script > "tag.
In an example, the resource file address of JavaScript code can be defined by:
<script src="/ai/assets/js/native/ri_projectedit.js"></script>
step 202, acquiring a JavaScript code from the server by adopting the resource file address;
after the resource file address is obtained, the JavaScript code can be obtained from the server by adopting the resource file address.
In practical application, after obtaining the address of the resource file, the template parsing engine in the client may send the address to the JavaScript parser, and the JavaScript parser sends a resource obtaining request for the address of the resource file, so that JavaScript codes are obtained from the server.
In the embodiment of the application, the JavaScript code can comprise the code of the business logic of the client, dynamic deployment can be realized by deploying the JavaScript code describing the business logic on the server, and the business logic code can be rapidly acquired from the server when the client is upgraded without the processes of compiling, packaging, publishing, downloading and installing, and the like, so that the deployment period is shortened.
In an embodiment of the present application, the page template description file may include a plurality of resource file addresses, and step 202 may include the following sub-steps:
acquiring a plurality of groups of codes to be spliced corresponding to the plurality of resource file addresses from the server by adopting the plurality of resource file addresses; and splicing the plurality of groups of codes to be spliced to generate JavaScript codes.
In practical application, when the page template description file includes a plurality of resource file addresses, the client may use the plurality of resource file addresses to obtain a plurality of groups of codes to be spliced from the server, where the plurality of groups of codes to be spliced may correspond to the plurality of resource file addresses one by one. After a plurality of groups of codes to be spliced are obtained, the plurality of groups of codes to be spliced can be spliced to generate JavaScript codes.
Step 203, when receiving the JavaScript code sent by the server, determining candidate UI components corresponding to the one or more preset user operation events and a first page element identifier corresponding to the candidate UI components;
as an example, the preset user operation event may include one or more preset user operation events, and the JavaScript code may include one or more sets of candidate JavaScript codes.
In a specific implementation, the JavaScript code may include one or more sets of candidate JavaScript codes, where each set of candidate JavaScript codes may correspond to a preset user operation event. Although the JavaScript code can be executed in the mobile terminal by embedding the JavaScript parser in the client, the basic JavaScript code cannot respond to the user operation event of the mobile terminal, based on which user event binding can be performed to notify the client of the JavaScript code to be executed and the corresponding executed operation when the user performs a specific operation.
When receiving the JavaScript code sent by the server, the client can determine the candidate UI component corresponding to the user operation event and the first page element identifier corresponding to the UI component.
In practical application, when rendering a page element in a page template description file, a UI component in a user interface may have a preset correspondence with the page element. Specifically, the UI component may have an ID identification, for example, may be specified in the following manner to specify that the ID identification of the "save" key is "submit":
< divid= "subset" class= "text" data-width= "200" data-height= "50> save >
The page element may be uniquely determined by a page element identification, which may also be referred to as an element selector. By setting the same identification, the correspondence of the UI component and the page element can be determined.
For example, when the "#name" selector is used, an element with an ID of "name" in the page template description file may be represented, and when the identifier of the UI component is "submit", the page element corresponding to the UI component may have a page element identifier "#submit". For example, "$ (" # submit ") may be used to determine page elements in a page template description file.
In an example, when the server receives a resource acquisition request sent by the client, the server may read a resource file address from the resource acquisition request, and send a JavaScript resource file determined by the resource file address to the client, where the JavaScript resource file may include JavaScript codes. After receiving the JavaScript resource file, the client can read the JavaScript resource file by adopting a JavaScript parser to obtain a JavaScript code.
Step 204, obtaining a corresponding second page element identifier from the one or more sets of candidate JavaScript codes;
In practical application, the JavaScript code may include a second page element identifier, and after determining the candidate UI component and the corresponding first page element identifier, the corresponding second page element identifier may be obtained from one or more sets of candidate JavaScript codes.
Step 205, when the second page element identifier is matched with the first page element identifier, storing a corresponding relation between the candidate JavaScript code and the first page element identifier in a preset event mapping table;
when the second page element identifier is matched with the first page element identifier, a corresponding relation between the candidate JavaScript code and the first page element identifier can be stored in a preset event mapping table.
Specifically, the "$ (doc) & ready ()" function may be used to bind user events, and when the preset user operation event is a user click event, for example, when the user clicks a UI component, the JavaScript parser may be used to execute the following code:
“$("#name").click(function(){
alert("hello");
})”
the code contains a second page element identifier "#name", the matching of the JavaScript code and a first page element identifier "#name" corresponding to the UI component can be determined, a mapping relation between a candidate JavaScript code and the first page element identifier can be established in an event mapping table in a memory of a JavaScript analyzer, user event binding is performed, and the following mapping relation can be established in the memory of the JavaScript analyzer:
event_map["#name"]["click"]=function(){
alert("hello");
};
In the execution process of the function "$ (doc) & ready ()" data initialization and user event binding processing can be performed, the execution of the function is completed without a return value, and the JavaScript parser can enter a waiting state to detect whether a user operation event occurs.
Because the UI component can be data belonging to a view layer and is responsible for page drawing, and the page element can be data belonging to a model layer, the data can be stored in the page element, and the separation of the view layer and the model layer can be realized by binding JavaScript codes in the page element corresponding to the UI component, so that a better decoupling effect is obtained.
Step 206, responding to the trigger of the user operation event, and determining a target UI component corresponding to the user operation event and a third page element identifier corresponding to the target UI component;
when the user operation event is detected, the client responds to the trigger of the user operation event, and the target UI component corresponding to the user operation event and the third page element identification corresponding to the target UI component can be determined.
In an embodiment of the present application, the step of determining the target UI component corresponding to the user operation event and the third page element identifier corresponding to the target UI component may include the following sub-steps:
A sub-step 11 of determining a triggered UI component corresponding to the user operation event and a page element identifier corresponding to the triggered UI component;
in practical applications, the space triggered by the user operation event may be determined as the triggered UI component, and the page element identifier corresponding to the triggered UI component is determined. For example, when the client detects a "save" key in a user click (click) interface, a click event written by native code in the client may be triggered, and the client may determine the "save" key as the triggered UI component and obtain the corresponding page element identification.
And a sub-step 12, when the page element identifier corresponding to the triggered UI component is determined to have the corresponding candidate JavaScript code in the event mapping table, determining that the triggered UI component is a target UI component, and determining that the page element identifier corresponding to the triggered UI component is a third page element identifier.
In practical applications, javaScript code may not be directly bound to a UI component clicked by a user, for example, in a picture UI component containing text, the picture UI component is a parent component of the text UI component, and JavaScript code is bound to the picture UI component.
After determining the page element identifier corresponding to the triggered UI component, it may be determined in the event mapping table whether a corresponding candidate JavaScript code exists in the page element identifier corresponding to the triggered UI component, and if it is determined that the candidate JavaScript code exists, it may be further determined that the triggered UI component is a target UI component, and the page element identifier corresponding to the triggered UI component is a third page element identifier.
If the triggered UI component is not found to have the corresponding candidate JavaScript code, event bubbling can be performed, the parent component of the triggered UI component and the page element identifier corresponding to the parent component are determined, whether the corresponding candidate JavaScript code exists in the event mapping table is continuously searched, if so, the triggered UI component can be determined to be a target component, otherwise, the upper layer component can be continuously searched until the uppermost layer component is searched.
Step 207, in the event mapping table, determining that the candidate JavaScript code corresponding to the third page element identifier is a target JavaScript code;
after determining the third page element identifier, the candidate JavaScript code corresponding to the third page element identifier may be determined as the target JavaScript code in the event mapping table.
Step 208, executing the target JavaScript code by adopting the JavaScript parser to obtain a first operation instruction;
step 209, performing system call in the operating system where the client is located by adopting the first operation instruction.
In order that those skilled in the art may better understand the above steps, an embodiment of the present application will be described below by way of an example, but it should be understood that the embodiment of the present application is not limited thereto.
As shown in fig. 3, the user may add text and pictures to the page, and when the user clicks the UI control "save" button 301, the client may upload the text and pictures to the server; here, the ID of the "save" key 301 is "submit".
In a specific application, a technical developer can write business logic in JavaScript codes for the process of uploading characters or pictures to a server, and the business logic is deployed in the server, and a JavaScript parser packaged as an SDK (Software Development Kit ) can be built in the client.
After the user starts the client or enters the interface shown in fig. 3, the client may download the JavaScript code corresponding to the page from the server, where the JavaScript code may include a service logic code of a service related to the page, and execute the JavaScript code by using a JavaScript parser.
In the process of executing the JavaScript code, a "$ (doc) & ready ()" method in the JavaScript code can be executed first by default, and the method can bind the JavaScript code with a user operation event. Specifically, in the "$ (doc) & ready ()" method, the "$ (" # submit ") & click (function)" method may be invoked, and by using the "# submit" selector (i.e., the first page element identifier), a click event of a key with an ID of "submit" in a page is associated with a callback function specified by a function parameter, and a mapping relationship is recorded in an event mapping table. After executing the "$ (doc) & ready ()" method, the client enters a standby state, waiting for the user to click the "save" key.
When the client detects that the user clicks the save button, the client can search in an event mapping table through event bubbling to judge whether the "# submit" selector has a corresponding callback function or not. When it is detected that the "# subset" is bound with the corresponding callback function in the JavaScript code, for example, "the" # subset "is bound with the" save function ", the" save function "may be executed by using the JavaScript parser, and the event cycle state is entered. During execution, the operating system can monitor the instruction queue through the native code of the client, and judge whether a new instruction is stored in the instruction queue in the memory of the JavaScript parser in the process of executing the save function.
When the JavaScript parser executes the "save function", an "upload picture instruction" may be generated and stored in the instruction queue, and when the operation instruction is generated, a callback function identifier a with uniqueness may be generated and added to the "upload picture instruction", where the callback function identifier a may be associated with the callback function A.
After the 'uploading picture instruction' is stored in the instruction queue, the operating system acquires the instruction from the instruction queue and acquires the callback function identification a from the instruction. After the system basic function is called to execute the "upload picture instruction" and the picture is uploaded to the address specified in the instruction, the operating system may return the callback function identifier a to the client to instruct the client to execute the callback function associated with the callback function identifier a. After uploading the instruction, a wait state may be entered.
After the callback function identifier a is obtained, the client can execute the function A by adopting a JavaScript parser, the JavaScript parser can generate a 'submit data instruction' in the process of executing the function A, the instruction is stored in an instruction queue, meanwhile, a callback function identifier B is generated, the callback function identifier B is added to the 'submit data instruction', and the callback function identifier B can be associated with the callback function B.
The execution of JavaScript code is a synchronous processing model; in the called mobile terminal operating system function, operations such as network request processing and user response are required, and the process is an asynchronous processing model, and in specific implementation, it is difficult for synchronous processing to wait for asynchronous processing to be completed. In the application, the operation instruction is generated by executing the JavaScript code, and the corresponding callback function is called after the operation instruction is executed, so that the problem that synchronous processing cannot be allowed to wait for asynchronous processing to be completed is solved.
After storing the "commit data instruction" to the instruction queue, the operating system may retrieve the instruction from the instruction queue and obtain the callback function identification b. After performing commit data processing to commit the data to the address specified in the "commit data instruction," the operating system may return the callback function identification b to the client.
After receiving the callback function identifier B, the client can execute the function B by adopting a JavaScript parser, and after the execution is finished, the loop state is ended, and an execution result is fed back to the user. In the example of the application, through JavaScript codes, business processes of uploading pictures and submitting data are performed, technical developers do not need to master development skills of the iOS application or the android application, and business logic applicable to the iOS application or the android application can still be written under the condition that only JavaScript codes develop experience.
In the interaction process, the native code in the client can respond to the user operation event, the JavaScript code is utilized to execute the service logic, the JavaScript code is utilized to call the built-in function of the mobile terminal operation system, and finally the effect of the execution result is fed back to the user, so that a complete service logic response closed loop is formed.
In the embodiment of the application, the corresponding second page element identification is obtained from one or more groups of candidate JavaScript codes, when the second page element identification is matched with the first page element identification, the corresponding relation between the candidate JavaScript codes and the first page element identification is stored in the preset event mapping table, so that the binding of the user operation event and the JavaScript codes is realized, and the JavaScript codes can respond to the user operation event of the mobile terminal.
It should be noted that, for simplicity of description, the method embodiments are shown as a series of acts, but it should be understood by those skilled in the art that the embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred embodiments, and that the acts are not necessarily required by the embodiments of the application.
Referring to fig. 4, a schematic structural diagram of a data processing apparatus according to an embodiment of the present application may be applied to a client, which may be an android client or an iOS client; the client is in communication connection with the server, the client is provided with a JavaScript parser, the server stores JavaScript codes, and the JavaScript codes can comprise business logic codes of the client. The method specifically comprises the following modules:
a user operation event binding module 401, configured to establish a binding relationship between a JavaScript code sent by the server and a preset user operation event when the JavaScript code is received;
the user operation event response module 402 is configured to execute the JavaScript code by using the JavaScript parser in response to a trigger of the user operation event, so as to obtain a first operation instruction;
and the system call module 403 is configured to use the first operation instruction to perform a system call in an operating system where the client is located.
In an embodiment of the present application, the first operation instruction includes a callback function identifier, and the apparatus further includes:
the callback function identification determining module is used for receiving the callback function identification sent by the operating system; the callback function identification is sent after the operating system makes a system call corresponding to the first operation instruction;
The callback function determining module is used for determining a callback function corresponding to the callback function identifier in the JavaScript code;
and the second operation instruction generation module is used for executing the callback function by adopting the JavaScript analyzer to obtain a second operation instruction.
In an embodiment of the present application, the JavaScript code includes one or more candidate JavaScript codes, the preset user operation event includes one or more preset user operation events, and the user operation event binding module 401 includes:
a first page element identification determining sub-module, configured to determine candidate UI components corresponding to the one or more preset user operation events, and a first page element identification corresponding to the candidate UI components;
a second page element identification determining submodule, configured to obtain a corresponding second page element identification from the one or more sets of candidate JavaScript codes;
and the element identification matching sub-module is used for storing the corresponding relation between the candidate JavaScript code and the first page element identification in a preset event mapping table when the second page element identification is matched with the first page element identification.
In one embodiment of the present application, the system call module 403 includes:
a third page element identification determining sub-module, configured to determine a target UI component corresponding to the user operation event and a third page element identification corresponding to the target UI component;
the target code determining submodule is used for determining that the candidate JavaScript code corresponding to the third page element identifier is a target JavaScript code in the event mapping table;
and the first operation instruction generation sub-module is used for executing the target JavaScript code by adopting the JavaScript parser to obtain a first operation instruction.
In another embodiment of the present application, the third page element identification determination submodule includes:
the triggered component determining unit is used for determining a triggered UI component corresponding to the user operation event and a page element identifier corresponding to the triggered UI component;
and the page element searching unit is used for determining the triggered UI component as a target UI component and determining the page element identifier corresponding to the triggered UI component as a third page element identifier when the page element identifier corresponding to the triggered UI component is determined to have the corresponding candidate JavaScript code in the event mapping table.
In another embodiment of the present application, the apparatus further comprises:
the resource file address acquisition module is used for acquiring a resource file address when the client is started;
and the code acquisition module is used for acquiring JavaScript codes from the server by adopting the resource file address.
In an embodiment of the present application, the resource file address obtaining module includes:
the page template description file determining submodule is used for determining a preset page template description file and acquiring a resource file address from the page template description file;
the code acquisition module includes:
the code to be spliced obtaining submodule is used for obtaining a plurality of groups of codes to be spliced corresponding to the plurality of resource file addresses from the server side by adopting the plurality of resource file addresses;
and the code splicing sub-module is used for splicing the plurality of groups of codes to be spliced to generate JavaScript codes.
In the embodiment of the application, when the JavaScript code sent by the server is received, the binding relation between the JavaScript code and the preset user operation event is established, the JavaScript analyzer is adopted to execute the JavaScript code in response to the trigger of the user operation event to obtain the first operation instruction, and the first operation instruction is adopted to carry out system call in the operating system where the client is positioned, so that the dynamic deployment of the business logic code in the server is realized, the overlong deployment period caused by steps such as compiling and packaging is avoided, and the same business logic can be executed in different clients by using the same JavaScript code, thereby avoiding repeated development of the business logic code and improving the development efficiency.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
An embodiment of the present application also provides an electronic device that may include a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program implementing the steps of the method of data processing as described above when executed by the processor.
An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored, which when executed by a processor, implements the steps of the method of data processing as above.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present application may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the application may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the scope of the embodiments of the application.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or terminal device comprising the element.
The foregoing has described in detail the method and apparatus for data processing, the electronic device, and the storage medium, and specific examples have been applied to illustrate the principles and embodiments of the present application, and the above examples are only used to help understand the method and core idea of the present application; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.

Claims (8)

1. The data processing method is characterized by being applied to a client, wherein the client is in communication connection with a server, the client is provided with a JavaScript parser, and the server stores JavaScript codes; the JavaScript code comprises a business logic code of the client, and the client is an android client or an iOS client; the method comprises the following steps:
when a JavaScript code sent by the server is received, establishing a binding relationship between the JavaScript code and a preset user operation event;
responding to the trigger of the user operation event, executing the JavaScript code by adopting the JavaScript analyzer to obtain a first operation instruction;
Adopting the first operation instruction to carry out system call in an operation system where the client is located;
the JavaScript code comprises one or more groups of candidate JavaScript codes, the preset user operation event comprises one or more preset user operation events, and the establishment of the binding relationship between the JavaScript code and the preset user operation event comprises the following steps:
determining candidate UI components corresponding to one or more preset user operation events and first page element identifiers corresponding to the candidate UI components;
acquiring corresponding second page element identifiers from the one or more groups of candidate JavaScript codes;
when the second page element identifier is matched with the first page element identifier, storing the corresponding relation between the candidate JavaScript code and the first page element identifier in a preset event mapping table;
the step of executing the JavaScript code by using the JavaScript parser to obtain a first operation instruction includes:
determining a target UI component corresponding to the user operation event and a third page element identifier corresponding to the target UI component;
in the event mapping table, determining that the candidate JavaScript code corresponding to the third page element identifier is a target JavaScript code;
And executing the target JavaScript code by adopting the JavaScript parser to obtain a first operation instruction.
2. The method of claim 1, wherein the first operation instruction includes a callback function identifier, the method further comprising:
receiving the callback function identification sent by the operating system; the callback function identification is sent after the operating system makes a system call corresponding to the first operation instruction;
determining a callback function corresponding to the callback function identifier in the JavaScript code;
and executing the callback function by adopting the JavaScript parser to obtain a second operation instruction.
3. The method of claim 1, wherein the determining the target UI component corresponding to the user operation event and the third page element identifier corresponding to the target UI component comprises:
determining a triggered UI component corresponding to the user operation event and a page element identifier corresponding to the triggered UI component;
when the page element identifier corresponding to the triggered UI component is determined to have the corresponding candidate JavaScript code in the event mapping table, the triggered UI component is determined to be a target UI component, and the page element identifier corresponding to the triggered UI component is determined to be a third page element identifier.
4. The method according to claim 1, wherein before the step of establishing a binding relationship between the JavaScript code and a preset user operation event when receiving the JavaScript code sent by the server, the method further comprises:
when a client is started, acquiring a resource file address;
and acquiring JavaScript codes from the server by adopting the resource file address.
5. The method of claim 4, wherein the step of obtaining the resource file address comprises:
determining a preset page template description file, and acquiring a resource file address from the page template description file;
the page template description file comprises a plurality of resource file addresses, and the step of acquiring JavaScript codes from the server side by adopting the resource file addresses comprises the following steps:
acquiring a plurality of groups of codes to be spliced corresponding to the plurality of resource file addresses from the server by adopting the plurality of resource file addresses;
and splicing the plurality of groups of codes to be spliced to generate JavaScript codes.
6. The data processing device is characterized by being applied to a client, wherein the client is in communication connection with a server, the client is provided with a JavaScript parser, and the server stores JavaScript codes; the JavaScript code comprises a business logic code of the client, and the client is an android client or an iOS client; the device comprises:
The user operation event binding module is used for establishing a binding relation between the JavaScript code and a preset user operation event when receiving the JavaScript code sent by the server;
the user operation event response module is used for responding to the trigger of the user operation event and executing the JavaScript code by adopting the JavaScript analyzer to obtain a first operation instruction;
the system call module is used for carrying out system call in an operating system where the client is located by adopting the first operation instruction;
the JavaScript code comprises one or more groups of candidate JavaScript codes, the preset user operation event comprises one or more preset user operation events, and the user operation event binding module comprises:
a first page element identification determining sub-module, configured to determine candidate UI components corresponding to the one or more preset user operation events, and a first page element identification corresponding to the candidate UI components;
a second page element identification determining submodule, configured to obtain a corresponding second page element identification from the one or more sets of candidate JavaScript codes;
the element identification matching sub-module is used for storing the corresponding relation between the candidate JavaScript code and the first page element identification in a preset event mapping table when the second page element identification is matched with the first page element identification;
Wherein, the system call module includes:
a third page element identification determining sub-module, configured to determine a target UI component corresponding to the user operation event and a third page element identification corresponding to the target UI component;
the target code determining submodule is used for determining that the candidate JavaScript code corresponding to the third page element identifier is a target JavaScript code in the event mapping table;
and the first operation instruction generation sub-module is used for executing the target JavaScript code by adopting the JavaScript parser to obtain a first operation instruction.
7. An electronic device comprising a processor, a memory and a computer program stored on the memory and capable of running on the processor, which when executed by the processor performs the steps of the method of data processing according to any one of claims 1 to 5.
8. A computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the method of data processing according to any one of claims 1 to 5.
CN202010451846.2A 2020-05-25 2020-05-25 Data processing method and device, electronic equipment and storage medium Active CN111679828B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010451846.2A CN111679828B (en) 2020-05-25 2020-05-25 Data processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010451846.2A CN111679828B (en) 2020-05-25 2020-05-25 Data processing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111679828A CN111679828A (en) 2020-09-18
CN111679828B true CN111679828B (en) 2023-08-15

Family

ID=72453602

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010451846.2A Active CN111679828B (en) 2020-05-25 2020-05-25 Data processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111679828B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112579156A (en) * 2020-12-11 2021-03-30 百果园技术(新加坡)有限公司 Processing system, processing method, processing device and processing equipment of business event
CN116627391B (en) * 2023-07-21 2023-10-27 上海秉匠信息科技有限公司 UI component detection method, device, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101154157A (en) * 2006-09-29 2008-04-02 国际商业机器公司 System and method for providing globalization function to application of JavaScript
CN102117294A (en) * 2009-12-31 2011-07-06 上海杉达学院 Information system based on Ajax (Asynchronous JavaScript and XML) technology
CN102681854A (en) * 2012-05-18 2012-09-19 华为技术有限公司 Service execution method, server and computer system
CN107770377A (en) * 2017-10-17 2018-03-06 广东广业开元科技有限公司 A kind of method of the establishment interactive voice mobile phone news client based on HTML5
CN109426492A (en) * 2017-07-13 2019-03-05 北京微影时代科技有限公司 A kind of client software development approach and device
CN110083790A (en) * 2019-04-30 2019-08-02 珠海随变科技有限公司 Page editing method, page output method, device, computer equipment and medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030103085A1 (en) * 2001-11-30 2003-06-05 Siemens Medical Solutions Health Services Corporation User interface display system providing user interactive image elements
US7614052B2 (en) * 2004-01-09 2009-11-03 Nexaweb Technologies Inc. System and method for developing and deploying computer applications over a network

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101154157A (en) * 2006-09-29 2008-04-02 国际商业机器公司 System and method for providing globalization function to application of JavaScript
CN102117294A (en) * 2009-12-31 2011-07-06 上海杉达学院 Information system based on Ajax (Asynchronous JavaScript and XML) technology
CN102681854A (en) * 2012-05-18 2012-09-19 华为技术有限公司 Service execution method, server and computer system
CN109426492A (en) * 2017-07-13 2019-03-05 北京微影时代科技有限公司 A kind of client software development approach and device
CN107770377A (en) * 2017-10-17 2018-03-06 广东广业开元科技有限公司 A kind of method of the establishment interactive voice mobile phone news client based on HTML5
CN110083790A (en) * 2019-04-30 2019-08-02 珠海随变科技有限公司 Page editing method, page output method, device, computer equipment and medium

Also Published As

Publication number Publication date
CN111679828A (en) 2020-09-18

Similar Documents

Publication Publication Date Title
CN111273898B (en) Automatic construction method, system and storage medium for web front-end code
CN105607895B (en) Application program operation method and device based on application program programming interface
WO2017124952A1 (en) Webpage script loading method and device
CN109634588B (en) Office document online editing method and system compatible with multiple browsers
WO2017196635A1 (en) Page component dynamic layout
EP2909998B1 (en) Webpages with onboard hardware functions
US9292253B2 (en) Methods and apparatus for voiced-enabling a web application
CN106294113B (en) creation method and device based on programmable test service
US9400633B2 (en) Methods and apparatus for voiced-enabling a web application
US9781262B2 (en) Methods and apparatus for voice-enabling a web application
US10157612B2 (en) Methods and apparatus for voice-enabling a web application
CN111090431B (en) Data processing method and device
CN104821954A (en) Cross-platform remote procedure call method
CN111679828B (en) Data processing method and device, electronic equipment and storage medium
CN110825430A (en) API document generation method, device, equipment and storage medium
CN110955409B (en) Method and device for creating resources on cloud platform
CN110365776B (en) Picture batch downloading method and device, electronic equipment and storage medium
Del Sole Microsoft computer vision APIs distilled: Getting started with cognitive services
CN113419729A (en) Front-end page building method, device, equipment and storage medium based on modularization
CN112835809A (en) Test data setting method, device, equipment and medium based on browser
CN113296653B (en) Simulation interaction model construction method, interaction method and related equipment
CN111679976A (en) Method and device for searching page object
CN111813385B (en) Page plug-in method, device and equipment based on Web application
CN105354490A (en) Method and device for processing hijacked browser
CN111881043A (en) Page testing method and device, storage medium and processor

Legal Events

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