Method, device, electronic device and system for exporting pages
By embedding webviews and interacting with the server in the client, page export is realized, and the problem of inefficient exporting pages by multiple clients in the existing technology is solved, saving development resources and improving efficiency.
Patent Information
- Application Number
- CN202210753208.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-28
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2042-06-28
AI Technical Summary
In the prior art, when exporting pages from multiple different clients, each client and server needs to be independently configured, resulting in inefficient exporting pages and occupies a lot of development resources.
Page export is realized by embedding webview webview in the client and interacting with the server. The client receives the operation, sends a page data request message to the server, obtains the target page, and obtains the page data from the webview.
Different clients realize page export based on the same embedded method, saving development resources between the client and server and improving page export efficiency.
Smart Images

Figure CN115062249B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device and system for exporting pages. Background Art
[0002] There are many ways to export pages. The way to export pages for clients is usually for the client to process part of the business logic and obtain data from the server. In this way, each client needs to develop its own interaction with the server to export the page. However, this page export method takes up more development resources and has low export efficiency. Summary of the invention
[0003] The embodiments of the present application provide a method, device, electronic device and system for exporting pages, which help to improve the efficiency of exporting pages and save client development resources.
[0004] To achieve the above objectives, the present application provides the following technical solutions:
[0005] In a first aspect, a page export method is provided, which is applied to a client with a web view webview embedded therein, the method comprising: the client receives a first operation for the webview; wherein the first operation is used to obtain target data based on the webview, and the target data is used to generate a target page; the webview sends a page data request message to the server according to the first operation; wherein the page data request message includes indication information of the target data and a file format of the target page, and the indication information is used to indicate the target data; the webview receives a response message sent by the server, and the response message is used to obtain the target page; the webview obtains the target page according to the response message; and the client obtains the target page from the webview.
[0006] At present, the server usually generates the target page according to the request sent by the client and the page generation method, and then sends it to the client to realize the client to export the page. However, when exporting pages to multiple different clients, the above method needs to independently configure each client and server, which greatly affects the efficiency of exporting pages. In this regard, the present application proposes the above method, in which the client interacts with the server through the embedded webview to realize the page export, which helps different clients to realize the page export based on the same embedded method, thereby saving the development resources of the client and the server and improving the efficiency of page export.
[0007] In one possible implementation, when the file format of the target page is in Excel format, the response message includes a download address, which is the download address of the target page generated according to the target data. The webview obtains the target page according to the response message, including: the webview starts a download process according to the download address to obtain the target page, and the download process includes a message header indicating the download; the client obtains the target page from the webview, including: the client identifies the message header, intercepts the download process, and obtains the target page.
[0008] This possible implementation method provides a specific implementation method for WebView to obtain the target page based on the server response message when exporting an Excel file, as well as a specific implementation method for the client to obtain the page from WebView, thereby improving the feasibility of the solution.
[0009] In a possible implementation, when the file format of the target page is in PDF format or image format, the response message includes target data, and the webview obtains the target page according to the response message, including: the webview generates the target page according to the target data.
[0010] This possible implementation method provides a method for Webview to generate a target page when exporting a PDF file or image to achieve the export of the target page. By generating it in Webview, it helps to save server resources and improve page export efficiency.
[0011] In a possible implementation, the method also includes: the webview receives a first indication message, the first indication message is used to instruct the webview to stop exporting pages; the webview sends export parameters to the client according to the first indication message, wherein the export parameters include at least the number of target pages and the export progress.
[0012] This possible implementation method provides a specific implementation method for webview to export relevant data when the user closes the client or webview process, which helps to avoid data loss when the page export is interrupted, and is beneficial for providing relevant parameters for subsequent page exports when the webview is restarted.
[0013] In a possible implementation, the method further includes: the client restarts the webview; the client sends export parameters to the webview; the webview receives the export parameters and continues to export according to the export parameters until the target page is exported.
[0014] In this possible implementation, a specific implementation method for automatic resumption of client upload is provided, which helps to continue exporting an interrupted page export process, thereby improving the efficiency of exporting pages.
[0015] In a possible implementation, a client is embedded with multiple webviews, each of which has a unique identifier. The method further includes: the multiple webviews send their own unique identifiers and corresponding export progress to the client.
[0016] In this possible implementation, when multiple webviews are embedded in the client, the export progress can be fed back to the client separately to facilitate unified management of the client.
[0017] In a second aspect, a page export device is provided, which is applied to a client with a web view webview embedded in it, and includes: a first receiving unit, used to receive a first operation; wherein the first operation is used to obtain target data based on the webview, and the target data is used to generate a target page; a request initiating unit, used to initiate a page data request message to the server according to the first operation; wherein the page data request message includes indication information of the target data and a file format of the target page, and the indication information is used to indicate the target data; a second receiving unit, used to receive a response message sent by the server, and the response message is used to obtain the target page; the first obtaining unit, also used to obtain the target page according to the response message, so that the webview obtains the target page; the second obtaining unit, also used to obtain the target page from the webview.
[0018] In a third aspect, an electronic device is provided, comprising: a processor and a memory. The processor is connected to the memory, the memory is used to store computer-executable instructions, and the processor executes the computer-executable instructions stored in the memory, thereby implementing any one of the methods provided in the first aspect.
[0019] In a fourth aspect, an export page system is provided, comprising a client and a server that execute any of the methods described in the first aspect, wherein the server is used to send a response message to the client, and the response message is used by the client to obtain a target page.
[0020] In a fifth aspect, a chip is provided, comprising: a processor and an interface circuit; the interface circuit is used to receive code instructions and transmit them to the processor; the processor is used to run the code instructions to execute any one of the methods provided in the first aspect.
[0021] In a sixth aspect, a computer-readable storage medium is provided, comprising computer execution instructions, which, when executed on a computer, enable the computer to execute any one of the methods provided in the first aspect.
[0022] In a seventh aspect, a computer program product is provided, comprising computer execution instructions, which, when executed on a computer, cause the computer to execute any one of the methods provided in the first aspect.
[0023] The technical effects brought about by any implementation method in the second to seventh aspects can refer to the technical effects brought about by the corresponding implementation method in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A schematic diagram of the structure of a page export system provided in an embodiment of the present application;
[0025] Figure 2 A schematic diagram of the structure of an export page device provided in an embodiment of the present application;
[0026] Figure 3 A flowchart of a page export method provided in an embodiment of the present application;
[0027] Figure 4 A flowchart of a page export method provided in an embodiment of the present application;
[0028] Figure 5 A schematic diagram of the composition of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] In the description of this application, unless otherwise specified, " / " means "or", for example, A / B can mean A or B. "And / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, "at least one" means one or more, and "plurality" means two or more. The words "first", "second", etc. do not limit the quantity and execution order, and the words "first", "second", etc. do not limit them to be different.
[0030] It should be noted that, in this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0031] The present application embodiment provides an export page system, such as Figure 1As shown, it includes a client and a server, wherein the client is embedded with a web view webview. The client refers to a program that provides local services to customers, corresponding to the server. Among them, the server can be a server. The network structure mode in which the system functions are jointly processed by the client and the server is the client / server mode (Client / Server, C / S). Among them, C represents the client and S represents the server. At present, part of the business logic is usually processed based on the client, and the server and the client interact with data to export files.
[0032] Among them, the browser / server mode (B / S) is a special C / S network structure mode. The browser as the client does not perform business processing, and all business processing is completed by the server, which helps to save maintenance costs. Webview is usually used in the software development process to embed the browser to run the browser in the software and complete data interaction.
[0033] The embodiment of the present application provides a method for exporting a page, which can be applied to an exporting page device. The embodiment of the present application does not impose any restrictions on the specific form of the exporting page device. For example, the exporting page device can be a terminal device or an electronic device. Among them, the terminal device or electronic device can be referred to as: terminal, user equipment (UE), terminal equipment, access terminal, user unit, user station, mobile station, remote station, remote terminal, mobile device, user terminal, wireless communication device, user agent or user device, etc. The terminal device or electronic device can be a mobile phone, an augmented reality (AR) device, a virtual reality (VR) device, a tablet computer, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc.
[0034] In hardware implementation, the above-mentioned export page device can be implemented as follows: Figure 2 The computer device shown is implemented as shown. Figure 2 FIG. 2 is a schematic diagram of the hardware structure of a computer device 20 provided in an embodiment of the present application. The computer device 20 can be used to implement the functions of the above-mentioned export page device.
[0035] Figure 2 The computer device 20 shown may include: a processor 201 , a memory 202 , a communication interface 203 , and a bus 204 . The processor 201 , the memory 202 , and the communication interface 203 may be connected via the bus 204 .
[0036] The processor 201 is the control center of the computer device 20, and may be a general-purpose central processing unit (CPU) or other general-purpose processors, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0037] As an example, the processor 201 may include one or more CPUs, such as Figure 2 CPU 0 and CPU 1 are shown in .
[0038] The memory 202 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.
[0039] In a possible implementation, the memory 202 may exist independently of the processor 201. The memory 202 may be connected to the processor 201 via a bus 204 and used to store data, instructions, or program codes. When the processor 201 calls and executes the instructions or program codes stored in the memory 202, the method for exporting pages provided in the embodiment of the present application can be implemented.
[0040] In another possible implementation, the memory 202 may also be integrated with the processor 201 .
[0041] The communication interface 203 is used for connecting the computer device 20 with other devices through a communication network, which may be Ethernet, a radio access network (RAN), a wireless local area network (WLAN), etc. The communication interface 203 may include a receiving unit for receiving data and a sending unit for sending data.
[0042] The bus 204 may be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 2 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0043] It should be pointed out that Figure 2 The structure shown in the figure does not constitute a limitation on the computer device 20, except Figure 2 In addition to the components shown, computer device 20 may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0044] like Figure 3 FIG. 1 is a flow chart of a method for exporting pages provided by the present application. The method includes:
[0045] S301: The client receives a first operation on the webview.
[0046] The first operation is used to obtain target data based on the webview, and the target data is used to generate a target page.
[0047] Optionally, the target data may be target table data, such as report data.
[0048] Optionally, the first operation is that the user sets search conditions in the search box, and the search conditions are used by the webview to request corresponding target data from the server.
[0049] The search condition is used to determine the target data. Exemplarily, the search condition is time information, and the webview obtains the corresponding target data according to the time information. For example, if the time information is a certain time period, the webview requests the target data within the time period, or if the time information is a certain time point, the webview requests the target data at the time point.
[0050] S302. The webview sends a page data request message to the server according to the first operation.
[0051] It can be understood that the page data request message is generated according to the above search conditions.
[0052] Optionally, the page data request message includes indication information of the target data and the file format of the target page. The indication information of the target data is used to indicate the data in the target page, and the file format of the target page includes an Excel format, a PDF format, or a picture format. In addition, the page request message may also include an identifier of the current page of the client.
[0053] It is understandable that any information that can indicate the target data can be used as the indication information of the target data. For example, the indication information is the time information in the above search condition.
[0054] Exemplarily, the webview initiates an http request in excel format or pdf format to the server to export the target page in the corresponding file format.
[0055] S303, webview receives a response message sent by the server.
[0056] The response message is used to obtain the target page. The specific implementation methods include the following two.
[0057] In the first possible implementation, the file format of the target page generated by the page request message is in Excel format, and the response message contains the download address. Specifically, the server generates an Excel file and a download address from the current page according to the page request message, that is, the server generates a target page according to the target data, and then creates a download address for the target page; wherein the download address is used to indicate the storage address of the Excel file on the server. In response to the page request message sent by the webview, the server sends a response message to the webview, and the response message includes the download address.
[0058] In a second possible implementation, the file format of the target page generated by the page request message is in PDF format or image format, and the response message includes the target data. Specifically, the server obtains the target data according to the page request message. In response to the page request message sent by the webview, the server sends a response message to the webview, and the response message includes the target data.
[0059] S304. Webview obtains the target page according to the response message.
[0060] In the first possible implementation method mentioned above, when the file format of the target page is an Excel file, the response message includes a download address, and step S304 specifically includes: webview starts a download process according to the download address to obtain the target page. The download process includes a message header indicating the download. Exemplarily, after webview obtains the Excel download address uniform resource locator (URL), it uses window.open("URL", "blank") to open an http network link, wherein the Content-Disposition message header of the http network link is set to attachment, and the attachment message header is used to indicate the download. webview obtains the target page through the download process.
[0061] Among them, window.open() loads the specified resource into the browser context with the specified name. If no name is specified, a new window will be opened and the specified resource will be loaded into the browser context of this window. The Content-Disposition response header indicates how the reply content should be displayed, whether it is displayed in the form of a network view, or downloaded and saved locally as an attachment.
[0062] In the above-mentioned second possible implementation manner, when the file format of the target page is a PDF file, the response message includes target data, and step S304 specifically includes: webview generates a target page according to the target data, exemplarily including the following steps ac.
[0063] a. Webview uses Document.createDocumentFragment() to create a new blank document fragment in the background and draws the target data in this document fragment.
[0064] b. Webview uses the html2canvas open source plug-in to generate a canvas of the content of the corresponding document fragment, and then takes a screenshot to generate an image.
[0065] c. Webview generates PDF files from PNG images through the jspdf open source plug-in.
[0066] It is understandable that if the file format of the target page is a picture format, webview can generate the picture through the above steps a and b. This application does not limit the format of the picture. For example, the format of the picture in the above step b is png format.
[0067] S305: The client obtains the target page from the webview.
[0068] In the first possible implementation, when the target page is in an Excel file format, step S305 specifically includes: the client identifies the message header, intercepts the download process, and obtains the target page. Exemplarily, during the process of webview starting the download process according to the download address, the client can obtain the message header indicating the download in the download process, and intercepts the message header indicating the download to obtain the target page.
[0069] The client obtains the target page from the webview, which is equivalent to the webview export page. The client intercepts the download process started by the webview to obtain the target page for export. When there are multiple pages to be exported, it helps the client to export them synchronously through multiple webviews. The client obtains multiple target pages by intercepting the download process, thereby improving the export efficiency of multiple target pages.
[0070] Optionally, the client may also obtain the download path according to the download process. After the first possible implementation, the client modifies the download path of the target page.
[0071] By modifying the download path of the target page, it is helpful to export the target page to a specific address according to user needs.
[0072] In the above-mentioned second possible implementation method, when the file format of the target page is in PDF format, after the above-mentioned step c, step d is also included, webview passes the target page to the client, and accordingly, the client receives the target page. Specifically, webview sends the PDF file of the target page to the client through the Chromium Embedded Framework (CEF). Among them, CEF is an open source Webbrowser control based on the Google Chromium project, supporting Windows, Linux, and Mac platforms. In addition to providing C / C++ interfaces, there are also ported versions in other languages. CEF is used for data transmission between the client and webview.
[0073] Optionally, after the above two possible implementations, the client modifies the file name of the target page.
[0074] Currently, the server usually generates the target page according to the request sent by the client and the page generation method, and then sends it to the client to realize the client to export the page. However, when exporting pages to multiple different clients, the above method needs to independently configure each client and server, which greatly affects the efficiency of exporting pages. In this regard, through the above-mentioned page export method, the client interacts with the server through the embedded webview to realize page export, which helps different clients to realize page export based on the same embedded method, thereby saving development resources on the client and server and improving page export efficiency.
[0075] The present application also provides an embodiment of batch exporting pages. Specifically, the batch exporting of pages includes batch exporting of multiple pages in one webview and batch exporting of multiple pages in multiple webviews.
[0076] like Figure 4 As shown, an embodiment of implementing batch export of multiple pages in a webview is shown, including steps S401-S405.
[0077] S401: The client receives a second operation on the webview.
[0078] Among them, the second operation is used for the webview to obtain target data from multiple pages and generate multiple target pages.
[0079] Optionally, similar to the first operation, the second operation is that the user sets search conditions in the search box, and the search conditions are used by the webview to request corresponding target data from the server.
[0080] The search condition is used to determine the target data. Optionally, the search condition is the identification information of the device to which the multiple pages belong, and the time information of the multiple pages, and the webview obtains the corresponding target data according to the identification information of the device to which the multiple pages belong and the time information of the multiple pages.
[0081] S402. The webview sends a page data request message to the server according to the second operation.
[0082] S403, webview receives a response message sent by the server.
[0083] In the first possible implementation method, the file format of the target page generated by the page request message is in Excel format. The server generates multiple Excel files and corresponding download addresses from multiple pages according to the page request message, and sends the download addresses to the webview.
[0084] In a second possible implementation, the file format of the target page generated by the page request message is in PDF format. The server obtains multiple target data according to the page request message, and sends the multiple target data as a data set to the webview.
[0085] S404. Webview obtains the target page according to the response message.
[0086] The first possible implementation method, when the file format of the target page is an Excel file, is similar to the first possible implementation method in the above step S304 and will not be described in detail.
[0087] The second possible implementation method is that when the file format of the target page is a PDF file, since the data set sent by the server received by the webview includes multiple target data, the webview executes the above steps ac for the multiple target data respectively to generate multiple PDF files.
[0088] S405: The client obtains the target page from the webview.
[0089] Specifically, it is similar to the first possible implementation manner and the second possible implementation manner in the above step S305.
[0090] Optionally, in the second possible implementation of the above step S304 or S404, when webview generates one or more PDF files and sends the PDF file of the target page to the client through CEF, webview passes the export progress of one or more PDF files to the client through CEF. It is understandable that webview generates a PDF file of a target page and sends it to the client, including the above steps ad. Exemplarily, when webview needs to generate and send 3 PDF files, each file needs to execute the above steps ad, so webview needs to execute 12 times to complete the export of all PDF files.
[0091] Specifically, when sending one or more PDF files to the client, the webview calculates the export progress P according to the current number of execution steps m and the number of target pages n using the following formula:
[0092] P=m÷4÷n×100%
[0093] Wherein, m and n are both integers greater than zero.
[0094] Exemplarily, the number of currently executed steps is 14, and the number of target pages is 4, then P calculated according to the above formula is 87.5%.
[0095] Webview passes the export progress and PDF files to the client through CEF to show the user the export progress of one or more PDF files.
[0096] Through the above steps S401-S405, it is possible to export multiple pages in a webview. When the multiple pages are PDF files, the file export progress can also be displayed to the user, so that the user can obtain the real-time export progress of the page.
[0097] The present application also provides an embodiment for implementing batch export of multiple pages in multiple webviews.
[0098] Specifically, the client is embedded with multiple webviews, each of which includes one or more pages. The specific implementation process is similar to the above steps S301-S305 and S401-S405.
[0099] Optionally, when multiple webviews export pages to PDF format, each webview feeds back the export progress to the client. Specifically, the webview sends a unique identifier and the corresponding export progress to the client. The unique identifier is used to represent the corresponding webview.
[0100] The above method enables the client to export pages through multiple webviews, and the independent export progress of multiple webviews can also be obtained, which is convenient for users to search and update.
[0101] Optionally, in case an interruption occurs during the export of a PDF file, the present application also provides the following embodiments.
[0102] Specifically, when the computer device executes the above steps S304, S305, S404 or S405, when the export of the PDF file is interrupted, the client receives a third operation from the user, which is used to instruct to close the client or webview. The closing is completed by the following steps S11-S13.
[0103] S11, the client sends a first instruction message to the webview, where the first instruction message is used to instruct the webview to stop exporting the page. Correspondingly, the webview receives the first instruction message.
[0104] It can be understood that when the third operation is used to instruct closing the client, since the webview is embedded in the client, at this time, the webview and the client need to be closed.
[0105] S12. Webview sends an export to the client according to the first instruction message.
[0106] Accordingly, the client receives and saves the export parameters to a local file (Ifile).
[0107] Among them, the export parameters at least include the target page number n and the export progress P.
[0108] Specifically, according to the calculation formula of P in the above step S405, the number of currently exported pages can be determined by P and n. For example, when n is 3 and P is 25%, then n×P = 3×25% = 0.75. According to the integer part of 0.75, the number of currently exported pages is 0. Similarly, when n is 4 and P is 50%, then n×P = 4×50% = 2. According to the integer part of 2, the number of currently exported pages is 2.
[0109] Optionally, when the product result of the above n and P is an integer, the export parameters further include the search conditions for the remaining unexported pages, and the search conditions are used for the webview to obtain the target data from the server again.
[0110] Specifically, if the product result of n and P is represented by x, then the value range of x is x = {0, 1, ……, n - 1}, indicating that there are x pages that have been exported, and there are n - x pages that have not started the generation and transmission process of the above steps a - d. For example, in the above example, when n is 4 and P is 50%, the number of currently exported pages is 2, and there are 2 pages that have not started to be exported. At this time, if the webview wants to continue to export the third and fourth pages, it needs to obtain the target data of the third and fourth pages from the server again and execute the above steps a - d respectively to complete the export. Therefore, in the above example, the search conditions in the export parameters are the search conditions for the third and fourth pages.
[0111] Optionally, when the product result of the above n and P is not an integer, the export parameters further include the specific parameters of the above steps a - d and the current export result.
[0112] Specifically, the value range of the product result x of n and P is 0 < x < n, and x is not an integer, indicating that at least one page has started to execute the above steps a - d but has not completed step d. For example, in the above example, when n is 3 and P is 25%, x = 0.75, indicating that the number of currently exported pages is 0, and the first page is being exported. At this time, the specific parameters of steps a - d in the export parameters are the specific parameters of the first page, which are represented in the following Table 1:
[0113] Table 1. Example of the specific parameters of steps a - d in a page parameter
[0114] a 1 b 1 c 0 d 0
[0115] Among them, the 0 or 1 corresponding to steps ad is used to indicate whether the step is executed or not. For example, 0 means that the step is not executed, and 1 means that the step is executed. In the above example, combined with Table 1 above, it can be seen that the first page should have executed steps a and b. If the export continues, the webview should execute steps c and d. Among them, the current export result should be the processing result of executing the above step b.
[0116] It should be noted that the search conditions for the remaining unexported pages, as well as the specific parameters of step ad and the current export results can exist in the export parameters at the same time. As in the above example, n is 3, P is 25%, and x=0.75, indicating that the number of currently exported pages is 0, and the first page is being exported. The export parameters also include the search conditions for the second and third pages, which are used for webview to obtain the target data of the second and third pages after completing the export of the first page, and then export them.
[0117] S13. Close webview.
[0118] After the client receives and saves the export parameters sent by the webview, the webview is closed. If the third operation indicates closing the client, after step S13, step S14 may also be included, closing the client.
[0119] It should be noted that, if the webview receives a third operation from the user during the export of the PDF file, it means closing the current webview. At this time, the client and the webview only need to execute the above steps S12-S13.
[0120] It should be noted that this application does not restrict the reasons for the interruption of exporting PDF files. The above gives two examples of users actively closing the webview or client. In the specific implementation process, if the webview or client is abnormally closed due to communication problems, the client and webview can also save the relevant parameters in the above manner, and this application does not restrict this.
[0121] Optionally, when the export of the PDF file is interrupted, the client receives a fourth operation from the user, and the fourth operation is used to instruct to start the client or start the webview. Specifically, the following steps S21-S23 are included.
[0122] S21. The client searches Ifile for any unfinished tasks.
[0123] The unfinished task refers to a target page whose export progress is less than 100%.
[0124] S22. If there are unfinished tasks, the client restarts the webview and sends the export parameters to the webview through CEF.
[0125] Accordingly, the webview receives export parameters.
[0126] It should be noted that if the fourth operation indicates starting a webview, the client can send the export parameters directly to the started webview through CEF.
[0127] S23, webview continues to export according to the export parameters until the target page is exported.
[0128] Specifically, the webview determines the pages that have not been exported according to the export parameters, as described in the above step S12.
[0129] In the above example, n is 3, P is 25%, and x=0.75, indicating that the number of currently exported pages is 0, and the first page is being exported. Further, the webview obtains the information in Table 1 above in the export parameters and the current export result, and continues to execute steps c and d to complete the export of the first page. Further, the webview obtains the search conditions for the second and third pages in the export parameters, initiates a page request message to the server, obtains the target data, and then executes subsequent export operations.
[0130] The above method helps to realize batch export of pages, and after the export is interrupted, the export progress can be saved to achieve breakpoint resumption.
[0131] The above mainly introduces the scheme of the embodiment of the present application from the perspective of the method. It is understandable that in order to realize the above functions, the export page device includes at least one of the hardware structure and software modules corresponding to the execution of each function. It should be easily appreciated by those skilled in the art that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.
[0132] The embodiment of the present application can divide the export page device into functional units according to the above method example. For example, each functional unit can be divided corresponding to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation.
[0133] For example, Figure 5 A possible structural diagram of an electronic device 50, in which the export page device involved in the above embodiment is recorded, is shown. The electronic device 50 includes a client 501 and a webview 502. The client 501 is used to receive a first operation; wherein the first operation is used to obtain target data based on the webview, and the target data is used to generate a target page. The webview 502 is used to initiate a page data request message to the server according to the first operation; wherein the page data request message includes indication information of the target data and a file format of the target page, and the indication information is used to indicate the target data. The webview 502 is also used to receive a response message sent by the server, and the response message is used to obtain the target page. The webview 502 is also used to obtain the target page according to the response message. The client 501 is also used to obtain the target page from the webview.
[0134] Optionally, when the file format of the target page is Excel format, the response message includes a download address, webview502 is specifically used to: start the download process according to the download address, obtain the target page, and the download process includes a message header indicating the download; the client 501 is specifically used to: identify the message header, intercept the download process, and obtain the target page.
[0135] Optionally, when the file format of the target page is in PDF format or image format, the response message includes target data, webview502, which is specifically used to: generate a target page according to the target data.
[0136] Optionally, webview502 is also used to receive a first indication message, which is used to instruct the webview to stop exporting pages; webview502 is also used to send export parameters to the first processing unit according to the first indication message, wherein the export parameters include at least the number of target pages and the export progress.
[0137] Optionally, client 501 is also used to restart webview; client 501 is also used to send export parameters to webview; webview502 is also used to receive the export parameters and continue exporting according to the export parameters until the target page is exported.
[0138] Optionally, the client 501 is embedded with multiple webviews, each of which has a unique identifier; the multiple webviews send their own unique identifiers and corresponding export progress to the client.
[0139] Optionally, the electronic device 50 further includes a storage unit 503. The storage unit 503 is used to store computer-executable instructions, and other units in the client can perform corresponding actions according to the computer-executable instructions stored in the storage unit 503.
[0140] For the detailed description of the above optional manner, please refer to the above method embodiment, which will not be repeated here. In addition, the explanation of any electronic device 50 provided above and the description of the beneficial effects can refer to the above corresponding method embodiment, which will not be repeated here.
[0141] As an example, combining Figure 1 , the functions implemented in part or all of the client 501, webview 502 and storage unit 503 in the electronic device 50 can be Figure 2 Processor 201 in the Figure 2 The program code in the memory 202 is implemented.
[0142] The embodiment of the present application also provides an export page device, which is applied to a client with a web view webview embedded therein, and the device includes: a first receiving unit, which is used to receive a first operation; wherein the first operation is used to obtain target data based on the webview, and the target data is used to generate a target page;
[0143] a request initiating unit, configured to initiate a page data request message to a server according to the first operation; wherein the page data request message includes indication information of the target data and a file format of the target page, and the indication information is used to indicate the target data;
[0144] The second receiving unit is further used to receive a response message sent by the server, wherein the response message is used to obtain the target page;
[0145] The first acquisition unit is further used to acquire the target page according to the response message, so that the webview acquires the target page;
[0146] The second acquisition unit is further used to acquire the target page from the webview.
[0147] In one embodiment, when the file format of the target page is in Excel format, the response message includes a download address, which is a download address of the target page generated according to the target data, and the first acquisition unit is specifically used to: start a download process according to the download address to acquire the target page, and the download process includes a message header indicating downloading;
[0148] The second acquisition unit is specifically used to: identify the message header, intercept the download process, and acquire the target page.
[0149] In one embodiment, when the file format of the target page is a pdf format or a picture format, the response message includes target data, and the first acquisition unit is specifically used to generate the target page according to the target data.
[0150] In one embodiment, the apparatus further comprises:
[0151] A third receiving unit is used to receive a first instruction message, where the first instruction message is used to instruct the webview to stop exporting the page;
[0152] The first sending unit is used to enable the webview to send export parameters to the client according to the first indication message, wherein the export parameters at least include the number of target pages and the export progress.
[0153] In one embodiment, the apparatus further comprises:
[0154] A restart unit, used to restart the webview;
[0155] The second sending unit is further used for sending the export parameter to the webview by the client;
[0156] The third receiving unit is further used to receive the export parameters and continue exporting according to the export parameters until the export of the target page is completed.
[0157] In one embodiment, the client is embedded with a plurality of the webviews, each of which has a unique identifier; and the plurality of webviews sends their own unique identifiers and corresponding export progress to the client.
[0158] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed on a computer, the computer is enabled to execute any of the methods executed by the computer devices provided above.
[0159] For the explanation of the relevant contents and description of the beneficial effects of any of the above-mentioned computer-readable storage media, reference may be made to the above-mentioned corresponding embodiments, which will not be repeated here.
[0160] The embodiment of the present application also provides a chip. The chip integrates a control circuit and one or more ports for implementing the functions of the above-mentioned electronic device 50. Optionally, the functions supported by the chip can be referred to above and will not be repeated here. A person of ordinary skill in the art can understand that all or part of the steps of implementing the above-mentioned embodiment can be completed by instructing the relevant hardware through a program. The program can be stored in a computer-readable storage medium. The storage medium mentioned above can be a read-only memory, a random access memory, etc. The above-mentioned processing unit or processor can be a central processing unit, a general-purpose processor, an application specific integrated circuit (ASIC), a microprocessor (digital signal processor, DSP), a field programmable gate array (field programmable gatearray, FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof.
[0161] The embodiment of the present application also provides a computer program product including instructions, when the instructions are run on a computer, the computer executes any one of the methods in the above embodiments. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more servers that can be integrated with the medium. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., an SSD), etc.
[0162] It should be noted that the above-mentioned devices for storing computer instructions or computer programs provided in the embodiments of the present application, such as but not limited to the above-mentioned memories, computer-readable storage media and communication chips, etc., are all non-transitory.
[0163] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using a software program, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loading and executing computer program instructions on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. Computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, data center, etc. that contains one or more servers that can be integrated with a medium. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (eg, a solid state disk (SSD)).
[0164] Although the present application is described herein in conjunction with various embodiments, in the process of implementing the claimed application, those skilled in the art may understand and implement other changes to the disclosed embodiments by viewing the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "one" or "an" does not exclude multiple situations. A single processor or other unit may implement several functions listed in the claims. Certain measures are recorded in different dependent claims, but this does not mean that these measures cannot be combined to produce good results.
[0165] Although the present application has been described in conjunction with specific features and embodiments thereof, it is obvious that various modifications and combinations may be made thereto without departing from the spirit and scope of the present application. Accordingly, this specification and the drawings are merely exemplary illustrations of the present application as defined by the appended claims, and are deemed to have covered any and all modifications, variations, combinations or equivalents within the scope of the present application. Obviously, those skilled in the art may make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for exporting a page, characterized in that: Applied to a client having a webview embedded therein, the method comprises: The client receives a first operation for the webview; wherein the first operation is used to obtain target data based on the webview, and the target data is used to generate a target page; The webview sends a page data request message to the server according to the first operation; wherein the page data request message includes indication information of the target data and a file format of the target page, and the indication information is used to indicate the target data; The webview receives a response message sent by the server; The webview obtains the target page according to the response message; The client obtains the target page from the webview; Wherein, when the file format of the target page is in Excel format, the response message includes the download address of the target page, and the webview obtains the target page according to the response message, including: the webview starts a download process according to the download address to obtain the target page; When the file format of the target page is PDF format or picture format, the response message includes target data, and the webview obtains the target page according to the response message, including: the webview generates the target page according to the target data.
2. The method according to claim 1, characterized in that When the file format of the target page is in Excel format, the download process includes a message header indicating downloading; The client obtains the target page from the webview, including: The client identifies the message header, intercepts the download process, and obtains the target page.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: The webview receives a first instruction message, where the first instruction message is used to instruct the webview to stop exporting the page; The webview sends export parameters to the client according to the first indication message, wherein the export parameters include at least the number of target pages and the export progress.
4. The method according to claim 3, characterized in that: The method further comprises: The client restarts the webview; The client sends the export parameters to the webview; The webview receives the export parameters and continues to export according to the export parameters until the target page is exported.
5. The method according to claim 1 or 2, characterized in that: The client is embedded with a plurality of the webviews, each of the plurality of webviews has a unique identifier, and the method further includes: The multiple webviews send their respective unique identifiers and corresponding export progress to the client.
6. A device for exporting pages, characterized in that: Applied to a client having a webview embedded therein, the device comprises: A first receiving unit, configured to receive a first operation; wherein the first operation is used to obtain target data based on the webview, and the target data is used to generate a target page; a request initiating unit, configured to initiate a page data request message to a server according to the first operation; wherein the page data request message includes indication information of the target data and a file format of the target page, and the indication information is used to indicate the target data; The second receiving unit is further used to receive a response message sent by the server; The first acquisition unit is further used to acquire the target page according to the response message, so that the webview acquires the target page; The second acquisition unit is further used to acquire the target page from the webview; Wherein, when the file format of the target page is in Excel format, the response message includes the download address of the target page, and the first acquisition unit is specifically used to start the download process according to the download address to acquire the target page; When the file format of the target page is a PDF format or a picture format, the response message includes target data, and the first acquisition unit is specifically configured to generate the target page according to the target data.
7. The page export device according to claim 6, characterized in that: When the file format of the target page is in Excel format, the download process includes a message header indicating downloading; The second acquisition unit is specifically used to: Identify the message header, intercept the download process, and obtain the target page; The device also includes: A third receiving unit is used to receive a first instruction message, where the first instruction message is used to instruct the webview to stop exporting the page; A first sending unit, configured to enable the webview to send export parameters to the client according to a first instruction message, wherein the export parameters at least include the number of target pages and export progress; The device also includes: A restart unit, used to restart the webview; The second sending unit is further used for sending the export parameter to the webview by the client; The third receiving unit is further used to receive the export parameters and continue to export according to the export parameters until the export of the target page is completed; The client is embedded with a plurality of webviews, each of which has a unique identifier; The multiple webviews send their respective unique identifiers and corresponding export progress to the client.
8. An electronic device, characterized in that: include: processor; The processor is connected to a memory, the memory is used to store computer-executable instructions, and the processor executes the computer-executable instructions stored in the memory so that the electronic device implements the method according to any one of claims 1 to 5.
9. An export page system, characterized in that: It comprises a client and a server for executing the method as described in any one of claims 1 to 5, wherein the server is used to send a response message to the client, and the response message is used by the client to obtain a target page.
10. A computer program product, characterized in that The method comprises computer-executable instructions, and when the computer-executable instructions are executed on a computer, the computer is enabled to implement the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Page generation method and device
CN105512318A
Method and device for processing webpage in application, terminal and storage medium
CN110717128A