Front-end communication method and system, electronic equipment, storage medium and program product

By creating a communication channel between native containers of different front-end frameworks, real-time communication between front-end frameworks is realized, the problem of low interface switching and update efficiency is solved, and development efficiency and fault tolerance is improved.

CN119003083APending Publication Date: 2024-11-22MIDEA GROUP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310578041.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-22
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

The lack of real-time communication methods between different front-end frameworks leads to low interface switching and update efficiency, affecting development efficiency.

Method used

By creating communication channels between native containers of different front-end frameworks, pre-loaded channel files and business files are used to achieve message delivery, ensuring real-time communication between different front-end frameworks.

Benefits of technology

It realizes smooth switching and updates between web interfaces made by different front-end frameworks, improves development efficiency, and improves the fault tolerance of native development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119003083A_ABST
    Figure CN119003083A_ABST
Patent Text Reader

Abstract

The invention relates to the field of communication, and provides a front-end communication method and system, electronic equipment, a storage medium and a program product. The method comprises the following steps: creating a communication channel between a first native container and a second native container by using a first channel file and a second channel file; the first native container and the second native container belong to different front end frames; and sending a message to the second service file through the communication channel by using the first service file. According to the method and the device, the message is sent from the service file of one front-end framework to the service file of another different front-end framework by using the communication channel, so that real-time communication among different front-end frameworks is realized, the realization and smoothness of switching and updating among web interfaces manufactured by adopting different front-end frameworks can be ensured, and the development efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communications, and in particular to a front-end communication method, system, electronic equipment, storage medium and program product. Background Art

[0002] Since native languages ​​cannot be used across platforms and the interface cannot be updated dynamically, in native development, a browser is usually used to load the front-end web interface that needs to be used.

[0003] However, different web interfaces are usually produced using different front-end frameworks. When switching and updating interfaces, real-time communication is required between different front-end frameworks to ensure the implementation and smoothness of interface switching and updating, thereby ensuring development efficiency. However, there is currently no real-time communication method between different front-end frameworks, resulting in low development efficiency. Summary of the invention

[0004] The present invention aims to solve at least one of the technical problems existing in the related art. To this end, the present invention proposes a front-end communication method, which realizes real-time communication between different front-end frameworks, can ensure the implementation and smoothness of switching and updating between web interfaces made by different front-end frameworks, and improve development efficiency.

[0005] The present invention also provides a front-end communication method, system, electronic device, storage medium and program product.

[0006] A front-end communication method according to an embodiment of the first aspect of the present invention includes:

[0007] Creating a communication channel between a first native container and a second native container using a first channel file and a second channel file; the first channel file is preloaded into the first native container, the second channel file is preloaded into the second native container, and the first native container and the second native container belong to different front-end frameworks;

[0008] A message is sent to a second business file through the communication channel using a first business file; the first business file is preloaded into the first native container, and the second business file is preloaded into the second native container.

[0009] According to the front-end communication method of an embodiment of the present invention, a communication channel between a first native container and a second native container is created by using a first channel file and a second channel file, and then a first business file is used to send a message to the second business file through the communication channel. Since the first native container and the second native container belong to different front-end frameworks, the first channel file and the first business file are pre-loaded into the first native container, and the second channel file and the second business file are pre-loaded into the second native container. Therefore, the first business file is used to send a message to the second business file through the communication channel, that is, the communication channel is used to send a message from one front-end framework to another different front-end framework, thereby realizing real-time communication between different front-end frameworks, and ensuring the realization and smoothness of switching and updating between web interfaces made using different front-end frameworks, thereby improving development efficiency.

[0010] According to an embodiment of the present invention, the using the first service file to send a message to the second service file through the communication channel includes:

[0011] Injecting a sending function predefined in the first channel file into the first native container;

[0012] Transferring the message to the sending function using the first service file;

[0013] The sending function is used to send a message to the second service file through the communication channel.

[0014] According to an embodiment of the present invention, the sending function is used to send a message to the second service file through the communication channel, including:

