CN111679828A - 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
CN111679828A
CN111679828A CN202010451846.2A CN202010451846A CN111679828A CN 111679828 A CN111679828 A CN 111679828A CN 202010451846 A CN202010451846 A CN 202010451846A CN 111679828 A CN111679828 A CN 111679828A
Authority
CN
China
Prior art keywords
javascript
client
javascript code
user operation
code
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.)
Granted
Application number
CN202010451846.2A
Other languages
Chinese (zh)
Other versions
CN111679828B (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

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • 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 a storage medium, wherein the method comprises the following steps: when receiving a JavaScript code sent by the server, establishing a binding relationship between the JavaScript code and a preset user operation event; responding to the trigger of the user operation event, and executing the JavaScript code by adopting the JavaScript parser to obtain a first operation instruction; by adopting the first operation instruction, system calling is carried out in the operation system where the client is located, dynamic deployment of service logic codes in the server is achieved, overlong deployment cycle caused by steps of compiling, packaging and the like is avoided, the same service logic can be executed in different clients by using the same JavaScript code, 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 method and an apparatus for data processing, an electronic device, and a storage medium.
Background
With the rapid development and popularization of mobile terminal technology, the market demand of mobile terminal applications is continuously expanding, and the variety of operating platforms of mobile terminal applications is various, such as the iOS operating system of apple and the Android operating system of google.
In the prior art, because the iOS and android programming languages are different, when mobile terminal application development is performed, technical developers need to write codes of the iOS and android mobile operating systems respectively for the same service content or service logic in mobile application, and after the codes are compiled, mobile terminal application installation packages can be generated by packaging and issued to an application store, and the mobile terminal application installation packages can be installed to a mobile phone of a user for execution after being downloaded.
However, in this method, a technical developer needs to have mobile application development skills of the iOS and the android platform at the same time, and to develop two kinds of codes for the same business logic, respectively, the development efficiency is extremely low. Moreover, after being developed, the codes can be finally operated on the mobile terminal after a series of processes such as compiling, packaging, releasing, downloading and installing, and the deployment period is long.
Disclosure of Invention
In view of the above, it is proposed to provide a method and apparatus, an electronic device, a storage medium for data processing that overcome or at least partially solve the above problems, including:
a 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 service logic code of the client, and the client is an android client or an iOS client; the method comprises the following steps:
when receiving a JavaScript code sent by the server, establishing a binding relationship between the JavaScript code and a preset user operation event;
responding to the trigger of the user operation event, and executing the JavaScript code by adopting the JavaScript parser to obtain a first operation instruction;
and carrying out system call in an operating system where the client is located by adopting the first operating instruction.
Optionally, the first operation instruction includes a callback function identifier, and the method further includes:
receiving the callback function identifier sent by the operating system; the callback function identifier is sent after the operating system carries out system call corresponding to the first operating instruction;
in the JavaScript code, determining a callback function corresponding to the callback function identifier;
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 the one or more preset user operation events and first page element identifications corresponding to the candidate UI components;
acquiring corresponding second page element identifications from the one or more groups of candidate JavaScript codes;
and 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 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.
Optionally, the determining a target UI component corresponding to the user operation event and a 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;
and when the corresponding candidate JavaScript code exists in the page element identifier corresponding to the triggered UI component 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.
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 a JavaScript code 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 the JavaScript code from the server by adopting the resource file addresses comprises the following steps:
acquiring a plurality of groups of codes to be spliced corresponding to the resource file addresses from the server by adopting the resource file addresses;
and splicing the multiple groups of codes to be spliced to generate a JavaScript code.
A 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 service 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 the JavaScript code sent by the server is received;
the user operation event response module is used for responding to the triggering of the user operation event and executing the JavaScript code by adopting the JavaScript parser to obtain a first operation instruction;
and the system calling module is used for carrying out system calling in an operating system where the client is located by adopting the first operating instruction.
An electronic device comprising a processor, a memory and a computer program stored on the memory and being executable on the processor, the computer program, when executed by the processor, implementing the steps of the method of data processing as described above.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of data processing as set forth above.
The embodiment of the application has the following advantages:
in the embodiment of the application, when receiving a JavaScript code sent by a server, a binding relationship between the JavaScript code and a preset user operation event is established, the JavaScript parser is adopted to execute the JavaScript code in response to the triggering of the user operation event to obtain a first operation instruction, and the first operation instruction is adopted to perform system calling in an operation system where a client is located, so that dynamic deployment of a service logic code in the server is realized, the phenomenon that the deployment cycle is too long due to compiling, packaging and other steps is avoided, the same service logic can be executed in different clients by using the same JavaScript code, repeated development of the service logic code is avoided, and the development efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions of the present application, the drawings needed to be used in the description of the present application will be briefly introduced below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive labor.
FIG. 1 is a flow chart of steps of a method of data processing according to an embodiment of the present application;
FIG. 2 is a flow chart of steps of another method of data processing provided by 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 to make the aforementioned objects, features and advantages of the present application more comprehensible, the present application is described in further detail with reference to the accompanying drawings and the detailed description. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, a flowchart illustrating steps of a data processing method provided in an embodiment of the present application is shown, and the method may be applied to a client, where the client may be in communication connection with a server, the client may be provided with a JavaScript parser, the parser may be used to parse JavaScript codes, and the server may store the JavaScript codes, and the JavaScript codes may include service logic codes of the client.
The client may be an android client or an iOS client. In the android platform, the client can be a client developed using the Java language; in the iOS platform, the client can be a client developed in Objective-C language.
Specifically, the method can comprise the following steps:
step 101, when receiving a JavaScript code sent by the server, 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 the JavaScript code to the client.
When receiving a JavaScript code sent by a server, a client may establish a binding relationship between the JavaScript code and a preset user operation event, where the preset user operation event may include a user clicking a UI control in an interface.
In practical application, for clients with the same service content, the Objective-C language and the Java language need to be respectively adopted to write service logic so as to run the clients in different platforms, however, the method has low development efficiency, and based on this, JavaScript codes can be introduced.
The JavaScript can be a lightweight, interpreted or just-in-time programming language with function priority, and is also a dynamic scripting language based on prototype programming and multiple paradigms.
In the embodiment of the application, a JavaScript parser built in an android client or an iOS client may be used to execute JavaScript codes. By adopting JavaScript language to compile service logic codes, the purpose of cross-platform compiling service logic can be achieved, the same service logic codes can be executed in the iOS platform and the android at the same time, technical developers do not need to compile the service logic codes repeatedly, and development efficiency is improved.
In an example, the service logic can be described by writing a page through HTML5 and embedding JavaScript code, and then, the HTML5 page can be loaded through WebView (web view) embedded in the mobile terminal, and the JavaScript code in the page can be executed.
Step 102, responding to the trigger of the user operation event, executing the JavaScript code by using the JavaScript parser 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, and when the preset user operation event is triggered, the client can adopt a JavaScript parser to execute a JavaScript code to obtain a first operation instruction in response to the triggering of the user operation event.
And 103, carrying out system call in an operating system where the client is located by adopting the first operating instruction.
After the first operation instruction is obtained, system call can be performed in an operating system where the client is located.
Specifically, the operating system may be developed by native code (code written in Objective-C language and Java language), and has basic functions of invoking a mobile terminal device function, a network request, managing a user event, refreshing a page, popping up a dialog box, and the like.
When the JavaScript code is executed, the client can generate a calling request for calling the basic function through the JavaScript parser, package the request into a first operation instruction and store the first operation instruction into an instruction queue in the memory of the JavaScript parser, and the operating system can acquire the first operation instruction to be executed from the instruction queue and continue to acquire the next operation instruction from the instruction queue after the execution is finished until all the operation instructions are executed.
In practical application, since the JavaScript code can be applied to the iOS platform or the android platform, the specific context environment of the native code in the operating system cannot be known under the condition that the operating system of the practical application cannot be determined; moreover, for security, the JavaScript parser does not directly display Objective-C or Java objects in the execution environment of the JavaScript code, so as to prevent the JavaScript code from acquiring too high execution authority and posing a threat to the security of the operating system, such as a reflection operation (a behavior of accessing, detecting and modifying a program or a program state). This results in methods that cannot directly call Objective-C or Java objects through JavaScript code.
In the embodiment of the application, the JavaScript code is executed to generate the operation instruction, and the operation system reads the instruction from the instruction queue, so that the purpose of calling the built-in function of the operation system is achieved, and the interaction between the JavaScript code and the operation system of the mobile terminal is coordinated.
In one example, an operation instruction may be added to the instruction queue to invoke the underlying function by:
Figure BDA0002507876760000071
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 identifier sent by the operating system; the callback function identifier is sent after the operating system carries out system call corresponding to the first operating instruction;
in the process of executing the JavaScript code and obtaining the first operation instruction, a callback function identifier (callbaccid) may be added to the first operation instruction, then the first operation instruction is stored in the instruction queue, and a system call is performed in the operation system, where the callback function identifier may map a corresponding callback function in a JavaScript parser memory.
After executing the system call corresponding to the first operation instruction, the operating system may send the callback function identifier in the first operation instruction to the client, so that the client may receive the callback function identifier sent by the operating system.
In an example, a 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:
Figure BDA0002507876760000081
in an example, the following manner may be adopted to add the mapping relationship between the callback function and the callback function identifier in the callback function mapping dictionary:
callbacks[callbackId]=callback;
and generating a first operation instruction by adopting the following mode, and adding a callback function identifier in the first operation instruction:
"JSON. string if" { "plugin": alert "," callback ": callback id", "args": your good!})
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 may determine the 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 the callback function is determined, the callback function can be executed by adopting a JavaScript analyzer to obtain a second operation instruction.
In the embodiment of the application, when receiving a JavaScript code sent by a server, a binding relationship between the JavaScript code and a preset user operation event is established, the JavaScript parser is adopted to execute the JavaScript code in response to the triggering of the user operation event to obtain a first operation instruction, and the first operation instruction is adopted to perform system calling in an operation system where a client is located, so that dynamic deployment of a service logic code in the server is realized, the phenomenon that the deployment cycle is too long due to compiling, packaging and other steps is avoided, the same service logic can be executed in different clients by using the same JavaScript code, repeated development of the service logic code is avoided, and the development efficiency is improved.
Referring to fig. 2, a flowchart illustrating steps of another data processing method provided in an embodiment of the present application is shown, which may be applied to a client, where the client 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, the parser can be used for parsing JavaScript codes, the server can store the JavaScript codes, and the JavaScript codes can contain business logic codes of the client.
Specifically, the method can comprise 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), and the Resource address in the server may be uniquely identified by the URL.
In practical application, when the client starts, the resource file address can be obtained.
In an embodiment of the present application, the step of obtaining the resource file address may include the following sub-steps:
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 store a page template description file, such as an HTML file, in a local resource or a server in advance. When the client is started or in the running process, a preset page template description file can be obtained.
In the page template description file, the resource file address can be defined by the < script > tag, and then after the client determines the page template description file, the template analysis engine can analyze the page template description file to obtain the resource file address from the content defined by the < script > tag.
In an example, the resource file address of the 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 the template analysis engine in the client acquires the resource file address, the template analysis engine can send the address to the JavaScript parser, and the JavaScript parser sends a resource acquisition request for the resource file address, so that the JavaScript code is acquired from the server.
In the embodiment of the application, the JavaScript code may include a code of the service logic of the client, dynamic deployment may be implemented by deploying the JavaScript code describing the service logic at the server, and when the client performs upgrading, the service logic code may be quickly obtained from the server without performing processes such as compiling, packaging, publishing, downloading, and installing, thereby shortening the deployment period.
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 resource file addresses from the server by adopting the resource file addresses; and splicing the multiple groups of codes to be spliced to generate a JavaScript code.
In practical application, when the page template description file includes a plurality of resource file addresses, the client may obtain a plurality of groups of codes to be spliced from the server by using the plurality of resource file addresses, and the plurality of groups of codes to be spliced may correspond to the plurality of resource file addresses one to one. After the multiple groups of codes to be spliced are obtained, the multiple groups of codes to be spliced can be spliced to generate JavaScript codes.
Step 203, when receiving a 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, and each set of candidate JavaScript codes may correspond to a preset user operation event. Although the JavaScript code can be executed on the mobile terminal by building the JavaScript parser in the client, the basic JavaScript code cannot respond to the user operation event of the mobile terminal, and based on this, user event binding can be performed to notify the client that the JavaScript code and the corresponding operation need to be executed when the user performs a specific operation.
When receiving a JavaScript code sent by a server, a client may determine a candidate UI component corresponding to a user operation event and a first page element identifier corresponding to the UI component.
In practical applications, 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 identifier, and may be specified, for example, in the following manner, to specify the ID identifier of the "save" key as "submit":
< div id ═ submit ═ 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 identifier, the correspondence between the UI component and the page element can be determined.
For example, when the "# name" selector is used, an element whose ID is "name" in the page template description file may be represented, and when the identification of the UI component is "submit", a page element corresponding to the UI component may have a page element identification "# submit". For example, "$ (" # submit ")" may be used to determine the page elements in the page template description file.
In an example, when the server receives a resource obtaining request sent by the client, the server may read a resource file address from the resource obtaining request, and send a JavaScript resource file determined by the resource file address to the client, where the JavaScript resource file may include a JavaScript code. After receiving the JavaScript resource file, the client can read the JavaScript resource file by using the JavaScript parser to obtain the JavaScript code.
Step 204, acquiring corresponding second page element identifiers from the one or more groups 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 matches the first page element identifier, storing the corresponding relationship between the candidate JavaScript code and the first page element identifier in a preset event mapping table;
when the second page element identifier matches the first page element identifier, the corresponding relationship between the candidate JavaScript code and the first page element identifier may be stored in a preset event mapping table.
Specifically, a "$ (doc). ready ()" function may be used to perform user event binding, and when a preset user operation event is a user click event, for example, when a user clicks a UI component, a JavaScript parser may be used to execute the following codes:
“$("#name").click(function(){
alert("hello");
})”
the code includes a second page element identifier "# name", it can be determined that the JavaScript code matches the first page element identifier "# name" corresponding to the UI component, a mapping relationship between the candidate JavaScript code and the first page element identifier can be established in an event mapping table in a memory of the JavaScript parser, and user event binding is performed, and the following mapping relationship can be established in the memory of the JavaScript parser:
event_map["#name"]["click"]=function(){
alert("hello");
};
in the execution process of the "$ (doc). ready ()" function, data initialization and user event binding processing can be carried out, the function is executed without a return value, and the execution is finished when the execution is finished, so that the JavaScript parser can enter a waiting state to detect whether a user operation event occurs.
The UI component can be data belonging to a view (view) layer and is responsible for page drawing, the page element can be data belonging to a model (model) layer, the data can be stored in the page element, and the JavaScript code is bound in the page element corresponding to the UI component, so that the view layer and the model layer can be separated, and a better decoupling effect is obtained.
Step 206, in response to the triggering of the user operation event, 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 a target UI component corresponding to the user operation event and a third page element identifier 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:
substep 11, 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 may be determined. For example, when the client detects that a user clicks a "save" button in a (click) interface, a click event written by native code in the client may be triggered, and the client may determine that the "save" button is a triggered UI component and obtain a corresponding page element identifier.
And substep 12, when determining that the page element identifier corresponding to the triggered UI component has the corresponding candidate JavaScript code in the event mapping table, determining that the triggered UI component is the target UI component, and determining that the page element identifier corresponding to the triggered UI component is the third page element identifier.
In practical applications, the JavaScript code may not be directly bound to the UI component clicked by the user, for example, in a picture UI component containing text, the picture UI component is a parent component of the text UI component, and the 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 whether the page element identifier corresponding to the triggered UI component has a corresponding candidate JavaScript code in the event mapping table, and if it is determined that the page element identifier corresponding to the triggered UI component exists, it may be further determined that the triggered UI component is the target UI component, and the page element identifier corresponding to the triggered UI component is the third page element identifier.
If the candidate JavaScript codes corresponding to the triggered UI component are not found, event bubbling can be carried out, the parent component of the triggered UI component and the page element identifier corresponding to the parent component are determined, whether the candidate JavaScript codes corresponding to the parent component exist or not is continuously searched in the event mapping table, if yes, the triggered UI component can be determined as the 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 the third page element identifier is determined, 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 using the JavaScript parser to obtain a first operation instruction;
and 209, adopting the first operation instruction to perform system call in an operation system where the client is located.
In order to enable those skilled in the art to better understand the above steps, the following is an example to illustrate the embodiments of the present application, but it should be understood that the embodiments of the present application are not limited thereto.
As shown in fig. 3, a user may add text and pictures in the page, and when the user clicks a "save" button 301 of the UI control, the client may upload the text and pictures to the server; here, the ID of the "save" button 301 is "submit".
In specific application, a technical developer can write business logic by using JavaScript codes according to a process of uploading text or pictures to a server, and deploy the business logic in the server, and a JavaScript parser packaged as an SDK (Software Development Kit) can be built in a 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, and the JavaScript code may include a service logic code of a service related to the page, and execute the JavaScript code by using the JavaScript parser.
In the process of executing the JavaScript code, a "$ (doc). ready ()" method in the JavaScript code may be executed first by default, and the method may bind the JavaScript code with a user operation event. Specifically, in the "$ (doc). ready ()" method, the "$ (" # submit "). click (function)" method may be called, and by using the "# submit" selector (i.e., the first page element identifier), the click event of the key with the ID "submit" in the page is associated with the callback function specified by the function parameter, and the mapping relationship is recorded in the event mapping table. After the "$ (doc). ready ()" method is executed, the client enters a standby state and waits for the user to click a "save" button.
In a standby state, the client can monitor all click events in the page, and when detecting that the user clicks a 'save' key, the client can search in an event mapping table through event bubbling to judge whether a '# submit' selector has a corresponding callback function. When detecting that the "# submit" binds the corresponding callback function in the JavaScript code, for example, "# submit" binds the "save function", the JavaScript parser can be used to execute the "save function", and the event loop state is entered. In the execution process, the operating system can monitor the instruction queue through the native code of the client, and judges whether a new instruction is stored in the instruction queue in the memory of the JavaScript parser or not in the process of executing the storage function by the JavaScript parser.
When the JavaScript parser executes the saving function, an uploading picture instruction can be generated and stored in the instruction queue, and when the operation instruction is generated, a callback function identifier a with uniqueness can be generated and added into the uploading picture instruction, and the callback function identifier a can 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 identifier a from the instruction. After the basic function of the calling system executes the "upload picture instruction" and the picture is uploaded to the address specified in the instruction, the operating system may return a callback function identifier a to the client to indicate that the client executes the callback function associated with the callback function identifier a. After the instruction is uploaded, a wait state may be entered.
After the callback function identifier a is obtained, the client side can execute the function A by adopting a JavaScript parser, the JavaScript parser can generate a 'data submitting instruction' in the process of executing the function A, the instruction is stored into an instruction queue, meanwhile, a callback function identifier B is generated, the callback function identifier B is added into the 'data submitting instruction', and the callback function identifier B can be associated with a callback function B.
The JavaScript code is executed and is a synchronous processing model; the called mobile terminal operating system function needs to perform operations such as network request processing, user response and the like, the process is an asynchronous processing model, and in specific implementation, synchronous processing is difficult to wait for completion of asynchronous processing. 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 wait for asynchronous processing to be completed is solved.
After storing the "submit data instruction" to the instruction queue, the operating system may obtain the instruction from the instruction queue, and obtain the callback function identifier b. After performing commit data processing to commit data to the address specified in the "commit data instruction," the operating system may return a callback function identification b to the client.
After receiving the callback function identifier B, the client may execute the function B by using a JavaScript parser, and after the execution is completed, end the loop state, and feed back the execution result to the user. In the example of the application, through the JavaScript code, business processing of uploading pictures and submitting data is performed, a technical developer does not need to master the development skills of the iOS application or the android application, and under the condition that only the development experience of the JavaScript code is available, business logic suitable for the iOS application or the android application can still be written.
In the interaction process, the native code in the client responds to the user operation event, the JavaScript code is used for executing the service logic, the built-in function of the mobile terminal operation system is called through the JavaScript code, and the execution result is finally 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 identifier is obtained from one or more groups of candidate JavaScript codes, and when the second page element identifier is matched with the first page element identifier, the corresponding relation between the candidate JavaScript codes and the first page element identifier is stored in a 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 described as a series of acts or combination of acts, but those skilled in the art will recognize that the embodiments are not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the embodiments. Further, those skilled in the art will also appreciate that the embodiments described in the specification are presently preferred and that no particular act is required of the embodiments of the application.
Referring to fig. 4, a schematic structural diagram of a data processing apparatus provided in an embodiment of the present application is shown, and the apparatus may be applied to a client, where the client 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 contain business logic codes of the client. The method specifically comprises the following modules:
the user operation event binding module 401 is configured to, when receiving a JavaScript code sent by the server, establish a binding relationship between the JavaScript code and a preset user operation event;
a user operation event response module 402, configured to respond to the trigger of the user operation event, execute the JavaScript code by using the JavaScript parser, and obtain a first operation instruction;
a system call module 403, configured to perform system call in the operating system where the client is located by using the first operation instruction.
In an embodiment of the present application, the first operation instruction includes a callback function identifier, and the apparatus further includes:
the callback function identifier determining module is used for receiving the callback function identifier sent by the operating system; the callback function identifier is sent after the operating system carries out system call corresponding to the first operating 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 generating module is used for executing the callback function by adopting the JavaScript parser to obtain a second operation instruction.
In an embodiment of the present application, 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 user operation event binding module 401 includes:
a first page element identifier determining sub-module, configured to determine 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;
the second page element identification determining submodule is used for acquiring corresponding second page element identifications from the one or more groups of candidate JavaScript codes;
and the element identifier matching submodule is used for storing the 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.
In an embodiment of the present application, the system call module 403 includes:
a third page element identifier determining submodule, configured to determine a target UI component corresponding to the user operation event and a third page element identifier corresponding to the target UI component;
the target code determining submodule is used for determining a candidate JavaScript code corresponding to the third page element identifier as a target JavaScript code in the event mapping table;
and the first operation instruction generation submodule 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 identifier determining sub-module 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 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 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 the JavaScript code 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 acquisition submodule is used for acquiring a plurality of groups of codes to be spliced corresponding to the resource file addresses from the server side by adopting the resource file addresses;
and the code splicing submodule is used for splicing the multiple groups of codes to be spliced to generate JavaScript codes.
In the embodiment of the application, when receiving a JavaScript code sent by a server, a binding relationship between the JavaScript code and a preset user operation event is established, the JavaScript parser is adopted to execute the JavaScript code in response to the triggering of the user operation event to obtain a first operation instruction, and the first operation instruction is adopted to perform system calling in an operation system where a client is located, so that dynamic deployment of a service logic code in the server is realized, the phenomenon that the deployment cycle is too long due to compiling, packaging and other steps is avoided, the same service logic can be executed in different clients by using the same JavaScript code, repeated development of the service logic code is avoided, and the development efficiency is improved.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
An embodiment of the present application also provides an electronic device, which may include a processor, a memory, and a computer program stored on the memory and capable of running on the processor, and when executed by the processor, the computer program implements the steps of the method for processing data as described above.
An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the above data processing method.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, 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 present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) 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 flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams 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 to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, 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 terminal 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 terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal 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 of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the true scope of the embodiments of the application.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be 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. Also, 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 an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The method and apparatus for data processing, the electronic device, and the storage medium provided above are introduced in detail, and a specific example is applied in this document to explain the principle and the implementation of the present application, and the description of the above embodiment is only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

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 service logic code of the client, and the client is an android client or an iOS client; the method comprises the following steps:
when receiving a JavaScript code sent by the server, establishing a binding relationship between the JavaScript code and a preset user operation event;
responding to the trigger of the user operation event, and executing the JavaScript code by adopting the JavaScript parser to obtain a first operation instruction;
and carrying out system call in an operating system where the client is located by adopting the first operating 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 identifier sent by the operating system; the callback function identifier is sent after the operating system carries out system call corresponding to the first operating instruction;
in the JavaScript code, determining a callback function corresponding to the callback function identifier;
and executing the callback function by adopting the JavaScript parser to obtain a second operation instruction.
3. The method of claim 1, wherein the JavaScript code comprises one or more sets of candidate JavaScript codes, the preset user operation event comprises one or more preset user operation events, and the establishing a binding relationship between the JavaScript code and the preset user operation event comprises:
determining candidate UI components corresponding to the one or more preset user operation events and first page element identifications corresponding to the candidate UI components;
acquiring corresponding second page element identifications from the one or more groups of candidate JavaScript codes;
and 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.
4. The method of claim 3, wherein the executing the JavaScript code with the JavaScript parser to obtain a first operation instruction comprises:
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.
5. The method according to claim 4, 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;
and when the corresponding candidate JavaScript code exists in the page element identifier corresponding to the triggered UI component 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.
6. 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 a JavaScript code from the server by adopting the resource file address.
7. The method of claim 6, 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 the JavaScript code from the server by adopting the resource file addresses comprises the following steps:
acquiring a plurality of groups of codes to be spliced corresponding to the resource file addresses from the server by adopting the resource file addresses;
and splicing the multiple groups of codes to be spliced to generate a JavaScript code.
8. 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 service 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 the JavaScript code sent by the server is received;
the user operation event response module is used for responding to the triggering of the user operation event and executing the JavaScript code by adopting the JavaScript parser to obtain a first operation instruction;
and the system calling module is used for carrying out system calling in an operating system where the client is located by adopting the first operating instruction.
9. An electronic device, comprising a processor, a memory and a computer program stored on the memory and capable of running on the processor, the computer program, when executed by the processor, implementing the steps of the method of data processing according to any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of data processing according to any one of claims 1 to 7.
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 true CN111679828A (en) 2020-09-18
CN111679828B 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)

