Multi-terminal data synchronization method, device and storage medium for client hybrid development

By verifying and processing user tokens on the server side, and setting request headers according to the jump source, the problem of difficult user data synchronization in cross-platform hybrid development is solved, and data management efficiency and user experience are improved.

CN118316945BActive Publication Date: 2024-09-24GUANGDONG JINTUO INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410423067.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-09
Publication Date
2024-09-24
Estimated Expiration
2044-04-09

AI Technical Summary

Technical Problem

In cross-platform hybrid development technology, user data synchronization is difficult, and traditional methods lead to low data management efficiency and poor user experience, especially when switching between native client apps, Flutter interfaces, and HTML5 pages.

Method used

By sending the event operation request to the server, it is determined whether user information needs to be verified, token verification or user login is performed, the target user token is obtained, and the token is set to the corresponding request header according to the jump source to achieve multi-end data synchronization.

Benefits of technology

It improves data management efficiency and user experience, reduces file reading frequency, and ensures the consistency of login operations and the smoothness of cross-end data synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118316945B
    Figure CN118316945B
Patent Text Reader

Abstract

The present invention discloses a multi-terminal data synchronization method, device and storage medium for mixed client development, and the method includes: sending an event operation request to a server; if the event operation request needs to verify user information, judging whether there is a first user token in the event operation request through the server; performing a token verification operation on the first user token, or performing a user login operation according to an error code and an error message to obtain a target user token; if the jump source is a native interface, setting the target user token to a first pending request header; if the jump source is a Flutter interface, setting the target user token to a second pending request header; if the jump source is an HTML5 page, setting the target user token to a third pending request header to obtain a target request header. The present invention realizes multi-terminal data synchronization and improves data management efficiency and user experience. The present invention can be widely used in the field of client development technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of client development, and in particular to a multi-terminal data synchronization method, device and storage medium for hybrid client development. Background Art

[0002] In daily operations, native client App development can no longer meet diverse business needs. The application scenarios of cross-platform hybrid development technology are constantly increasing, and there are a large number of hybrid development businesses, such as implementing picture, text and video collections through the Flutter interface or implementing sign-in gifts through HTML5 pages. As the client user scale gradually expands and the business continues to increase, cross-platform hybrid development technology has the problem of difficulty in synchronizing user data. The traditional method achieves data synchronization by reading a shared data file on multiple terminals, but file read and write operations are frequently performed when switching across platforms, and data management efficiency is low. At the same time, different platforms need to repeatedly read user login information, resulting in inconsistent operations before and after login and poor user experience.