[0015] A first transfer receiver is used to monitor and receive messages sent by the sending function, and the messages sent by the sending function are sent to a second transfer receiver through the communication channel, and the second transfer receiver sends messages to the second business file; the first transfer receiver is pre-created in the first native container, and the second transfer receiver is pre-created in the second native container.

[0016] According to an embodiment of the present invention, after using the sending function to send a message to the second service file through the communication channel, the method includes:

[0017] The first native container is destroyed, a message that the container is in a destroyed state is received by a first removal receiver, and the message that the container is in a destroyed state is sent to a second removal receiver; the first removal receiver is pre-created in the first native container, and the second removal receiver is pre-created in the second native container.

[0018] A front-end communication method according to an embodiment of the second aspect of the present invention includes:

[0019] Creating a communication channel between a second native container and a first native container using a second channel file and a first channel file; the second channel file is preloaded into the second native container, the first channel file is preloaded into the first native container, and the second native container and the first native container belong to different front-end frameworks;

[0020] A message sent by a first business file is received through the communication channel, and the message is sent to a second business file; the first business file is pre-loaded into the first native container, and the second business file is pre-loaded into the second native container.

[0021] According to an embodiment of the present invention, the receiving, through the communication channel, a message sent by the first business file, and sending the message to the second business file includes:

[0022] The receiving function is used to receive the message sent by the first business file through the communication channel, and the message is sent to the second business file; the receiving function is predefined by the second channel file.

[0023] According to an embodiment of the present invention, the using of the receiving function to receive the message sent by the first business file through the communication channel and sending the message to the second business file includes:

[0024] Using a second transit receiver to monitor and receive a message sent by the first transit receiver through the communication channel; the second transit receiver is pre-created in the second native container, and the first transit receiver is pre-created in the first native container;

[0025] Using the second relay receiver to call the receiving function and send the message to the receiving function;

[0026] The message is sent to the second service file using the receiving function.

[0027] According to an embodiment of the present invention, after sending the message to the second service file, the method further includes:

[0028] Using a second removal receiver to receive a message sent by a first removal receiver that the container is in a destroyed state; the second removal receiver is pre-created in the second native container, and the first removal receiver is pre-created in the first native container;

[0029] Calling a removal function predefined in the second channel file;

[0030] The remove function is used to remove the instance and channel created in the second native container that match the instance identifier in the first native container.

[0031] According to an embodiment of the present invention, after sending the message to the second service file, the method further includes:

[0032] The receiving function is used to call the processing function of the communication channel, and the message is processed by the processing function; the processing function is predefined in the second channel file.

[0033] A front-end communication system according to an embodiment of a third aspect of the present invention includes: a first front-end framework and a second front-end framework;

[0034] The first front-end framework is used for:

[0035] Creating a communication channel between a first native container and a second native container using a first channel file and a second channel file; the first channel file is preloaded into the first native container, the second channel file is preloaded into the second native container, and the first native container and the second native container belong to different front-end frameworks;

[0036] Using the first business file, sending a message to the second business file through the communication channel; the first business file is preloaded into the first native container, and the second business file is preloaded into the second native container;

[0037] The second front-end framework is used for:

[0038] Creating a communication channel between the second native container and the first native container using the second channel file and the first channel file;

[0039] A message sent by the first business file is received through the communication channel, and the message is sent to the second business file.

[0040] According to an embodiment of the fourth aspect of the present invention, an electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the program, it implements any of the front-end communication methods described above.

[0041] According to the non-transitory computer-readable storage medium of the fifth aspect of the present invention, a computer program is stored thereon, and when the computer program is executed by a processor, the front-end communication method as described above is implemented.

[0042] According to a sixth aspect of the present invention, a computer program product comprises a computer program, which, when executed by a processor, implements any of the above-described front-end communication methods.

[0043] The above one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects:

