[go: up one dir, main page]

CN117591106A - Calling method and device of native function component, electronic equipment and storage medium - Google Patents

Calling method and device of native function component, electronic equipment and storage medium Download PDF

Info

Publication number
CN117591106A
CN117591106A CN202311709208.6A CN202311709208A CN117591106A CN 117591106 A CN117591106 A CN 117591106A CN 202311709208 A CN202311709208 A CN 202311709208A CN 117591106 A CN117591106 A CN 117591106A
Authority
CN
China
Prior art keywords
target
jsbridge
component
calling
framework
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.)
Pending
Application number
CN202311709208.6A
Other languages
Chinese (zh)
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.)
Shenzhen Lexin Software Technology Co Ltd
Original Assignee
Shenzhen Lexin Software Technology 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 Shenzhen Lexin Software Technology Co Ltd filed Critical Shenzhen Lexin Software Technology Co Ltd
Priority to CN202311709208.6A priority Critical patent/CN117591106A/en
Publication of CN117591106A publication Critical patent/CN117591106A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • 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/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

本申请实施例公开了一种原生功能组件的调用方法、装置、电子设备及存储介质。应用于电子设备的原生功能组件调用框架,该框架包括多个功能模块,功能模块包括原生功能组件以及与原生功能组件匹配的Jsbridge组件,方法包括:通过预设的目标前端框架获取目标调用请求;从多个Jsbridge组件中确定与目标Jsbridge标识对应的目标Jsbridge组件;通过目标Jsbridge组件将目标调用信息发送给目标原生功能组件;通过目标原生功能组件生成目标调用信息的目标响应信息;通过目标Jsbridge组件将目标响应信息返回给目标前端框架。本申请实施例电子设备中的Jsbridge组件为根据调用能力拆分后的Jsbridge组件,解耦了不同调用能力的Jsbridge组件,当有Jsbridge故障时,可以更快地找到故障的Jsbridge组件,提高了Jsbridge组件的维护效率。

Embodiments of the present application disclose a method, device, electronic device, and storage medium for calling native functional components. A native functional component calling framework applied to electronic devices. The framework includes multiple functional modules. The functional modules include native functional components and Jsbridge components that match the native functional components. The method includes: obtaining a target calling request through a preset target front-end framework; Determine the target Jsbridge component corresponding to the target Jsbridge identifier from multiple Jsbridge components; send the target call information to the target native function component through the target Jsbridge component; generate the target response information of the target call information through the target native function component; use the target Jsbridge component Return the target response information to the target front-end framework. The Jsbridge component in the electronic device of the embodiment of the present application is a Jsbridge component split according to the calling capabilities, which decouples the Jsbridge components with different calling capabilities. When there is a Jsbridge fault, the faulty Jsbridge component can be found faster, which improves the Jsbridge component. Component maintenance efficiency.

Description

原生功能组件的调用方法、装置、电子设备及存储介质Calling methods, devices, electronic devices and storage media of native functional components

技术领域Technical field

本申请涉及数据处理技术领域,尤其涉及一种原生功能组件的调用方法、装置、电子设备及存储介质。The present application relates to the field of data processing technology, and in particular to a method, device, electronic device and storage medium for calling native functional components.

背景技术Background technique

当前中大型应用程序(Application,APP)中,除native原生页面外,往往还会同时存在两到三种前端框架,如H5、Weex、ReactNative或Flutter对应的前端框架。In current medium and large applications (Application, APP), in addition to native pages, there are often two to three front-end frameworks at the same time, such as front-end frameworks corresponding to H5, Weex, ReactNative or Flutter.

前端框架需要通过调用Jsbridge来使用原生功能组件,如调用原生的刷脸组件,光学字符识别(Optical Character Recognition,OCR)组件以及微信支付组件等功能组件,在现有技术中,需要将所有的原生功能组件对应的Jsbridge都放在一起作为一个Jsbridge组件中,并将该Jsbridge组件部署在对应的APP中,然而,将所有功能对应的Jsbridge都放在一起,不同功能的Jsbridge耦合严重,当有Jsbridge出现故障时,由于各功能的Jsbridge耦合在一起,维护效率低。The front-end framework needs to use native functional components by calling Jsbridge, such as calling native facial recognition components, optical character recognition (Optical Character Recognition, OCR) components, WeChat payment components and other functional components. In the existing technology, all native functional components need to be The Jsbridges corresponding to the functional components are put together as one Jsbridge component, and the Jsbridge component is deployed in the corresponding APP. However, if the Jsbridges corresponding to all functions are put together, the Jsbridges with different functions are seriously coupled. When there is a Jsbridge When a fault occurs, maintenance efficiency is low because the Jsbridge of each function is coupled together.

发明内容Contents of the invention

本申请实施例提供了一种原生功能组件的调用方法、装置、电子设备及存储介质,可以提高Jsbridge组件的维护效率。The embodiments of this application provide a calling method, device, electronic device and storage medium for native functional components, which can improve the maintenance efficiency of Jsbridge components.

第一方面,本申请实施例提供了一种原生功能组件的调用方法,所述方法应用于电子设备的原生功能组件调用框架,所述原生功能组件调用框架包括多个功能模块,各所述功能模块均包括原生功能组件以及与所述原生功能组件匹配的Jsbridge组件,所述方法包括:In a first aspect, embodiments of the present application provide a method for calling native functional components. The method is applied to a native functional component calling framework of an electronic device. The native functional component calling framework includes a plurality of functional modules, each of which functions The modules all include native functional components and Jsbridge components that match the native functional components. The methods include:

通过预设的目标前端框架获取目标调用请求,所述目标调用请求包括目标Jsbridge标识以及目标调用信息;Obtain the target call request through the preset target front-end framework, and the target call request includes the target Jsbridge identification and target call information;

从多个所述Jsbridge组件中确定与所述目标Jsbridge标识对应的目标Jsbridge组件;Determine the target Jsbridge component corresponding to the target Jsbridge identifier from a plurality of the Jsbridge components;

通过所述目标Jsbridge组件将所述目标调用信息发送给目标原生功能组件,所述目标原生功能组件与所述目标Jsbridge组件位于同一功能模块内;Send the target calling information to the target native functional component through the target Jsbridge component, and the target native functional component and the target Jsbridge component are located in the same functional module;

通过所述目标原生功能组件生成所述目标调用信息的目标响应信息;Generate target response information of the target call information through the target native functional component;

通过所述目标Jsbridge组件将所述目标响应信息返回给所述目标前端框架。The target response information is returned to the target front-end framework through the target Jsbridge component.

第二方面,本申请实施例还提供了原生功能组件调用框架,所述原生功能组件调用框架部署在电子设备中,所述原生功能组件调用框架包括容器层、中间调用层以及独立功能模块层,所述容器层包括多个业务框架容器,不同的业务框架容器承载有不同类型的前端框架,所述中间调用层包括各所述业务框架容器分别对应的调用入口以及注册表,所述独立功能模块层包括多个功能模块,各所述功能模块均包括原生功能组件以及与所述原生功能组件匹配的Jsbridge组件,其中:In the second aspect, embodiments of the present application also provide a native functional component calling framework, which is deployed in an electronic device. The native functional component calling framework includes a container layer, an intermediate calling layer, and an independent functional module layer. The container layer includes multiple business framework containers, and different business frame containers carry different types of front-end frameworks. The intermediate call layer includes call entrances and registration tables corresponding to each of the business frame containers. The independent functional modules The layer includes multiple functional modules, each of which includes native functional components and Jsbridge components that match the native functional components, where:

所述容器层,用于通过多个所述前端框架中的目标前端框架获取目标调用请求,所述目标调用请求包括目标Jsbridge标识以及目标调用信息;The container layer is used to obtain a target call request through a target front-end framework in multiple front-end frameworks, where the target call request includes a target Jsbridge identifier and target call information;