[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention

[0004] The embodiments of the present invention provide a multi-terminal data synchronization method, device and storage medium for client hybrid development, which effectively improves data management efficiency and user experience.

[0005] On the one hand, an embodiment of the present invention provides a multi-terminal data synchronization method for client hybrid development, comprising the following steps:

[0006] Sending the event operation request to the server, wherein the server is used to determine whether the event operation request requires verification of user information;

[0007] Determining, based on the information returned by the server, that the event operation request does not require verification of user information, then performing an information response operation based on the response information;

[0008] Determining, according to the information returned by the server, that the event operation request needs to verify user information, then judging, through the server, whether there is a first user token in the event operation request;

[0009] Determining, based on the information returned by the server, that a first user token exists in the event operation request, then performing a token verification operation on the first user token;

[0010] Determining, based on the information returned by the server, that the first user token does not exist in the event operation request, then performing a user login operation based on the error code and the error information to obtain a target user token;

[0011] If the jump source of the event operation request is a native interface, the target user token is set to the first request header to be processed to obtain a target request header;

[0012] If the jump source of the event operation request is the Flutter interface, the target user token is set to the second request header to be processed to obtain the target request header;

[0013] If the jump source of the event operation request is an HTML5 page, the target user token is set to the third request header to be processed to obtain the target request header, which includes a native interface request header, a Flutter interface request header or an HTML5 page request header. The target request header is used to characterize the completion of multi-terminal data synchronization.

[0014] In some embodiments, performing an information response operation according to the response information includes:

[0015] Receiving the response information from the server;

[0016] According to the response information, a response interface is displayed.

[0017] In some embodiments, performing a token verification operation on the first user token includes:

[0018] Determining, by the server, whether the first user token is within the validity period;

[0019] If the first user token is within the validity period, performing the information response operation according to the response information;

[0020] If the first user token is not within the validity period, the user login operation is performed according to the error code and the error information.

[0021] In some embodiments, performing a user login operation according to the error code and the error information to obtain a target user token includes:

[0022] Receiving the error code and the error information from the server;

[0023] According to the error code and the error message, determining whether user login is required;

[0024] If user login is required, the jump source, event operation type, request address, request parameters, user account and user password are sent to the server, and the server is also used to generate the target user token;

[0025] The target user token is received from the server.

[0026] In some embodiments, setting the target user token into the first request header to be processed to obtain the target request header includes:

[0027] If the jump target is a native interface, the target user token is set to the first request header to be processed through the first network request library to obtain the native interface request header;

[0028] If the jump target is a Flutter interface, the target user token is transmitted through a local file, and the target user token is set to the first request header to be processed through a second network request library to obtain the Flutter interface request header;

[0029] If the jump target is an HTML5 page, the target user token is transmitted through the HTML5 function method, and the target user token is set to the first request header to be processed through the third network request library to obtain the HTML5 page request header.

[0030] In some embodiments, setting the target user token into the second request header to be processed to obtain the target request header includes:

[0031] If the jump target is a native interface, the target user token is set to the second request header to be processed through the first network request library to obtain the native interface request header;

[0032] If the jump target is a Flutter interface, the target user token is transmitted through the event message bus according to the first subscriber, and the target user token is set to the second pending request header through the second network request library to obtain the Flutter interface request header;

[0033] If the jump target is an HTML5 page, after receiving the target user token on the first jump source interface, the target user token is transmitted through the HTML5 function method, and the target user token is set to the second pending request header through the third network request library to obtain the HTML5 page request header.

[0034] In some embodiments, setting the target user token into a third request header to be processed to obtain the target request header includes:

[0035] If the jump target is a native interface, the target user token is set to the third request header to be processed through the first network request library to obtain the native interface request header;

[0036] If the jump target is a Flutter interface, after receiving the target user token on the second jump source interface, the target user token is transmitted through the local file, and the target user token is set to the third request header to be processed through the second network request library to obtain the Flutter interface request header;

[0037] If the jump target is an HTML5 page, the target user token is transmitted through the event message bus according to the second subscriber, and the target user token is set to the third request header to be processed through the third network request library to obtain the HTML5 page request header.

[0038] On the other hand, an embodiment of the present invention provides a multi-terminal data synchronization device for client hybrid development, including:

[0039] The first module is used to send an event operation request to a server, and the server is used to determine whether the event operation request needs to verify user information;

[0040] The second module is used to determine that the event operation request does not need to verify user information according to the information returned by the server, and then perform an information response operation according to the response information;

[0041] A third module is used to determine, according to the information returned by the server, that the event operation request needs to verify user information, and then determine, through the server, whether there is a first user token in the event operation request;

[0042] A fourth module is used to determine, based on the information returned by the server, that a first user token exists in the event operation request, and then perform a token verification operation on the first user token;

[0043] A fifth module is used to determine that the first user token does not exist in the event operation request according to the information returned by the server, and then perform a user login operation according to the error code and the error information to obtain a target user token;

[0044] The sixth module is used for setting the target user token into the first request header to be processed to obtain a target request header if the jump source of the event operation request is a native interface;

[0045] The seventh module is used to set the target user token to the second request header to be processed if the jump source of the event operation request is the Flutter interface, so as to obtain the target request header;

[0046] The eighth module is used to set the target user token to the third request header to be processed if the jump source of the event operation request is an HTML5 page, and obtain the target request header. The target request header includes a native interface request header, a Flutter interface request header or an HTML5 page request header. The target request header is used to characterize the completion of multi-terminal data synchronization.

[0047] In another aspect, an embodiment of the present invention provides a computer device, comprising:

[0048] at least one processor;

[0049] at least one memory for storing at least one program;

[0050] When the at least one program is executed by the at least one processor, the at least one processor implements the described method.

[0051] On the other hand, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.

[0052] The beneficial effects of the present invention are as follows:

[0053] The present invention first sends an event operation request to a server side, and determines through the server side whether the event operation request needs to verify user information to perform an information response operation or determine whether a first user token exists, and then performs a token verification operation on the first user token or performs a user login operation according to an error code and error information to obtain a target user token, and then determines the jump source. If it is a native interface, the target user token is set to the first request header to be processed; if it is a Flutter interface, the target user token is set to the second request header to be processed; if it is an HTML5 page, the target user token is set to the third request header to be processed, thereby obtaining a target request header, thereby realizing multi-terminal data synchronization, and improving data management efficiency and user experience.

[0054] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0056] Figure 1 A flowchart of a multi-terminal data synchronization method for client hybrid development according to an embodiment of the present invention;

[0057] Figure 2 A schematic diagram of an overall process of a server-side detection requiring login according to an embodiment of the present invention;

[0058] Figure 3 A schematic diagram of a user operation triggering login according to an embodiment of the present invention;

[0059] Figure 4 A schematic diagram of a data synchronization process in interface initialization according to an embodiment of the present invention;

[0060] Figure 5 A schematic diagram of a data synchronization and response processing flow according to an embodiment of the present invention;

[0061] Figure 6 A schematic diagram of a message event driven registration process according to an embodiment of the present invention;