[0044] A communication channel between the first native container and the second native container is created by using the first channel file and the second channel file, and then a message is sent to the second business file through the communication channel by using the first business file. Since the first native container and the second native container belong to different front-end frameworks, the first channel file and the first business file are pre-loaded into the first native container, and the second channel file and the second business file are pre-loaded into the second native container. Therefore, the first business file is used to send a message to the second business file through the communication channel, that is, the communication channel is used to send a message from one front-end framework to another different front-end framework, thereby realizing real-time communication between different front-end frameworks, and ensuring the realization and smoothness of switching and updating between web interfaces made with different front-end frameworks, thereby improving development efficiency.

[0045] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0047] Figure 1 This is one of the flow charts of the front-end communication method provided by an embodiment of the present invention;

[0048] Figure 2 This is a second flow chart of the front-end communication method provided by an embodiment of the present invention;

[0049] Figure 3 This is a third flow chart of the front-end communication method provided by an embodiment of the present invention;

[0050] Figure 4 This is a fourth flow chart of the front-end communication method provided by an embodiment of the present invention;

[0051] Figure 5 This is a fifth flow chart of the front-end communication method provided by an embodiment of the present invention;

[0052] Figure 6 is an operation framework diagram of a front-end communication system provided by an embodiment of the present invention;

[0053] Figure 7 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0054] The following embodiments of the present invention are described in further detail in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.

[0055] In the description of the embodiments of the present invention, it should be noted that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the embodiments of the present invention and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore cannot be understood as limitations on the embodiments of the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance.

[0056] In the description of the embodiments of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "connected" and "connection" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms in the embodiments of the present invention can be understood according to specific circumstances.

[0057] In the embodiments of the present invention, unless otherwise clearly specified and limited, the first feature being "above" or "below" the second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, the first feature being "above", "above" and "above" the second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. The first feature being "below", "below" and "below" the second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.

[0058] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0059] Figure 1 This is one of the flow charts of the front-end communication method provided by the embodiment of the present invention. Figure 1 , the embodiment of the present application provides a front-end communication method, which may include:

[0060] 101. Create a communication channel between a first native container and a second native container by using a first channel file and a second channel file;

[0061] The first channel file is preloaded into the first native container, and the second channel file is preloaded into the second native container. The first native container and the second native container belong to different front-end frameworks.

[0062] 102. Use the first business file to send a message to the second business file through the communication channel.

[0063] The first business file is preloaded into the first native container, and the second business file is preloaded into the second native container.

[0064] In step 101, the first channel file and the second channel file may both be channel JS files, and the main functions of the channel JS files include: defining channel objects, channel storage, receiving function receiveMessage and removing function removeMessage;

[0065] in:

[0066] The channel object includes the channel name, channel instance identifier, processing function onMessage and sending function postMessage. Among them, the processing function onMessage is mainly used to monitor the internal callback function of the specified channel name and process the received message, and the sending function postMessage is mainly used to send messages to the channel;

[0067] Channel storage is a global object, mainly used to store channel objects;

[0068] The receiving function receiveMessage is implemented in the channel JS file. It is mainly used to filter whether the external message is valid. If it is valid, the corresponding channel object is found from the channel storage and the processing function onMessage of the channel object is called.

[0069] The removeMessage function is mainly used to remove instances and channels matching the instance identifier created in other containers according to the instance identifier in the current container when the current container is destroyed.

[0070] In step 102, the first business file may be a first business JS file, and the second business file may be a second business JS file. The first business file and the second business file are pre-loaded into a container of a corresponding front-end framework for displaying web interfaces of different front ends.

[0071] Weex is a cross-platform mobile interface design framework. Weex developers can use web-like syntax to build iOS, Android, and Web applications, allowing mobile developers to write native-level performance experiences using simple H5 syntax.

[0072] The OpenHarmony ArkUI framework is another open source interface design and development framework that provides developers with the necessary capabilities for application interface design and development, including interface design components, animation, drawing, interactive events, etc., and can build iOS, Android and OpenHarmony applications.

[0073] Vue is a progressive framework for building user interfaces. It is easy to learn, has excellent performance, and is suitable for a variety of web front-end frameworks.