所述中间调用层,用于根据所述注册表从多个所述Jsbridge组件中确定与所述目标Jsbridge标识对应的目标Jsbridge组件;The intermediate calling layer is used to determine the target Jsbridge component corresponding to the target Jsbridge identifier from a plurality of the Jsbridge components according to the registration table;

所述独立功能模块层,用于通过所述目标Jsbridge组件将所述目标调用信息发送给目标原生功能组件,所述目标原生功能组件与所述目标Jsbridge组件位于同一功能模块内;通过所述目标原生功能组件生成所述目标调用信息的目标响应信息;通过所述目标Jsbridge组件将所述目标响应信息返回给所述目标前端框架。The independent function module layer is used to send the target call information to the target native function component through the target Jsbridge component, and the target native function component and the target Jsbridge component are located in the same functional module; through the target The native functional component generates target response information of the target call information; and returns the target response information to the target front-end framework through the target Jsbridge component.

第三方面,本申请实施例还提供了一种电子设备,所述电子设备中部署有原生功能组件调用框架,所述原生功能组件调用框架包括多个功能模块,各所述功能模块均包括原生功能组件以及与所述原生功能组件匹配的Jsbridge组件,所述电子设备包括存储器及处理器,所述存储器上存储有计算机程序,原生功能组件调用框架通过所述处理器执行所述计算机程序时实现上述方法。In a third aspect, embodiments of the present application further provide an electronic device. A native functional component calling framework is deployed in the electronic device. The native functional component calling framework includes a plurality of functional modules, and each of the functional modules includes a native functional component calling framework. Functional components and Jsbridge components matching the native functional components. The electronic device includes a memory and a processor. A computer program is stored on the memory. The native functional component calling framework is implemented when the processor executes the computer program. the above method.

第四方面,本申请实施例还提供了一种计算机可读存储介质,所述存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时可实现上述方法。In a fourth aspect, embodiments of the present application also provide a computer-readable storage medium, the storage medium stores a computer program, the computer program includes program instructions, and when executed by a processor, the program instructions can implement the above method. .

本申请实施例提供了一种原生功能组件的调用方法、装置、电子设备及存储介质。其中,所述方法应用于电子设备的原生功能组件调用框架,所述的原生功能组件调用框架包括多个功能模块,各所述功能模块均包括原生功能组件以及与所述原生功能组件匹配的Jsbridge组件,所述方法包括:通过预设的目标前端框架获取目标调用请求,所述目标调用请求包括目标Jsbridge标识以及目标调用信息;从多个所述Jsbridge组件中确定与所述目标Jsbridge标识对应的目标Jsbridge组件;通过所述目标Jsbridge组件将所述目标调用信息发送给目标原生功能组件,所述目标原生功能组件与所述目标Jsbridge组件位于同一功能模块内;通过所述目标原生功能组件生成所述目标调用信息的目标响应信息;通过所述目标Jsbridge组件将所述目标响应信息返回给所述目标前端框架。本申请实施例中的Jsbridge组件为根据调用能力拆分后的Jsbridge组件,解耦了不同调用能力的Jsbridge组件,当有Jsbridge故障时,可以更快地找到故障的Jsbridge组件,提高了Jsbridge组件的维护效率。Embodiments of the present application provide a method, device, electronic device, and storage medium for calling native functional components. Wherein, the method is applied to a native functional component calling framework of an electronic device. The native functional component calling framework includes a plurality of functional modules, and each of the functional modules includes a native functional component and a Jsbridge that matches the native functional component. component, the method includes: obtaining a target call request through a preset target front-end framework, the target call request including a target Jsbridge identification and target call information; determining from a plurality of the Jsbridge components corresponding to the target Jsbridge identification Target Jsbridge component; send the target call information to the target native functional component through the target Jsbridge component, and the target native functional component and the target Jsbridge component are located in the same functional module; generate the target native functional component through the target native functional component The target response information of the target call information is returned to the target front-end framework through the target Jsbridge component. The Jsbridge component in the embodiment of this application is a Jsbridge component split according to calling capabilities, which decouples Jsbridge components with different calling capabilities. When there is a Jsbridge failure, the faulty Jsbridge component can be found faster, which improves the performance of the Jsbridge component. Maintenance efficiency.

附图说明Description of drawings

为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of the present application, which are of great significance to this field. Ordinary technicians can also obtain other drawings based on these drawings without exerting creative work.

图1为本申请实施例提供的原生功能组件的调用方法的应用场景示意图;Figure 1 is a schematic diagram of the application scenario of the calling method of the native functional component provided by the embodiment of the present application;

图2为本申请实施例提供的原生功能组件的调用方法的流程示意图;Figure 2 is a schematic flow chart of the calling method of the native functional component provided by the embodiment of the present application;

图3为本申请实施例提供的电子设备的示意性框图。Figure 3 is a schematic block diagram of an electronic device provided by an embodiment of the present application.

具体实施方式Detailed ways

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of this application.

应当理解,当在本说明书和所附权利要求书中使用时,术语“包括”和“包含”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It should be understood that, when used in this specification and the appended claims, the terms "comprises" and "comprises" indicate the presence of described features, integers, steps, operations, elements and/or components but do not exclude the presence of one or The presence or addition of multiple other features, integers, steps, operations, elements, components and/or collections thereof.

还应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。It should also be understood that the terminology used in the specification of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a", "an" and "the" are intended to include the plural forms unless the context clearly dictates otherwise.

还应当进一步理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。It will be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items. .

本申请实施例提供了一种原生功能组件的调用方法、装置、电子设备及存储介质。Embodiments of the present application provide a method, device, electronic device, and storage medium for calling native functional components.

该原生功能组件的调用方法的执行主体可以是本申请实施例提供的原生功能组件的调用装置,或者集成了该原生功能组件的调用装置的电子设备,其中,该原生功能组件的调用装置可以采用硬件或者软件的方式实现,该电子设备为终端设备,该终端设备可以为手机,其中,该终端设备的系统可以为安卓系统也可以为IOS系统。即本申请电子设备中的原生功能组件可以为安卓原生功能组件也可以为IOS原生功能组件。The execution subject of the calling method of the native functional component may be the calling device of the native functional component provided in the embodiment of the present application, or an electronic device integrated with the calling device of the native functional component, wherein the calling device of the native functional component may be It is implemented in the form of hardware or software. The electronic device is a terminal device, and the terminal device can be a mobile phone. The system of the terminal device can be an Android system or an IOS system. That is, the native functional components in the electronic device of this application can be Android native functional components or IOS native functional components.

其中,本申请实施例提供的原生功能组件调用框架包括多个功能模块,且不同的功能模块由不同的原生功能组件以及对应的Jsbridge组件组成,Jsbridge组件可以调用位于同一功能模块内的原生功能组件,原生功能组件也可以通过位于同一功能模块内的Jsbridge组件向前端框架发送信息。Among them, the native functional component calling framework provided by the embodiment of the application includes multiple functional modules, and different functional modules are composed of different native functional components and corresponding Jsbridge components. The Jsbridge component can call the native functional components located in the same functional module. , Native functional components can also send information to the front-end framework through the Jsbridge component located in the same functional module.

在一些实施例中,请参阅图1,图1为本申请实施例提供的一种原生功能组件调用框架的结构示意图,该原生功能组件调用框架部署在本申请提供的电子设备中,该所述原生功能组件调用框架包括容器层、中间调用层以及独立功能模块层,其中:In some embodiments, please refer to Figure 1. Figure 1 is a schematic structural diagram of a native functional component calling framework provided by an embodiment of the present application. The native functional component calling framework is deployed in the electronic device provided by the present application. The native functional component calling framework includes the container layer, the intermediate calling layer and the independent function module layer, among which:

所述容器层:包括多个业务框架容器,不同的业务框架容器承载有不同类型的前端框架,在一些实施例中,该前端框架包括webview业务框架、weex业务框架和flutter业务框架,其中,根据APP的需要,该前端框架还可以是其他类型的前端框架,具体的前端框架类型本实施例不作限定。The container layer: includes multiple business framework containers, and different business framework containers carry different types of front-end frameworks. In some embodiments, the front-end framework includes webview business framework, weex business framework and flutter business framework, wherein, according to Depending on the needs of the APP, the front-end framework can also be other types of front-end frameworks. The specific front-end framework type is not limited in this embodiment.

所述中间调用层:为Bridge层,包括各所述业务框架容器分别对应的调用入口以及所述注册表,所述独立功能模块层包括多个所述功能模块。例如,如图1所示,webview容器对应的调用入口为webEvent,weex容器对应的调用入口为weexEvent,flutter容器对应的调用入口为flutterEvent。不同的前端框架的调用请求可以通过对应的调用入口进行Jsbridge组件的调用,该注册表中的Jsbridge数据为APP在编译阶段,字节码插桩库依据APP编译脚本中的配置插入注册表中,在注册表中实现对应Jsbridge组件的注册,具体地,该注册表中包括各所述Jsbridge组件的Jsbridge标识与调用代码之间的映射关系,在对Jsbridge组件进行注册时,会将Jsbridge组件的Jsbridge标识写入注册表中,并通过字节码插装技术将对应Jsbridge组件的调用代码(即实现类)插入到与Jsbridge标识对应的位置,完成Jsbridge标识与调用代码之间的映射关系的构建。The intermediate calling layer: is the Bridge layer, including the calling entrance and the registration table corresponding to each of the business framework containers, and the independent functional module layer includes a plurality of the functional modules. For example, as shown in Figure 1, the call entry corresponding to the webview container is webEvent, the call entry corresponding to the weex container is weexEvent, and the call entry corresponding to the flutter container is flutterEvent. Call requests from different front-end frameworks can call the Jsbridge component through the corresponding call entrance. The Jsbridge data in the registry is the APP during the compilation phase. The bytecode instrumentation library is inserted into the registry according to the configuration in the APP compilation script. Register the corresponding Jsbridge component in the registry. Specifically, the registry includes the mapping relationship between the Jsbridge identifier of each Jsbridge component and the calling code. When registering the Jsbridge component, the Jsbridge component of the Jsbridge component will be registered. The logo is written into the registry, and the calling code (i.e., implementation class) corresponding to the Jsbridge component is inserted into the location corresponding to the Jsbridge logo through bytecode instrumentation technology to complete the construction of the mapping relationship between the Jsbridge logo and the calling code.

所述独立功能模块层:包括多个所述原生功能组件,每个功能模块均包括原生功能组件以及与所述原生功能组件匹配的Jsbridge组件,需要说明的是,不一定所有原生功能组件都有其匹配的Jsbridge组件,有一些不能被前端框架调用的原生功能组件则不需设置对应的Jsbridge组件,如图1所示,刷脸功能模块包括刷脸Jsbridge组件以及刷脸组件、日志功能模块包括日志Jsbridge组件以及日志组件、OCR功能模块包括OCR Jsbridge组件以及OCR组件。The independent functional module layer: includes a plurality of the native functional components. Each functional module includes a native functional component and a Jsbridge component that matches the native functional component. It should be noted that not all native functional components may have them. Its matching Jsbridge component, some native functional components that cannot be called by the front-end framework do not need to set the corresponding Jsbridge component, as shown in Figure 1, the face brushing function module includes the face brushing Jsbridge component and the face brushing component, and the log function module includes Log Jsbridge component and log component, OCR function module include OCR Jsbridge component and OCR component.

具体地,在本申请实施例中,所述容器层,用于通过多个所述前端框架中的目标前端框架获取目标调用请求,所述目标调用请求包括目标Jsbridge标识以及目标调用信息;所述中间调用层,用于根据所述注册表从多个所述Jsbridge组件中确定与所述目标Jsbridge标识对应的目标Jsbridge组件;所述独立功能模块层,用于通过所述目标Jsbridge组件将所述目标调用信息发送给目标原生功能组件,所述目标原生功能组件与所述目标Jsbridge组件位于同一功能模块内;通过所述目标原生功能组件生成所述目标调用信息的目标响应信息;通过所述目标Jsbridge组件将所述目标响应信息返回给所述目标前端框架。Specifically, in this embodiment of the application, the container layer is used to obtain a target call request through a target front-end framework in multiple front-end frameworks, and the target call request includes a target Jsbridge identification and target call information; The intermediate calling layer is used to determine the target Jsbridge component corresponding to the target Jsbridge identifier from a plurality of the Jsbridge components according to the registration table; the independent function module layer is used to transfer the target Jsbridge component to the target Jsbridge component through the target Jsbridge component. The target call information is sent to the target native function component, and the target native function component and the target Jsbridge component are located in the same functional module; the target response information of the target call information is generated through the target native function component; through the target The Jsbridge component returns the target response information to the target front-end framework.

图2是本申请实施例提供的原生功能组件的调用方法的流程示意图。如图2所示,该方法包括以下步骤S110-S150。Figure 2 is a schematic flowchart of the calling method of the native functional component provided by the embodiment of the present application. As shown in Figure 2, the method includes the following steps S110-S150.

S110、通过预设的目标前端框架获取目标调用请求,所述目标调用请求包括目标Jsbridge标识以及目标调用信息。S110. Obtain the target call request through the preset target front-end framework, where the target call request includes the target Jsbridge identifier and target call information.

本实施例中,所述目标前端框架为多个所述前端框架中目标页面对应的页面框架,所述目标页面为所述电子设备当前显示的页面,所述目标页面中包括至少一个所述原生功能组件的调用控件;所述通过预设的目标前端框架获取目标调用请求,包括:In this embodiment, the target front-end frame is a page frame corresponding to a target page in multiple front-end frames, the target page is a page currently displayed by the electronic device, and the target page includes at least one of the native The calling control of functional components; obtaining the target calling request through the preset target front-end framework includes:

接收用户针对至少一个所述调用控件中目标调用控件的调用操作,所述目标调用控件为至少一个所述调用控件中用于调用所述目标原生功能组件的调用控件;基于所述调用操作获取所述目标调用信息,并根据与所述目标调用控件绑定的所述目标Jsbridge标识以及所述目标调用信息生成所述目标调用请求。Receive a user's calling operation for a target calling control in at least one of the calling controls, where the target calling control is a calling control used to call the target native functional component in at least one of the calling controls; obtain the call operation based on the calling operation The target call information is generated, and the target call request is generated according to the target Jsbridge identifier bound to the target call control and the target call information.

例如,用户通过电子设备打开目标APP,并进入目标APP的某一页面(目标页面),此时,电子设备显示目标页面,该目标页面基于目标前端框架(如webview业务框架)展示,并且该目标页面中显示有至少一个所述原生功能组件的调用控件,不同的调用控件绑定有对应功能的Jsbridge组件的Jsbridge标识;然后用户点击目标页面中的目标调用控件,电子设备展示调用信息获取界面,该调用信息获取界面用于获取目标调用信息,然后基于该调用信息获取界面获取目标调用信息,最后基于获取到的目标调用信息以及对应的目标Jsbridge标识生成目标调用请求。For example, the user opens the target APP through an electronic device and enters a certain page (target page) of the target APP. At this time, the electronic device displays the target page. The target page is displayed based on the target front-end framework (such as the webview business framework), and the target The page displays at least one call control of the native functional component, and different call controls are bound to the Jsbridge logo of the Jsbridge component with the corresponding function; then the user clicks the target call control in the target page, and the electronic device displays the call information acquisition interface. The call information acquisition interface is used to obtain the target call information, then obtain the target call information based on the call information acquisition interface, and finally generate a target call request based on the obtained target call information and the corresponding target Jsbridge identification.