[0062] Figure 7 The figure is a schematic diagram of a message event-driven publishing process according to an embodiment of the present invention. DETAILED DESCRIPTION

[0063] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.

[0064] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".

[0065] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.

[0066] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0067] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.

[0068] Flutter: It is an open source user interface (UI) toolkit developed by Google. It helps developers efficiently build beautiful multi-platform applications through a set of code bases, supporting mobile, web, desktop and embedded platforms. Flutter is open source and free, has a loose open source agreement, and can be easily added to existing projects, making it suitable for commercial projects.

[0069] HTML5 (Hyper Text Markup Language 5): is a language description method for building Web content. HTML5 is a new generation standard for the Internet. It is a language method for building and presenting Internet content and is considered one of the core technologies of the Internet. HTML5 is the specification of HTML, the core language of the Web. When users browse the web by any means, the content they see is originally in HTML format, which is converted into recognizable information in the browser through some technical processing.

[0070] In the related technologies, in actual business, pure native client App development can no longer meet business needs. There are more and more scenarios of one or more cross-platform hybrid development technologies, and there are a large number of hybrid development businesses, such as Flutter for picture, text and video collections, and HTML5 for sign-in gifts. The main reason for introducing Flutter technology in the client is that it has a cross-platform, high-performance and consistent interface. The biggest feature of introducing HTML5 in the client, in addition to multi-purpose use on one end, is flexibility, and there is no need to upgrade the client version when updating functions. As the scale of client App users gradually expands and more and more businesses are available, it is difficult to manage and synchronize the user information data of the three ends of the hybrid development of pure native client App, Flutter and HTML5. In the traditional technical solution, by saving a shared data file, the same shared user data file information is read between the pure native client App and Flutter and HTML5 technology switches to solve the data management and synchronization problems. However, this solution has two disadvantages. First, the client native interface, Flutter and HTML5 will read the file operation more frequently when switching, which leads to low data management efficiency. Second, the lack of a dynamic update mechanism leads to inconsistent operations before and after login, and poor user experience.

[0071] The multi-terminal data synchronization method for client hybrid development provided in the embodiment of the present application relates to the technical field of client development. The multi-terminal data synchronization method for client hybrid development provided in the embodiment of the present application can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or it can be configured as a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network; the software can be an application of a multi-terminal data synchronization method for implementing client hybrid development, etc., but is not limited to the above forms.

[0072] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0073] The following is a detailed explanation of the embodiments of the present application in conjunction with the accompanying drawings:

[0074] Figure 1 is an optional flowchart of a multi-terminal data synchronization method for client hybrid development provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S108.

[0075] Step S101: Send an event operation request to a server, and the server determines whether the event operation request needs to verify user information;

[0076] Step S102: determining, based on the information returned by the server, that the event operation request does not require verification of user information, and performing an information response operation based on the response information;

[0077] Step S103: Determine, based on the information returned by the server, that the event operation request requires verification of user information, and then determine, through the server, whether there is a first user token in the event operation request;

[0078] Step S104: determining, based on the information returned by the server, that the event operation request contains a first user token, and then performing a token verification operation on the first user token;

[0079] Step S105: Determine, based on the information returned by the server, that the first user token does not exist in the event operation request, and then perform a user login operation based on the error code and error information to obtain a target user token;

[0080] Step S106: If the jump source of the event operation request is the native interface, the target user token is set to the first request header to be processed to obtain the target request header;

[0081] Step S107: If the jump source of the event operation request is the Flutter interface, the target user token is set to the second request header to be processed to obtain the target request header;

[0082] Step S108: If the jump source of the event operation request is an HTML5 page, the target user token is set to the third request header to be processed to obtain a target request header, which includes a native interface request header, a Flutter interface request header, or an HTML5 page request header. The target request header is used to indicate that multi-terminal data synchronization is completed.

[0083] Steps S101 to S108 shown in the embodiment of the present application realize multi-terminal data synchronization, thereby improving data management efficiency and user experience.