[0074] However, due to their different native languages, the Weex framework, OpenHarmony ArkUI framework, and Vue framework cannot communicate with each other in real time, which makes it impossible to switch and update the front-end web interfaces made using these frameworks.

[0075] The front-end communication method provided in this embodiment uses the first channel file and the second channel file to create a communication channel between the first native container and the second native container, and then uses the first business file to send a message to the second business file through the communication channel. Since the first native container and the second native container belong to different front-end frameworks, the first channel file and the first business file are pre-loaded into the first native container, and the second channel file and the second business file are pre-loaded into the second native container. Therefore, the first business file is used to send a message to the second business file through the communication channel, that is, the communication channel is used to send a message from one front-end framework to another different front-end framework, thereby realizing real-time communication between different front-end frameworks, ensuring the realization and smoothness of switching and updating between web interfaces made with different front-end frameworks, improving development efficiency, and being applicable to a variety of front-end frameworks including Weex framework, OpenHarmony ArkUI framework and Vue framework.

[0076] In addition, since real-time communication between different front-end frameworks is achieved and can proceed smoothly, the fault tolerance of native development is also improved, which provides convenience for subsequent system maintenance.

[0077] Figure 2 This is the second flow chart of the front-end communication method provided by the embodiment of the present invention. Figure 2 In one embodiment, using the first service file to send a message to the second service file through a communication channel may include:

[0078] 201. Inject a sending function predefined in a first channel file into a first native container;

[0079] 202. Transfer the message to the sending function using the first business file;

[0080] 203. Use the sending function to send a message to the second business file through the communication channel.

[0081] In step 201, the sending function postMessage is injected into the first native container, and a corresponding relationship is established between the sending function postMessage and the native function in the first native container.

[0082] This embodiment transfers the message of the first business file by sending the function postMessage, and sends the message to the second business file through the communication channel, thereby realizing message transmission between business files located in two different front-end frameworks, that is, realizing real-time communication between different front-end frameworks, and ensuring the realization and smoothness of switching and updating between web interfaces made with different front-end frameworks.

[0083] In one embodiment, using the sending function to send a message to the second service file through the communication channel may include:

[0084] Using the first transfer receiver to monitor and receive the message sent by the sending function, and sending the message sent by the sending function to the second transfer receiver through the communication channel, and the second transfer receiver sends the message to the second business file;

[0085] The first transit receiver is pre-created in the first native container, and the second transit receiver is pre-created in the second native container.

[0086] The first transfer receiver and the second transfer receiver can be used to monitor the message sent by the container through the postMessage sending function, and filter and deduplicate the monitored message to make the message more accurate.

[0087] In this embodiment, the message sent by the sending function is transmitted to the second transit receiver in the second native container through the first transit receiver in the first native container, and the recipient can be prompted to prepare for receiving through the transit receiver, thereby improving the message response speed and further improving the real-time performance of the communication.

[0088] In one embodiment, after sending a message to the second service file through the communication channel using the sending function, the following may be included:

[0089] Destroying the first native container, receiving a message that the container is in a destroyed state by using a first removal receiver, and sending the message that the container is in a destroyed state to a second removal receiver;

[0090] The first removal receiver is pre-created into the first native container, and the second removal receiver is pre-created into the second native container.

[0091] When the process of the first native container ends, it needs to be destroyed to release memory. With the destruction of the first native container, all objects inside it are destroyed, and objects related to the first native container created in other containers are also destroyed.

[0092] In this embodiment, the first removal receiver in the first native container transmits a message that the first native container is in a destroyed state to the second removal receiver in the second native container, and the second native container can be prompted by the message to destroy the related objects in time, thereby improving the destruction response speed and further improving the real-time performance of the communication.

[0093] Figure 3 This is the third flow chart of the front-end communication method provided by the embodiment of the present invention. Figure 3 , the embodiment of the present application provides a front-end communication method, which may include:

[0094] 301. Create a communication channel between the second native container and the first native container by using the second channel file and the first channel file;

[0095] The second channel file is preloaded into the second native container, the first channel file is preloaded into the first native container, and the second native container and the first native container belong to different front-end frameworks;

[0096] 302. Receive a message sent by the first business file through a communication channel, and send the message to the second business file.

[0097] The first business file is preloaded into the first native container, and the second business file is preloaded into the second native container.

[0098] The front-end communication method provided in this embodiment uses the second channel file and the first channel file to create a communication channel between the first native container and the second native container, and then receives the message sent by the first business file through the communication channel, and sends the message to the second business file. Since the second native container and the first native container belong to different front-end frameworks, the second channel file and the second business file are pre-loaded into the second native container, and the first channel file and the first business file are pre-loaded into the first native container, therefore, the message sent by the first business file is received through the communication channel, and the message is sent to the second business file, that is, the message sent by another different front-end framework is received from one front-end framework using the communication channel, which realizes real-time communication between different front-end frameworks, can ensure the realization and smoothness of switching and updating between web interfaces made with different front-end frameworks, improve development efficiency, and is applicable to a variety of front-end frameworks including Weex framework, OpenHarmonyArkUI framework and Vue framework.

[0099] In addition, since real-time communication between different front-end frameworks is achieved and can proceed smoothly, the fault tolerance of native development is also improved, which provides convenience for subsequent system maintenance.

[0100] In one embodiment, receiving a message sent by a first business file through a communication channel and sending the message to a second business file may include:

[0101] Using the receiving function, receiving the message sent by the first business file through the communication channel, and sending the message to the second business file;

[0102] The receiving function is predefined in the second channel file.

[0103] This embodiment receives the message sent by the first business file through the receiving function receiveMessage in the second native container, and sends the message to the second business file, thereby realizing message transmission between business files in two different front-end frameworks, that is, realizing real-time communication between different front-end frameworks, and ensuring the realization and smoothness of switching and updating between web interfaces made with different front-end frameworks.

[0104] Figure 4 This is a fourth flow chart of the front-end communication method provided by an embodiment of the present invention. Figure 4 In one embodiment, using a receiving function to receive a message sent by a first business file through a communication channel and sending the message to a second business file may include:

[0105] 401. Using a second transfer receiver to monitor and receive a message sent by a first transfer receiver through a communication channel;

[0106] The second transit receiver is pre-created in the second native container, and the first transit receiver is pre-created in the first native container.

[0107] 402. Using the second transfer receiver to call the receiving function, and sending the message to the receiving function;

[0108] 403. Use the receiving function to send the message to the second business file.

[0109] In this embodiment, the second transit receiver in the second native container monitors and receives the message sent by the first transit receiver in the first native container, and can prepare for reception through the transit receiver, thereby improving the response speed of calling the receiving function and transmitting the message using the receiving function, thereby improving the real-time performance of the communication.

[0110] Figure 5 This is a fifth flow chart of the front-end communication method provided by an embodiment of the present invention. Figure 5 In one embodiment, after sending the message to the second service file, the method may include:

[0111] 501. Receive, using a second removal receiver, a message from a first removal receiver indicating that a container is in a destroyed state;

[0112] The second removal receiver is pre-created into the second native container, and the first removal receiver is pre-created into the first native container;

[0113] 502. Calling a removal function predefined in the second channel file;

[0114] 503. Use a removal function to remove the instance and channel created in the second native container that match the instance identifier in the first native container.

[0115] In step 502, the second removal receiver may be used to call a removal function predefined in the second channel file.

[0116] In this embodiment, the second removal receiver is used to receive the message that the container is in a destroyed state sent by the first removal receiver, and the relevant objects can be destroyed in time through the prompt of the message, thereby improving the message response speed and further improving the real-time performance of communication; the removal function is used to remove the instances and channels created in the second native container that match the instance identifiers in the first native container, so as to release the memory of the relevant objects, avoid unnecessary memory occupation, and improve the rationality of memory use.