Cited By (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
CN116627391A (en) * 2023-07-21 2023-08-22 上海秉匠信息科技有限公司 UI component detection method, device, equipment and storage medium

Citations (8)

* 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
US20050155027A1 (en) * 2004-01-09 2005-07-14 Wei Coach K. System and method for developing and deploying computer applications over a network
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

Patent Citations (8)

* 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
US20050155027A1 (en) * 2004-01-09 2005-07-14 Wei Coach K. System and method for developing and deploying computer applications over a network
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

Cited By (3)

* 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
CN116627391A (en) * 2023-07-21 2023-08-22 上海秉匠信息科技有限公司 UI component detection method, device, equipment and storage medium
CN116627391B (en) * 2023-07-21 2023-10-27 上海秉匠信息科技有限公司 UI component detection method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN111679828B (en) 2023-08-15

Similar Documents

Publication Publication Date Title
CN111273898B (en) Automatic construction method, system and storage medium for web front-end code
CN109634588B (en) Office document online editing method and system compatible with multiple browsers
WO2017124952A1 (en) Webpage script loading method and device
US20150378864A1 (en) Systems and methods for instrumenting applications for performance monitoring
EP2909998B1 (en) Webpages with onboard hardware functions
CN111680253B (en) Page application data packet generation method and device, computer equipment and storage medium
CN108920365B (en) WebUI automatic testing method based on docker
US9292253B2 (en) Methods and apparatus for voiced-enabling a web application
WO2016177341A1 (en) Interface calling method and device, and terminal
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
CN107276842B (en) Interface test method and device and electronic equipment
CN110955409B (en) Method and device for creating resources on cloud platform
CN111880790A (en) Page rendering method, page rendering system, and computer-readable storage medium
CN111679828B (en) Data processing method and device, electronic equipment and storage medium
CN117693734A (en) Front-end item processing method, device, equipment, management system and storage medium
CN112835809A (en) Test data setting method, device, equipment and medium based on browser
CN113296653A (en) Simulation interaction model construction method, interaction method and related equipment
CN111813385B (en) Page plug-in method, device and equipment based on Web application
CN117519877A (en) Rendering method and device of quick application card, storage medium and electronic equipment
CN105354490A (en) Method and device for processing hijacked browser
CN111881043A (en) Page testing method and device, storage medium and processor
CN114721784B (en) Application running method and device, electronic equipment and readable medium
CN113486267B (en) Method, device, equipment and storage medium for analyzing application entry page

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