[0084] In some embodiments, the overall process of the server-side detection requiring login is as follows Figure 2 When you are not logged in, accessing a page that requires user information to be logged in, or performing an operation that requires user information to be logged in, the login is triggered as shown in Figure 3As shown, the following three situations may be included: login is triggered when accessed or operated from the native interface but the user is not logged in; login is triggered when accessed or operated from the Flutter interface but the user is not logged in; login is triggered when accessed or operated from the HTML5 interface but the user is not logged in. In some embodiments, when the server detects that there is no user information in the client request header, a specific error code 400 is returned. At this time, the native client App or Flutter or HTML5 uniformly pops up the login interface of the native client after identification to allow the user to log in. Then after the native client successfully logs in, the user information returned by the server is encrypted and stored in the client. The user information is then encapsulated into a unified interface so that the native client App, Flutter and HTML5 can call it, which may include the following three situations: when initiating user login from the native client interface, the Okhttp network request library is used to add the request header to put the user information and user token and other information into the request header, and then each server-side request automatically carries this information. When triggering user login from the Flutter interface, the http_manger of the dart network request library is used to set addBaseHeader to put the user information and user token and other information into the request header, and synchronize it to the request header of the native client Okhttp. When triggering user login from the HTML5 page, the CookieManager of the WebView network request library is used to set the user token and other information into the cookie, and synchronize the request header information of the native client Okhttp. It can be understood that the native client only needs to complete the setting of the request header information of Okhttp to initiate and complete the user login, without having to process Flutter and HTML5, because both Flutter and HTML5 are parasitic on the native client. In addition, when initiating user login in Flutter or HTML5, it is necessary to synchronize to the native client. In some embodiments, after completing the user login, the user will not be interrupted during the access or operation process due to the need to log in, and the whole process is coherent, which may include the following 3 situations: when the native client interface is accessed or operated before logging in, the server returns an error code that requires login, and passes the information of the access page or operation to the login interface. After completing the login, the user's access or operation before logging in is automatically re-executed; when the Flutter interface is accessed or operated before logging in, after completing the login, the Flutter interface is automatically refreshed or the operation request is executed; when the HTML5 page is accessed or operated before logging in, the HTML5 page is automatically refreshed or the operation request is executed after completing the login. In some embodiments, the data synchronization process in the interface initialization is as follows Figure 4As shown, after completing the login and executing the current interface or page or performing the operation, cross-end access can include the following two situations: when jumping from the native interface to the Flutter interface, the user information synchronization is completed while initializing the Flutter interface; when jumping from the native interface to the HTML5 page, the user information synchronization is completed while initializing the WebView. In some embodiments, when the client initiates a request to the server to verify the user's identity information, if the server verifies that the user has logged in and the user information exists but the user token is invalid, the server returns an error code 300. After receiving the error code, the client jumps to the native client login interface. The login interface will prompt that the user's identity information has expired and needs to be re-logined and authenticated, so that the user can log in on the login interface.

[0085] In some embodiments, in step S101, the event operation request may be sent to the server, and the server determines whether the event operation request needs to verify the user information. If the event operation request does not need to verify the user information, step S102 may be executed; if the event operation request needs to verify the user information, step S103 may be executed. It is understandable that operations with high relevance to the user need to verify the user information, while ordinary information with low relevance to the user can be directly obtained without user information verification.

[0086] In some embodiments, in step S102, performing information response operations according to the response information may include but is not limited to the following steps:

[0087] Receive response information from the server;

[0088] According to the response information, the response interface is displayed.

[0089] In some embodiments, if it is determined based on the information returned by the server that the event operation request does not require verification of user information, an information response operation is performed based on the response information. Specifically, the response information can be received from the server first, and then the response interface can be displayed on the client or a response operation can be performed based on the response information. Furthermore, in subsequent operations, if the native interface is jumped to, step S101 can be executed; if the Flutter interface is jumped to, step S107 can be executed; if the HTML5 page is jumped to, step S108 can be executed.

[0090] In some embodiments, in step S103, it is determined that the event operation request needs to verify user information according to the information returned by the server, and the server can determine whether there is a first user token in the event operation request. If there is a first user token in the event operation request, step S104 can be executed; if there is no first user token in the event operation request, step S105 can be executed.

[0091] In some embodiments, in step S104, performing a token verification operation on the first user token may include but is not limited to the following steps:

[0092] Determine, by the server side, whether the first user token is within the validity period;

[0093] If the first user token is within the validity period, performing an information response operation according to the response information;

[0094] If the first user token is not within the validity period, the user login operation is performed according to the error code and error information.

[0095] In some embodiments, if it is determined that the first user token exists in the event operation request according to the information returned by the server, a token verification operation is performed on the first user token. Specifically, the server can first determine whether the first user token is within the validity period. If the first user token is within the validity period, the server responds to the information normally and returns the response information to the client. The client can perform an information response operation according to the response information and execute step S102; if the first user token is not within the validity period, the server returns a specific error code 300 and an error message to the client. The client can perform a user login operation according to the error code and the error message and execute step S105.

[0096] In some embodiments, in step S105, performing a user login operation according to the error code and the error information to obtain a target user token may include but is not limited to the following steps:

[0097] Receive error code and error message from the server;

[0098] Determine whether user login is required based on the error code and error message;

[0099] If user login is required, the jump source, event operation type, request address, request parameters, user account and user password are sent to the server, which is also used to generate the target user token;

[0100] Receive the target user token from the server.