[0117] In one embodiment, after sending the message to the second service file, the method may include:

[0118] The receiving function is used to call the processing function of the communication channel, and the processing function is used to process the message;

[0119] This processing function is predefined in the second channel file.

[0120] The processing function of this embodiment can complete the processing of the received message, which is helpful for the use and transmission of the message.

[0121] Figure 6 1 is an operational framework diagram of a front-end communication system provided by an embodiment of the present invention. Figure 6 , an embodiment of the present application provides a front-end communication system, which may include: a first front-end framework and a second front-end framework;

[0122] The first front-end framework is used for:

[0123] A communication channel between the first native container and the second native container is created using a first channel file and a second channel file; the first channel file is preloaded into the first native container, the second channel file is preloaded into the second native container, and the first native container and the second native container belong to different front-end frameworks;

[0124] Using the first business file, sending a message to the second business file through the communication channel; the first business file is preloaded into the first native container, and the second business file is preloaded into the second native container;

[0125] The second front-end framework is used for:

[0126] Creating a communication channel between the second native container and the first native container using the second channel file and the first channel file;

[0127] A message sent by the first business file is received through the communication channel, and the message is sent to the second business file.

[0128] Reference Figure 6 , the communication between the first front-end framework and the second front-end framework is as follows:

[0129] After starting the application of the mobile terminal, the first native container, the second native container and the engine are initialized, and the engine may be a JS engine;

[0130] 1. The first front-end framework creates a first transit receiver and a first removal receiver in the first native container, and the second front-end framework creates a second transit receiver and a second removal receiver in the second native container;

[0131] 2. The first front-end framework uses the engine to load the first channel file into the first native container, and the second front-end framework uses the engine to load the second channel file into the second native container;

[0132] 3. The first front-end framework uses the engine to load the first business file into the first native container, and the second front-end framework loads the second business file into the second native container;

[0133] 4. The first front-end framework uses the first channel file, and the second front-end framework uses the second channel file to create a communication channel between the first native container and the second native container;

[0134] 5. The first front-end framework uses the first channel defined by the first channel file to store and save the communication channel, and the second front-end framework uses the second channel defined by the second channel file to store and save the communication channel;

[0135] 6. The first front-end framework uses the first business file to create a channel name C for the communication channel in the first channel storage; the second front-end framework uses the second business file to create a channel name C for the communication channel in the second channel storage, and sets a processing function onMessage, which is pre-defined in the second channel file;

[0136] 7. The first front-end framework injects the sending function postMessage into the first native container, where the sending function postMessage is predefined in the first channel file;

[0137] 8. The first front-end framework transfers the message to the sending function postMessage using the first business file;

[0138] 9. The first front-end framework uses the first transfer receiver to monitor and receive the message sent by the sending function postMessage;

[0139] 10. The first front-end framework uses the first relay receiver to send the message to the second relay receiver;

[0140] 11. The second front-end framework uses the second transfer receiver to call the receiving function predefined in the second channel file through the engine, and sends the message to the receiving function;

[0141] 12. The second front-end framework uses the receiving function to send the message to the second business file;

[0142] 13. The second front-end framework uses the receiving function to call the processing function onMessage of the channel name C to process the message;

[0143] 14. The first front-end framework destroys the first native container;

[0144] 15. The first front-end framework receives a message that the container is in a destroyed state using a first removal receiver;

[0145] 16. The second front-end framework uses the second removal receiver to receive the message sent by the first removal receiver that the container is in a destroyed state;

[0146] 17. The second front-end framework uses the second removal receiver to call the removal function removeMessage through the engine to remove the instance and channel created in the second native container that match the instance identifier in the first native container.

[0147] It should be noted that this embodiment is an example of using a first business file to send a message to a second business file. The same method can be used to use the second business file to send a message to the first business file, or to use the first business file or the second business file to send or receive messages to a business file in another front-end framework.

