CN109714470B - Method and system for realizing mobile phone application modularization based on nodejs - Google Patents
Method and system for realizing mobile phone application modularization based on nodejs Download PDFInfo
- Publication number
- CN109714470B CN109714470B CN201811281666.3A CN201811281666A CN109714470B CN 109714470 B CN109714470 B CN 109714470B CN 201811281666 A CN201811281666 A CN 201811281666A CN 109714470 B CN109714470 B CN 109714470B
- Authority
- CN
- China
- Prior art keywords
- protocol
- nodejs
- request instruction
- mobile phone
- phone application
- 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
Links
Images
Abstract
The invention discloses a method and a system for realizing mobile phone application modularization based on nodejs, wherein the method comprises the steps of introducing a nodejs module into mobile phone application; defining a protocol class related to the functions of the mobile phone application in a nodejs module; calling a protocol corresponding to the request instruction in the protocol class; introducing the content contained in the request instruction into a nodejs module; and calling the relevant function in the interface service layer to execute the request instruction. The invention utilizes the nodeJs module to form a protocol transfer layer between the mobile phone application and the interface service layer, so that the mobile phone application can be shared by ios and android terminals, and the code reuse rate is reduced. And the method depends on the nodejs module to transfer the protocol, so that the mobile phone application and the interface service are not directly linked, and the coupling of the mobile phone application and the interface service is greatly reduced.
Description
Technical Field
The invention relates to the technical field of mobile phone application software, in particular to a method and a system for realizing mobile phone application modularization based on nodejs.
Background
Modularity is a way to divide a complete project into a number of functional components. The method has the advantages of low coupling among functions, convenience in function and task decomposition, functional independence and reduction of the risk of instability of the whole system caused by certain abnormal function.
Most of the existing modular methods use native ios (mobile operating system of apple) code or android (operating system based on L inux free and open source code, operating system developed by Google corporation) code to directly interact with interface services by means of annotation and the like.
The main drawback of the modular implementation described above is that the code coupling between App (Application, mobile phone Application) and the interface server is too high. And the ios and Android modules have overlarge difference and the code reuse rate is not high. Therefore, there is a need in the art to provide a solution for modularizing a mobile phone application to solve the above-mentioned problems.
Disclosure of Invention
The invention aims to provide a method and a system for realizing mobile phone application modularization based on nodejs, and the method and the system are used for solving the problems that the code coupling of mobile phone application software and an interface server side is too high, the difference between ios and Android modules is too large, and the code reuse rate is not high in the conventional modularization realization mode.
In order to achieve the above object, the present invention provides a method for realizing mobile phone application modularization based on nodejs, which comprises:
introducing a nodejs module into the mobile phone application;
defining a protocol class related to the functions of the mobile phone application in the nodejs module;
calling a protocol corresponding to the request instruction in the protocol class according to the request instruction of the mobile phone application;
introducing the content contained in the request instruction into the nodejs module by using the protocol corresponding to the request instruction;
and carrying out network request in the nodejs module, and calling related functions in an interface service layer to execute the request instruction.
Optionally, the defining a protocol class related to the mobile phone application in the nodejs module specifically includes:
carrying out protocol definition on each function in the mobile phone application by using a javascript code in a Nodejs running environment to form a function implementation protocol;
and encapsulating the function realization protocol in the nodejs module to form a protocol class, wherein the protocol class comprises a receiving protocol, a data processing protocol and a sending protocol.
Optionally, the invoking a protocol in the protocol class corresponding to the request instruction according to the request instruction of the mobile phone application specifically includes:
determining an operation to be executed according to the request instruction;
determining a corresponding function realization protocol according to the function of the operation to be executed;
and determining a protocol corresponding to the request instruction according to the function realization protocol.
Optionally, the making a network request in the nodejs module and invoking a related function in an interface service layer to execute the request instruction specifically include:
calling a functional application related to the request instruction in the interface service layer by using the nodejs module;
transmitting the content in the request instruction to the interface service layer;
and executing the request instruction by using the functional application related to the request instruction through the interface service layer.
Optionally, the method further includes that the mobile phone application obtains the request data from the interface service layer through the nodejs module.
The invention also provides a system for realizing the mobile phone application modularization based on nodejs, which comprises:
introducing a nodejs unit for introducing a nodejs module into the mobile phone application;
a defining protocol class unit, configured to define a protocol class related to the function of the mobile phone application in the nodejs module;
a protocol calling unit, configured to call, according to the request instruction of the mobile phone application, a protocol in the protocol class corresponding to the request instruction;
a content introducing unit, configured to introduce, by using the protocol corresponding to the request instruction, a content included in the request instruction into the nodejs module;
and the interface service execution unit is used for carrying out network request in the nodejs module and calling related functions in an interface service layer to execute the request instruction.
Optionally, the defining the protocol class unit specifically includes:
a function realization protocol definition subunit, configured to perform protocol definition on each function in the mobile phone application in a nodjs operating environment by using a javascript code, so as to form a function realization protocol;
and the protocol encapsulation subunit is used for encapsulating the function realization protocol in the nodejs module to form a protocol class, wherein the protocol class comprises a receiving protocol, a data processing protocol and a sending protocol.
Optionally, the invoking protocol unit specifically includes:
the to-be-executed operation determining subunit is used for determining to-be-executed operation according to the request instruction;
the function realization protocol determining subunit is used for determining a corresponding function realization protocol according to the function of the operation to be executed;
and the protocol determining subunit corresponding to the request instruction is used for determining a protocol corresponding to the request instruction according to the function realization protocol.
Optionally, the interface service execution unit specifically includes:
a function application calling subunit, configured to call, by using the nodejs module, a function application related to the request instruction in the interface service layer;
the content transmission subunit is used for transmitting the content in the request instruction to the interface service layer;
and the request instruction execution subunit is used for executing the request instruction by using the functional application related to the request instruction through the interface service layer.
Optionally, the system further includes a unit configured to enable the mobile phone application to obtain the request data from the interface service layer through the nodejs module.
According to the specific embodiment provided by the invention, the invention discloses the following technical effects:
the method and the system for realizing the modularization of the mobile phone application based on nodeJs form a protocol transfer layer between the mobile phone application and an interface service layer by utilizing a nodeJs module, nodeJs is the operating environment of the scripting language Javascript, and the scripting language Javascript can be simultaneously and well operated at ios and addriod ends, so that the mobile phone application can be shared at the ios and addriod ends, and the code reuse rate is reduced. And the protocol transfer is carried out by depending on the nodejs module, so that the interaction between the mobile phone application and the nodejs module and the interaction between the interface service layer and the nodejs module are realized, the mobile phone application and the interface service are not directly linked, and the coupling of the mobile phone application and the interface service is greatly reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a flowchart of a method for implementing mobile phone application modularization based on nodejs according to an embodiment of the present invention;
fig. 2 is a system block diagram of a system for implementing mobile phone application modularization based on nodejs according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the 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 invention.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
As shown in fig. 1, the method for implementing mobile phone application modularization based on nodejs provided in this embodiment includes:
step 101: a nodejs module is introduced into the mobile phone application.
Step 102: and defining a protocol class related to the functions of the mobile phone application in the nodejs module. The step 102 specifically includes:
carrying out protocol definition on each function in the mobile phone application by using a javascript code in a Nodejs running environment to form a function implementation protocol;
and encapsulating the function realization protocol in the nodejs module to form a protocol class, wherein the protocol class comprises a receiving protocol, a data processing protocol and a sending protocol.
Step 103: and calling a protocol corresponding to the request instruction in the protocol class according to the request instruction of the mobile phone application. The step 103 specifically includes:
determining an operation to be executed according to the request instruction;
determining a corresponding function realization protocol according to the function of the operation to be executed;
determining a protocol corresponding to the request instruction according to the function implementation protocol
Step 104: and introducing the content contained in the request instruction into the nodejs module by using the protocol corresponding to the request instruction.
Step 105: and carrying out network request in the nodejs module, and calling related functions in an interface service layer to execute the request instruction. The step 105 specifically includes:
calling a functional application related to the request instruction in the interface service layer by using the nodejs module;
transmitting the content in the request instruction to the interface service layer;
and executing the request instruction by using the functional application related to the request instruction through the interface service layer.
As an optional implementation manner, the method further includes that the mobile phone application acquires the request data from the interface service layer through the nodejs module.
As shown in fig. 2, this embodiment further provides a system for implementing mobile phone application modularization based on nodejs, which corresponds to the method for implementing mobile phone application modularization based on nodejs, where the system includes:
a nodejs unit 201 is introduced for introducing nodejs modules within the handset application.
A defining protocol class unit 202, configured to define a protocol class related to the function of the mobile phone application in the nodejs module. The defining protocol class unit 202 specifically includes:
a function realization protocol definition subunit, configured to perform protocol definition on each function in the mobile phone application in a nodjs operating environment by using a javascript code, so as to form a function realization protocol;
and the protocol encapsulation subunit is used for encapsulating the function realization protocol in the nodejs module to form a protocol class, wherein the protocol class comprises a receiving protocol, a data processing protocol and a sending protocol.
And the protocol calling unit 203 is configured to call a protocol in the protocol class corresponding to the request instruction according to the request instruction of the mobile phone application. The invoking protocol unit 203 specifically includes:
the to-be-executed operation determining subunit is used for determining to-be-executed operation according to the request instruction;
the function realization protocol determining subunit is used for determining a corresponding function realization protocol according to the function of the operation to be executed;
and the protocol determining subunit corresponding to the request instruction is used for determining a protocol corresponding to the request instruction according to the function realization protocol.
A content introducing unit 204, configured to introduce, by using the protocol corresponding to the request instruction, the content included in the request instruction into the nodejs module.
And the interface service execution unit 205 is configured to perform a network request in the nodejs module, and call a related function in the interface service layer to execute the request instruction. The interface service execution unit 205 specifically includes:
a function application calling subunit, configured to call, by using the nodejs module, a function application related to the request instruction in the interface service layer;
the content transmission subunit is used for transmitting the content in the request instruction to the interface service layer;
and the request instruction execution subunit is used for executing the request instruction by using the functional application related to the request instruction through the interface service layer.
As an optional implementation manner, the system further includes a unit configured to enable the mobile phone application to obtain the requested data from the interface service layer through the nodejs module.
The following describes the application and execution process of the present embodiment in detail by taking a commonly used image capturing module in a mobile phone application as an example.
The flow of the service of requesting the picture storage by the mobile phone application is as follows:
(1) and calling a native code (java, a code language applied by compiling android application or oc, a code language applied by compiling ios application) at the application end of the mobile phone to realize a picture shooting function. If shooting is canceled, the flow is re-executed. I.e. the shooting function is placed inside the App.
(2) In the nodeJs module, a protocol class is defined. The protocol class contains a picture receiving protocol picReceive (), a picture processing protocol picHandle () and a sending protocol picSend ().
(3) According to a request instruction sent by the App for storing the pictures, calling a corresponding picture receiving protocol picReceive () in a nodeJs module, and introducing picture instances into the nodeJs module.
(4) And carrying out network request in the nodeJs module, calling the storage function of the interface service layer related to the stored pictures, and transmitting the pictures to the interface service layer.
(5) The interface service layer saves the pictures to the server using IO storage (a local file storage method).
The flow of the service of requesting to acquire the picture by the mobile phone application is as follows:
(1) the mobile phone application calls a sending protocol picSend () in the nodeJs module, and the nodeJs module is informed that the request instruction of the mobile phone application is the required picture through the sending protocol.
(2) And carrying out network request in the nodeJs module, and calling the function of extracting the picture in the interface service layer.
(3) And distributing the pictures sent by the interface service layer to the mobile phone application through the nodeJs module, and displaying the pictures to the user by the mobile phone application.
In this embodiment, the App and the protocol transit layer of the interface service layer are generated by using nodejs, so that the coupling between the App and the interface service layer is very low, and the functional module is more easily split. And the module reuse rate of ios and android can be improved.
For the system disclosed by the embodiment, the description is relatively simple because the system corresponds to the method disclosed by the embodiment, and the relevant points can be referred to the method part for description.
The principles and embodiments of the present invention have been described herein using specific examples, which are provided only to help understand the method and the core concept of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, the specific embodiments and the application range may be changed. In view of the above, the present disclosure should not be construed as limiting the invention.
Claims (6)
1. A method for realizing mobile phone application modularization based on nodejs is characterized by comprising the following steps:
introducing a nodejs module into the mobile phone application;
defining a protocol class related to the functions of the mobile phone application in the nodejs module, specifically comprising:
carrying out protocol definition on each function in the mobile phone application by using a javascript code in a Nodejs running environment to form a function implementation protocol;
encapsulating the function realization protocol in the nodejs module to form a protocol class, wherein the protocol class comprises a receiving protocol, a data processing protocol and a sending protocol;
calling a protocol corresponding to the request instruction in the protocol class according to the request instruction of the mobile phone application, and specifically comprising:
determining an operation to be executed according to the request instruction;
determining a corresponding function realization protocol according to the function of the operation to be executed;
determining a protocol corresponding to the request instruction according to the function realization protocol;
introducing the content contained in the request instruction into the nodejs module by using the protocol corresponding to the request instruction;
and carrying out network request in the nodejs module, and calling related functions in an interface service layer to execute the request instruction.
2. The method for realizing mobile phone application modularization based on nodejs as claimed in claim 1, wherein the network request is performed in the nodejs module, and the related function in the interface service layer is called to execute the request instruction, specifically comprising:
calling a functional application related to the request instruction in the interface service layer by using the nodejs module;
transmitting the content in the request instruction to the interface service layer;
and executing the request instruction by using the functional application related to the request instruction through the interface service layer.
3. The method for realizing modularization of mobile phone applications based on nodejs as claimed in claim 1, wherein the method further comprises the step of the mobile phone application obtaining the request data from the interface service layer through the nodejs module.
4. A system for realizing mobile phone application modularization based on nodejs is characterized in that the system comprises:
introducing a nodejs unit for introducing a nodejs module into the mobile phone application;
a defining protocol class unit, configured to define a protocol class related to the function of the mobile phone application in the nodejs module, and specifically include:
a function realization protocol definition subunit, configured to perform protocol definition on each function in the mobile phone application in a nodjs operating environment by using a javascript code, so as to form a function realization protocol;
a protocol encapsulation subunit, configured to encapsulate the function implementation protocol in the nodejs module to form a protocol class, where the protocol class includes a receiving protocol, a data processing protocol, and a sending protocol;
a protocol calling unit, configured to call, according to the request instruction of the mobile phone application, a protocol in the protocol class corresponding to the request instruction, specifically including:
the to-be-executed operation determining subunit is used for determining to-be-executed operation according to the request instruction;
the function realization protocol determining subunit is used for determining a corresponding function realization protocol according to the function of the operation to be executed;
a protocol determining subunit corresponding to the request instruction, configured to determine, according to the function implementation protocol, a protocol corresponding to the request instruction;
a content introducing unit, configured to introduce, by using the protocol corresponding to the request instruction, a content included in the request instruction into the nodejs module;
and the interface service execution unit is used for carrying out network request in the nodejs module and calling related functions in an interface service layer to execute the request instruction.
5. The system for realizing mobile phone application modularization based on nodejs as claimed in claim 4, wherein the interface service execution unit specifically comprises:
a function application calling subunit, configured to call, by using the nodejs module, a function application related to the request instruction in the interface service layer;
the content transmission subunit is used for transmitting the content in the request instruction to the interface service layer;
and the request instruction execution subunit is used for executing the request instruction by using the functional application related to the request instruction through the interface service layer.
6. The system for realizing modularization of mobile phone applications based on nodejs as claimed in claim 4, wherein the system further comprises a unit for realizing that the mobile phone applications obtain the request data from the interface service layer through the nodejs module.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811281666.3A CN109714470B (en) | 2018-10-23 | 2018-10-23 | Method and system for realizing mobile phone application modularization based on nodejs |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811281666.3A CN109714470B (en) | 2018-10-23 | 2018-10-23 | Method and system for realizing mobile phone application modularization based on nodejs |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109714470A CN109714470A (en) | 2019-05-03 |
CN109714470B true CN109714470B (en) | 2020-08-04 |
Family
ID=66254126
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811281666.3A Active CN109714470B (en) | 2018-10-23 | 2018-10-23 | Method and system for realizing mobile phone application modularization based on nodejs |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109714470B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104252339A (en) * | 2013-06-25 | 2014-12-31 | 腾讯科技(深圳)有限公司 | Method and device for developing interface layers and realizing data interaction of interface layers |
CN104375858A (en) * | 2014-10-27 | 2015-02-25 | 深信服网络科技(深圳)有限公司 | Method and device for multiple browser platforms to execute javascript |
CN105468398A (en) * | 2014-09-30 | 2016-04-06 | 阿里巴巴集团控股有限公司 | Module uploading method, request method and loading method for cross-terminal architecture |
CN107193668A (en) * | 2017-04-26 | 2017-09-22 | 深圳中兴网信科技有限公司 | The call method and system at interface service end |
CN107305527A (en) * | 2016-04-22 | 2017-10-31 | 腾讯科技(深圳)有限公司 | The treating method and apparatus of code file |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130091197A1 (en) * | 2011-10-11 | 2013-04-11 | Microsoft Corporation | Mobile device as a local server |
-
2018
- 2018-10-23 CN CN201811281666.3A patent/CN109714470B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104252339A (en) * | 2013-06-25 | 2014-12-31 | 腾讯科技(深圳)有限公司 | Method and device for developing interface layers and realizing data interaction of interface layers |
CN105468398A (en) * | 2014-09-30 | 2016-04-06 | 阿里巴巴集团控股有限公司 | Module uploading method, request method and loading method for cross-terminal architecture |
CN104375858A (en) * | 2014-10-27 | 2015-02-25 | 深信服网络科技(深圳)有限公司 | Method and device for multiple browser platforms to execute javascript |
CN107305527A (en) * | 2016-04-22 | 2017-10-31 | 腾讯科技(深圳)有限公司 | The treating method and apparatus of code file |
CN107193668A (en) * | 2017-04-26 | 2017-09-22 | 深圳中兴网信科技有限公司 | The call method and system at interface service end |
Non-Patent Citations (3)
Title |
---|
《Nodejs作为Web架构中间层的使用》;IDEADATA大数据;《http://baijiahao.baidu.com/?id=1596694936338471441》;20180403;第1-4页 * |
NodeJS中间层搭建;winyh;《https://www.cnblogs.com/winyh/articles/7851361.html》;20171117;第1-5页 * |
基于Node.js的前后端分离框架的实现与应用;孔令旭;《万方数据》;20170516;摘要,第5-7、14-15页 * |
Also Published As
Publication number | Publication date |
---|---|
CN109714470A (en) | 2019-05-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108345531B (en) | Test method, device and system | |
CN111338623B (en) | Method, device, medium and electronic equipment for developing user interface | |
CN109714332B (en) | Protocol conversion method and device based on Thrift and syntax tree analysis | |
CN112286529A (en) | Development method, device and equipment of front-end page and storage medium | |
CN110580154A (en) | access method based on H5 access mode, access assembly and mobile terminal thereof | |
CN113360807B (en) | Page display method and device of mixed-mode mobile application and related equipment | |
CN111581555B (en) | Document loading method, device, equipment and storage medium | |
CN111506368B (en) | Method, device, equipment and storage medium for converting asynchronous call into synchronous call | |
CN110851240B (en) | Function calling method, device and storage medium | |
CN114168460A (en) | Remote debugging method, device and storage medium for front-end code in hybrid development | |
CN106357654B (en) | Remote procedure calling method, device and communication system | |
CN109343970B (en) | Application program-based operation method and device, electronic equipment and computer medium | |
CN107438097B (en) | Network request processing method and device | |
CN111324376B (en) | Function configuration method, device, electronic equipment and computer readable medium | |
CN113760264A (en) | Method and device for multiplexing components among multiple applications | |
CN109714470B (en) | Method and system for realizing mobile phone application modularization based on nodejs | |
CN110806856A (en) | Data loading method and device and electronic equipment | |
CN111240801A (en) | Method, device, medium and electronic equipment for generating heap memory snapshot file | |
CN112162755B (en) | Data processing method, device, medium and electronic equipment | |
CN113709171A (en) | Method and device for cross-component state communication | |
CN114301970A (en) | Service calling method and device, electronic equipment and storage medium | |
CN109669679B (en) | Service detection and processing method and device and electronic equipment | |
CN112015384A (en) | Interface mapping method and device | |
CN113391811A (en) | Function compiling method and device, electronic equipment and computer readable storage medium | |
CN113778566A (en) | Native application calling method and device, electronic equipment and computer readable medium |
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 |