[0101] In some embodiments, if it is determined that the first user token does not exist in the event operation request according to the information returned by the server, the server returns a specific error code 400 and an error message, and the client can perform a user login operation according to the error code and the error message to obtain the target user token. Specifically, the error code and error message can be received from the server first, and then the error code and error message can be used to determine whether the user login needs to be performed. If the user login needs to be performed, the jump source, event operation type, request address, request parameters, user account and user password are sent to the server. Among them, the jump source can include a native interface, a Flutter interface or an HTML5 page, and the event operation type can include opening a new interface or operating an event. After receiving the login information sent by the client, the server checks whether the login information is verified. If the verification fails, an error message is returned, and the account and password are prompted to be re-entered; if the verification passes, the target user token Token is generated and the user information is queried, and the target user token and user information are sent to the client. Finally, the client receives the target user token and the corresponding user information from the server and saves them to a local file. So that the target user token and user information can be set to the client Okhttp request header according to the local file, and each request will carry this information. In addition, after obtaining the target user token and logging in successfully, the data synchronization and response processing flow is as follows Figure 5 As shown, data dynamic synchronization and data message event-driven operations can be performed according to the jump source to the native login interface. When the jump source is the native interface, step S106 can be executed; when the jump source is the Flutter interface, step S107 can be executed; when the jump source is the HTML5 page, step S108 can be executed.

[0102] In some embodiments, in step S106, setting the target user token into the first request header to be processed to obtain the target request header may include but is not limited to the following steps:

[0103] If the jump target is a native interface, the target user token is set to the first request header to be processed through the first network request library to obtain a native interface request header;

[0104] If the jump target is the Flutter interface, the target user token is transmitted through the local file, and the target user token is set to the first request header to be processed through the second network request library to obtain the Flutter interface request header;

[0105] If the jump target is an HTML5 page, the target user token is transmitted through the HTML5 function method, and the target user token is set to the first request header to be processed through the third network request library to obtain the HTML5 page request header.

[0106] In some embodiments, the target request header may include a native interface request header, a Flutter interface request header, or an HTML5 page request header. If the jump source of the event operation request is a native interface, the target user token can be set to the first pending request header to obtain the target request header. Specifically, it can be judged according to the event operation type. When the event operation type is to open a new interface or page, the request address is the new interface or page address. According to this address, it can be judged which specific interface or page to be opened (i.e., the jump target) is. If the jump target is a native interface, the http network request library can be set to the first network request library, and the target user token is set to the first pending request header through the http network request library to obtain the native interface request header, that is, the Okhttp request header. If the jump target is a Flutter interface, the dart network request library can be set to the second network request library, the target user token is transferred through a local file, and the target user token is set to the first pending request header through the http_manger of the dart network request library to obtain the Flutter interface request header, so that the target user token Token and other information will be automatically brought in the subsequent Flutter interface request. If the jump target is an HTML5 page, you can use webView.loadUrl("javascript: method name A (pass data parameters)") to implement the client's local file data transmission of the target user token, and implement the "method name A (pass data parameters)" method on the HTML5 page to receive the user information of the client's native interface and the target user token data, and then set the target user token to the first pending request header through the third network request library. Specifically, you can set WebView to the third network request library, and use WebView's CookieManager to set the Token to the cookie to get the HTML5 page request header. After that, each HTML5 request will automatically carry the Token. More importantly, when the event operation type is an operation event, it is an operation on the same interface or page. Since step S106 has been set to the case where the jump source is the native interface, all Flutter interfaces and HTML5 pages can be excluded. The request is automatically initiated to the server according to the request address and parameters. At this time, since the login has been completed and the request header carries Token information, the request can be automatically completed. The user does not need to perform the original operation again after the login operation is completed. That is, the synchronization of user data and event processing after the native interface operation to the native login interface is successfully realized.

[0107] In some embodiments, in step S107, setting the target user token into the second request header to be processed to obtain the target request header may include but is not limited to the following steps:

[0108] If the jump target is the native interface, the target user token is set to the second request header to be processed through the first network request library to obtain the native interface request header;

[0109] If the jump target is the Flutter interface, the target user token is transmitted through the event message bus according to the first subscriber, and the target user token is set to the second to-be-processed request header through the second network request library to obtain the Flutter interface request header;

[0110] If the jump target is an HTML5 page, after receiving the target user token in the first jump source interface, the target user token is transmitted through the HTML5 function method, and the target user token is set to the second pending request header through the third network request library to obtain the HTML5 page request header.