[0148] This embodiment can realize message transmission between business files in different front-end architectures, realize real-time communication between different front-end frameworks, ensure the implementation and smoothness of switching and updating between web interfaces made with different front-end frameworks, improve development efficiency, and is suitable for multiple front-end frameworks including Weex framework, OpenHarmony ArkUI framework and Vue framework.

[0149] In addition, since real-time communication between different front-end frameworks is achieved and can proceed smoothly, the fault tolerance of native development is also improved, which provides convenience for subsequent system maintenance.

[0150] Figure 7 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 7As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the following method:

[0151] Creating a communication channel between a first native container and a second native container using a first channel file and a second channel file; the first channel file is preloaded into the first native container, the second channel file is preloaded into the second native container, and the first native container and the second native container belong to different front-end frameworks;

[0152] Using a first business file, sending a message to a second business file through the communication channel; the first business file is preloaded into the first native container, and the second business file is preloaded into the second native container; or

[0153] Creating a communication channel between a second native container and a first native container using a second channel file and a first channel file; the second channel file is preloaded into the second native container, the first channel file is preloaded into the first native container, and the second native container and the first native container belong to different front-end frameworks;

[0154] A message sent by a first business file is received through the communication channel, and the message is sent to a second business file; the first business file is pre-loaded into the first native container, and the second business file is pre-loaded into the second native container.

[0155] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the relevant technology or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0156] On the other hand, an embodiment of the present invention discloses a computer program product, wherein the computer program product includes a computer program stored on a non-transitory computer-readable storage medium, wherein the computer program includes program instructions. When the program instructions are executed by a computer, the computer can perform the methods provided by the above-mentioned method embodiments, for example, including:

[0157] Creating a communication channel between a first native container and a second native container using a first channel file and a second channel file; the first channel file is preloaded into the first native container, the second channel file is preloaded into the second native container, and the first native container and the second native container belong to different front-end frameworks;

[0158] Using a first business file, sending a message to a second business file through the communication channel; the first business file is preloaded into the first native container, and the second business file is preloaded into the second native container; or

[0159] Creating a communication channel between a second native container and a first native container using a second channel file and a first channel file; the second channel file is preloaded into the second native container, the first channel file is preloaded into the first native container, and the second native container and the first native container belong to different front-end frameworks;

[0160] A message sent by a first business file is received through the communication channel, and the message is sent to a second business file; the first business file is pre-loaded into the first native container, and the second business file is pre-loaded into the second native container.

[0161] In another aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the methods provided in the above embodiments, for example, including:

[0162] Creating a communication channel between a first native container and a second native container using a first channel file and a second channel file; the first channel file is preloaded into the first native container, the second channel file is preloaded into the second native container, and the first native container and the second native container belong to different front-end frameworks;

[0163] Using a first business file, sending a message to a second business file through the communication channel; the first business file is preloaded into the first native container, and the second business file is preloaded into the second native container; or

[0164] Creating a communication channel between a second native container and a first native container using a second channel file and a first channel file; the second channel file is preloaded into the second native container, the first channel file is preloaded into the first native container, and the second native container and the first native container belong to different front-end frameworks;

[0165] A message sent by a first business file is received through the communication channel, and the message is sent to a second business file; the first business file is pre-loaded into the first native container, and the second business file is pre-loaded into the second native container.

[0166] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution can be essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.

[0167] Finally, it should be noted that the above embodiments are only used to illustrate the present invention, rather than to limit the present invention. Although the present invention is described in detail with reference to the embodiments, it should be understood by those skilled in the art that various combinations, modifications or equivalent substitutions of the technical solutions of the present invention do not depart from the spirit and scope of the technical solutions of the present invention, and should be included in the scope of the claims of the present invention.

Claims

1. A front-end communication method, It is characterized in that include: Creating a communication channel between the first native container and the second native container using the first channel file and the second channel file; The first channel file is preloaded into the first native container, the second channel file is preloaded into the second native container, and the first native container and the second native container belong to different front-end frameworks; A message is sent to a second business file through the communication channel using a first business file; the first business file is preloaded into the first native container, and the second business file is preloaded into the second native container.

