A web page file processing method and device
By packaging webpage code on the server and performing path matching and dynamic replacement on the client, the problem of being unable to customize after merging code files is solved, webpage performance is improved, and customization needs are met.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING XINWANG RUIJIE NETWORK TECH CO LTD
- Filing Date
- 2023-02-24
- Publication Date
- 2026-06-05
AI Technical Summary
In front-end web development, merging code files makes customization impossible, preventing modifications to specific code files and impacting webpage performance and customization needs.
The server packages the webpage code file, generating a packaged file containing code snippets. At runtime on the client side, path matching is performed based on mapping information and customization information, and the execution results of the code snippets are dynamically replaced to meet customization needs.
While improving webpage performance, it also enabled customized modifications to specific code files, avoiding the impact of directory structure corruption.
Smart Images

Figure CN116186441B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of web page processing technology, and in particular to a method and apparatus for processing web page files. Background Technology
[0002] In the process of front-end web development, in order to facilitate later maintenance and reuse, the code of a webpage is usually split into different files. Multiple file transfers are required to load the code files needed for the webpage, and the more files there are, the more transfers are required.
[0003] In related technologies, multiple code files of a webpage are merged into a package file, and the client loads and displays the webpage based on the package file, thereby reducing the number of network requests and improving the webpage loading speed.
[0004] However, the above method directly runs the packaged file to display the webpage. Since the original directory structure of the code files will be destroyed during the packaging process, it is impossible to customize specific code files in this way. Summary of the Invention
[0005] This application provides a web page file processing method and apparatus to meet customized needs while improving web page performance.
[0006] In a first aspect, embodiments of this application provide a first webpage file processing method, applied to a client, the method comprising:
[0007] Obtain the packaged file, mapping information, and customization information of the target webpage; wherein, the packaged file is obtained by the server packaging multiple code files of the target webpage, the packaged file contains code fragments corresponding to the code files, the mapping information includes the mapping relationship between each code fragment in the packaged file and a first path, and the customization information includes a second path;
[0008] For any code snippet in the packaged file, after running the code snippet, the first path of the code snippet is matched with the second path in the customization information;
[0009] Based on the matching results, determine whether to replace the execution result of the code snippet.
[0010] The above solution packages the target webpage's code files into a single package on the server, reducing file size and quantity and improving webpage loading speed. Furthermore, since the second path is the path to be replaced, the client matches the first path of each code snippet with the second path after execution, precisely determining whether to replace the execution result of that code snippet based on the matching result. Although the directory structure in the packaged file is corrupted, making direct replacement of code snippets impossible, dynamically replacing the execution result at runtime on the client side is unaffected by directory structure corruption, thus improving webpage performance while simultaneously meeting customization needs.
[0011] In some optional implementations, based on the matching results, it is determined whether to replace the execution result of the code snippet, including:
[0012] If a second path successfully matches the first path of the code snippet, then the replacement file corresponding to the successfully matched second path is obtained, and the execution result of the code snippet is replaced with the execution result of the replacement file.
[0013] In the above scheme, since the second path is the path that needs to be replaced, if the first path of the code snippet matches a certain second path, it means that the execution result of the code snippet needs to be replaced (i.e., the code file before packaging the code snippet has been customized), thus accurately determining the execution results of all code snippets that need to be replaced. The client then obtains the replacement file corresponding to the successfully matched second path, and after running the replacement file, replaces the execution result of the above code snippet with the execution result of the replacement file, achieving file customization under that path.
[0014] In some optional implementations, the replacement file corresponding to the successfully matched second path is obtained, including:
[0015] Send a file retrieval instruction containing the successfully matched second path to the server, so that the server sends the replacement file corresponding to the successfully matched second path to the client based on the file retrieval instruction.
[0016] In the above scheme, after the client determines that a second path successfully matches the first path of the code snippet, it sends a file retrieval instruction containing the successfully matched second path to the server. Based on the file retrieval instruction, the server sends the replacement file corresponding to the successfully matched second path to the client. In this way, the client can dynamically obtain the replacement file corresponding to the second path that needs to be replaced, and then replace the execution result of the above code snippet with the execution result of the replacement file after running the replacement file.
[0017] In some optional implementations, matching the first path of the code snippet with the second path in the customization information includes:
[0018] Determine whether the second path in the customized information contains a second path that is identical to the first path of the code fragment;
[0019] If so, it is determined that the same second path successfully matches the first path of the code fragment;
[0020] Otherwise, it is determined that no second path successfully matches the first path of the code snippet.
[0021] The above scheme accurately matches paths by determining whether there is a second path in the second path that is the same as the first path of each code snippet.
[0022] Secondly, embodiments of this application provide a second method for processing web page files, applied to a server, the method comprising:
[0023] Multiple code files of a target webpage are packaged together to obtain at least one packaged file of the target webpage; wherein the packaged file contains code fragments corresponding to the code files;
[0024] The packaged file, mapping information, and customization information are sent to the client so that the client can determine whether to replace the execution result of each code segment based on the matching result of the first path of each code segment and the second path in the customization information.
[0025] The mapping information includes the mapping relationship between each code segment in the packaged file and the first path; the customization information includes the second path.
[0026] The above solution packages the target webpage's code files into a single package on the server, reducing file size and quantity and improving webpage loading speed. Furthermore, since the second path is the path to be replaced, the client matches the first path of each code snippet with the second path after execution, precisely determining whether to replace the execution result of that code snippet based on the matching result. Although the directory structure in the packaged file is corrupted, making direct replacement of code snippets impossible, dynamically replacing the execution result at runtime on the client side is unaffected by directory structure corruption, thus improving webpage performance while simultaneously meeting customization needs.
[0027] In some optional implementations, multiple code files of the target webpage are packaged together to obtain at least one packaged file of the target webpage, including:
[0028] For any entry code file among the plurality of code files, determine the dependent code file corresponding to the entry code file from the plurality of code files;
[0029] The entry code file and the dependent code files are packaged together to obtain the packaged file corresponding to the entry code file.
[0030] The above solution ensures file coherence by including entry code files in the webpage's code files, which in turn need to reference other code files. These referenced code files are the dependent code files corresponding to the entry code files.
[0031] In some optional implementations, after sending the packaged file, mapping information, and customization information to the client, the method further includes:
[0032] In response to a file retrieval command, the replacement file corresponding to the successfully matched second path is sent to the client; wherein, the file retrieval command is triggered by the client after determining that a second path successfully matches the first path of any code fragment, and the file retrieval command includes the successfully matched second path.
[0033] In the above scheme, after the client determines that a second path successfully matches the first path of the code snippet, it sends a file retrieval instruction containing the successfully matched second path to the server. Based on the file retrieval instruction, the server sends the replacement file corresponding to the successfully matched second path to the client, so that the client can dynamically obtain the replacement file corresponding to the second path that needs to be replaced.
[0034] In some alternative implementations, the customization information is determined in the following ways:
[0035] After parsing the customized plugin, the second path in the customized plugin is scanned to obtain the customization information containing the second path.
[0036] Thirdly, embodiments of this application provide a first webpage file processing apparatus applied to a client, the apparatus comprising:
[0037] The file acquisition module is used to acquire the packaged file, mapping information, and customization information of the target webpage; wherein, the packaged file is obtained by the server packaging multiple code files of the target webpage, the packaged file contains code fragments corresponding to the code files, the mapping information includes the mapping relationship between each code fragment in the packaged file and a first path, and the customization information includes a second path;
[0038] The matching module is used to match the first path of any code segment in the packaged file with the second path in the customization information after the code segment is run.
[0039] The replacement module is used to determine whether to replace the execution result of the code snippet based on the matching results.
[0040] In some alternative implementations, the replacement module is specifically used for:
[0041] If a second path successfully matches the first path of the code snippet, then the replacement file corresponding to the successfully matched second path is obtained, and the execution result of the code snippet is replaced with the execution result of the replacement file.
[0042] In some alternative implementations, the replacement module is specifically used for:
[0043] Send a file retrieval instruction containing the successfully matched second path to the server, so that the server sends the replacement file corresponding to the successfully matched second path to the client based on the file retrieval instruction.
[0044] In some optional implementations, the matching module is specifically used for:
[0045] Determine whether the second path in the customized information contains a second path that is identical to the first path of the code fragment;
[0046] If so, it is determined that the same second path successfully matches the first path of the code fragment;
[0047] Otherwise, it is determined that no second path successfully matches the first path of the code snippet.
[0048] Fourthly, embodiments of this application provide a second web page file processing apparatus, applied to a server, the apparatus comprising:
[0049] A packaging module is used to package multiple code files of a target webpage to obtain at least one packaged file of the target webpage; wherein the packaged file contains code fragments corresponding to the code files;
[0050] The sending module is used to send the packaged file, mapping information and customization information to the client, so that the client can determine whether to replace the running result of each code segment based on the matching result of the first path of each code segment and the second path in the customization information;
[0051] The mapping information includes the mapping relationship between each code segment in the packaged file and the first path; the customization information includes the second path.
[0052] In some optional implementations, the packaging module is specifically used for:
[0053] For any entry code file among the plurality of code files, determine the dependent code file corresponding to the entry code file from the plurality of code files;
[0054] The entry code file and the dependent code files are packaged together to obtain the packaged file corresponding to the entry code file.
[0055] In some optional implementations, after sending the packaged file, mapping information, and customization information to the client, the sending module is further configured to:
[0056] In response to a file retrieval command, the replacement file corresponding to the successfully matched second path is sent to the client; wherein, the file retrieval command is triggered by the client after determining that a second path successfully matches the first path of any code fragment, and the file retrieval command includes the successfully matched second path.
[0057] In some alternative implementations, the customization information is determined in the following ways:
[0058] After parsing the customized plugin, the second path in the customized plugin is scanned to obtain the customization information containing the second path.
[0059] Fifthly, embodiments of this application provide a client comprising at least one processor and at least one memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform any of the web page file processing methods described in the first aspect.
[0060] In a sixth aspect, embodiments of this application provide a server, including at least one processor and at least one memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform any of the web page file processing methods described in the second aspect above.
[0061] In a seventh aspect, embodiments of this application provide a computer-readable storage medium storing a computer program executable by a processor, which, when run on the processor, causes the processor to perform the web page file processing method described in either the first or second aspect above. Attached Figure Description
[0062] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0063] Figure 1 This is a schematic diagram of the system architecture provided for an embodiment of this application;
[0064] Figure 2 An interactive flowchart of the first webpage file processing method provided in this application embodiment;
[0065] Figure 3 An interactive flowchart of the second webpage file processing method provided in this application embodiment;
[0066] Figure 4 An interactive flowchart of a third webpage file processing method provided in an embodiment of this application;
[0067] Figure 5 An interactive flowchart of the fourth web page file processing method provided in this application embodiment;
[0068] Figure 6 A flowchart illustrating the first webpage file processing method provided in this application embodiment;
[0069] Figure 7 A flowchart illustrating the second webpage file processing method provided in this application embodiment;
[0070] Figure 8 A schematic diagram of the structure of the first web page file processing device provided in the embodiments of this application;
[0071] Figure 9 A schematic diagram of the structure of the second web page file processing device provided in the embodiments of this application;
[0072] Figure 10 This is a schematic diagram of the structure of the client provided in an embodiment of this application. Detailed Implementation
[0073] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0074] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, unless otherwise stated, "a plurality of" means two or more.
[0075] In the description of this application, it should be noted that, unless otherwise expressly specified and limited, the term "connection" should be interpreted broadly. For example, it can refer to a direct connection, an indirect connection through an intermediate medium, or a connection within two devices. Those skilled in the art can understand the specific meaning of the above term in this application based on the specific circumstances.
[0076] In the process of front-end web development, in order to facilitate later maintenance and reuse, the code of a webpage is usually split into different files. Multiple file transfers are required to load the code files needed for the webpage, and the more files there are, the more transfers are required.
[0077] In related technologies, multiple code files of a webpage are merged into a package file, and the client loads and displays the webpage based on the package file, thereby reducing the number of network requests and improving the webpage loading speed.
[0078] A software product may need to be deployed to multiple customer sites, requiring modifications to some code files. However, the method described above directly runs the packaged file to display the webpage. Because the original directory structure of the code files is destroyed during the packaging process, the code files become code fragments within the packaged file. Therefore, this method cannot be used to customize specific code files.
[0079] In view of this, embodiments of this application propose a web page file processing method and apparatus. This method is applied to a client to meet customized needs while improving web page performance.
[0080] See Figure 1 As shown, this embodiment provides a system architecture including a client and a server;
[0081] The aforementioned server is used to package multiple code files of a target webpage to obtain at least one packaged file of the target webpage; wherein the packaged file contains code fragments corresponding to the code files; and to send the packaged file, mapping information, and customization information to the client; wherein the mapping information includes the mapping relationship between each code fragment in the packaged file and a first path, and the customization information includes a second path;
[0082] The aforementioned client is used to, for any code segment in the packaged file, after running the code segment, match the first path of the code segment with the second path in the customization information; based on the matching result, determine whether to replace the running result of the code segment.
[0083] The above solution packages the target webpage's code files into a single package on the server, reducing file size and quantity and improving webpage loading speed. Furthermore, since the second path is the path to be replaced, the client matches the first path of each code snippet with the second path after execution, precisely determining whether to replace the execution result of that code snippet based on the matching result. Although the directory structure in the packaged file is corrupted, making direct replacement of code snippets impossible, dynamically replacing the execution result at runtime on the client side is unaffected by directory structure corruption, thus improving webpage performance while simultaneously meeting customization needs.
[0084] The technical solution of this application and how it solves the above-mentioned technical problems will be described in detail below with reference to the accompanying drawings and specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0085] Figure 2 An interactive flowchart of the first webpage file processing method provided in the embodiments of this application is shown below. Figure 2 As shown, it includes the following steps:
[0086] Step S201: The server packages multiple code files of the target webpage to obtain at least one packaged file of the target webpage.
[0087] In practice, in order to reduce the size and number of files and improve the page loading speed, the code files of the target page are packaged by the server to obtain a packaged file, which contains the code fragments corresponding to the code files.
[0088] Since a packaged file is created by bundling at least one code file, the number of files is reduced; and since the packaged files are compressed during the packaging process, the file size is reduced. This, in turn, reduces the time required for subsequent file transfers.
[0089] Step S202: The server sends the packaged file, mapping information, and customization information to the client.
[0090] The mapping information includes the mapping relationship between each code segment in the packaged file and the first path, and the customization information includes the second path.
[0091] For example, due to the corrupted directory structure in the package file, code snippets in the package file cannot be directly replaced. In order to achieve customization, the client needs to know which code snippets need to be replaced.
[0092] Based on this, this embodiment establishes the association between files through paths. During the packaging process, the server constructs the mapping relationship between each code segment in the packaged file and the first path, such as the correspondence between the module name of each code segment and the physical file path before packaging; and determines customized information including paths that represent replacement, such as a list of paths that need to be replaced.
[0093] The above customization information can be found in Table 1:
[0094] Table 1
[0095]
[0096] Table 1 above is only an example. In practice, the mapping information can be implemented in other ways, such as the mapping information containing path 1: module 1, path 2: module 2, ..., path M: module M.
[0097] In some alternative implementations, customization information is determined in the following ways:
[0098] After parsing the customized plugin, the second path in the customized plugin is scanned to obtain the customization information containing the second path.
[0099] For example, to meet the needs of webpage customization, a plugin can be customized on-site. The server parses the customized plugin and scans the second path in the customized plugin using a plugin scanner to obtain a path list (customization information) containing the second path and a replacement file.
[0100] The above customization information can be found in Table 2:
[0101] Table 2
[0102]
[0103] Table 1 above uses N second paths as an example; in practice, more or fewer second paths can be set.
[0104] Step S203: For any code snippet in the packaged file, after running the code snippet, the client matches the first path of the code snippet with the second path in the customization information.
[0105] As mentioned above, the second path is the path that needs to be replaced, and the mapping information contains the first path of each code snippet;
[0106] Based on this, after running each code snippet, the client obtains the corresponding execution result (original function). Instead of executing the original function, the client matches the first path of the code snippet with the second path. Based on the matching result, it can determine whether to replace the execution result (original function) of the code snippet. If replacement is required, the execution result (original function) of the code snippet is replaced with the execution result (customized function) of the replacement file before the customized function is executed.
[0107] Step S204: Based on the matching results, the client determines whether to replace the execution result of the code snippet.
[0108] The above solution packages the target webpage's code files into a single package on the server, reducing file size and quantity and improving webpage loading speed. Furthermore, since the second path is the path to be replaced, the client matches the first path of each code snippet with the second path after execution, precisely determining whether to replace the execution result of that code snippet based on the matching result. Although the directory structure in the packaged file is corrupted, making direct replacement of code snippets impossible, dynamically replacing the execution result at runtime on the client side is unaffected by directory structure corruption, thus improving webpage performance while simultaneously meeting customization needs.
[0109] In some optional implementations, step S203 above can be implemented in, but is not limited to, the following ways:
[0110] Determine whether the second path in the customized information contains a second path that is identical to the first path of the code fragment;
[0111] If so, it is determined that the same second path successfully matches the first path of the code fragment;
[0112] Otherwise, it is determined that no second path successfully matches the first path of the code snippet.
[0113] For example, the second path is the path that needs to be replaced. For any code snippet, if the first path of the code snippet is the same as a certain second path, it means that the running result of the code snippet needs to be replaced (that is, the code file before the code snippet was packaged has been customized), and the running result of the replacement file corresponding to the second path is replaced. Therefore, it is determined that the second path and the first path are successfully matched.
[0114] Conversely, if the first path of the code snippet is different from all the second paths, it means that the result of running the code snippet does not need to be replaced (i.e., the code file before the code snippet was packaged was not customized), so it is determined that no second path matches the first path successfully.
[0115] The above scheme accurately matches paths by determining whether there is a second path in the second path that is the same as the first path of each code snippet.
[0116] Figure 3 An interactive flowchart of the second webpage file processing method provided in the embodiments of this application is shown below. Figure 3 As shown, it includes the following steps:
[0117] Step S301: The server packages multiple code files of the target webpage to obtain at least one packaged file of the target webpage.
[0118] Step S302: The server sends the packaged file, mapping information, and customization information to the client.
[0119] Step S303: For any code snippet in the packaged file, after running the code snippet, the client matches the first path of the code snippet with the second path in the customization information.
[0120] The specific implementation of steps S301 to S303 can be found in other embodiments, and will not be repeated here.
[0121] Step S304: If a second path successfully matches the first path of the code snippet, the client determines to replace the execution result of the code snippet.
[0122] For example, the second path is the path that needs to be replaced. For any code snippet, if the first path of the code snippet matches a certain second path, it means that the execution result of the code snippet needs to be replaced (that is, the code file before the code snippet was packaged was customized).
[0123] Based on this, once the client determines that a second path successfully matches the first path of the code snippet, it can then determine that the execution result of the code snippet needs to be replaced.
[0124] In the above scheme, since the second path is the path that needs to be replaced, if the first path of the code snippet matches a certain second path, it means that the execution result of the code snippet needs to be replaced (that is, the code file before the code snippet was packaged was customized), thereby accurately determining the execution result of all code snippets that need to be replaced.
[0125] In some optional implementations, after determining that the result of running the code snippet should be replaced, the following steps are also performed:
[0126] Obtain the replacement file corresponding to the successfully matched second path, and replace the execution result of the code snippet with the execution result of the replacement file.
[0127] In practice, the second path is the path that needs to be replaced, and the replacement file corresponding to the second path is a customized file. After determining that the execution result of the code snippet needs to be replaced, it is necessary to obtain the replacement file corresponding to the successfully matched second path, and then replace the execution result of the code snippet with the execution result of the replacement file.
[0128] In the above scheme, after the client determines that a second path successfully matches the first path of the code snippet, it obtains the replacement file corresponding to the successfully matched second path, and then, after running the replacement file, replaces the execution result of the above code snippet with the execution result of the replacement file, thereby realizing the customization of files under that path.
[0129] In some optional implementations, obtaining the replacement file corresponding to the successfully matched second path can be referred to... Figure 4 The corresponding steps are implemented.
[0130] Figure 4 The interactive flowchart of the third webpage file processing method provided in the embodiments of this application is as follows: Figure 4 As shown, it includes the following steps:
[0131] Step S401: The server packages multiple code files of the target webpage to obtain at least one packaged file of the target webpage.
[0132] Step S402: The server sends the packaged file, mapping information, and customization information to the client.
[0133] Step S403: For any code snippet in the packaged file, after running the code snippet, the client matches the first path of the code snippet with the second path in the customization information.
[0134] Step S404: If a second path successfully matches the first path of the code snippet, the client determines to replace the execution result of the code snippet.
[0135] The specific implementation of steps S401 to S404 can be found in other embodiments, and will not be repeated here.
[0136] Step S405: The client sends a file retrieval instruction containing the successfully matched second path to the server.
[0137] For example, to meet the needs of webpage customization, a custom plugin can be made on-site, and the server obtains all the replacement files of the plugin.
[0138] During the process of running the packaged file, whenever the client determines that a second path matches the first path of the code snippet, it triggers a file retrieval instruction containing the successfully matched second path and retrieves the corresponding replacement file from the server side.
[0139] Step S406: In response to the file retrieval command, the server sends the replacement file corresponding to the successfully matched second path to the client.
[0140] For example, the server selects the replacement file corresponding to the file retrieval instruction from all replacement files of the plugin (the replacement file corresponding to the second path that is successfully matched) based on the client's file retrieval instruction.
[0141] Step S407: The client replaces the execution result of the code snippet with the execution result of the replacement file.
[0142] In the above scheme, after the client determines that a second path successfully matches the first path of the code snippet, it sends a file retrieval instruction containing the successfully matched second path to the server. Based on the file retrieval instruction, the server sends the replacement file corresponding to the successfully matched second path to the client. In this way, the client can dynamically obtain the replacement file corresponding to the second path that needs to be replaced, and then replace the execution result of the above code snippet with the execution result of the replacement file after running the replacement file.
[0143] Figure 5 The interactive flowchart of the fourth webpage file processing method provided in the embodiments of this application is as follows: Figure 5 As shown, it includes the following steps:
[0144] Step S501: For any entry code file among the plurality of code files, the server determines the dependent code file corresponding to the entry code file from the plurality of code files.
[0145] In implementation, the code files of a webpage contain entry code files. These files need to reference other code files, and the referenced code files are the dependent code files corresponding to the entry code files. Therefore, there is a relationship between the entry code files and their dependent code files. When packaging, these related files need to be packaged into the same package file.
[0146] Step S502: The server packages the entry code file and the dependent code files to obtain the packaged file corresponding to the entry code file.
[0147] For example, the configuration file of the webpage contains information about the entry code file (filename, file identifier, etc.). The server determines the entry code file and its dependent code files based on the configuration file, and uses a bundler to merge the entry code file and its dependent code files into the same bundled file. The name of the bundled file can be set to the name of the entry code file or other custom names.
[0148] Step S503: The server sends the packaged file, mapping information, and customization information to the client.
[0149] Step S504: For any code snippet in the packaged file, after running the code snippet, the client matches the first path of the code snippet with the second path in the customization information.
[0150] Step S505: Based on the matching results, the client determines whether to replace the execution result of the code snippet.
[0151] The specific implementation of steps S503 to S505 can be found in the above embodiments, and will not be repeated here.
[0152] The above solution ensures file coherence by including entry code files in the webpage's code files, which in turn need to reference other code files. These referenced code files are the dependent code files corresponding to the entry code files.
[0153] The following is a specific example to illustrate this:
[0154] The packaged file contains 10 code snippets: code snippet 1, code snippet 2, code snippet 3, code snippet 4, code snippet 5, code snippet 6, code snippet 7, code snippet 8, code snippet 9, and code snippet 10 (these numbers are not ordered according to the order in which the code appears in the file, but according to the order in which it is called); among them, code snippet 1 corresponds to the first path 1, code snippet 2 corresponds to the first path 2, code snippet 3 corresponds to the first path 3, code snippet 4 corresponds to the first path 4, code snippet 5 corresponds to the first path 5, code snippet 6 corresponds to the first path 6, code snippet 7 corresponds to the first path 7, code snippet 8 corresponds to the first path 8, code snippet 9 corresponds to the first path 9, and code snippet 10 corresponds to the first path 10.
[0155] The customized information includes second path 1, second path 2, and second path 3;
[0156] After running code snippet 1, the client determines that no second path matches the first path 1, and then executes the result of running code snippet 1.
[0157] Run code snippet 2 to confirm that no second path matches the first path 2 successfully, and then execute the result of running code snippet 2;
[0158] Run code snippet 3 to confirm that the second path 1 and the first path 3 match successfully, obtain the replacement file corresponding to the second path 1, replace the running result of code snippet 3 with the running result of the replacement file, and execute the running result of the replacement file;
[0159] After running code snippet 4, it is determined that no second path matches the first path 4 successfully, and the result of running code snippet 4 is executed.
[0160] Run code snippet 5 to confirm that the second path 2 matches the first path 5 successfully. Obtain the replacement file corresponding to the second path 2, replace the running result of code snippet 5 with the running result of the replacement file, and execute the running result of the replacement file.
[0161] After running code snippet 6, it is determined that no second path matches the first path 6 successfully, and the result of running code snippet 6 is executed.
[0162] After running code snippet 7, it is determined that no second path matches the first path 7 successfully, and the result of running code snippet 7 is executed.
[0163] After running code snippet 8, it is determined that no second path matches the first path 8 successfully, and the result of running code snippet 8 is executed.
[0164] After running code snippet 9, it is determined that no second path matches the first path 9 successfully, and the result of running code snippet 9 is executed.
[0165] The second path 3 successfully matches the first path 10. The replacement file corresponding to the second path 3 is obtained, and the execution result of code snippet 10 is replaced with the execution result of the replacement file. The execution result of the replacement file is then executed.
[0166] The above examples are only for illustrating the process of dynamic replacement on the client side more clearly, and this application is not limited thereto.
[0167] The web page file processing method executed by the client in the embodiments of this application is as follows: Figure 6 As shown, it includes the following steps:
[0168] Step S601: Obtain the packaged file, mapping information, and customization information of the target webpage; wherein, the packaged file is obtained by the server packaging multiple code files of the target webpage, the packaged file contains code fragments corresponding to the code files, the mapping information includes the mapping relationship between each code fragment in the packaged file and the first path, and the customization information includes the second path;
[0169] Step S602: For any code snippet in the packaged file, after running the code snippet, match the first path of the code snippet with the second path in the customization information;
[0170] Step S603: Based on the matching results, determine whether to replace the execution result of the code snippet.
[0171] In some optional implementations, based on the matching results, it is determined whether to replace the execution result of the code snippet, including:
[0172] If a second path successfully matches the first path of the code snippet, then the replacement file corresponding to the successfully matched second path is obtained, and the execution result of the code snippet is replaced with the execution result of the replacement file.
[0173] In some optional implementations, the replacement file corresponding to the successfully matched second path is obtained, including:
[0174] Send a file retrieval instruction containing the successfully matched second path to the server, so that the server sends the replacement file corresponding to the successfully matched second path to the client based on the file retrieval instruction.
[0175] In some optional implementations, matching the first path of the code snippet with the second path in the customization information includes:
[0176] Determine whether the second path in the customized information contains a second path that is identical to the first path of the code fragment;
[0177] If so, it is determined that the same second path successfully matches the first path of the code fragment;
[0178] Otherwise, it is determined that no second path successfully matches the first path of the code snippet.
[0179] The web page file processing method performed by the server in the embodiments of this application is as follows: Figure 7 As shown, it includes the following steps:
[0180] Step S701: Package multiple code files of the target webpage to obtain at least one packaged file of the target webpage; wherein the packaged file contains code fragments corresponding to the code files;
[0181] Step S702: Send the packaged file, mapping information and customization information to the client, so that the client can determine whether to replace the running results of each code segment based on the matching result of the first path of each code segment and the second path in the customization information;
[0182] The mapping information includes the mapping relationship between each code segment in the packaged file and the first path; the customization information includes the second path.
[0183] In some optional implementations, multiple code files of the target webpage are packaged together to obtain at least one packaged file of the target webpage, including:
[0184] For any entry code file among the plurality of code files, determine the dependent code file corresponding to the entry code file from the plurality of code files;
[0185] The entry code file and the dependent code files are packaged together to obtain the packaged file corresponding to the entry code file.
[0186] In some optional implementations, after sending the packaged file, mapping information, and customization information to the client, the method further includes:
[0187] In response to a file retrieval command, the replacement file corresponding to the successfully matched second path is sent to the client; wherein, the file retrieval command is triggered by the client after determining that a second path successfully matches the first path of any code fragment, and the file retrieval command includes the successfully matched second path.
[0188] In some alternative implementations, the customization information is determined in the following ways:
[0189] After parsing the customized plugin, the second path in the customized plugin is scanned to obtain the customization information containing the second path.
[0190] Figures 6-7 For details on the specific implementation of the embodiments, please refer to the implementation of the above-described interaction method; repeated details will not be repeated here.
[0191] like Figure 8 As shown, based on and Figure 6 The present application provides a first webpage file processing apparatus 800, which is based on the same inventive concept as the webpage file processing method shown, and is applied to a client. The apparatus includes:
[0192] The file acquisition module 801 is used to acquire the packaged file, mapping information and customization information of the target webpage; wherein, the packaged file is obtained by the server packaging multiple code files of the target webpage, the packaged file contains code fragments corresponding to the code files, the mapping information includes the mapping relationship between each code fragment in the packaged file and a first path, and the customization information includes a second path;
[0193] The matching module 802 is used to match the first path of any code segment in the packaged file with the second path in the customization information after the code segment is run.
[0194] The replacement module 803 is used to determine whether to replace the execution result of the code snippet based on the matching result.
[0195] In some alternative implementations, the replacement module 803 is specifically used for:
[0196] If a second path successfully matches the first path of the code snippet, then the replacement file corresponding to the successfully matched second path is obtained, and the execution result of the code snippet is replaced with the execution result of the replacement file.
[0197] In some alternative implementations, the replacement module 803 is specifically used for:
[0198] Send a file retrieval instruction containing the successfully matched second path to the server, so that the server sends the replacement file corresponding to the successfully matched second path to the client based on the file retrieval instruction.
[0199] In some optional implementations, the matching module 802 is specifically used for:
[0200] Determine whether the second path in the customized information contains a second path that is identical to the first path of the code fragment;
[0201] If so, it is determined that the same second path successfully matches the first path of the code fragment;
[0202] Otherwise, it is determined that no second path successfully matches the first path of the code snippet.
[0203] like Figure 9 As shown, based on and Figure 7 Using the same inventive concept as the webpage file processing method shown, this application provides a second webpage file processing apparatus 900, applied to a server, which includes:
[0204] The packaging module 901 is used to package multiple code files of a target webpage to obtain at least one packaged file of the target webpage; wherein the packaged file contains code fragments corresponding to the code files;
[0205] The sending module 902 is used to send the packaged file, mapping information, and customization information to the client, so that the client can determine whether to replace the execution result of each code segment based on the matching result of the first path of each code segment and the second path in the customization information; wherein, the mapping information includes the mapping relationship between each code segment in the packaged file and the first path; the customization information includes the second path.
[0206] In some alternative implementations, the packaging module 901 is specifically used for:
[0207] For any entry code file among the plurality of code files, determine the dependent code file corresponding to the entry code file from the plurality of code files;
[0208] The entry code file and the dependent code files are packaged together to obtain the packaged file corresponding to the entry code file.
[0209] In some optional implementations, after sending the packaged file, mapping information, and customization information to the client, the sending module 902 is further configured to:
[0210] In response to a file retrieval command, the replacement file corresponding to the successfully matched second path is sent to the client; wherein, the file retrieval command is triggered by the client after determining that a second path successfully matches the first path of any code fragment, and the file retrieval command includes the successfully matched second path.
[0211] In some alternative implementations, the customization information is determined in the following ways:
[0212] After parsing the customized plugin, the second path in the customized plugin is scanned to obtain the customization information containing the second path.
[0213] Figures 8-9 For details on the specific implementation of the embodiments, please refer to the implementation of the above-described interaction method; repeated details will not be repeated here.
[0214] Based on the same technical concept, this application also provides a client 1000, such as... Figure 10 As shown, it includes at least one processor 1001 and a memory 1002 connected to at least one processor. In this embodiment, the specific connection medium between the processor 1001 and the memory 1002 is not limited. Figure 10Taking the connection between processor 1001 and memory 1002 via bus 1003 as an example. Buses can be categorized into path buses, data buses, control buses, etc. For ease of illustration, Figure 10 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0215] The processor 1001 serves as the control center for the client, connecting various parts of the client via various interfaces and lines. It performs data processing by running or executing instructions stored in the memory 1002 and accessing data stored in the memory 1002. Optionally, the processor 1001 may include one or more processing units. The processor 1001 may integrate an application processor and a modem processor. The application processor primarily handles the operating system, user interface, and applications, while the modem processor primarily handles issuing instructions. It is understood that the modem processor may not be integrated into the processor 1001. In some embodiments, the processor 1001 and the memory 1002 may be implemented on the same chip; in other embodiments, they may be implemented on separate chips.
[0216] The processor 1001 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit (ASIC), field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of the web page file processing method can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.
[0217] Memory 1002, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 1002 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic memory, magnetic disk, optical disk, etc. Memory 1002 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 1002 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.
[0218] In this embodiment, the memory 1002 stores a computer program, which, when executed by the processor 1001, causes the processor 1001 to perform the following:
[0219] Obtain the packaged file, mapping information, and customization information of the target webpage; wherein, the packaged file is obtained by the server packaging multiple code files of the target webpage, the packaged file contains code fragments corresponding to the code files, the mapping information includes the mapping relationship between each code fragment in the packaged file and a first path, and the customization information includes a second path;
[0220] For any code snippet in the packaged file, after running the code snippet, the first path of the code snippet is matched with the second path in the customization information;
[0221] Based on the matching results, determine whether to replace the execution result of the code snippet.
[0222] In some optional implementations, processor 1001 specifically performs:
[0223] If a second path successfully matches the first path of the code snippet, then the replacement file corresponding to the successfully matched second path is obtained, and the execution result of the code snippet is replaced with the execution result of the replacement file.
[0224] In some optional implementations, processor 1001 specifically performs:
[0225] Send a file retrieval instruction containing the successfully matched second path to the server, so that the server sends the replacement file corresponding to the successfully matched second path to the client based on the file retrieval instruction.
[0226] In some optional implementations, processor 1001 specifically performs:
[0227] Determine whether the second path in the customized information contains a second path that is identical to the first path of the code fragment;
[0228] If so, it is determined that the same second path successfully matches the first path of the code fragment;
[0229] Otherwise, it is determined that no second path successfully matches the first path of the code snippet.
[0230] Based on the same technical concept, embodiments of this application also provide a server, including at least one processor and at least one memory, wherein the memory stores a computer program, and when the program is executed by the processor, the processor performs the following:
[0231] Multiple code files of a target webpage are packaged together to obtain at least one packaged file of the target webpage; wherein the packaged file contains code fragments corresponding to the code files;
[0232] The packaged file, mapping information, and customization information are sent to the client so that the client can determine whether to replace the execution result of each code segment based on the matching result of the first path of each code segment and the second path in the customization information; wherein, the mapping information includes the mapping relationship between each code segment in the packaged file and the first path; the customization information includes the second path.
[0233] In some alternative implementations, the processor specifically executes:
[0234] For any entry code file among the plurality of code files, determine the dependent code file corresponding to the entry code file from the plurality of code files;
[0235] The entry code file and the dependent code files are packaged together to obtain the packaged file corresponding to the entry code file.
[0236] In some optional implementations, after sending the packaged file, mapping information, and customization information to the client, the processor also performs:
[0237] In response to a file retrieval command, the replacement file corresponding to the successfully matched second path is sent to the client; wherein, the file retrieval command is triggered by the client after determining that a second path successfully matches the first path of any code fragment, and the file retrieval command includes the successfully matched second path.
[0238] In some alternative implementations, the customization information is determined in the following ways:
[0239] After parsing the customized plugin, the second path in the customized plugin is scanned to obtain the customization information containing the second path.
[0240] Based on the same technical concept, embodiments of this application also provide a computer-readable storage medium storing a computer program executable by a processor, which, when run on the processor, causes the processor to perform the steps of the above-described web page file processing method.
[0241] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0242] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0243] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0244] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0245] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0246] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for processing webpage files, characterized in that, Applied to the client, the method includes: Obtain the packaged file, mapping information, and customization information of the target webpage; wherein, the packaged file is obtained by the server packaging multiple code files of the target webpage, the packaged file contains code fragments corresponding to the code files, the mapping information includes the mapping relationship between each code fragment in the packaged file and a first path, and the customization information includes a second path; the first path includes the physical file path before packaging, and the second path indicates the replacement path; For any code snippet in the packaged file, after running the code snippet, the first path of the code snippet is matched with the second path in the customization information; If there is a second path in the second path that is the same as the first path of the code snippet, then the second path and the first path of the code snippet are successfully matched. Then, the replacement file corresponding to the successfully matched second path is obtained, and the running result of the code snippet is replaced with the running result of the replacement file.
2. The method as described in claim 1, characterized in that, Retrieve the replacement file corresponding to the successfully matched second path, including: Send a file retrieval instruction containing the successfully matched second path to the server, so that the server sends the replacement file corresponding to the successfully matched second path to the client based on the file retrieval instruction.
3. The method as described in claim 1 or 2, characterized in that, Matching the first path of the code snippet with the second path in the customized information includes: Determine whether the second path in the customized information contains a second path that is identical to the first path of the code fragment; If so, it is determined that the same second path successfully matches the first path of the code fragment; Otherwise, it is determined that no second path successfully matches the first path of the code snippet.
4. A method for processing web page files, characterized in that, Applied to a server, the method includes: Multiple code files of a target webpage are packaged together to obtain at least one packaged file of the target webpage; wherein the packaged file contains code fragments corresponding to the code files; The packaged file, mapping information, and customization information are sent to the client so that the client, for any code segment among the code segments, can, based on the matching result of the first path of the code segment and the second path in the customization information, if there is a second path in the second path that is the same as the first path of the code segment, obtain the replacement file corresponding to the successfully matched second path, and replace the running result of the code segment with the running result of the replacement file; wherein, the mapping information includes the mapping relationship between each code segment in the packaged file and the first path; the customization information includes the second path; the first path includes the physical file path before packaging, and the second path indicates the replacement path.
5. The method as described in claim 4, characterized in that, Multiple code files of the target webpage are packaged together to obtain at least one packaged file of the target webpage, including: For any entry code file among the plurality of code files, determine the dependent code file corresponding to the entry code file from the plurality of code files; The entry code file and the dependent code files are packaged together to obtain the packaged file corresponding to the entry code file.
6. The method as described in claim 4, characterized in that, After sending the packaged file, mapping information, and customization information to the client, the process also includes: In response to a file retrieval command, the replacement file corresponding to the successfully matched second path is sent to the client; wherein, the file retrieval command is triggered by the client after determining that a second path successfully matches the first path of any code fragment, and the file retrieval command includes the successfully matched second path.
7. The method according to any one of claims 4 to 6, characterized in that, The customized information is determined in the following ways: After parsing the customized plugin, the second path in the customized plugin is scanned to obtain the customization information containing the second path.
8. A webpage file processing device, characterized in that, For use on a client, the device includes: The file acquisition module is used to acquire the packaged file, mapping information, and customization information of the target webpage; wherein, the packaged file is obtained by the server packaging multiple code files of the target webpage, the packaged file contains code fragments corresponding to the code files, the mapping information includes the mapping relationship between each code fragment in the packaged file and a first path, and the customization information includes a second path; the first path includes the physical file path before packaging, and the second path indicates the replacement path; The matching module is used to match the first path of any code segment in the packaged file with the second path in the customization information after the code segment is run. The replacement module is configured to, if there is a second path in the second path that is the same as the first path of the code fragment, then the second path and the first path of the code fragment are successfully matched, obtain the replacement file corresponding to the successfully matched second path, and replace the running result of the code fragment with the running result of the replacement file.
9. A webpage file processing device, characterized in that, Applied to servers, the device includes: A packaging module is used to package multiple code files of a target webpage to obtain at least one packaged file of the target webpage; wherein the packaged file contains code fragments corresponding to the code files; The sending module is used to send the packaged file, mapping information, and customization information to the client, so that the client, for any code segment among the code segments, based on the matching result of the first path of the code segment and the second path in the customization information, if there is a second path in the second path that is the same as the first path of the code segment, obtains the replacement file corresponding to the successfully matched second path, and replaces the running result of the code segment with the running result of the replacement file; wherein, the mapping information includes the mapping relationship between each code segment in the packaged file and the first path; the customization information includes the second path; the first path includes the physical file path before packaging, and the second path indicates the replacement path.