[0111] In some embodiments, since the Flutter interface has been opened before logging in, the initialization of the interface has been completed. At this time, the request header information of Flutter cannot be updated through initialization after the native login interface completes the login. At this time, it can be implemented through the data message event-driven method, that is, the event message bus EventBus. Its principle is mainly based on the observer pattern, and an intermediate event bus is used to decouple the connection between publishers and subscribers. It can be understood that the main working principles of EventBus include: Defining events: Developers need to define corresponding event classes, which contain some necessary data. For example, an event named UserLoggedInEvent can be defined to indicate that the user has logged in successfully. The message event-driven registration process is as follows: Figure 6 As shown, when registration is required, the cache is searched according to the current registration class. If the event to be registered does not exist in the cache, all subscription methods in the subscriber class are added to the collection, otherwise all subscription methods in the subscriber class are returned and added to the map collection. Registered subscribers: Subscribers are components that are interested in events and want to receive event notifications. By registering subscribers, they inform the event bus of themselves so that they can receive corresponding events. Publish events: Publishers are components that generate and trigger events. When an event occurs, the publisher publishes the event through the event bus and passes it to all subscribers who have subscribed to the event. The message event-driven publishing process is as follows: Figure 7As shown, after obtaining the event type, the subscriber and subscription method are obtained according to the type, and then judged according to whether it is in the main thread and the threadmode subthread, and finally the subscriber's subscription method is directly called through reflection to complete the communication. Receive events: The subscriber receives the event published by the publisher from the event bus and performs corresponding processing operations when necessary. The key principle of EventBus lies in its role as an event center, which manages the relationship between all events, subscribers and publishers. EventBus can significantly reduce the coupling of the code through this method, making the dependencies between components looser. In the registration phase, the EventBus class obtains all receiving methods with specific annotations (such as @Subscribe) of the registered object by reflection and puts them into a list. These receiving methods are used to process the received events. In the message sending phase, EventBus searches the list for objects that meet the parameter requirements through its internal message distribution mechanism, and calls the corresponding object method through reflection. This embodiment makes the communication between components simpler and more efficient through its flexible event-driven mechanism, thereby improving the maintainability and scalability of the system. In some embodiments, if the jump source of the event operation request is the Flutter interface, the target user token can be set to the second request header to be processed to obtain the target request header. Specifically, it can be judged according to the event operation type. When the event operation type is to open a new interface or page, the request address is the new interface or page address. According to this address, it can be judged which specific interface or page to be opened (ie, the jump target) is. If the jump target is a native interface, the target user token can be set to the second pending request header through the http network request library to obtain the native interface request header, that is, the Okhttp request header. If the jump target is a Flutter interface, the subscriber can be registered in the Flutter interface base class. After completing the login and saving the user data and Token on the login interface, the update data event is sent through EventBus. After the Flutter interface receives the update data event, the target user token is set to the second pending request header through the http_manger of the dart network request library. After obtaining the Flutter interface request header, the jump of the target Flutter interface is executed. It can be understood that the first jump source interface is the Flutter interface.If the jump target is an HTML5 page, then the native interface->Flutter interface->login interface->after completing the login, save the data and synchronize it to the native interface Okhttp, and then send the update data event through EventBus->close the login interface. After the Flutter interface receives the update data event, it jumps to the HTML5 page. When opening the HTML5 page, the target user token Token is set to the second request header to be processed through the CookieManager of WebView, that is, the Token is set to the cookie using the CookieManager of WebView to obtain the HTML5 page request header. After that, each HTML5 request will automatically carry the Token. More importantly, when the event operation type is an operation event, since step S107 has been set as the Flutter interface, the native interface and HTML5 page are excluded, and a request with Token information is automatically initiated to the server according to the request address and parameters. At this time, just wait for the server to respond, thereby realizing the synchronization and event processing of returning user data after the native interface operation to the Flutter login interface is successful.

[0112] In some embodiments, in step S108, setting the target user token into the third request header to be processed to obtain the target request header may include but is not limited to the following steps:

[0113] If the jump target is the native interface, the target user token is set to the third request header to be processed through the first network request library to obtain the native interface request header;

[0114] If the jump target is the Flutter interface, after receiving the target user token in the second jump source interface, the target user token is transferred through the local file, and the target user token is set to the third request header to be processed through the second network request library to obtain the Flutter interface request header;

[0115] If the jump target is an HTML5 page, the target user token is transmitted through the event message bus according to the second subscriber, and the target user token is set to the third request header to be processed through the third network request library to obtain the HTML5 page request header.