其中,该目标调用信息即需要发送给目标原生功能组件处理的信息,例如,用户输入的需要进行OCR识别的待识别图片,此时,对应的目标原生功能组件为OCR组件,用户需要上传待识别图片至调用信息获取界面。其中,Jsbridge标识具体可以为对应Jsbridge组件的Jsbridge名称。Among them, the target call information is the information that needs to be sent to the target native functional component for processing. For example, the user inputs an image to be recognized that needs to be OCR recognized. At this time, the corresponding target native functional component is an OCR component, and the user needs to upload the image to be recognized. Picture to call the information acquisition interface. Specifically, the Jsbridge identifier may be the Jsbridge name corresponding to the Jsbridge component.

S120、从多个所述Jsbridge组件中确定与所述目标Jsbridge标识对应的目标Jsbridge组件。S120. Determine the target Jsbridge component corresponding to the target Jsbridge identifier from the plurality of Jsbridge components.

在一些实施例中,所述原生功能组件调用框架还包括注册表,所述注册表中包括各所述Jsbridge组件的Jsbridge标识与调用代码之间的映射关系,步骤S120包括:从所述注册表中确定与所述目标Jsbridge标识对应的目标调用代码;基于所述调用代码,从多个所述Jsbridge组件中反射调用所述目标Jsbridge组件。In some embodiments, the native functional component calling framework also includes a registry, which includes a mapping relationship between the Jsbridge identifier of each Jsbridge component and the calling code. Step S120 includes: Determine the target calling code corresponding to the target Jsbridge identifier; based on the calling code, reflectively call the target Jsbridge component from a plurality of the Jsbridge components.

例如,当通过图1容器层中的承载有webview业务框架的webview容器获取到目标调用请求时,Bridge层通过与webview容器连接的webEvent获取该目标调用请求,该目标调用请求为json格式的数据,通过解析该目标调用请求可得到目标Jsbridge标识以及目标调用信息,然后使用该目标Jsbridge标识在注册表中匹配,如果匹配到对应的Jsbridge标识,则将匹配到的Jsbridge标识对应的调用代码确定为目标调用代码,然后再基于该目标调用代码通过反射去调用目标Jsbridge组件,即调用目标Jsbridge标识的实体类。For example, when the target call request is obtained through the webview container carrying the webview business framework in the container layer in Figure 1, the Bridge layer obtains the target call request through the webEvent connected to the webview container. The target call request is data in json format. By parsing the target call request, the target Jsbridge ID and target call information can be obtained, and then the target Jsbridge ID is used to match in the registry. If the corresponding Jsbridge ID is matched, the calling code corresponding to the matched Jsbridge ID is determined as the target. Call the code, and then call the target Jsbridge component through reflection based on the target call code, that is, call the entity class identified by the target Jsbridge.

可见,本实施例可以通过在Bridge层放置注册表,然后基于注册表中的Jsbridge标识以及对应的调用代码去反射调用Jsbridge组件,不需要直接调用Jsbridge组件,从而实现了Bridge层与Jsbridge组件之间的解耦。It can be seen that this embodiment can realize the connection between the Bridge layer and the Jsbridge component by placing a registry in the Bridge layer, and then reflectively calling the Jsbridge component based on the Jsbridge identifier and the corresponding calling code in the registry without directly calling the Jsbridge component. of decoupling.

需要说明的是,在执行步骤S120之前,首先需要确定所述注册表中是否存在所述目标Jsbridge标识;当确定注册表中存在所述目标Jsbridge标识时,才执行步骤S120,若注册表中不存在该目标Jsbridge标识,则需要向所述目标前端框架返回调用失败信息。It should be noted that before executing step S120, it is first necessary to determine whether the target Jsbridge identifier exists in the registry; when it is determined that the target Jsbridge identifier exists in the registry, step S120 is executed. If the target Jsbridge identifier does not exist in the registry, If the target Jsbridge identifier exists, the call failure information needs to be returned to the target front-end framework.

S130、通过所述目标Jsbridge组件将所述目标调用信息发送给目标原生功能组件,所述目标原生功能组件与所述目标Jsbridge组件位于同一功能模块内。S130. Send the target calling information to the target native functional component through the target Jsbridge component. The target native functional component and the target Jsbridge component are located in the same functional module.

本实施例中,确定了目标Jsbridge组件之后,通过该目标Jsbridge组件将目标调用信息发送给与该目标Jsbridge组件位于同一功能模块内的目标原生功能组件。In this embodiment, after the target Jsbridge component is determined, the target calling information is sent to the target native functional component located in the same functional module as the target Jsbridge component through the target Jsbridge component.

例如,通过调用OCR Jsbridge组件将待识别图片发送给目标原生功能组件。For example, by calling the OCR Jsbridge component, the image to be recognized is sent to the target native functional component.

S140、通过所述目标原生功能组件生成所述目标调用信息的目标响应信息。S140. Generate target response information of the target call information through the target native functional component.

本实施例中,当目标原生功能组件收到目标调用信息之后,将对该目标调用信息进行处理,并生成处理结果,该处理结果即该目标响应信息。In this embodiment, after the target native function component receives the target call information, it will process the target call information and generate a processing result, which is the target response information.

例如,OCR组件获取到待识别图片之后,对该待识别图片进行OCR识别处理,并生成识别结果。For example, after the OCR component obtains the image to be recognized, it performs OCR recognition processing on the image to be recognized and generates a recognition result.

S150、通过所述目标Jsbridge组件将所述目标响应信息返回给所述目标前端框架。S150. Return the target response information to the target front-end framework through the target Jsbridge component.

本实施例中,当目标原生功能组件生成所述目标调用信息的目标响应信息之后,会通过目标Jsbridge组件将该目标响应信息返回给所述目标前端框架。In this embodiment, after the target native functional component generates the target response information of the target call information, the target response information is returned to the target front-end framework through the target Jsbridge component.

例如,OCR组件通过OCR Jsbridge组件将识别结果返回给目标前端框架,此时,电子设备会基于该目标前端框架显示识别结果,使得用户获取到识别结果。For example, the OCR component returns the recognition result to the target front-end framework through the OCR Jsbridge component. At this time, the electronic device displays the recognition result based on the target front-end framework, so that the user can obtain the recognition result.

需要说明的是,本实施例中的Jsbridge组件在开发阶段便根据不同的功能进行了细分,以下对目标APP的开发阶段进行描述:It should be noted that the Jsbridge component in this embodiment is subdivided according to different functions during the development stage. The development stage of the target APP is described below:

由于不同的APP所需调用的原生功能组件不同,为了使得不同的APP快速接入所需的Jsbridge功能,在开发之前,首选需要按照调用功能将原来耦合在一起的Jsbridge细分成多个Jsbridge组件,即把不同功能Jsbridge独立出来,单独封装在一组件中。Since different APPs need to call different native functional components, in order to allow different APPs to quickly access the required Jsbridge functions, before development, it is first necessary to subdivide the original coupled Jsbridge into multiple Jsbridge components according to the calling functions. , that is, separate Jsbridge with different functions and encapsulate them in one component.

在开发阶段中,对应Jsbridge组件接入可以在gradle脚本中通过一行类似“implementation'com.xxx.component:face:1.0.2”这样的引入代码完成Jsbridge组件的引入;Jsbridge组件的移除则是移除gradle脚本中的“implementation'com.xxx.component:face:1.0.2”这行代码即可。In the development stage, corresponding to the Jsbridge component access, the introduction of the Jsbridge component can be completed in the gradle script through a line of introduction code similar to "implementation'com.xxx.component:face:1.0.2"; the removal of the Jsbridge component is Just remove the "implementation'com.xxx.component:face:1.0.2" line of code in the gradle script.