2. The front-end communication method according to claim 1, It is characterized in that The using the first service file to send a message to the second service file through the communication channel includes: Injecting a sending function predefined in the first channel file into the first native container; Transferring the message to the sending function using the first service file; The sending function is used to send a message to the second service file through the communication channel.

3. The front-end communication method according to claim 2, It is characterized in that The using the sending function to send a message to the second business file through the communication channel includes: A first transfer receiver is used to monitor and receive messages sent by the sending function, and the messages sent by the sending function are sent to a second transfer receiver through the communication channel, and the second transfer receiver sends messages to the second business file; the first transfer receiver is pre-created in the first native container, and the second transfer receiver is pre-created in the second native container.

4. The front-end communication method according to claim 2 or 3, It is characterized in that After using the sending function to send a message to the second business file through the communication channel, the method includes: The first native container is destroyed, a message that the container is in a destroyed state is received by a first removal receiver, and the message that the container is in a destroyed state is sent to a second removal receiver; the first removal receiver is pre-created in the first native container, and the second removal receiver is pre-created in the second native container.

5. A front-end communication method, It is characterized in that include: Creating a communication channel between the second native container and the first native container using the second channel file and the first channel file; The second channel file is preloaded into the second native container, the first channel file is preloaded into the first native container, and the second native container and the first native container belong to different front-end frameworks; A message sent by a first business file is received through the communication channel, and the message is sent to a second business file; the first business file is pre-loaded into the first native container, and the second business file is pre-loaded into the second native container.

6. The front-end communication method according to claim 5, It is characterized in that The receiving a message sent by the first business file through the communication channel and sending the message to the second business file includes: The receiving function is used to receive the message sent by the first business file through the communication channel, and the message is sent to the second business file; the receiving function is predefined by the second channel file.

7. The front-end communication method according to claim 6, It is characterized in that The using the receiving function to receive the message sent by the first business file through the communication channel, and sending the message to the second business file includes: Using a second transit receiver to monitor and receive a message sent by the first transit receiver through the communication channel; the second transit receiver is pre-created in the second native container, and the first transit receiver is pre-created in the first native container; Using the second relay receiver to call the receiving function, and sending the message to the receiving function; The message is sent to the second service file using the receiving function.

8. The front-end communication method according to any one of claims 5 to 7, It is characterized in that After sending the message to the second service file, the method further comprises: Using a second removal receiver to receive a message sent by a first removal receiver that the container is in a destroyed state; the second removal receiver is pre-created in the second native container, and the first removal receiver is pre-created in the first native container; Calling a removal function predefined in the second channel file; The remove function is used to remove the instance and channel created in the second native container that match the instance identifier in the first native container.

9. The front-end communication method according to claim 6 or 7, It is characterized in that After sending the message to the second service file, the method further comprises: The receiving function is used to call the processing function of the communication channel, and the message is processed by the processing function; the processing function is predefined in the second channel file.

10. A front-end communication system, It is characterized in that include: a first front end frame and a second front end frame; The first front-end framework is used for: Creating a communication channel between a first native container and a second native container using a first channel file and a second channel file; the first channel file is preloaded into the first native container, the second channel file is preloaded into the second native container, and the first native container and the second native container belong to different front-end frameworks; Using the first business file, sending a message to the second business file through the communication channel; the first business file is preloaded into the first native container, and the second business file is preloaded into the second native container; The second front-end framework is used for: Creating a communication channel between the second native container and the first native container using the second channel file and the first channel file; A message sent by the first business file is received through the communication channel, and the message is sent to the second business file.

11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, it implements the front-end communication method as described in any one of claims 1 to 4, or implements the front-end communication method as described in any one of claims 5 to 9.

12. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, it implements the front-end communication method as described in any one of claims 1 to 4, or implements the front-end communication method as described in any one of claims 5 to 9.

13. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, it implements the front-end communication method according to any one of claims 1 to 4, or implements the front-end communication method according to any one of claims 5 to 9.