[0116] In some embodiments, a subscriber is registered when the HTML5 page is initialized. After the login is completed and the user data and Token are saved on the login interface, an update data event is sent using EventBus. After HTML5 receives the update data event, the Token is set to the cookie using the CookieManager of WebView. In some embodiments, if the jump source of the event operation request is an HTML5 page, the target user token can be set to the third pending request header to obtain the target request header, which is used to characterize the completion of multi-terminal data synchronization. Specifically, it can be judged according to the event operation type. When the event operation type is to open a new interface or page, the request address is the new interface or page address. According to this address, it can be determined which specific interface or page to be opened (i.e., the jump target) is. If the jump target is a native interface, the target user token can be set to the third pending request header through the http network request library to obtain the native interface request header, i.e., the Okhttp request header. It can be understood that the second jump source interface is an HTML5 page. If the jump target is the Flutter interface, that is, the native interface -> HTML5 page -> login interface -> after completing the login, save the data and synchronize it to the native Okhttp, and then use EventBus to send the update data event -> close the login interface. After the HTML5 page receives the EventBus event, it updates the data of the HTML5 page and synchronizes the Token, and then jumps to the Flutter interface. The Flutter interface data update is completed during initialization, and there is no need to receive EventBus events for update. During the initialization of the Flutter interface, it is determined whether the Flutter request header has a Token. If yes, it will not be processed. Otherwise, the client's local data file is first accessed to check whether there is data. If yes, it will be synchronized. If no, it will not be processed. The core of initialization synchronization is the reading of the client's local file. It can be understood that the standard for determining whether it is necessary to receive the EventBus event to update the data is to look at the source of opening the login interface. Only when the source is HTML5 and Flutter, after completing the login and closing the login interface, when returning to the HTML5 page or Flutter interface, because the HTML5 page or Flutter interface has been initialized before logging in, the update data event is sent through EventBus for data update and synchronization. In client hybrid development, different network request frameworks are used, so the token and user data in the request header need to be managed and updated synchronously. For example, the native client uses Okhttp, HTML5 uses CookieManager in WebView, and Flutter uses http_manger in Dio, the network request framework of the Dart language.If the jump target is an HTML5 page, that is, native interface -> HTML5 page -> login interface -> after completing login, save the data and synchronize it to the native Okhttp, then use EventBus to send an update data event -> close the login interface, the HTML5 page receives the update data event, CookieManager sets the Token to the cookie, gets the HTML5 page request header, and finally jumps to the target HTML5 page. More importantly, when the event operation type is an operation event, since step S108 has been set as an HTML5 page, the native interface and Flutter interface are excluded, and a request with Token information is automatically initiated to the server according to the request address and parameters. At this time, just wait for the server to respond, thereby realizing the synchronization and event processing of user data after the native interface operation to the HTML5 login interface is successfully returned.

[0117] In some embodiments, a dynamic update method is used to replace the traditional method of sharing the same data file, and the native interface, Flutter interface or HTML5 page is treated as a whole, so that the user does not need to repeatedly read the file information in any interface operation, reducing the frequency of file reading. This embodiment adopts a data message event-driven method. During operation, if the user is not logged in, the login interface pops up. After completing the login, the request header information of the interface before the operation will be automatically updated, and the operation before the user logged in can be continued. There is no need for the user to log in again due to the interface jump, thereby improving the user experience.

[0118] The beneficial effects of implementing the embodiments of the present invention include: the embodiments of the present invention first send an event operation request to the server side, and determine through the server side whether the event operation request needs to verify user information to perform an information response operation or determine whether a first user token exists, and then perform a token verification operation on the first user token or perform a user login operation according to the error code and error information to obtain a target user token, and then determine the jump source. If it is a native interface, the target user token is set to the first pending request header; if it is a Flutter interface, the target user token is set to the second pending request header; if it is an HTML5 page, the target user token is set to the third pending request header, thereby obtaining the target request header, thereby realizing multi-terminal data synchronization and improving data management efficiency and user experience.

[0119] The embodiment of the present invention also provides a multi-terminal data synchronization device for client hybrid development, including:

[0120] The first module is used to send the event operation request to the server, and the server is used to determine whether the event operation request needs to verify user information;

[0121] The second module is used to determine that the event operation request does not need to verify user information according to the information returned by the server, and then perform an information response operation according to the response information;

[0122] The third module is used to determine that the event operation request needs to verify user information according to the information returned by the server, and then determine whether the first user token exists in the event operation request through the server;

[0123] The fourth module is used to determine that the first user token exists in the event operation request according to the information returned by the server, and then perform a token verification operation on the first user token;

[0124] The fifth module is used to determine that the first user token does not exist in the event operation request according to the information returned by the server, and then perform a user login operation according to the error code and the error information to obtain a target user token;

[0125] The sixth module is used for setting the target user token into the first request header to be processed if the jump source of the event operation request is the native interface, so as to obtain the target request header;

[0126] The seventh module is used to set the target user token to the second request header to be processed if the jump source of the event operation request is the Flutter interface, so as to obtain the target request header;

[0127] The eighth module is used to set the target user token to the third pending request header if the jump source of the event operation request is an HTML5 page, and obtain the target request header. The target request header includes a native interface request header, a Flutter interface request header or an HTML5 page request header. The target request header is used to indicate that multi-terminal data synchronization is completed.

[0128] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0129] An embodiment of the present invention further provides a computer device, comprising:

[0130] at least one processor;

[0131] at least one memory for storing at least one program;

[0132] When at least one program is executed by at least one processor, the at least one processor implements Figure 1 The method shown.

[0133] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0134] The embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, Figure 1 The method shown.