可见,在APP的开发阶段中,Jsbridge组件的接入以及移除非常方便,从而提高了开发效率。It can be seen that during the development stage of APP, the access and removal of Jsbridge components is very convenient, thus improving development efficiency.

这样,在电子设备中安装对应的APP时,APP的编码阶段,Jsbridge代码中会实现一个指定接口的指定方法也就是该Jsbridge的注册方法,这个指定接口和方法会配置在编译脚本中。在APP编译阶段:在编译过程中字节码插桩库会依据编译脚本中的配置将这些Jsbridge注册方法的调用代码插入到指定的注册方法中如命名为“initEvent”。APP启动阶段:在APP启动过程中调用“initEvent”,就相当于调用了这些Jsbridge的注册方法。In this way, when the corresponding APP is installed in an electronic device, during the coding phase of the APP, the Jsbridge code will implement a specified method of a specified interface, which is the registration method of the Jsbridge. This specified interface and method will be configured in the compilation script. During the APP compilation phase: During the compilation process, the bytecode instrumentation library will insert the calling code of these Jsbridge registration methods into the specified registration method according to the configuration in the compilation script, such as named "initEvent". APP startup phase: Calling "initEvent" during the APP startup process is equivalent to calling these Jsbridge registration methods.

具体地,APP通过注册方法会将Jsbridge信息添加到注册表中,这样在APP运行过程中就知道了本APP接入了哪些Jsbridge。注册表是一个键值对的数据格式,即Jsbridge名和实现类(调用代码)对应。这样就完成了Jsbridge的注册。这样注册的目的就是解耦,即接入方APP不直接调用Jsbridge中的类及方法。Specifically, the APP will add Jsbridge information to the registry through the registration method, so that when the APP is running, it will know which Jsbridges the APP is connected to. The registry is a key-value pair data format, that is, the Jsbridge name corresponds to the implementation class (calling code). This completes the Jsbridge registration. The purpose of such registration is decoupling, that is, the accessing APP does not directly call the classes and methods in Jsbridge.

综上所述,第一方面,本申请实施例电子设备中的Jsbridge组件为根据调用能力拆分后的Jsbridge组件,解耦了不同调用能力的Jsbridge组件,当有Jsbridge故障时,可以更快地找到故障的Jsbridge组件,提高了Jsbridge组件的维护效率;第二方面,根据调用能力对Jsbridge组件进行细分,可以便于开发人员对Jsbridge组件的使用,从而提高开发效率;第三方面,将细分后的Jsbridge组件与电子设备中对应的原生功能组件绑定,避免载入电子设备中没有的原生功能组件的Jsbridge组件,即避免接入不需要的Jsbridge组件,从而减少了电子设备中的冗余代码。To sum up, in the first aspect, the Jsbridge component in the electronic device of the embodiment of the present application is a Jsbridge component split according to the calling capabilities, which decouples the Jsbridge components with different calling capabilities. When there is a Jsbridge failure, the Jsbridge component can be processed more quickly. Finding faulty Jsbridge components improves the maintenance efficiency of Jsbridge components; secondly, subdividing Jsbridge components according to their calling capabilities can facilitate developers to use Jsbridge components, thereby improving development efficiency; thirdly, subdividing Jsbridge components The final Jsbridge component is bound to the corresponding native functional component in the electronic device to avoid loading the Jsbridge component of the native functional component that is not found in the electronic device, that is, to avoid accessing unnecessary Jsbridge components, thereby reducing redundancy in the electronic device. code.

本申请还提供一种原生功能组件调用框架,所述原生功能组件调用框架部署在电子设备中,所述原生功能组件调用框架包括容器层、中间调用层以及独立功能模块层,所述容器层包括多个业务框架容器,不同的业务框架容器承载有不同类型的前端框架,所述中间调用层包括各所述业务框架容器分别对应的调用入口以及注册表,所述独立功能模块层包括多个功能模块,各所述功能模块均包括原生功能组件以及与所述原生功能组件匹配的Jsbridge组件,其中:This application also provides a native functional component calling framework, which is deployed in an electronic device. The native functional component calling framework includes a container layer, an intermediate calling layer and an independent function module layer. The container layer includes Multiple business framework containers. Different business framework containers carry different types of front-end frameworks. The intermediate call layer includes call entrances and registration tables corresponding to each business frame container. The independent function module layer includes multiple functions. Modules, each of the functional modules includes native functional components and Jsbridge components matching the native functional components, where:

所述容器层,用于通过多个所述前端框架中的目标前端框架获取目标调用请求,所述目标调用请求包括目标Jsbridge标识以及目标调用信息;The container layer is used to obtain a target call request through a target front-end framework in multiple front-end frameworks, where the target call request includes a target Jsbridge identifier and target call information;

所述中间调用层,用于根据所述注册表从多个所述Jsbridge组件中确定与所述目标Jsbridge标识对应的目标Jsbridge组件;The intermediate calling layer is used to determine the target Jsbridge component corresponding to the target Jsbridge identifier from a plurality of the Jsbridge components according to the registration table;

所述独立功能模块层,用于通过所述目标Jsbridge组件将所述目标调用信息发送给目标原生功能组件,所述目标原生功能组件与所述目标Jsbridge组件位于同一功能模块内;通过所述目标原生功能组件生成所述目标调用信息的目标响应信息;通过所述目标Jsbridge组件将所述目标响应信息返回给所述目标前端框架。The independent function module layer is used to send the target call information to the target native function component through the target Jsbridge component, and the target native function component and the target Jsbridge component are located in the same functional module; through the target The native functional component generates target response information of the target call information; and returns the target response information to the target front-end framework through the target Jsbridge component.

在一些实施例中,所述注册表中包括各所述Jsbridge组件的Jsbridge标识与调用代码之间的映射关系,所述中间调用层在执行所述从多个所述Jsbridge组件中确定与所述目标Jsbridge标识对应的目标Jsbridge组件步骤时,具体用于:In some embodiments, the registration table includes a mapping relationship between the Jsbridge identifier of each Jsbridge component and the calling code, and the intermediate calling layer determines the relationship between the Jsbridge component and the Jsbridge component when executing the When the target Jsbridge identifies the corresponding target Jsbridge component step, it is specifically used for:

从所述注册表中确定与所述目标Jsbridge标识对应的目标调用代码;基于所述调用代码,从多个所述Jsbridge组件中反射调用所述目标Jsbridge组件。The target calling code corresponding to the target Jsbridge identifier is determined from the registry; based on the calling code, the target Jsbridge component is reflectively called from a plurality of the Jsbridge components.

在一些实施例中,所述目标前端框架为多个所述前端框架中目标页面对应的页面框架,所述目标页面为所述电子设备当前显示的页面,所述目标页面中包括至少一个所述原生功能组件的调用控件;所述容器层在执行所述通过预设的目标前端框架获取目标调用请求步骤时,具体用于:In some embodiments, the target front-end frame is a page frame corresponding to a target page in multiple front-end frames, the target page is a page currently displayed by the electronic device, and the target page includes at least one of the The calling control of the native functional component; when the container layer executes the step of obtaining the target calling request through the preset target front-end framework, it is specifically used to:

接收用户针对目标调用控件的调用操作,所述目标调用控件为至少一个所述调用控件中用于调用所述目标原生功能组件的调用控件;基于所述调用操作获取所述目标调用信息,并根据与所述目标调用控件绑定的所述目标Jsbridge标识以及所述目标调用信息生成所述目标调用请求。Receive the user's calling operation for the target calling control, which is the calling control used to call the target native functional component in at least one of the calling controls; obtain the target calling information based on the calling operation, and according to The target Jsbridge identifier bound to the target call control and the target call information generate the target call request.

