Multi-window generation method, electronic equipment and computer storage medium
By creating a parent window in a multi-window application to manage data communication between the child window and the main process, the problem of excessive memory resource consumption of multi-window application in the prior art is solved, and more efficient data communication and faster response speed are achieved.
Patent Information
- Application Number
- CN202311349162.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-17
- Publication Date
- 2025-04-18
AI Technical Summary
In the prior art, an application composed of multiple windows needs to create a rendering process for each window, resulting in excessive memory resource consumption and reducing the application's response speed and user experience.
By creating a parent window, it manages data communication between all child windows and the main process, which communicates with the parent window without the need to establish an independent rendering process between each child window and the main process.
The communication process is simplified, the consumption of memory resources by multi-window generation is reduced, the convenience of data communication between multiple windows and software response speed is improved, and the user experience of developers and users is improved.
Smart Images

Figure CN119847606A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a multi-window generation method, an electronic device, and a computer storage medium. Background Art
[0002] With the development of electronic technology, more and more electronic devices are involved in people's daily lives. As market demand evolves, more and more applications can support multi-window generation to better meet people's daily needs.
[0003] In the prior art, applications consisting of multiple windows often need to create a separate rendering process for each window, which usually takes up too much memory resources, reduces the response speed of the application, and degrades the user experience. Summary of the Invention
[0004] The present application provides a multi-window generation method, electronic device, and computer storage medium, which can simplify the communication process, greatly reduce the consumption of memory resources by multi-window generation, and improve the convenience of data communication between multiple windows, increase software response speed, and enhance the user experience of developers and users.
[0005] To solve the above technical problems, the present application provides a multi-window generation method, which includes: creating a parent window in response to a first window creation instruction; creating a child window in the parent window in response to a second window creation instruction; wherein the parent window is used to communicate data with the main process, and the child window communicates data with the parent window.
[0006] The child window communicates data with the parent window.
[0007] The step of creating a child window in a parent window includes: creating a child window in the parent window through a window.open interface.
[0008] Among them, creating a child window in the parent window through the window.open interface includes: the parent window creates an initial window through the window.open interface, and passes the target window properties of the initial window to the main process; the main process generates rendering data based on the target window properties, and passes the rendering data to the parent window; the parent window renders the child window based on the rendering data.
[0009] The target window attributes include at least one of the window position, window size, and window content of the sub-window.
[0010] The multi-window generation method further includes: in response to data update of the child window, the parent window broadcasts the updated data to other successfully created child windows in the parent window.
[0011] Among them, the multi-window generation method also includes: the child window sends the interaction data and the target window address to the parent window; the parent window sends the interaction data to the child window corresponding to the target window address; the child window corresponding to the target window address sends feedback data of the interaction data to the parent window; the parent window feeds back the feedback data to the child window that sent the interaction data.
[0012] Among them, the multi-window generation method also includes: the parent window obtains the update properties of the child window to be updated and passes them to the main process; the main process generates update rendering data based on the update properties, and passes the update rendering data to the parent window; the parent window updates the rendering of the child window to be updated based on the update rendering data.
[0013] The multi-window generation method further includes: the parent window broadcasting the data obtained from the main process to the successfully created target child window in the parent window.
[0014] To solve the above technical problems, the present application further provides an electronic device, which includes a processor and a memory connected to the processor, wherein the memory stores program data, and the processor executes the program data stored in the memory to implement the above multi-window generation method.
[0015] In order to solve the above technical problems, the present application further provides a computer storage medium, which stores program instructions therein, and the program instructions are executed to implement the above multi-window generation method.
[0016] The beneficial effects of the present application are as follows: in software composed of multiple windows, the present application can first create a parent window, create other child windows in the parent window, the child windows communicate data with the parent window, and the parent window realizes data communication between all child windows and the main process. This method can simplify the communication process and improve the convenience of development and maintenance for developers; further, this method does not require the establishment of an independent rendering process between each child window and the main process. Since each child window shares a rendering process with the parent window, the consumption of memory resources can be greatly reduced; further, this method allows child windows to communicate data through the parent window, without the need to rely on the main process to realize data interaction between multiple child windows, which can increase the speed at which the software responds to user operations, thereby improving the user experience, and is easy to develop and maintain, improving the developer experience. Therefore, the present application can simplify the communication process, greatly reduce the consumption of memory resources for multi-window generation, and can improve the convenience of data communication between multiple windows, improve the software response speed, and improve the user experience of developers and users. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without inventive efforts. Among them:
[0018] Figure 1 This is a flowchart of an embodiment of the multi-window generation method of the present application;
[0019] Figure 2 yes Figure 1 Schematic diagram of the process of step S12 of the embodiment;
[0020] Figure 3 This is a flowchart of another embodiment of the multi-window generation method of the present application;
[0021] Figure 4 This is a structural diagram of an embodiment of an electronic device of the present application;
[0022] Figure 5 This is a schematic diagram of the structure of an embodiment of the computer storage medium of the present application. DETAILED DESCRIPTION
[0023] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of this application without making creative efforts are within the scope of protection of this application.
[0024] The terms "first", "second", etc. in this application are used to distinguish different objects rather than to describe a specific order. In addition, the terms "include", "have" and any variations thereof are intended to cover non-exclusive inclusions.
[0025] It should be noted that when an element is fixed to another element, it includes fixing the element directly to the other element, or fixing the element to the other element through at least one other element in the middle. When an element is connected to another element, it includes connecting the element directly to the other element, or connecting the element to the other element through at least one other element in the middle.
[0026] This application first proposes a multi-window generation method, such as Figures 1 to 2 As shown, Figure 1 This is a flowchart of an embodiment of the multi-window generation method of the present application. Figure 2 yes Figure 1Schematic diagram of the flow of step S12 of an embodiment. The multi-window generation method specifically includes the following steps:
[0027] Step S11: In response to the first window creation instruction, create a parent window.
[0028] The parent window is used to communicate data with the main process. This embodiment can be applied to software composed of multiple windows. For example, in one application scenario, the main process is the Electron main process. In response to the creation instruction of the first window, the Electron main process creates a window as the parent window. This parent window is resident in the software and is used to create new child windows and manage the data of all windows.
[0029] Step S12: In response to the second window creation instruction, a child window is created in the parent window.
[0030] The child window communicates data with the parent window. For example, in response to the second window creation instruction, a child window is created in the parent window, and the child window communicates data with the parent window. Specifically, the child window does not communicate directly with the main process. Multiple child windows in the software communicate with the main process through the parent window. Furthermore, this embodiment does not require the establishment of an independent rendering process between each window and the main process. Each child window shares a rendering process with the parent window. For example, assuming that each rendering process consumes 20M of memory, N windows require a total of (20*N)M of memory. In this embodiment, multiple windows can share one rendering process, that is, no matter how many windows are created, only 20M of memory is occupied, which greatly reduces resource consumption. Specifically, the child window communicates data with the parent window, so data communication between multiple child windows, such as data sharing, can be achieved through the parent window without the help of the main process. Data sharing is convenient and the response speed is fast.
[0031] Optionally, in this embodiment, a child window can be created in a parent window through the window.open interface.
[0032] Specifically, using the window open interface to create a child window can further improve the convenience of creating a child window in the parent window, and can enable the child window and the parent window to share a rendering process, without the need to establish an independent rendering process between each window and the main process, thereby reducing resource consumption; data sharing no longer needs to be broadcast through the main process, and data can be shared directly between windows, which can improve the response speed and greatly improve the user experience; and it is convenient to maintain, which can enhance the developer experience; and creating a child window through the window open interface can realize cross-platform reuse of windows, such as Windows and Android systems, and this method can also be used directly in the browser to create a window, thereby improving the user experience and the convenience of developer development and maintenance.
[0033] Optionally, this embodiment can be Figure 2 The method shown implements step S12, Figure 2 The method shown specifically includes step S21 and step S23:
[0034] Step S21: In response to the second window creation instruction, the parent window creates an initial window through the window.open interface and passes the target window attribute of the initial window to the main process.
[0035] For example, the parent window creates an initial window of a new child window through the Window open interface provided by the browser, and passes the target window attributes to the main process.
[0036] Step S22: The main process generates rendering data based on the target window attributes and passes the rendering data to the parent window.
[0037] For example, the Electron main process intercepts the window open interface, obtains the target window properties passed by the parent window, generates rendering data, and passes the rendering data to the parent window.
[0038] Optionally, the target window attribute includes at least one of a window position, a window size, and a window content of the sub-window.
[0039] Specifically, the window size includes the window width, height, etc. For example, in one application scenario, the target window attributes may include the window position and window size, and in another application scenario, the target window attributes may include the window position and window content, which is not specifically limited.
[0040] Step S23: The parent window renders the child window based on the rendering data.
[0041] For example, the parent window renders the child window process based on the rendering data passed by the Electron main process, thereby completing the creation of the child window.
[0042] In the above-mentioned settings of steps S21 to S23, the parent window is first used to create the initial window of the new child window through the window.open interface, and then the target window properties are passed to the main process, and the main process generates rendering data. This method can not only enable the main process to generate rendering data for the creation of all child windows, but also only requires one rendering process to achieve the creation of multiple child windows, which consumes less resources and can improve the rendering effect.
[0043] In other embodiments, the parent window may also implement creation and rendering of the child window in other ways, which are not specifically limited.
[0044] The above-mentioned setting of steps S11 to S12 has the beneficial effect that, in software composed of multiple windows, a parent window can be first created, and other child windows can be created in the parent window. The child windows communicate data with the parent window, and the parent window realizes data communication between all child windows and the main process. This method can simplify the communication process and improve the convenience of development and maintenance for developers. Furthermore, this method does not require the establishment of an independent rendering process between each child window and the main process. Since each child window shares a rendering process with the parent window, the consumption of memory resources can be greatly reduced. Furthermore, this method allows child windows to communicate data through the parent window, without the need for the main process to realize data interaction between multiple child windows, which can increase the speed of software response to user operations, thereby improving the user experience, and is convenient for development and maintenance, improving the developer experience. Therefore, this embodiment can simplify the communication process, greatly reduce the consumption of memory resources for multi-window generation, and can improve the convenience of data communication between multiple windows, improve the software response speed, and improve the developer and user experience.
[0045] Alternatively, as Figure 1 As shown, the multi-window generation method further includes step S13: in response to the data update of the child window, the parent window broadcasts the updated data to other child windows that have been successfully created in the parent window.
[0046] For example, if the data of a created child window changes, the parent window can broadcast the updated data to other successfully created child windows without going through the main process, reducing memory resource consumption, improving the simplicity of the communication process, and enhancing the user experience.
[0047] Alternatively, as Figure 1 As shown, the multi-window generation method further includes steps S14 to S17, which are specifically as follows:
[0048] Step S14: The child window sends the interactive data and the target window address to the parent window.
[0049] For example, if a created child window has data interaction requirements, the interaction data and the target window address can be sent to the parent window.
[0050] Step S15: The parent window sends the interactive data to the child window corresponding to the target window address.
[0051] Specifically, the parent window sends the received interactive data to the child window corresponding to the target window address, where the target window address may include addresses of multiple child windows, that is, the parent window can send the received interactive data to the multiple child windows corresponding to the target window address.
[0052] Step S16: The child window corresponding to the target window address sends feedback data of the interaction data to the parent window.
[0053] For example, after receiving the interactive data, the child window corresponding to the target window address may generate feedback data and pass the feedback data to the parent window.
[0054] Step S17: The parent window feeds back the feedback data to the child window that sent the interaction data.
[0055] Specifically, the parent window feeds back the received feedback data to the child window that sends the interactive data. For example, in one application scenario, this feedback data may include feedback data generated by multiple different child windows, which may also include the child window address corresponding to each feedback data.
[0056] The beneficial effect of the above-mentioned setting of step S14 to step S17 is that the data communication between child windows is specifically to transmit interactive data through the parent window, and to transmit feedback data through the parent window. This communication method does not require passing through the main process, is simple and convenient, has a fast response speed, and can improve the user experience of developers and users.
[0057] Optionally, the multi-window generation method further includes steps S18 to S19, which are specifically as follows:
[0058] Step S18: The parent window obtains the update properties of the child window to be updated and passes them to the main process.
[0059] For example, the parent window passes the update properties of the child window to be updated and rendered to the main process. In one application scenario, the parent window can pass the update properties corresponding to multiple child windows to be updated and rendered to the main process, where the update properties can be window content, window size, or window position, etc., without specific limitation.
[0060] Step S19: The main process generates updated rendering data based on the updated attributes, and transmits the updated rendering data to the parent window.
[0061] For example, the Electron main process can generate corresponding updated rendering data based on the updated properties and pass it to the parent window.
[0062] Step S20: The parent window updates the rendering of the child window to be updated based on the updated rendering data.
[0063] For example, the parent window may implement update rendering of the to-be-updated child window based on the update rendering data corresponding to the child window.
[0064] The beneficial effect of the above-mentioned setting of steps S18 to S20 is that the update rendering of the child window can be achieved through the rendering process between the parent window and the main process, without the need to create a separate rendering process, reducing resource consumption and improving the user experience.
[0065] In other embodiments, similar improvements can be made to the multi-window generation method, which will not be described in detail here.
[0066] This application further proposes a multi-window generation method, such as Figure 3 As shown, Figure 3 This is a flow chart of another embodiment of the multi-window generation method of the present application. Based on the above embodiment, the multi-window generation method of this embodiment specifically includes steps S31 to S33:
[0067] Step S31: In response to the first window creation instruction, a parent window is created, where the parent window is used to communicate data with the main process.
[0068] The parent window is used to communicate data with the main process. This embodiment can be applied to software composed of multiple windows. For example, in one application scenario, the main process is the Electron main process. In response to the creation instruction of the first window, the Electron main process creates a window as the parent window. This parent window is resident in the software and is used to create new child windows and manage the data of all windows.
[0069] Step S32: In response to the second window creation instruction, a child window is created in the parent window, and the child window communicates data with the parent window.
[0070] The child window communicates data with the parent window. For example, in response to the second window creation instruction, a child window is created in the parent window, and the child window communicates data with the parent window. Specifically, the child window does not communicate directly with the main process. Multiple child windows in the software communicate with the main process through the parent window. Furthermore, this embodiment does not require the establishment of an independent rendering process between each window and the main process. Each child window shares a rendering process with the parent window. For example, assuming that each rendering process consumes 20M of memory, N windows require a total of (20*N)M of memory. In this embodiment, multiple windows can share one rendering process, that is, no matter how many windows are created, only 20M of memory is occupied, which greatly reduces resource consumption. Specifically, the child window communicates data with the parent window, so data communication between multiple child windows, such as data sharing, can be achieved through the parent window without the help of the main process. Data sharing is convenient and the response speed is fast.
[0071] Optionally, in this embodiment, a child window can be created in a parent window through the window.open interface.
[0072] Specifically, using the window open interface to create a child window can further improve the convenience of creating a child window in the parent window, and can enable the child window and the parent window to share a rendering process, without the need to establish an independent rendering process between each window and the main process, thereby reducing resource consumption; data sharing no longer needs to be broadcast through the main process, and data can be shared directly between windows, which can improve the response speed and greatly improve the user experience; and it is convenient to maintain, which can enhance the developer experience; and creating a child window through the window open interface can realize cross-platform reuse of windows, such as Windows and Android systems, and this method can also be used directly in the browser to create a window, thereby improving the user experience and the convenience of developer development and maintenance.
[0073] Step S33: The parent window broadcasts the data obtained from the main process to the successfully created target child window in the parent window.
[0074] For example, when the main process needs to broadcast data to multiple child windows, it can be implemented through the parent window. The parent window can broadcast the data obtained from the main process to the target child window created by the parent window, simplifying the communication network and improving the developer experience.
[0075] In other embodiments, similar improvements can be made to the multi-window generation method, which will not be described in detail here.
[0076] This application further proposes an electronic device, such as Figure 4 As shown, Figure 4 1 is a schematic diagram of the structure of an embodiment of an electronic device of the present application. The electronic device 100 includes a processor 101 and a memory 102 connected to the processor 101. The memory 102 stores program data. The processor 101 executes the program data stored in the memory 102 to implement the multi-window generation method described above.
[0077] Optionally, the electronic device 100 of this embodiment further includes an input / output device 103 and a bus 104. The processor 101, the memory 102, and the input / output device 103 are connected to the bus 104 respectively.
[0078] In this embodiment, the processor 101 may also be referred to as a CPU (Central Processing Unit). The processor 101 may be an integrated circuit chip having signal processing capabilities. The processor 101 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. A general-purpose processor may be a microprocessor, or the processor 101 may be any conventional processor.
[0079] This application further proposes a computer storage medium, such as Figure 5 As shown, Figure 5 The computer storage medium 131 stores program instructions 132 therein, and the program instructions 132 are executed to implement the multi-window generation method described above.
[0080] The program instructions 132 may be formed into a program file and stored in the aforementioned storage medium in the form of a software product, so that an electronic device (which may be a personal computer, server, or network device, etc.) or a processor executes all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., which can store program code, or a terminal device such as a computer, server, mobile phone, or tablet.
[0081] The computer storage medium 131 of this embodiment can be, but is not limited to, a USB flash drive, an SD card, a PD optical drive, a mobile hard drive, a large-capacity floppy drive, a flash memory, a multimedia memory card, a server, and the like.
[0082] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer storage medium. A processor of an electronic device reads the computer instructions from the computer storage medium and executes the computer instructions, causing the electronic device to perform the steps of each of the above method embodiments.
[0083] In addition, if the above functions are implemented as software functions and sold or used as independent products, they can be stored in a storage medium readable by a mobile terminal. That is, the present application also provides a storage device storing program data, which can be executed to implement the methods of the above embodiments. The storage device can be, for example, a USB flash drive, an optical disk, a server, etc. In other words, the present application can be embodied in the form of a software product, which includes a number of instructions for causing a smart terminal to execute all or part of the steps of the methods described in each embodiment.
[0084] Different from the prior art, the present application can first create a parent window in a software composed of multiple windows, create other child windows in the parent window, and the child windows communicate data with the parent window. The parent window realizes data communication between all child windows and the main process. This method can simplify the communication process and improve the convenience of development and maintenance for developers. Furthermore, this method does not require the establishment of an independent rendering process between each child window and the main process. Since each child window shares a rendering process with the parent window, the consumption of memory resources can be greatly reduced. Furthermore, this method allows child windows to communicate data through the parent window, without the need for the main process to realize data interaction between multiple child windows, which can increase the speed at which the software responds to user operations, thereby improving the user experience, and is easy to develop and maintain, improving the developer experience. Therefore, the present application can simplify the communication process, greatly reduce the consumption of memory resources for multi-window generation, and can improve the convenience of data communication between multiple windows, improve the software response speed, and improve the user experience of developers and users.
[0085] The above description is only an implementation method of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the description and drawings of this application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A multi-window generation method, characterized in that: include: In response to the first window creation instruction, create a parent window; In response to the second window creation instruction, creating a child window in the parent window; The parent window is used for data communication with the main process, and the child window is used for data communication with the parent window.
2. The multi-window generation method according to claim 1, characterized in that: The creating a child window in the parent window comprises: Create a child window in the parent window through the window.open interface.
3. The multi-window generation method according to claim 2, characterized in that: The creating a child window in the parent window through the window.open interface includes: The parent window creates an initial window through the window.open interface, and passes the target window attribute of the initial window to the main process; The main process generates rendering data based on the target window attributes, and transmits the rendering data to the parent window; The parent window renders the child window based on the rendering data.
4. The multi-window generation method according to claim 3, characterized in that: The target window attribute includes at least one of the window position, window size, and window content of the sub-window.
5. The multi-window generation method according to claim 1, characterized in that: The multi-window generation method further includes: In response to the data update of the child window, the parent window broadcasts the updated data to other child windows that have been successfully created in the parent window.
6. The multi-window generation method according to claim 1, characterized in that: The multi-window generation method further includes: The child window sends the interactive data and the target window address to the parent window; The parent window sends the interactive data to the child window corresponding to the target window address; The child window corresponding to the target window address sends feedback data of the interaction data to the parent window; The parent window feeds back the feedback data to the child window that sends the interaction data.
7. The multi-window generation method according to claim 1, characterized in that: The multi-window generation method further includes: The parent window obtains the update attribute of the child window to be updated and transmits it to the main process; The main process generates update rendering data based on the update attribute, and transmits the update rendering data to the parent window; The parent window updates the rendering of the child window to be updated based on the update rendering data.
8. The multi-window generation method according to claim 1, characterized in that: The multi-window generation method further includes: The parent window broadcasts the data obtained from the main process to the successfully created target child window in the parent window.
9. An electronic device, characterized in that: The electronic device includes a processor and a memory connected to the processor, wherein the memory stores program data, and the processor executes the program data stored in the memory to implement the multi-window generation method according to claims 1 to 8.
10. A computer storage medium, characterized in that: Program instructions are stored therein, and the program instructions are executed to implement the multi-window generating method according to claims 1 to 8.