[0135] The contents of the above method embodiments are all applicable to the present storage medium embodiments. The functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0136] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A multi-terminal data synchronization method for mixed client development, characterized in that: The following steps are involved: Sending the event operation request to the server, wherein the server is used to determine whether the event operation request requires verification of user information; Determining, based on the information returned by the server, that the event operation request does not require verification of user information, then performing an information response operation based on the response information; Determining, according to the information returned by the server, that the event operation request needs to verify user information, then judging, through the server, whether there is a first user token in the event operation request; Determining, based on the information returned by the server, that a first user token exists in the event operation request, then performing a token verification operation on the first user token; Determining, based on the information returned by the server, that the first user token does not exist in the event operation request, then performing a user login operation based on the error code and the error information to obtain a target user token; If the jump source of the event operation request is a native interface, the target user token is set to the first request header to be processed to obtain a target request header; If the jump source of the event operation request is the Flutter interface, the target user token is set to the second request header to be processed to obtain the target request header; If the jump source of the event operation request is an HTML5 page, the target user token is set to the third request header to be processed to obtain the target request header, which includes a native interface request header, a Flutter interface request header or an HTML5 page request header. The target request header is used to characterize the completion of multi-terminal data synchronization.

2. The method according to claim 1, characterized in that The performing information response operation according to the response information includes: Receiving the response information from the server; According to the response information, a response interface is displayed.

3. The method according to claim 1, characterized in that The performing a token verification operation on the first user token includes: Determining, by the server, whether the first user token is within the validity period; If the first user token is within the validity period, performing the information response operation according to the response information; If the first user token is not within the validity period, the user login operation is performed according to the error code and the error information.

4. The method according to claim 1, characterized in that: The step of performing a user login operation according to the error code and the error information to obtain a target user token includes: Receiving the error code and the error information from the server; According to the error code and the error message, determining whether user login is required; If user login is required, the jump source, event operation type, request address, request parameters, user account and user password are sent to the server, and the server is also used to generate the target user token; The target user token is received from the server.

5. The method according to claim 1, characterized in that: The step of setting the target user token into the first request header to be processed to obtain the target request header includes: If the jump target is a native interface, the target user token is set to the first request header to be processed through the first network request library to obtain the native interface request header; If the jump target is a Flutter interface, the target user token is transmitted through a local file, and the target user token is set to the first request header to be processed through a second network request library to obtain the Flutter interface request header; If the jump target is an HTML5 page, the target user token is transmitted through the HTML5 function method, and the target user token is set to the first request header to be processed through the third network request library to obtain the HTML5 page request header.

6. The method according to claim 5, characterized in that The step of setting the target user token into the second request header to be processed to obtain the target request header includes: If the jump target is a native interface, the target user token is set to the second request header to be processed through the first network request library to obtain the native interface request header; If the jump target is a Flutter interface, the target user token is transmitted through the event message bus according to the first subscriber, and the target user token is set to the second pending request header through the second network request library to obtain the Flutter interface request header; If the jump target is an HTML5 page, after receiving the target user token on the first jump source interface, the target user token is transmitted through the HTML5 function method, and the target user token is set to the second pending request header through the third network request library to obtain the HTML5 page request header.

7. The method according to claim 6, characterized in that The step of setting the target user token into a third request header to be processed to obtain the target request header includes: If the jump target is a native interface, the target user token is set to the third request header to be processed through the first network request library to obtain the native interface request header; If the jump target is a Flutter interface, after receiving the target user token on the second jump source interface, the target user token is transmitted through the local file, and the target user token is set to the third request header to be processed through the second network request library to obtain the Flutter interface request header; If the jump target is an HTML5 page, the target user token is transmitted through the event message bus according to the second subscriber, and the target user token is set to the third request header to be processed through the third network request library to obtain the HTML5 page request header.

8. A multi-terminal data synchronization device with mixed client development, characterized in that: include: The first module is used to send an event operation request to a server, and the server is used to determine whether the event operation request needs to verify user information; The second module is used to determine that the event operation request does not need to verify user information according to the information returned by the server, and then perform an information response operation according to the response information; A third module is used to determine, based on the information returned by the server, that the event operation request needs to verify user information, and then determine, through the server, whether there is a first user token in the event operation request; A fourth module is used to determine, based on the information returned by the server, that a first user token exists in the event operation request, and then perform a token verification operation on the first user token; A fifth module is used to determine, according to the information returned by the server, that the first user token does not exist in the event operation request, and then perform a user login operation according to the error code and the error information to obtain a target user token; The sixth module is used for setting the target user token into the first request header to be processed to obtain a target request header if the jump source of the event operation request is a native interface; The seventh module is used to set the target user token to the second request header to be processed if the jump source of the event operation request is the Flutter interface, so as to obtain the target request header; The eighth module is used to set the target user token to the third request header to be processed if the jump source of the event operation request is an HTML5 page, and obtain the target request header. The target request header includes a native interface request header, a Flutter interface request header or an HTML5 page request header. The target request header is used to characterize the completion of multi-terminal data synchronization.

9. A computer device, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.