在一些实施例中,所述业务框架容器中的前端框架包括webview业务框架、weex业务框架或flutter业务框架。In some embodiments, the front-end framework in the business framework container includes a webview business framework, a weex business framework or a flutter business framework.

在一些实施例中,所述中间调用层在执行所述从所述注册表中确定与所述目标Jsbridge标识对应的目标调用代码件步骤之前,还用于:In some embodiments, before executing the step of determining the target calling code corresponding to the target Jsbridge identifier from the registry, the intermediate calling layer is also used to:

确定所述注册表中是否存在所述目标Jsbridge标识;Determine whether the target Jsbridge identifier exists in the registry;

此时,所述中间调用层在执行所述从所述注册表中确定与所述目标Jsbridge标识对应的目标调用代码步骤时,具体用于:At this time, when the intermediate calling layer executes the step of determining the target calling code corresponding to the target Jsbridge identifier from the registry, it is specifically used to:

若所述注册表中存在所述目标Jsbridge标识,则将所述注册表中与所述目标Jsbridge标识对应的调用代码确定为所述目标调用代码。If the target Jsbridge identifier exists in the registry, the calling code corresponding to the target Jsbridge identifier in the registry is determined as the target calling code.

在一些实施例中,所述中间调用层在执行所述确定所述注册表中是否存在所述目标Jsbridge标识步骤之后,还用于:In some embodiments, after performing the step of determining whether the target Jsbridge identification exists in the registry, the intermediate calling layer is also used to:

若所述预设的注册表中不存在所述目标Jsbridge标识,则向所述目标前端框架返回调用失败信息。If the target Jsbridge identifier does not exist in the preset registry, a call failure message is returned to the target front-end framework.

综上所述,第一方面,本申请实施例原生功能组件调用框架中的Jsbridge组件为根据调用能力拆分后的Jsbridge组件,解耦了不同调用能力的Jsbridge组件,当有Jsbridge故障时,可以更快地找到故障的Jsbridge组件,提高了Jsbridge组件的维护效率;第二方面,根据调用能力对Jsbridge组件进行细分,可以便于开发人员对Jsbridge组件的使用,从而提高开发效率;第三方面,将细分后的Jsbridge组件与电子设备中对应的原生功能组件绑定,避免载入电子设备中没有的原生功能组件的Jsbridge组件,即避免接入不需要的Jsbridge组件,从而减少了电子设备中的冗余代码。To sum up, in the first aspect, the Jsbridge component in the native functional component calling framework of the embodiment of the present application is a Jsbridge component split according to the calling capabilities, which decouples the Jsbridge components with different calling capabilities. When there is a Jsbridge failure, you can Finding faulty Jsbridge components faster improves the maintenance efficiency of Jsbridge components; secondly, subdividing Jsbridge components according to their calling capabilities can facilitate developers to use Jsbridge components, thereby improving development efficiency; thirdly, Bind the subdivided Jsbridge components to the corresponding native functional components in the electronic device to avoid loading Jsbridge components that do not have native functional components in the electronic device, that is, to avoid accessing unnecessary Jsbridge components, thus reducing the number of components in the electronic device. redundant code.

需要说明的是,所属领域的技术人员可以清楚地了解到,上述原生功能组件的调用装置和各单元的具体实现过程,可以参考前述方法实施例中的相应描述,为了描述的方便和简洁,在此不再赘述。It should be noted that those skilled in the art can clearly understand that the calling device of the above-mentioned native functional components and the specific implementation process of each unit can refer to the corresponding descriptions in the foregoing method embodiments. For the convenience and simplicity of description, in This will not be described again.

上述原生功能组件的调用装置可以实现为一种计算机程序的形式,该计算机程序可以在如图3所示的电子设备上运行。The above-mentioned calling device of the native functional component can be implemented in the form of a computer program, and the computer program can be run on the electronic device as shown in Figure 3.

请参阅图3,图3是本申请实施例提供的一种电子设备的示意性框图。该电子设备300可以是终端,其中,终端可以是智能手机、平板电脑、笔记本电脑、台式电脑、个人数字助理和穿戴式设备等具有通信功能和原生功能组件的电子设备。其中,所述电子设备中部署有原生功能组件调用框架,原生功能组件调用框架包括多个功能模块,各所述功能模块均包括原生功能组件以及与所述原生功能组件匹配的Jsbridge组件。Please refer to FIG. 3 , which is a schematic block diagram of an electronic device provided by an embodiment of the present application. The electronic device 300 may be a terminal, where the terminal may be an electronic device with communication functions and native functional components, such as a smartphone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, a wearable device, etc. Wherein, a native functional component calling framework is deployed in the electronic device. The native functional component calling framework includes a plurality of functional modules, and each of the functional modules includes a native functional component and a Jsbridge component matching the native functional component.

参阅图3,该电子设备300包括通过系统总线301连接的处理器302、存储器和网络接口305,其中,存储器可以包括非易失性存储介质303和内存储器304。Referring to FIG. 3 , the electronic device 300 includes a processor 302 , a memory, and a network interface 305 connected through a system bus 301 , where the memory may include a nonvolatile storage medium 303 and an internal memory 304 .

该非易失性存储介质303可存储操作系统3031和计算机程序3032。该计算机程序3032包括程序指令,该程序指令被执行时,可使得处理器302执行一种原生功能组件的调用方法。The non-volatile storage medium 303 can store an operating system 3031 and a computer program 3032. The computer program 3032 includes program instructions that, when executed, can cause the processor 302 to execute a calling method of a native functional component.

该处理器302用于提供计算和控制能力,以支撑整个电子设备300的运行。The processor 302 is used to provide computing and control capabilities to support the operation of the entire electronic device 300 .

该内存储器304为非易失性存储介质303中的计算机程序3032的运行提供环境,该计算机程序3032被处理器302执行时,可使得处理器302执行一种原生功能组件的调用方法。The internal memory 304 provides an environment for the execution of the computer program 3032 in the non-volatile storage medium 303. When the computer program 3032 is executed by the processor 302, it can cause the processor 302 to execute a calling method of native functional components.

该网络接口305用于与其它设备进行网络通信。本领域技术人员可以理解,图3中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的电子设备300的限定,具体的电子设备300可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。The network interface 305 is used for network communication with other devices. Those skilled in the art can understand that the structure shown in Figure 3 is only a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the electronic device 300 to which the solution of the present application is applied. Specific electronic devices 300 may include more or fewer components than shown, some combinations of components, or a different arrangement of components.

其中,所述处理器302用于运行存储在存储器中的计算机程序3032,以实现如下步骤:Wherein, the processor 302 is used to run the computer program 3032 stored in the memory to implement the following steps:

通过预设的目标前端框架获取目标调用请求,所述目标调用请求包括目标Jsbridge标识以及目标调用信息;Obtain the target call request through the preset target front-end framework, and the target call request includes the target Jsbridge identification and target call information;

从多个所述Jsbridge组件中确定与所述目标Jsbridge标识对应的目标Jsbridge组件;Determine the target Jsbridge component corresponding to the target Jsbridge identifier from a plurality of the Jsbridge components;

通过所述目标Jsbridge组件将所述目标调用信息发送给目标原生功能组件,所述目标原生功能组件与所述目标Jsbridge组件位于同一功能模块内;Send the target calling information to the target native functional component through the target Jsbridge component, and the target native functional component and the target Jsbridge component are located in the same functional module;

通过所述目标原生功能组件生成所述目标调用信息的目标响应信息;Generate target response information of the target call information through the target native functional component;

通过所述目标Jsbridge组件将所述目标响应信息返回给所述目标前端框架。The target response information is returned to the target front-end framework through the target Jsbridge component.

