Development framework and webpage control integration method and device
By embedding web controls in the MFC development framework, building a data conversion layer and resource loading structure, and integrating MFC and web controls, the limitations of the MFC application interface and insufficient utilization of local resources in Web applications are solved, and efficient desktop application development is achieved.
Patent Information
- Application Number
- CN202411701572.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-04-11
AI Technical Summary
The limitations of the MFC application interface in the prior art and the problem of insufficient utilization of local resources of Web applications.
By embedding the target web controls in the target development framework and building the target layer and target structure, the data type conversion, event delivery and data exchange between the target development framework and the target web control are realized, the resource loading method is determined, and the target application is finally integrated.
It solves the limitations of the MFC application interface and the insufficient utilization of local resources of Web applications, and realizes that desktop applications not only retain native advantages, but also introduces the flexibility of web controls.
Smart Images

Figure CN119806517A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software development technology, and in particular to a method and device for integrating a development framework with a web page control. Background Art
[0002] With the rapid development of information technology, users have put forward higher requirements for the interactive experience of software applications. In the field of desktop application development, traditional MFC (Microsoft Foundation Classes) applications are favored by developers for their stable performance and efficient use of local resources. However, MFC applications have certain limitations in building complex and modern user interfaces, especially in processing dynamic content, achieving smooth animation effects, and supporting multi-platform compatibility. MFC can provide relatively little support.
[0003] At the same time, web-based technologies, such as HTML (HyperText Markup Language), CSS (Cascading Style Sheets), and JavaScript (a programming language), provide powerful tools and frameworks for building rich and interactive user interfaces. These technologies allow developers to create visually appealing interfaces with good user experience, and can easily run across platforms. However, pure web applications usually run in a browser environment, and it is difficult to directly access and utilize local system resources, such as hardware acceleration, file systems, local databases, etc. This limits the use of web applications in scenarios where performance requirements are high or deep system integration is required.
[0004] Therefore, in modern software development, how to balance the advantages and disadvantages of traditional MFC applications and pure Web applications and make full use of their respective advantages has become an urgent problem to be solved.
[0005] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0006] The present application provides a method and device for integrating a development framework with a web page control, so as to at least solve the technical problems of the limitations of the MFC application interface and the insufficient utilization of local resources of Web applications in the prior art.
[0007] According to one aspect of the present application, a method for integrating a development framework with a web page control is provided, comprising: embedding a target web page control in a target development framework, wherein the target development framework is used to access a local file system, a registry, and a local interface, and the target web page control is used to display and interact with web page content in a native application; constructing a target layer and a target structure, wherein the target layer is used to process data type conversion, event delivery, and data exchange between the target development framework and the target web page control, and the target structure is used to determine a resource loading method; integrating the target development framework and the target web page control according to the target layer and the target structure to obtain a target application.
[0008] Optionally, constructing a target layer and a target structure includes: constructing a target layer according to a first communication method, a second communication method, and a third communication method, wherein the first communication method is used to realize one-way communication between a target development framework and a target web page control, the second communication method is used to realize two-way communication between the target development framework and the target web page control, and the third communication method is used to process data transmission between the target development framework and the target web page control; determining a target structure according to a resource loading strategy and a page display method, wherein the resource loading strategy is used to determine the source of data resources, and the page display method is used to determine a switching method between pages.
[0009] Optionally, before building the target layer according to the first communication mode, the second communication mode and the third communication mode, the method for integrating the development framework and the web page control also includes: obtaining a first calling method and a second calling method, wherein the first calling method is used to transfer information from the target development framework to the target web page control, and the second calling method is used to transfer information from the target web page control to the target development framework; determining the first communication mode according to the first calling method and the second calling method; obtaining a third calling method, wherein the third calling method is used to open the calling permission of the function object in the target development framework to the target web page control; determining the second communication mode according to the third calling method; obtaining a fourth calling method, wherein the fourth calling method is used to establish a shared memory channel between the target development framework and the target web page control; and determining the third communication mode according to the fourth calling method.
[0010] Optionally, the method for integrating the development framework with the web page control also includes: in the process of determining the second communication method according to the third calling method, creating a target function object, wherein the target function object includes multiple function processing methods and function properties; and registering the target function object to the target web page control according to the third calling method.
[0011] Optionally, determining the third communication mode according to the fourth calling method includes: creating a shared memory cache area in the target development framework; obtaining a target interface, wherein the target interface is used as an access channel for the target web page control to access the shared memory cache area; determining the third communication mode according to the shared memory cache area, the fourth calling method and the target interface.
[0012] Optionally, the resource loading strategy is obtained through the following steps, including: obtaining a resource request; determining whether the target resource corresponding to the resource request belongs to a resource in the local cache; if it is determined that the target resource belongs to a resource in the local cache, checking whether the version of the target resource is the latest version; if the version of the target resource is the latest version, outputting the target resource; if the version of the target resource is not the latest version, obtaining the latest version of the resource from the network, updating the latest version of the resource to the local cache, and outputting the latest version of the resource from the local cache; if the target resource does not belong to a resource in the local cache, obtaining the target resource from the network, updating it to the local cache, and outputting the target resource.
[0013] Optionally, the method for integrating the development framework with the web page control also includes: obtaining a target method, wherein the target method is used to preload data resources in a target web page control; in the process of starting a target application, preloading data resources whose usage frequency exceeds a first preset threshold according to the target method; configuring a delayed loading strategy and an operation cache strategy, wherein the delayed loading strategy is used to delay the loading of first-category data resources and second-category data resources, wherein the first-category data resources are data resources that do not affect the normal startup of the target application, and the second-category data resources are data resources that are not related to processing user requests, and the operation cache strategy is used to cache historical data resources that have been loaded by the target web page control.
[0014] According to another aspect of the present application, there is also provided an integration device of a development framework and a web page control, comprising: an embedding unit, which embeds a target web page control in a target development framework, wherein the target development framework is used to access a local file system, a registry, and a local interface, and the target web page control is used to display and interact with web page content in a native application; a construction unit, which constructs a target layer and a target structure, wherein the target layer is used to process data type conversion, event transmission, and data exchange between the target development framework and the target web page control, and the target structure is used to determine a resource loading method; and an integration unit, which integrates the target development framework and the target web page control according to the target layer and the target structure to obtain a target application.
[0015] According to another aspect of the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, wherein when the computer program runs, the device where the computer-readable storage medium is located executes the above-mentioned method of integrating the development framework with the web page control.
[0016] According to another aspect of the present application, an electronic device is also provided, wherein the electronic device includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors execute the above-mentioned method of integrating the development framework with the web page control.
[0017] It can be seen from the above content that in the present application, by embedding the target web page control in the target development framework, wherein the target development framework is used to access the local file system, registry, and local interface, and the target web page control is used to display and interact with web page content in the native application, and then constructing the target layer and the target structure, the data type conversion, event transmission and data exchange between the target development framework and the target web page control are realized according to the constructed target layer, and the request resource loading method is determined according to the constructed target structure, that is, the target development framework and the target web page control are integrated according to the target layer and the target structure, and finally a desktop application is obtained. The desktop application retains the native advantages of the target development framework and introduces the flexibility of the target web page control, thereby achieving the purpose of integrating the target development framework with the target web page control, thereby solving the technical problems of the limitations of the MFC application interface and the insufficient utilization of local resources of Web applications in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0019] Figure 1 is a flowchart of an optional method for integrating a development framework with a web page control according to an embodiment of the present application;
[0020] Figure 2 It is a structural block diagram of an optional method for integrating a development framework with a web page control according to an embodiment of the present application;
[0021] Figure 3 is a schematic diagram of an optional communication through a dynamic bridging layer according to an embodiment of the present application;
[0022] Figure 4 is a flow chart of an optional intelligent routing system according to an embodiment of the present application;
[0023] Figure 5 It is a schematic diagram of an optional integrated device of a development framework and a web page control according to an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0026] It should also be noted that the information and data collected by this application are authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data comply with the relevant laws, regulations and standards of the relevant regions, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation portals for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or institutions. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or institution through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or institution.
[0027] According to an embodiment of the present application, an embodiment of a method for integrating a development framework with a web page control is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0028] It should be noted that an intelligent integration system can be used as the execution subject of the development framework and web page control integration method of the embodiment of the present application. It is understandable that the development framework and web page control integration method provided in the embodiment of the present application can also be executed by other systems or devices, and the embodiment of the present application does not specifically limit this.
[0029] Figure 1 is a flowchart of an optional method for integrating a development framework with a web page control according to an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:
[0030] Step S101, embedding a target web page control in a target development framework.
[0031] In step S101, the target development framework is used to access the local file system, registry, and local interface, and the target web page control is used to display and interact with web page content in the native application.
[0032] Optionally, the target development framework is the MFC framework, which is a C++ (a programming language) class library for developing Windows applications, and can quickly develop desktop applications under the Windows operating system. The MFC framework encapsulates the complexity of the Win32 API (Microsoft Windows 32-bit Application Programming Interface), can directly interact with the Windows system, and provides better performance. It also provides a series of predefined classes to represent common GUI elements (Graphical User Interface Elements), such as windows, dialog boxes, and controls, and simplifies the programming of message processing and event processing.
[0033] Optionally, the target web page control is Webview2 (Microsoft Web View, an embedded browser control), which allows a web view based on the Chromium (a browser kernel) open source project to be embedded in a native application. The WebView2 control supports the latest Web standards, can render complex web page content, and provides an API (Application Programming Interface) for interacting with the host application. Developers can use the WebView2 control to integrate Web technology in desktop applications and create hybrid applications, thereby combining the performance of native applications with the flexibility of Web applications.
[0034] Optionally, the intelligent integration system first embeds the Webview2 control into the MFC framework, which usually involves introducing necessary Webview2 library files and header files into the MFC project, and then creating and initializing the Webview2 control in the MFC interface designer or code.
[0035] Step S102, constructing a target layer and a target structure.
[0036] In step S102, the target layer is used to process data type conversion, event delivery and data exchange between the target development framework and the target web page control, and the target structure is used to determine the resource loading method.
[0037] Optionally, the intelligent integration system builds a dynamic bridging layer (target layer) and an intelligent routing system (target structure) to achieve communication between MFC and Webview2 and determine the source of the user's requested resources.
[0038] Optionally, the dynamic bridging layer acts as a bridge for data type conversion and communication protocol differences between MFC and WebView2, and handles event transfer between the two. For example, MFC's native user interface events are passed to WebView2, or JavaScript events in WebView2 are passed to MFC, to achieve two-way data exchange, so that MFC components and Web content can share and synchronize data, etc. The dynamic bridging layer provides a unified API interface, encapsulates complex WebView2 operations, and dynamically adjusts the bridging strategy according to the operating environment and application requirements. By dynamically adjusting the bridging strategy, the response speed of the application can be significantly improved, especially when dealing with complex Web interactions. The bridging strategy can be adjusted according to real-time needs, which is suitable for scenarios that require highly customized interactions, such as game development, graphical user interface design, etc.
[0039] Optionally, the intelligent routing system mainly handles resource loading strategies and security controls, where the resource loading strategies include: deciding whether resources, such as HTML, CSS, JavaScript, images, etc., are loaded locally or obtained from the network; security control mainly refers to: implementing an intelligent caching mechanism, optimizing resource loading speed and efficiency, and performing security checks on requests to prevent potential security threats.
[0040] Optionally, the intelligent routing system may also include an algorithm for automatically switching cache strategies to adapt to different network environments. This algorithm can intelligently select the most appropriate resource loading method based on network conditions, reduce the impact of network delays on application performance, and is suitable for application scenarios with unstable network conditions or frequently changing resource requirements, such as mobile office software, online collaboration platforms, etc.
[0041] Step S103, integrating the target development framework and the target web page control according to the target layer and the target structure to obtain the target application.
[0042] Optionally, the intelligent integration system integrates the MFC framework and the WebView2 control according to the dynamic bridging layer and the intelligent routing system, and finally obtains a desktop application.
[0043] Optionally, Figure 2is a structural block diagram of an optional method for integrating a development framework and a web page control according to an embodiment of the present application, such as Figure 2 As shown in the figure, the integration process of the development framework and the web page control involves three stages. The first stage is the MFC initialization stage. In this stage, the MFC application will set up its basic operating environment, such as initializing Windows and MFC libraries, creating the main window, etc. The second stage is the WebView2 processing stage. In this stage, Webview2 is introduced and used to render Web content. This stage mainly includes four modules, namely the dynamic bridging layer, the intelligent routing system, resource management, and WebView2 content preparation. The dynamic bridging layer is the communication intermediary between MFC and WebView2. It is responsible for handling data type conversion, protocol differences, and two-way transmission of events and data between the two. The intelligent routing system is responsible for resource loading strategies and security control. Resource management is used to manage data resources. WebView2 content preparation is used to render Web content. The third stage is the rendering and display stage. In this stage, the MFC dialog box or FormView (a form view control) is mixed with the Web content in WebView2 for rendering, and finally a unified user interface is presented to the user.
[0044] It can be seen from the contents of steps S101 to S103 that in the present application, a target web page control is first embedded in a target development framework, wherein the target development framework is used to access the local file system, registry, and local interface, and the target web page control is used to display and interact with web page content in a native application. Then a target layer and a target structure are constructed, wherein the target layer is used to process data type conversion, event delivery, and data exchange between the target development framework and the target web page control, and the target structure is used to determine the resource loading method. Finally, the target development framework and the target web page control are integrated according to the target layer and the target structure to obtain a target application.
[0045] It can be seen from the above content that in the present application, by embedding the target web page control in the target development framework, wherein the target development framework is used to access the local file system, registry, and local interface, and the target web page control is used to display and interact with web page content in the native application, and then constructing the target layer and the target structure, the data type conversion, event transmission and data exchange between the target development framework and the target web page control are realized according to the constructed target layer, and the request resource loading method is determined according to the constructed target structure, that is, the target development framework and the target web page control are integrated according to the target layer and the target structure, and finally a desktop application is obtained. The desktop application retains the native advantages of the target development framework and introduces the flexibility of the target web page control, thereby achieving the purpose of integrating the target development framework with the target web page control, thereby solving the technical problems of the limitations of the MFC application interface and the insufficient utilization of local resources of Web applications in the prior art.
[0046] In an optional embodiment, the intelligent integration system constructs a target layer according to a first communication mode, a second communication mode and a third communication mode, wherein the first communication mode is used to realize one-way communication between a target development framework and a target web page control, the second communication mode is used to realize two-way communication between the target development framework and the target web page control, and the third communication mode is used to process data transmission between the target development framework and the target web page control, and then determines the target structure according to a resource loading strategy and a page display method, wherein the resource loading strategy is used to determine the source of data resources, and the page display method is used to determine the switching method between pages.
[0047] Optionally, the intelligent integration system builds a dynamic bridging layer based on PostMessage communication (first communication mode), HostObjects communication (second communication mode) and shared memory communication (third communication mode), which enables the system to flexibly handle communication and data transmission between the MFC framework and WebView2.
[0048] Optionally, PostMessage communication is suitable for simple interaction scenarios and is used when no return result is required. For example, a user operation event is sent from the MFC framework to WebView2, such as clicking a button, but WebView2 does not need to return a specific processing result. This communication method realizes simple, one-way data transmission. Its advantages are lightweight and suitable for frequent interactions, reducing unnecessary processing overhead; HostObjects communication is suitable for complex interaction scenarios that need to return results. This mechanism supports two-way communication, making the interaction between the MFC framework and WebView2 more flexible and rich; shared memory communication is used to process efficient transmission of large amounts of data. When processing large amounts of data, the traditional serialization and deserialization process consumes a lot of time and computing resources. Through shared memory communication, memory can be shared between the MFC framework and WebView2 to directly transmit data, avoiding the overhead of serialization and deserialization, and significantly improving the efficiency and speed of data transmission.
[0049] Optionally, the intelligent integration system can flexibly select and apply three communication methods, namely PostMessage communication, HostObjects communication and shared memory communication, according to different communication requirements and data transmission characteristics, to achieve efficient communication between the MFC framework and WebView2.
[0050] Optionally, Figure 3 is a schematic diagram of an optional communication through a dynamic bridging layer according to an embodiment of the present application, such as Figure 3 As shown, in the backend of MFC, MFC components are connected through a dynamic bridging layer. The communication channel connected by the dynamic bridging layer has three communication modes, namely PostMessage communication, HostObjects communication and shared memory communication. The communication between MFC components and WebView2 controls is realized through these three communication modes.
[0051] Optionally, the intelligent integration system determines the intelligent routing system based on the resource loading strategy and the page display method, wherein the resource loading strategy is used to determine the source of data resources, such as whether to load from the local cache or obtain from a remote server, and the page display method involves a switching mechanism between pages, such as using hash routing technology to implement front-end page navigation. This page switching method will not trigger page refresh, which is beneficial to improving application performance and user experience.
[0052] From the above content, it can be seen that by introducing three different communication methods, the intelligent integration system can adapt to a variety of development scenarios and needs, thereby improving the flexibility and adaptability of communication, and through a special data transmission communication method, the system can better protect the security and integrity of the data. In addition, through intelligent decision-making on resource loading strategies and page display methods, the system can provide a smoother and more intuitive user experience, and enable developers to implement complex interactive functions more easily and quickly, thereby improving development efficiency.
[0053] In an optional embodiment, the intelligent integrated system obtains a first calling method and a second calling method, wherein the first calling method is used to transfer information from a target development framework to a target web page control, and the second calling method is used to transfer information from a target web page control to a target development framework, and then determines a first communication mode according to the first calling method and the second calling method, and then obtains a third calling method, wherein the third calling method is used to open the calling permission of a function object in the target development framework to the target web page control, and then determines a second communication mode according to the third calling method, and then obtains a fourth calling method, wherein the fourth calling method is used to establish a shared memory channel between the target development framework and the target web page control, and then determines a third communication mode according to the fourth calling method.
[0054] Optionally, the first calling method is the PostWebMessageAsJson method, which is used to send messages from MFC to WebView2. When calling this method, a string in JSON format (JavaScript Object Notation) can be passed as a parameter, and the string includes the data you want to send to the web page. For example, this method can be used to notify the web page of a user operation or to send some initialization data. The second calling method is the window.chrome.webview.postMessage method. This method is located in the JavaScript environment and is used to send messages from the web page of WebView2 to the host application (here is the MFC application). In the JavaScript code of the web page, the window.chrome.webview.postMessage method is used to send data. This method receives a parameter, usually a JavaScript object, which will be serialized into a JSON string and then passed to the MFC application.
[0055] Optionally, in an MFC application, when data needs to be sent to a web page, call the PostWebMessageAsJson method to send the data in JSON format. In the JavaScript of the web page, use the window.chrome.webview.postMessage method to respond to the MFC application or send data to the MFC application.
[0056] Optionally, the third calling method is the AddHostObjectToScript method, which is provided by WebView2 and is a mechanism for using native (C++) code in JavaScript. Through this method, you can define a name in JavaScript and then associate a reference to a C++ object with this name. After that, in the JavaScript code of the Web page, you can call member functions of the C++ object through this name, and even access certain member variables.
[0057] Optionally, the fourth calling method is the PostSharedBufferToScript method, which is also provided by WebView2. Simply put, this method is used to pass a shared memory buffer to JavaScript, so that JavaScript can access this shared memory buffer directly in the browser rendering process without serializing and deserializing the data, greatly improving the data transmission speed and efficiency.
[0058] From the above content, it can be seen that the intelligent integration system realizes one-way communication between Web pages and MFC applications according to the PostWebMessageAsJson method and the window.chrome.webview.postMessage method, realizes two-way communication between Web pages and MFC applications according to the AddHostObjectToScript method, and can realize the processing of large amounts of data between Web pages and MFC applications according to the PostSharedBufferToScript method. Through these three communication methods, efficient integration and communication between the MFC framework and the Webview2 control are realized, which not only improves the performance of the application and user experience, but also ensures the security and flexibility of data exchange.
[0059] In an optional embodiment, the intelligent integrated system creates a target function object in the process of determining the second communication mode according to the third calling method, wherein the target function object includes multiple function processing methods and function properties, and then registers the target function object to the target web page control according to the third calling method.
[0060] Optionally, the AddHostObjectToScript method allows native objects (usually C++) to be exposed to JavaScript code in WebView2, thereby enabling two-way communication between the two. In layman's terms, a direct communication channel is established between the MFC application and the embedded Webview2 environment, allowing the MFC application to directly control the Web content, and the Web content can also call methods in the MFC application or access its properties.
[0061] Optionally, the intelligent integration system first needs to create a C++ class that meets the WebView2 bridging requirements. This class will be encapsulated into an object that can be called by JavaScript. Then, through the AddHostObjectToScript method, this C++ class instance is added to the context of Webview2, so that in the web page loaded by WebView2, this C++ object can be accessed through a specific namespace and object name to call its methods or get its properties. At the same time, event handlers can also be defined in the C++ object so that when specific JavaScript events are triggered, the MFC application can receive these events and respond.
[0062] From the above content, it can be seen that the intelligent integration system can use WebView2 using C++ objects and its methods and properties according to the third calling method, thereby realizing two-way communication between the two. It is suitable for scenarios that require real-time interaction and result feedback, and can provide a more direct and efficient data processing and interaction experience.
[0063] In an optional embodiment, the intelligent integration system creates a shared memory cache area in the target development framework, and then obtains the target interface, wherein the target interface is used as an access channel for the target web page control to access the shared memory cache area, and finally determines the third communication mode based on the shared memory cache area, the fourth calling method and the target interface.
[0064] Optionally, the intelligent integration system first needs to create a shared memory buffer on the C++ side and fill it with the data to be transmitted, and then pass this buffer to JavaScript using the PostSharedBufferToScript method. On the JavaScript side, a specific API (such as window.chrome.webview.getBuffer()) is used to access this shared memory buffer. JavaScript can read the data in the buffer, process it, and if necessary, write it back to the shared memory for further processing on the C++ side.
[0065] From the above content, it can be seen that the intelligent integration system avoids the serialization and deserialization process of data between C++ and JavaScript through shared memory communication, significantly reduces data transmission delay, and improves the efficiency of large data transmission, thereby enhancing the interaction speed between Webview2 and MFC and improving user experience. In addition, by creating a shared memory cache area at the MFC layer, the system can store and quickly access commonly used or large data locally, avoiding frequent network requests and resource loading, reducing bandwidth consumption, and enhancing the responsiveness and offline capabilities of the application.
[0066] In an optional embodiment, the intelligent integration system first obtains a resource request, then determines whether the target resource corresponding to the resource request belongs to a resource in the local cache. If it is determined that the target resource belongs to a resource in the local cache, check whether the version of the target resource is the latest version. If the version of the target resource is the latest version, output the target resource. If the version of the target resource is not the latest version, obtain the latest version of the resource from the network, update the latest version of the resource to the local cache, and output the latest version of the resource from the local cache. If the target resource does not belong to a resource in the local cache, obtain the target resource from the network, update it to the local cache, and output the target resource.
[0067] Optionally, an intelligent routing system receives all user requests and decides how to handle them, and divides the requests into two categories: front-end requests and resource requests. Figure 4 is a flow chart of an optional intelligent routing system according to an embodiment of the present application, such as Figure 4 As shown, after obtaining the user request, it is first determined whether it is a resource request or a front-end request. If it is a front-end request, the corresponding page is switched according to the user's request. If it is a resource request, it is first determined whether the requested resource exists locally. If the resource exists locally, check whether the resource version is the latest version, and determine whether the resource needs to be updated based on the check result. If the resource is not the latest version, the latest version corresponding to the resource is re-obtained from the network and updated to the local cache, and then the resource is loaded from the local cache and returned. If the resource is the latest version, the resource is directly loaded from the local and returned. If the resource does not exist locally, the resource is directly loaded from the network and cached locally, and finally the resource is returned.
[0068] From the above content, it can be seen that the intelligent integration system achieves efficient, secure and flexible resource loading through intelligent caching, version checking and network resource management, effectively improving the performance and user experience of the efficient Webview2 integration system and method based on the MFC framework, while ensuring the latest and consistency of resources.
[0069] In an optional embodiment, the intelligent integration system first obtains a target method, wherein the target method is used to preload data resources in a target web page control, and then in the process of starting a target application, preloads data resources whose usage frequency exceeds a first preset threshold according to the target method, and configures a delayed loading strategy and a running cache strategy, wherein the delayed loading strategy is used to delay the loading of first-category data resources and second-category data resources, wherein the first-category data resources are data resources that do not affect the normal startup of the target application, and the second-category data resources are data resources that are not related to processing user requests, and the running cache strategy is used to cache historical data resources that have been loaded by the target web page control.
[0070] Optionally, the target method is a NavigateToString method, which is a method provided in WebView2. The NavigateToString method is used to preload some commonly used resources, such as HTML, CSS, or JavaScript code, when the application starts, to reduce the loading time of subsequent operations.
[0071] Optionally, the lazy loading strategy postpones the loading of non-critical resources (such as images, videos, JavaScript scripts, etc.) until after the initial loading of the page is completed, or loads them only when the user actually needs to view or use these resources. By lazy loading of non-critical resources, the loading time when the user first opens the page can be significantly reduced, because the browser or application only needs to load the most basic resources that make up the first screen display, such as page structure and core styles, which makes the page or application startup appear faster and improves the user experience.
[0072] Optionally, running a cache strategy allows the browser control (WebView2 control) to store already loaded network resources locally so that subsequent requests for the same resource can be read directly from the cache without having to download it from the network again. Using the WebView2 cache mechanism can significantly shorten resource loading time and avoid repeated network requests, thereby improving page loading speed and the overall performance of the WebView2 component.
[0073] From the above content, it can be seen that the intelligent integration system significantly improves the startup speed and responsiveness of the application by preloading commonly used resources and delaying the loading of non-critical resources, thereby improving the overall user experience. It also reduces network transmission and repeated resource loading by running caching strategies, reduces the complexity of resource management, improves resource utilization efficiency, and enhances the offline operation capabilities of the application.
[0074] According to another aspect of the embodiments of the present application, an embodiment of a device for integrating a development framework with a web page control is also provided. Figure 5is a schematic diagram of an optional integrated device of a development framework and a web page control according to an embodiment of the present application, such as Figure 5 As shown, the integration device of the development framework and the web page control includes: an embedding unit 501 , a construction unit 502 and an integration unit 503 .
[0075] Optionally, an embedding unit 501 is used to embed a target web page control in a target development framework, wherein the target development framework is used to access a local file system, a registry, and a local interface, and the target web page control is used to display and interact with web page content in a native application; a construction unit 502 is used to construct a target layer and a target structure, wherein the target layer is used to process data type conversion, event delivery, and data exchange between the target development framework and the target web page control, and the target structure is used to determine a resource loading method; an integration unit 503 is used to integrate the target development framework and the target web page control according to the target layer and the target structure to obtain a target application.
[0076] Optionally, the construction unit 502 includes: a first construction subunit and a first determination subunit. The first construction subunit is used to construct the target layer according to the first communication mode, the second communication mode and the third communication mode, wherein the first communication mode is used to realize the one-way communication between the target development framework and the target web page control, the second communication mode is used to realize the two-way communication between the target development framework and the target web page control, and the third communication mode is used to process the data transmission between the target development framework and the target web page control; the first determination subunit is used to determine the target structure according to the resource loading strategy and the page display mode, wherein the resource loading strategy is used to determine the source of the data resource, and the page display mode is used to determine the switching mode between pages.
[0077] Optionally, the first construction subunit includes: a first acquisition module, a first determination module, a second acquisition module, a second determination module, a third acquisition module and a third determination module. The first acquisition module is used to acquire a first calling method and a second calling method, wherein the first calling method is used to transfer information from a target development framework to a target web page control, and the second calling method is used to transfer information from a target web page control to a target development framework; the first determination module is used to determine a first communication method according to the first calling method and the second calling method; the second acquisition module is used to acquire a third calling method, wherein the third calling method is used to open the calling authority of a function object in the target development framework to the target web page control; the second determination module is used to determine a second communication method according to the third calling method; the third acquisition module is used to acquire a fourth calling method, wherein the fourth calling method is used to establish a shared memory channel between the target development framework and the target web page control; the third determination module is used to determine a third communication method according to the fourth calling method.
[0078] Optionally, the integrated device of the development framework and the web page control further includes: a creation unit and a registration unit. The creation unit is used to create a target function object in the process of determining the second communication mode according to the third calling method, wherein the target function object includes a plurality of function processing methods and function properties; and the registration unit is used to register the target function object into the target web page control according to the third calling method.
[0079] Optionally, the third determination module includes: a first creation submodule, a first acquisition submodule and a first determination submodule. The first creation submodule is used to create a shared memory cache in the target development framework; the first acquisition submodule is used to acquire a target interface, wherein the target interface is used as an access channel for the target web page control to access the shared memory cache; the first determination submodule is used to determine the third communication mode according to the shared memory cache, the fourth calling method and the target interface.
[0080] Optionally, the first determination subunit includes: a fourth acquisition module, a first judgment module, a first inspection module, a first output module, a second output module and a third output module. Among them, the fourth acquisition module is used to obtain a resource request; the first judgment module is used to determine whether the target resource corresponding to the resource request belongs to a resource in the local cache; the first inspection module is used to check whether the version of the target resource is the latest version when it is determined that the target resource belongs to a resource in the local cache; the first output module is used to output the target resource when the version of the target resource is the latest version; the second output module is used to obtain the latest version of the resource from the network when the version of the target resource is not the latest version, and update the latest version of the resource to the local cache, and output the latest version of the resource from the local cache; the third output module is used to obtain the target resource from the network when the target resource does not belong to a resource in the local cache, update it to the local cache, and output the target resource.
[0081] Optionally, the integrated device of the development framework and the web page control further includes: an acquisition unit, a processing unit, and a configuration unit. The acquisition unit is used to acquire a target method, wherein the target method is used to preload data resources in a target web page control; the processing unit is used to preload data resources whose usage frequency exceeds a first preset threshold according to the target method during the process of starting the target application; the configuration unit is used to configure a delayed loading strategy and a running cache strategy, wherein the delayed loading strategy is used to delay the loading of a first type of data resources and a second type of data resources, wherein the first type of data resources are data resources that do not affect the normal startup of the target application, and the second type of data resources are data resources that are not related to processing user requests, and the running cache strategy is used to cache historical data resources that have been loaded by the target web page control.
[0082] According to another aspect of the present application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, wherein when the computer program is executed, the device where the computer-readable storage medium is located executes the above-mentioned method of integrating the development framework with the web page control.
[0083] According to another aspect of the present application, an electronic device is also provided, wherein the electronic device includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned method of integrating the development framework with the web page control.
[0084] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0085] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0086] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0087] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0088] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0089] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including 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 application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0090] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for integrating a development framework with a web page control, characterized in that: include: Embedding a target web page control in a target development framework, wherein the target development framework is used to access a local file system, a registry, and a local interface, and the target web page control is used to display and interact with web page content in a native application; Constructing a target layer and a target structure, wherein the target layer is used to process data type conversion, event transmission and data exchange between the target development framework and the target web page control, and the target structure is used to determine a resource loading method; The target development framework and the target web page control are integrated according to the target layer and the target structure to obtain a target application program.
2. The method for integrating a development framework with a web page control according to claim 1, characterized in that: Build the target layer and target structure, including: The target layer is constructed according to a first communication mode, a second communication mode and a third communication mode, wherein the first communication mode is used to realize one-way communication between the target development framework and the target web page control, the second communication mode is used to realize two-way communication between the target development framework and the target web page control, and the third communication mode is used to process data transmission between the target development framework and the target web page control; The target structure is determined according to a resource loading strategy and a page display method, wherein the resource loading strategy is used to determine the source of data resources, and the page display method is used to determine the switching method between pages.
3. The method for integrating a development framework with a web page control according to claim 2, characterized in that: Before constructing the target layer according to the first communication mode, the second communication mode and the third communication mode, the method for integrating the development framework with the web page control further includes: Acquire a first calling method and a second calling method, wherein the first calling method is used to transfer information from the target development framework to the target web page control, and the second calling method is used to transfer information from the target web page control to the target development framework; Determine the first communication mode according to the first calling method and the second calling method; Obtaining a third calling method, wherein the third calling method is used to open the calling permission of the function object in the target development framework to the target web page control; Determine the second communication mode according to the third calling method; Acquire a fourth calling method, wherein the fourth calling method is used to establish a shared memory channel between the target development framework and the target web page control; The third communication mode is determined according to the fourth calling method.
4. The method for integrating a development framework with a web page control according to claim 3, characterized in that: The method for integrating the development framework with the web page control also includes: In the process of determining the second communication mode according to the third calling method, creating a target function object, wherein the target function object includes a plurality of function processing methods and function attributes; The target function object is registered in the target web page control according to the third calling method.
5. The method for integrating a development framework with a web page control according to claim 3, characterized in that: Determining the third communication mode according to the fourth calling method includes: Creating a shared memory buffer in the target development framework; Acquire a target interface, wherein the target interface is used as an access channel for the target web page control to access the shared memory cache area; The third communication mode is determined according to the shared memory cache area, the fourth calling method and the target interface.
6. The method for integrating a development framework with a web page control according to claim 2, characterized in that: The resource loading strategy is obtained through the following steps, including: Get resource request; Determine whether the target resource corresponding to the resource request belongs to the resource in the local cache; In the case where it is determined that the target resource belongs to the resource in the local cache, checking whether the version of the target resource is the latest version; When the version of the target resource is the latest version, output the target resource; When the version of the target resource is not the latest version, obtaining the latest version of the resource from the network, updating the latest version of the resource to the local cache, and outputting the latest version of the resource from the local cache; In the case that the target resource does not belong to the resources in the local cache, the target resource is acquired from the network, updated into the local cache, and outputted.
7. The method for integrating a development framework with a web page control according to claim 1, characterized in that: The method for integrating the development framework with the web page control also includes: Obtaining a target method, wherein the target method is used to preload data resources in the target web page control; In the process of starting the target application, preloading data resources with a usage frequency exceeding a first preset threshold according to the target method; Configure a delayed loading strategy and a running cache strategy, wherein the delayed loading strategy is used to delay the loading of a first category of data resources and a second category of data resources, wherein the first category of data resources are data resources that do not affect the normal startup of the target application, and the second category of data resources are data resources that are not related to processing user requests, and the running cache strategy is used to cache historical data resources that have been loaded by the target web page control.
8. An integrated device for developing a framework and a web page control, characterized in that: include: An embedding unit, which embeds a target web page control in a target development framework, wherein the target development framework is used to access a local file system, a registry, and a local interface, and the target web page control is used to display and interact with web page content in a native application; A construction unit, constructing a target layer and a target structure, wherein the target layer is used to process data type conversion, event transmission and data exchange between the target development framework and the target web page control, and the target structure is used to determine a resource loading method; The integration unit integrates the target development framework and the target web page control according to the target layer and the target structure to obtain a target application.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located executes the method for integrating the development framework and the web page control according to any one of claims 1 to 7.
10. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the method for integrating the development framework and the web page control as described in any one of claims 1 to 7.