应当理解,在本申请实施例中,处理器302可以是中央处理单元(CentralProcessing Unit,CPU),该处理器302还可以是其他通用处理器、数字信号处理器(DigitalSignal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that in this embodiment of the present application, the processor 302 may be a central processing unit (Central Processing Unit, CPU). The processor 302 may also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), dedicated integrated processors, etc. Circuit (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general processor may be a microprocessor or the processor may be any conventional processor.

本领域普通技术人员可以理解的是实现上述实施例的方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成。该计算机程序包括程序指令,计算机程序可存储于一存储介质中,该存储介质为计算机可读存储介质。该程序指令被该计算机系统中的至少一个处理器执行,以实现上述方法的实施例的流程步骤。Those of ordinary skill in the art can understand that all or part of the processes in the methods of implementing the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, and the storage medium is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above method.

因此,本申请还提供一种存储介质。该存储介质可以为计算机可读存储介质。该存储介质存储有计算机程序,其中计算机程序包括程序指令。该程序指令被处理器执行时使处理器执行如下步骤:Therefore, this application also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, where the computer program includes program instructions. When executed by the processor, the program instructions cause the processor to perform the following steps:

通过预设的目标前端框架获取目标调用请求,所述目标调用请求包括目标Jsbridge标识以及目标调用信息;Obtain the target call request through the preset target front-end framework, and the target call request includes the target Jsbridge identification and target call information;

从多个所述Jsbridge组件中确定与所述目标Jsbridge标识对应的目标Jsbridge组件;Determine the target Jsbridge component corresponding to the target Jsbridge identifier from a plurality of the Jsbridge components;

通过所述目标Jsbridge组件将所述目标调用信息发送给目标原生功能组件,所述目标原生功能组件与所述目标Jsbridge组件位于同一功能模块内;Send the target calling information to the target native functional component through the target Jsbridge component, and the target native functional component and the target Jsbridge component are located in the same functional module;

通过所述目标原生功能组件生成所述目标调用信息的目标响应信息;Generate target response information of the target call information through the target native functional component;

通过所述目标Jsbridge组件将所述目标响应信息返回给所述目标前端框架。The target response information is returned to the target front-end framework through the target Jsbridge component.

所述存储介质可以是U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的计算机可读存储介质。The storage medium may be a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a magnetic disk or an optical disk, and other computer-readable storage media that can store program codes.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art can appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of both. In order to clearly illustrate the relationship between hardware and software Interchangeability, in the above description, the composition and steps of each example have been generally described according to functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each specific application, but such implementations should not be considered beyond the scope of this application.

在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的。例如,各个单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of each unit is only a logical function division, and there may be other division methods during actual implementation. For example multiple units or components may be combined or integrated into another system, or some features may be omitted, or not implemented.

本申请实施例方法中的步骤可以根据实际需要进行顺序调整、合并和删减。本申请实施例装置中的单元可以根据实际需要进行合并、划分和删减。另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以是两个或两个以上单元集成在一个单元中。The steps in the methods of the embodiments of this application can be sequence adjusted, combined, and deleted according to actual needs. The units in the device of the embodiment of the present application can be merged, divided, and deleted according to actual needs. In addition, each functional unit in various embodiments of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.

该集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分,或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台电子设备(可以是个人计算机,终端,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present application is essentially or contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to cause an electronic device (which may be a personal computer, terminal, or network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application.

以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。The above are only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person familiar with the technical field can easily think of various equivalent methods within the technical scope disclosed in the present application. Modification or replacement, these modifications or replacements shall be covered by the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.

Claims (10)

1.一种原生功能组件的调用方法,其特征在于,所述方法应用于电子设备的原生功能组件调用框架,所述原生功能组件调用框架包括多个功能模块,各所述功能模块均包括原生功能组件以及与所述原生功能组件匹配的Jsbridge组件,所述方法包括:1. A method of calling native functional components, characterized in that the method is applied to a native functional component calling framework of an electronic device, and the native functional component calling framework includes a plurality of functional modules, each of which includes a native functional component. Functional components and Jsbridge components matching the native functional components, the method includes: 通过预设的目标前端框架获取目标调用请求,所述目标调用请求包括目标Jsbridge标识以及目标调用信息;Obtain the target call request through the preset target front-end framework, and the target call request includes the target Jsbridge identification and target call information; 从多个所述Jsbridge组件中确定与所述目标Jsbridge标识对应的目标Jsbridge组件;Determine the target Jsbridge component corresponding to the target Jsbridge identifier from a plurality of the Jsbridge components; 通过所述目标Jsbridge组件将所述目标调用信息发送给目标原生功能组件,所述目标原生功能组件与所述目标Jsbridge组件位于同一功能模块内;Send the target calling information to the target native functional component through the target Jsbridge component, and the target native functional component and the target Jsbridge component are located in the same functional module; 通过所述目标原生功能组件生成所述目标调用信息的目标响应信息;Generate target response information of the target call information through the target native functional component; 通过所述目标Jsbridge组件将所述目标响应信息返回给所述目标前端框架。The target response information is returned to the target front-end framework through the target Jsbridge component. 2.根据权利要求1所述的方法,其特征在于,所述原生功能组件调用框架还包括注册表,所述注册表中包括各所述Jsbridge组件的Jsbridge标识与调用代码之间的映射关系;所述从多个所述Jsbridge组件中确定与所述目标Jsbridge标识对应的目标Jsbridge组件,包括:2. The method according to claim 1, characterized in that the native function component calling framework further includes a registry, and the registry includes a mapping relationship between the Jsbridge identifier of each Jsbridge component and the calling code; Determining the target Jsbridge component corresponding to the target Jsbridge identifier from the plurality of Jsbridge components includes: 从所述注册表中确定与所述目标Jsbridge标识对应的目标调用代码;Determine the target calling code corresponding to the target Jsbridge identifier from the registry; 基于所述目标调用代码,从多个所述Jsbridge组件中反射调用所述目标Jsbridge组件。Based on the target calling code, the target Jsbridge component is reflectively called from a plurality of the Jsbridge components. 3.根据权利要求2所述的方法,其特征在于,所述原生功能组件调用框架包括容器层、中间调用层以及独立功能模块层,所述容器层包括多个业务框架容器,不同的业务框架容器承载有不同类型的前端框架,所述中间调用层包括各所述业务框架容器分别对应的调用入口以及所述注册表,所述独立功能模块层包括多个所述功能模块。3. The method according to claim 2, characterized in that the native functional component calling framework includes a container layer, an intermediate calling layer and an independent function module layer, and the container layer includes multiple business framework containers, and different business frameworks Containers carry different types of front-end frameworks. The intermediate call layer includes call entrances and the registration table corresponding to each business framework container. The independent function module layer includes a plurality of the function modules. 4.根据权利要求3所述的方法,其特征在于,所述目标前端框架为多个所述前端框架中目标页面对应的页面框架,所述目标页面为所述电子设备当前显示的页面,所述目标页面中包括至少一个所述原生功能组件的调用控件;所述通过预设的目标前端框架获取目标调用请求,包括:4. The method according to claim 3, wherein the target front-end frame is a page frame corresponding to a target page in a plurality of the front-end frames, and the target page is a page currently displayed by the electronic device, so The target page includes at least one call control of the native functional component; the obtaining the target call request through the preset target front-end framework includes: 接收用户针对目标调用控件的调用操作,所述目标调用控件为至少一个所述调用控件中用于调用所述目标原生功能组件的调用控件;Receive a user's calling operation for a target calling control, which is a calling control used to call the target native functional component in at least one of the calling controls; 基于所述调用操作获取所述目标调用信息,并根据与所述目标调用控件绑定的所述目标Jsbridge标识以及所述目标调用信息生成所述目标调用请求。The target calling information is obtained based on the calling operation, and the target calling request is generated according to the target Jsbridge identifier bound to the target calling control and the target calling information. 5.根据权利要求3所述的方法,其特征在于,所述业务框架容器中的前端框架包括webview业务框架、weex业务框架或flutter业务框架。5. The method according to claim 3, characterized in that the front-end framework in the business framework container includes a webview business framework, a weex business framework or a flutter business framework. 6.根据权利要求2所述的方法,其特征在于,所述从所述注册表中确定与所述目标Jsbridge标识对应的目标调用代码之前,所述方法还包括:6. The method according to claim 2, characterized in that, before determining the target calling code corresponding to the target Jsbridge identifier from the registry, the method further includes: 确定所述注册表中是否存在所述目标Jsbridge标识;Determine whether the target Jsbridge identifier exists in the registry; 所述从所述注册表中确定与所述目标Jsbridge标识对应的目标调用代码,包括:Determining the target calling code corresponding to the target Jsbridge identifier from the registry includes: 若所述注册表中存在所述目标Jsbridge标识,则将所述注册表中与所述目标Jsbridge标识对应的调用代码确定为所述目标调用代码。If the target Jsbridge identifier exists in the registry, the calling code corresponding to the target Jsbridge identifier in the registry is determined as the target calling code. 7.根据权利要求6所述的方法,其特征在于,所述确定所述注册表中是否存在所述目标Jsbridge标识之后,所述方法还包括:7. The method according to claim 6, wherein after determining whether the target Jsbridge identifier exists in the registry, the method further includes: 若所述预设的注册表中不存在所述目标Jsbridge标识,则向所述目标前端框架返回调用失败信息。If the target Jsbridge identifier does not exist in the preset registry, a call failure message is returned to the target front-end framework. 8.一种原生功能组件调用框架,其特征在于,所述原生功能组件调用框架部署在电子设备中,所述原生功能组件调用框架包括容器层、中间调用层以及独立功能模块层,所述容器层包括多个业务框架容器,不同的业务框架容器承载有不同类型的前端框架,所述中间调用层包括各所述业务框架容器分别对应的调用入口以及注册表,所述独立功能模块层包括多个功能模块,各所述功能模块均包括原生功能组件以及与所述原生功能组件匹配的Jsbridge组件,其中:8. A native functional component calling framework, characterized in that the native functional component calling framework is deployed in an electronic device, and the native functional component calling framework includes a container layer, an intermediate calling layer and an independent functional module layer, and the container The layer includes multiple business framework containers, and different business frame containers carry different types of front-end frameworks. The intermediate call layer includes call entrances and registration tables corresponding to each of the business frame containers. The independent function module layer includes multiple Each functional module includes a native functional component and a Jsbridge component matching the native functional component, where: 所述容器层,用于通过多个所述前端框架中的目标前端框架获取目标调用请求,所述目标调用请求包括目标Jsbridge标识以及目标调用信息;The container layer is used to obtain a target call request through a target front-end framework in multiple front-end frameworks, where the target call request includes a target Jsbridge identifier and target call information; 所述中间调用层,用于根据所述注册表从多个所述Jsbridge组件中确定与所述目标Jsbridge标识对应的目标Jsbridge组件;The intermediate calling layer is used to determine the target Jsbridge component corresponding to the target Jsbridge identifier from a plurality of the Jsbridge components according to the registration table; 所述独立功能模块层,用于通过所述目标Jsbridge组件将所述目标调用信息发送给目标原生功能组件,所述目标原生功能组件与所述目标Jsbridge组件位于同一功能模块内;通过所述目标原生功能组件生成所述目标调用信息的目标响应信息;通过所述目标Jsbridge组件将所述目标响应信息返回给所述目标前端框架。The independent function module layer is used to send the target call information to the target native function component through the target Jsbridge component, and the target native function component and the target Jsbridge component are located in the same functional module; through the target The native functional component generates target response information of the target call information; and returns the target response information to the target front-end framework through the target Jsbridge component. 9.一种电子设备,所述电子设备中部署有原生功能组件调用框架,所述原生功能组件调用框架包括多个功能模块,各所述功能模块均包括原生功能组件以及与所述原生功能组件匹配的Jsbridge组件,所述电子设备包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,原生功能组件调用框架通过所述处理器执行所述计算机程序时实现如权利要求1-7中任一项所述的原生功能组件的调用方法。9. An electronic device. A native functional component calling framework is deployed in the electronic device. The native functional component calling framework includes a plurality of functional modules. Each of the functional modules includes a native functional component and a native functional component. Matching Jsbridge components, the electronic device includes a memory, a processor and a computer program stored on the memory and executable on the processor. The feature is that the native function component calling framework executes all operations through the processor. The computer program implements the calling method of the native functional component as described in any one of claims 1-7. 10.一种存储介质,其特征在于,所述存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求1-7任一项所述的原生功能组件的调用方法。10. A storage medium, characterized in that the storage medium stores a computer program, the computer program includes program instructions, and when executed by a processor, the program instructions cause the processor to execute claims 1-7 The calling method of any of the native functional components described above.
CN202311709208.6A 2023-12-12 2023-12-12 Calling method and device of native function component, electronic equipment and storage medium Pending CN117591106A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311709208.6A CN117591106A (en) 2023-12-12 2023-12-12 Calling method and device of native function component, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311709208.6A CN117591106A (en) 2023-12-12 2023-12-12 Calling method and device of native function component, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117591106A true CN117591106A (en) 2024-02-23

Family

ID=89920033

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311709208.6A Pending CN117591106A (en) 2023-12-12 2023-12-12 Calling method and device of native function component, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117591106A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119011686A (en) * 2024-10-25 2024-11-22 杭州菲助科技有限公司 Method and device for decoupling jsbridge and schema based on Hongmon webview container

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119011686A (en) * 2024-10-25 2024-11-22 杭州菲助科技有限公司 Method and device for decoupling jsbridge and schema based on Hongmon webview container

Similar Documents

Publication Publication Date Title
CN107729041B (en) Application program hot updating method, device, terminal and storage medium
US10263910B2 (en) Resource calling for hybrid applications
CN111290806B (en) Calling method and device of application program interface, computer equipment and storage medium
WO2019161619A1 (en) Automatic interface test method and apparatus, and device and computer-readable storage medium
CN113765982A (en) Request response method, device, system, server and storage medium
CN110162429A (en) System repair, server and storage medium
CN108647032A (en) Using loading method and device, computer installation and computer readable storage medium
CN112256672B (en) Database change approval method and device
CN117591106A (en) Calling method and device of native function component, electronic equipment and storage medium
CN113191889A (en) Wind control configuration method, configuration system, electronic device and readable storage medium
CN112434278A (en) Bare computer authentication method, apparatus, device and medium
CN114185804B (en) Interface testing method and device and terminal equipment
US11861214B2 (en) Memory device forensics and preparation
CN117539571A (en) Micro front-end application control method, device, equipment and storage medium
CN117251361A (en) Method, device, equipment and storage medium for testing system stability
CN116795548A (en) Interface processing method, device, system and storage medium based on multi-cloud management
CN116594874A (en) Operating environment usability testing method, device, computer equipment and storage medium
CN110085237B (en) Recovery method, device and equipment of interactive process
CN116149941A (en) Monitoring method, device, server and storage medium of server components
CN114816482A (en) Upgrading method, device, computer equipment and storage medium for block storage service
CN116302165A (en) Firmware support package trusted loading method, device, terminal and storage medium
CN111930626B (en) Automated testing method and device based on PaaS cloud service
CN112947948B (en) Deployment method and device of application service
CN116954991A (en) Data processing methods, devices, electronic equipment and readable storage media
CN110327626B (en) Virtual server creation method and device

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