Request processing method and related device
By splitting the mobile application into main project and sub-project, and dynamically loading the corresponding offline packages according to user needs, the problem of lowering the load success rate caused by the increase in offline package volume is solved, and the user experience is improved.
Patent Information
- Application Number
- CN202411713912.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-02-18
AI Technical Summary
With the iteration of mobile application functions, the volume of offline packages increases, resulting in a decrease in the success rate of users' one-time loading when loading offline packages, affecting the user experience.
By splitting the target application into one main project and multiple sub-projects, the main project includes a public resource offline package and a main project offline package, and the sub-project includes a sub-project offline package. When the user loads the request, the main project and the public resource offline package are first loaded, and the corresponding sub-project offline package is loaded according to the user's instructions. The sub-project offline package corresponding to the function that is not clicked is prohibited from loading.
It realizes loading only the data required by the user, reducing the amount of loading data, improving the success rate of one-time loading, thereby improving the user experience.
Smart Images

Figure CN119473435A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of mobile applications, and more specifically, to a request processing method and related devices. Background Art
[0002] Mobile applications provide users with a more convenient, efficient and personalized experience. Embedded H5 pages are widely used in the development of lightweight mobile applications due to their cross-platform compatibility and flexible application scenarios. The offline package has low traffic cost, fast loading response, and support for offline use, which has accelerated the use and development of H5 offline package technology. With the continuous iteration of application functions, a lightweight mobile application will gradually become "heavy".
[0003] During long-term development and maintenance, the project has become increasingly large, which has increased the size of the offline package. This has resulted in a lower one-time loading success rate when users load the offline package, affecting the user experience. Summary of the invention
[0004] In view of this, the present application provides a request processing method and related devices to solve the problem that the increase in the size of the offline package leads to a decrease in the one-time loading success rate when the user loads the offline package, thereby affecting the user experience.
[0005] In order to solve the above technical problems, this application adopts the following technical solutions: A request processing method, comprising: Receive user loading request; In response to the user loading request, the main project offline package and the public resource offline package of the target application are loaded; the target application is divided into a main project and multiple sub-projects, the main project includes the public resource offline package and the main project offline package; the sub-project includes the sub-project offline package; If an instruction is received from a user to click a target function on an interface obtained after loading the offline package of the main project, a target sub-project corresponding to the target function is determined; Jump to the sub-project offline package corresponding to the target sub-project through the routing center and the designated interface, load the sub-function offline package corresponding to the target sub-project to respond to the instruction; wherein, the sub-project offline package corresponding to the function not clicked by the user is prohibited from loading.
[0006] Optionally, the target application splitting process includes: Obtain a target application and a splitting rule corresponding to the target application; Processing the target application based on the splitting rule to generate sub-project splitting information and a public resource identifier; the sub-project splitting information includes a global variable configuration file and a modified marking result; Splitting the target application into a main project and multiple sub-projects according to the sub-project splitting information and the public resource identifier; Decomposing the main project into a public resource offline package and a main project offline package, and packaging the sub-projects to obtain sub-project offline packages; Based on the public resource offline package, the main project offline package and the sub-project offline package, a logical relationship between the main project and the sub-project is established.
[0007] Optionally, the target application is processed based on the splitting rule to generate sub-project splitting information and a public resource identifier, including: Based on the splitting rule, the code structure of the target application is analyzed to obtain a global variable configuration file; Determine the file resource call frequency of the file in the target application; Identify a public resource file based on the file resource call frequency, mark the public resource file, and obtain a public resource identifier of the public resource file; Perform modification marking processing on files that reference public resources in the target application to obtain modification marking results; The global variable configuration file and the modified marking result are combined to obtain sub-project splitting information.
[0008] Optionally, splitting the target application into a main project and multiple sub-projects according to the sub-project splitting information and the public resource identifier includes: Create multiple sub-projects; According to the sub-project splitting information, move the sub-project directory part in the directory of the target application and the files corresponding to the sub-project directory part to the corresponding sub-project; For files whose locations have changed in a sub-project, modify the import path of the files to obtain multiple sub-projects after splitting; Move the file corresponding to the public resource identifier to the first designated directory of the main project; In the target application, the contents of the main project except the file corresponding to the public resource identifier are moved to the second designated directory of the main project to obtain a split main project.
[0009] Optionally, the main project is decomposed into a common resource offline package and a main project offline package, including: Configure the JS file in the main project; Using the JS file as an entry, extracting public resource information from the main project, and packaging the public resource information to obtain a public resource offline package; The part of the main project except the public resource information is packaged into a main project offline package.
[0010] Optionally, based on the public resource offline package, the main project offline package and the sub-project offline package, a logical relationship between the main project and the sub-project is established, including: Generate routing configuration information; Introducing the public resource offline package and the public configuration file into the main project offline package and the sub-project offline package; Modify the resource reference path according to the modification marking result; The main project offline package is used as the only entry to the target application, and a linkage relationship between the main project offline package and each of the sub-project offline packages is constructed to establish a logical relationship between the main project and the sub-projects.
[0011] Optionally, generate routing configuration information, including: Based on the splitting rule, determining the attribution information of the function directory in the directory of the target application; If the belonging information is a main project, configure the internal jump relationship of the function directory in the routing configuration information of the offline package of the main project; If the belonging information is a sub-project, the jump information of the sub-project offline package of the sub-project to which the function directory belongs is added to the routing configuration information of the main project offline package to obtain the routing configuration information.
[0012] A request processing device, comprising: A request receiving module, used for receiving a user loading request; A first loading module is used to respond to the user loading request and load the main project offline package and the public resource offline package of the target application; the target application is divided into a main project and multiple sub-projects, the main project includes the public resource offline package and the main project offline package; the sub-project includes the sub-project offline package; The instruction response module is used to determine the target sub-project corresponding to the target function upon receiving an instruction from the user to click on the target function on the interface obtained after loading the offline package of the main project; The second loading module is used to jump to the sub-project offline package corresponding to the target sub-project through the routing center and the designated interface, and load the sub-function offline package corresponding to the target sub-project to respond to the instruction; wherein, the sub-project offline package corresponding to the function not clicked by the user is prohibited from loading.
[0013] An electronic device comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the above-mentioned request processing method.
[0014] A computer storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the above-mentioned request processing method.
[0015] The present application provides a request processing method and related devices. In the present application, the target application is divided into a main project and multiple sub-projects. The main project includes a public resource offline package and a main project offline package; the sub-project includes a sub-project offline package. On this basis, if a user loading request is received, the main project offline package and the public resource offline package of the target application are first loaded. If an instruction is received that the user clicks on the target function on the interface obtained after loading the main project offline package, the target sub-project corresponding to the target function is determined, and the sub-project offline package corresponding to the target sub-project is jumped to through the routing center and the specified interface, and the sub-function offline package is loaded to respond to the instruction. The sub-project offline package corresponding to the function that is not clicked by the user is prohibited from loading. That is, through the present invention, only the data required by the user is loaded, and the data that the user does not need is temporarily not loaded, which can reduce the amount of loaded data, improve the one-time loading success rate, and thus improve the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0017] Figure 1 The overall framework diagram of the mobile application engineering splitting and integration device based on H5 offline package provided by the embodiment of the present invention; Figure 2 A flowchart of the application splitting process provided by an embodiment of the present invention; Figure 3 A process flow chart of project splitting provided by an embodiment of the present invention; Figure 4 A routing configuration workflow diagram provided by an embodiment of the present invention; Figure 5 A workflow diagram of a public resource importer provided by an embodiment of the present invention; Figure 6 A workflow diagram of an offline package integrator provided by an embodiment of the present invention; Figure 7A schematic diagram of an interactive mode after the H5 offline package is split and integrated according to an embodiment of the present invention; Figure 8 A flowchart of a request processing method provided by an embodiment of the present invention; Fig. 9 A schematic diagram of the structure of a request processing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0019] In order to enable those skilled in the art to more clearly understand the present invention, the professional terms in the present invention are now explained.
[0020] H5 offline package: H5 offline package is to pack static resources in the page, including HTML (Hyper Text Markup Language), JavaScript, CSS (Cascading Style Sheets), etc. into a compressed package. Download the offline package to the local computer in advance, then open it through the client and load the offline package directly from the local computer, thus eliminating the influence of the network environment on the H5 page.
[0021] A common resource package is a subdivision of an H5 offline package, which packages static resources on a page, including HTML, JavaScript, CSS, etc., into a compressed package.
[0022] A public resource package is a subdivision of an H5 offline package, which refers to a resource package that puts together common resources that can be referenced by multiple other common resource packages.
[0023] ES6 / ES5: The full name is ECMAScript 6.0 / ECMAScript 5.0, which is a standard of the JavaScript language. The goal of this standard is to enable JavaScript to be used to write complex large-scale applications and become an enterprise-level development language.
[0024] iframe: is an HTML tag that is used as an inline frame to embed another document in the current HTML document.
[0025] JSAPI (JavaScript API): It is the JS interface for H5 applications to access native client functions. By calling JSAPI, event calling and data communication between H5 and native clients can be realized.
[0026] Mobile applications provide users with a more convenient, efficient and personalized experience. Embedded H5 pages are widely used in the development of lightweight mobile applications due to their cross-platform compatibility and flexible application scenarios. The offline package has low traffic cost, fast loading response, and support for offline use, which has accelerated the use and development of H5 offline package technology. With the continuous iteration of application functions, a lightweight mobile application will gradually become "heavy".
[0027] In the long-term development and maintenance, the project engineering has gradually become huge, which has increased the size of the offline package, resulting in a decrease in the one-time loading success rate when users load the offline package, affecting the user experience. In addition, as the functions of the mobile terminal are continuously improved and the platformization of the mobile terminal becomes more and more obvious, a mobile application project can be divided into multiple business modules, which are developed by different teams. There are problems such as chaotic branch management and code version conflicts in the development of the same project. The increasing number of developers involved has made project management and maintenance difficult. The code is intertwined, which makes it difficult to manage within the module. The slow loading speed of the homepage leads to a long white screen time, affecting the user experience. At the same time, the existing mobile development platforms have set limits on the size of offline packages. When the offline package exceeds 5M, the one-time download success rate will be reduced to less than 50%, which is a high risk. Therefore, it is clearly recommended that the size of the offline package should not exceed 5M.
[0028] In order to solve the above problems, whether from the perspective of technical maintenance or platform restrictions, offline package splitting is a necessary means to improve application download speed and user experience.
[0029] In order to realize offline package splitting, iframe and other technologies disclose the idea of micro-frontend, that is, splitting a complex monolithic application into multiple small sub-applications. However, iframe cannot be directly used to handle the scenario of H5 offline package splitting. If it is modified and applied to the scenario of H5 offline package splitting, it is necessary to combine iframe and other tools to adapt to the scenario of H5 offline package splitting, which has a high learning and transformation cost. In addition, it will make the packaging process more complicated, and the total size of the offline package after splitting may increase, which deviates from the original intention of reducing the size of the offline package in some scenarios.
[0030] In addition, developers can also split the data manually, which will cause a lot of workload for developers.
[0031] In addition, the idea of centralized routing can also be used for splitting, but this idea relies on the browser's routing jump, which is only suitable for jumping within a function. It does not have the function of jumping between mobile H5 offline packages, and cannot be applied to the splitting of mobile application projects based on H5 offline package deployment.
[0032] In view of the above problems, the present invention proposes a method for splitting and integrating mobile application projects based on H5 offline packages. Starting from the perspective of a huge project project, in line with the principles of technical architecture reuse and singleness, it is split into a platform project (also called the main project) and multiple business module projects (also called sub-projects), wherein each business module project can be independently developed, packaged as an independent offline package and deployed, and can also jump with the platform project offline package to achieve loading, isolation and communication between offline packages; the platform project includes the platform basic functions and public resources required by the business modules. In order to fully reduce the volume of each offline package and reduce redundancy, the public resources are extracted and packaged separately for each business module offline package to call. This solves the problem of large amount of project splitting and transformation, and high reliance on manual operations of developers, and greatly improves the efficiency of framework transformation.
[0033] When loading later, you can only load the platform project and the business module project required by the user to reduce the loading amount, thereby improving the loading success rate.
[0034] The embodiment of the present invention supports the splitting and integration of a mobile application project deployed in the form of an H5 offline package, so as to split a large volume of offline packages and allow the offline packages to access each other, thereby meeting the problem that there is no solution suitable for solving the splitting scenario of a mobile application project deployed in the form of an H5 offline package in the prior art. The device includes four parts: a custom splitting rule unit, a code structure analysis unit, a splitting unit, and an integration unit. Figure 1 shown.
[0035] exist Figure 1 Based on this, take the target application as an example to introduce the target application splitting process. Figure 2 , the splitting process of the target application may include: S11. Obtain a target application and a splitting rule corresponding to the target application.
[0036] In actual scenarios, the target application can be an H5 mobile application.
[0037] The custom split rule unit is used for users to formulate split rules. This unit supports users to upload split rule table files of target applications. First, according to the existing directory structure of the project, the user fills in the project rule template to specify the split rules, as shown in Table 1, and finally uploads them to the unit in the form of a table file and parses them.
[0038] Table 1
[0039] In Table 1, a large project is divided into a platform project (also called the main project) and multiple business module projects (also called sub-projects). The main project and sub-projects have corresponding function package names and offline package IDs. Each sub-project contains only a certain type of business function, and a certain type of business function can include multiple sub-functions. For example, business module project 1 in Table 1 includes chidAbility1 (function 1), chidAbility2 (function 2), chidAbility3 (function 3)... S12: Process the target application based on the splitting rule to generate sub-project splitting information and a public resource identifier.
[0040] The sub-project splitting information includes a global variable configuration file and a modified marking result.
[0041] In actual scenarios, the code structure analysis unit is used to analyze the current project code structure according to the splitting rule information filled in by the user, and generate configuration files such as main.js for the sub-project. Configuration files such as main.js are global variable configuration files, including the root node, font size, main entrance of the sub-project, main project style, and variables that the sub-project needs to be consistent with the main project.
[0042] The code structure analysis unit will also determine the file resource call frequency of the files in the target application, identify the public resource files according to the file resource call frequency, mark the public resource files, and obtain the public resource identifier of the public resource files, which is used as the basis for splitting by the engineering splitting unit.
[0043] In addition, the code structure analysis unit will also perform modification marking processing on the files that reference the public resources in the target application to obtain modification marking results, which are used as a modification basis for the integration unit.
[0044] In this embodiment, after obtaining the modification marking result, the global variable configuration file and the modification marking result are combined to obtain sub-project splitting information.
[0045] S13: Split the target application into a main project and multiple sub-projects according to the sub-project splitting information and the public resource identifier.
[0046] The splitting process in this embodiment is mainly implemented by a splitting unit, which is mainly used to split a large project into a platform project (also called a main project) and multiple business module projects (also called sub-projects); extract common resources, which can be packaged separately for offline package calls of each sub-project; generate routing configuration file information in the main project to manage the routing of each function in the main project and the routing information of the offline package of each sub-project, so as to be used for loading and communication between functions and offline packages.
[0047] In one implementation, the splitting unit is composed of a project splitter, a common resource extractor, and a routing configuration generator.
[0048] The project splitter is used to split the entire application project into a main project and multiple sub-projects according to the sub-project splitting information and public resource identifiers generated by the code structure analysis unit. The overall workflow is as follows: Figure 3 As shown. It is particularly noted that, in order to reduce maintenance costs, the embodiment of the present invention places the public resource-related content in the common directory of the main project; the sub-projects are divided based on the realization of business function classification, that is, each sub-project only contains a certain type of business function, and a certain type of business function can include multiple sub-functions. For example, the business module project 1 in Table 1 includes chidAbility1 (function 1), chidAbility2 (function 2), chidAbility3 (function 3)..., and each project has an independent code resource library, HIML, and JS entry file.
[0049] When the project splitter is split, the implementation steps are as follows: Step 1: Get the original project directory structure and create multiple sub-projects; Step 2: According to the sub-project splitting information, move the sub-project directory part in the directory of the target application and the files corresponding to the sub-project directory part to the corresponding sub-project.
[0050] Specifically, under the directory structure of the original target application, based on the user-defined splitting rule, according to the sub-project splitting information, the project files are traversed to determine whether the current file or its directory is in the user-defined splitting rule. If it is in the splitting rule, the files in its directory are moved to the sub-project. The files in the directory include the sub-project directory part in the directory of the target application and the files corresponding to the sub-project directory part.
[0051] Due to the movement of the file, the location of the file changes. In order to be able to access and call the file normally later, it is necessary to modify the import path of the file whose location has changed in the sub-project to obtain multiple sub-projects after splitting.
[0052] Step 3: Move the file corresponding to the public resource identifier to the first designated directory of the main project, and move the contents of the main project (excluding the sub-projects) in the target application except the file corresponding to the public resource identifier to the second designated directory of the main project, to obtain a split main project.
[0053] The first designated directory may be a common directory, which is used to store files corresponding to the public resource identifier, that is, public resource files. The second designated directory may be other directories under the main project except the common directory.
[0054] Specifically, a new common directory is created in the original project, and public images, CSS, public components, etc. are identified as public resource files and moved to the directory. Specifically, if the current file or its directory is not in the user-defined splitting rule, it is further determined based on the determined public resource identifier whether the current file is identified as a public resource. If it is marked as a public resource, it is moved to the common directory. If it is not marked, the duplicate content of the transplanted files (files that have been moved into the sub-project and the common directory) in the original project is removed, that is, the files that have been moved into the sub-project and the common directory in the original project are deleted, and the remaining content is moved to the second designated directory of the main project to obtain a main project after splitting.
[0055] After the above steps, an application can be split into a main project and multiple sub-projects. The main project and the sub-projects are then packaged to obtain corresponding offline packages.
[0056] S14: Decompose the main project into a public resource offline package and a main project offline package, and package the sub-projects to obtain sub-project offline packages.
[0057] The public resource extractor is used to separate the public resource offline package. The public resource extractor further splits the main project, that is, the public resources are separated during packaging and packaged separately as public resource offline packages, including public images, CSS, public components, etc. Generate public resource configuration information such as common-vendor.js, common.js, common-components.js and the information of the packaging configuration file of the public resource configuration in the main project, and configure package.json, so that the public resource offline package can be extracted by running the packaging command.
[0058] The specific steps are as follows: Step 1: Configure the JS file for outputting public resource information in the main project, which is used as the entry for outputting public resource information. The JS files and the resources they contain are shown in Table 2:
[0059] Table 2
[0060] Step 2: Add a packaged configuration file a.config.js to the main project, and use the JS file configured above as the entry to extract public resource information from the main project. The public resource information includes: Configure the loader to convert ES6 to ES5, process JS information, configure the loader to process inline styles, the loader to process CSS, the loader to uniformly add browser prefixes, the loader to process CSS variables and functions, configure the loader to process files, and the loader to process public images.
[0061] Step 3: In package.json, configure the public resource packaging command, which is specifically the build command.
[0062] Step 4: After running the package build command on common, the public resource offline package can be extracted from the main project offline package, and the public resource information is packaged to obtain the public resource offline package. In addition, the part of the main project except the public resource information is packaged into the main project offline package. The main project offline package is the packaging configuration file in the embodiment of the present invention, that is, the packaging configuration file does not include the above public resource information, so as to ensure that when the main project is packaged, there is no need to repeatedly package the public resource information.
[0063] As described above, through the above four steps, the public resource information can be extracted from the main project offline package to generate a public resource offline package. At the same time, in the package.json of the main project, configure the packaging command and execute it to generate the main project offline package.
[0064] For the sub-project, the sub-project is packaged to obtain the sub-project offline package. Specifically, by configuring respective packaging commands in each sub-project, the sub-project offline package can be generated by running the run build command.
[0065] S15: Establish a logical relationship between the main project and the sub-project based on the public resource offline package, the main project offline package and the sub-project offline package.
[0066] In this embodiment, through the above steps, the target application has been split into a main project and multiple sub-projects, the main project includes a public resource offline package and a main project offline package; the sub-project includes a sub-project offline package. Subsequently, a logical relationship needs to be established between the main project and the sub-project to implement the call between the two.
[0067] Specifically, step S15 may include: 1) Generate routing configuration information.
[0068] The routing configuration information includes the internal routing of the main project offline package and the jump routing between the main project offline package and the sub-project offline package.
[0069] Specifically, the routing configuration generator is used to generate jump information between the functions in the main project offline package, the main project offline package and the sub-project offline package in the main project, providing a basis for the integration and communication between offline packages. Its operation process is as follows: Figure 4 shown.
[0070] Step 1: Get the user-defined splitting rules; Step 2: traverse the original project directory and determine the function directory in the directory of the target application to which the user-defined splitting rule belongs, that is, determine the attribution information of the function directory in the directory of the target application. The attribution information can be the main project or sub-project. If it is the main project, execute step 4; if it is a business module project, execute step 3; Step 3: Mark the function jump mode as external jump, and add the jump information of the sub-project offline package of the sub-project to which the function directory belongs to the routing configuration information of the main project offline package; Step 4: Configure the internal jump relationship of the function directory in the routing configuration information of the main project offline package. Specifically, mark the function jump mode as internal jump, and generate the routing configuration information of the function jump inside the main project offline package; Step 5: Generate routing center routing configuration information.
[0071] From the above, we can see that the routing configuration information of the internal routing of the main project offline package and the sub-function offline package jump routing in the corresponding project, the routing configuration generator generates a routing center according to the location of each function in the offline package, providing a basis for the introduction and jump between offline packages.
[0072] 2) Introducing the public resource offline package and the public configuration file into the main project offline package and the sub-project offline package, and modifying the resource reference path according to the modification marking result.
[0073] Specifically, the integration unit is mainly used to complete the introduction of common resources in the main and sub-projects and the jump transformation between the main project offline package and the sub-project offline package. The unit consists of a common resource introducer and an offline package jump integrator.
[0074] The public resource importer is used to complete the import of public resource offline packages in the main and sub-projects. Its operation process is as follows: Figure 5 shown.
[0075] Step 1: Get the access URL (uniform resource locator) and other information of the public resource offline package; Step 2: configure the information in step 1 to the main and sub-project packaging configuration files respectively in the form of packaging tool plug-in parameters; wherein the main and sub-project packaging configuration files are the main project offline package and the sub-project offline package.
[0076] Step 3: Import public configuration files such as js and css into the public / index.html file in the offline package of the main project and the offline package of the sub-project respectively; Step 4: Based on the modification marking results, determine whether the file has a modification mark, filter the files marked with modification marks in the code analysis unit, and modify the reference paths of resources such as images in the file.
[0077] 3) Using the main project offline package as the only entry to the target application, a linkage relationship between the main project offline package and each of the sub-project offline packages is constructed to establish a logical relationship between the main project and the sub-projects.
[0078] Specifically, the offline package integrator is mainly used to link the offline packages together, use the main project offline package as the only entry point for the application, obtain the sub-project offline package resources through the routing center, click the entry point for the sub-project offline package, and the main project offline package jumps to the sub-project offline package through the native JSAPI, and passes shared data to the sub-project offline package through params. After receiving the resource request, the sub-project offline package downloads the sub-project offline package resources. Based on the above process, integration, access and communication between offline packages are realized. Its operation process is as follows: Figure 6 shown.
[0079] Step 1: Obtain configuration information of each function from the routing center; Step 2: Traverse step 1 to obtain configuration information, and determine whether the jump mode is internal jump or external jump. If it is external jump, execute steps 3 and 4; Step 3: Change the response event when clicking the function in the main project to call the sub-project offline package, that is, call the native JSAPI instead, notify the native application to open a new webView, and pass parameters through params; Step 4: Modify the created() function of the sub-project entry page to receive parameters when it is opened.
[0080] Through the above steps, a project is split into a main project and multiple sub-projects. After packaging and publishing in each project, the offline package splitting can be completed; the main project offline package is used as the entry point of the application, and the integrated interaction of each sub-project offline package is realized through the routing center and the native JSAPI. Subsequently, the main project offline package, the public resource offline package, and the sub-project offline package required by the user are loaded based on the user's loading requirements. The interaction mode of each offline package output by this device is as follows Figure 7 shown.
[0081] For the H5 offline package, the embodiment of the present invention is based on the design principles of modularity, reusability, and scalability, and splits the project into the form of "one platform + multiple business modules". The packaged offline package is divided into a public resource offline package (pictures, CSS, components, etc.), a main project offline package (home page, login authentication, routing center, etc.) and each business module offline package (that is, the above-mentioned sub-project offline package, including business information, communication within the offline package, etc.). The public resource offline package can be called by the main project offline package and the sub-project offline package. When calling the sub-project offline package, the main project offline package can pass parameters through params.
[0082] Each business module can introduce public resources as needed for independent development, packaging, and deployment, thereby achieving mutual decoupling between business functions and better project engineering maintenance. The size of each offline package is greatly reduced to increase the loading speed of the application, save user traffic, improve user experience, and adapt to the needs of different users and scenarios.
[0083] In summary, the present invention proposes a mobile application project splitting and integration method suitable for H5 offline packages. Through user-defined splitting rules, the project is automatically split, which solves the problem of large amount of project splitting and transformation and high dependence on manual operation of developers, and greatly improves the efficiency of framework transformation.
[0084] In addition, the present invention solves the loading and communication problems of mobile applications after splitting based on H5 offline package deployment by combining routing center configuration and calling native methods, so that the distributed system application concept can be applied to the H5 offline package scenario.
[0085] In addition, based on the idea of distributed systems, the present invention splits a project into multiple projects, isolates the project codes from each other, places public resources in the main project at the project level during the splitting process, and extracts public resources at the offline package packaging level, so that sub-projects can introduce public resources as needed when using them. This reduces the complexity of project management while allowing public resources to be used multiple times, greatly reducing redundancy, improving the modular flexibility and maintainability of mobile applications, and making it easier for developers to update and maintain each module separately.
[0086] After the application is split through the above steps, it can be put online for use to respond to user needs. Specifically, another embodiment of the present invention provides a request processing method, referring to Figure 8 , which may include: S101: Receive a user loading request.
[0087] Among them, taking the application as an H5 mobile application as an example, if a user clicks on a certain H5 mobile application, it can be considered that a user loading request is received.
[0088] S102: In response to the user loading request, load the main project offline package and the public resource offline package of the target application.
[0089] The target application is divided into a main project and multiple sub-projects. The main project includes a public resource offline package and a main project offline package; the sub-project includes a sub-project offline package. The specific implementation process refers to the corresponding description above.
[0090] Specifically, when a user accesses the project, the main project offline package is installed and loaded first and put into memory to achieve efficient caching. At the same time, the public resource offline package is pulled and loaded.
[0091] S103: If an instruction is received from the user to click on a target function on an interface obtained after loading the offline package of the main project, a target sub-project corresponding to the target function is determined.
[0092] After loading the main project offline package, the H5 mobile application interface can be displayed. On this interface, multiple types of business functions are configured. Each type of business function corresponds to a sub-project offline package. Users can choose whether to click on a business function according to their own needs. If the user does not click on the business function corresponding to the sub-project offline package, the sub-project offline package will not be loaded.
[0093] If the user clicks on a business function, such as a target function, the sub-project offline package corresponding to the function needs to be loaded. At this time, the target sub-project corresponding to the target function is determined, and then the sub-project offline package corresponding to the target sub-project is determined.
[0094] S104, jumping to the sub-project offline package corresponding to the target sub-project through the routing center and the designated interface, loading the sub-function offline package corresponding to the target sub-project, to respond to the instruction.
[0095] Among them, the sub-project offline packages corresponding to the functions that are not clicked by the user are prohibited from loading. Please refer to the above corresponding instructions for details.
[0096] For the target function clicked by the user, for the sub-project offline package of the target sub-project corresponding to the target function, the main project offline package jumps to the sub-project offline package through the routing center and native JSAPI, and loads the currently clicked sub-project offline package at the same time.
[0097] After the sub-project offline package is loaded, the sub-project offline package can be used to respond to user instructions, allowing the user to perform corresponding operations.
[0098] In this embodiment, the target application is divided into a main project and multiple sub-projects, the main project includes a public resource offline package and a main project offline package; the sub-project includes a sub-project offline package. On this basis, if a user loading request is received, the main project offline package and the public resource offline package of the target application are loaded first. If the user clicks on the target function on the interface obtained after loading the main project offline package, the target sub-project corresponding to the target function is determined, and the sub-project offline package corresponding to the target sub-project is jumped to through the routing center and the designated interface, and the sub-function offline package is loaded to respond to the instruction. The sub-project offline package corresponding to the function that is not clicked by the user is prohibited from loading. That is, through the present invention, only the data required by the user is loaded, and the data not required by the user is temporarily not loaded, which can reduce the amount of loaded data, improve the one-time loading success rate, and thus improve the user experience.
[0099] In addition, while solving the problems of too large offline packages and long resource loading time, this method also caches resources and loads them on demand, improving the user experience. In addition, the offline packages of sub-projects can be expanded independently, which is highly flexible.
[0100] Based on the above-mentioned request processing method embodiment, another embodiment of the present invention provides a request processing device, referring to Fig. 9 , which may include: A request receiving module 111 is used to receive a user loading request; The first loading module 112 is used to respond to the user's loading request and load the main project offline package and the public resource offline package of the target application; the target application is divided into a main project and multiple sub-projects, the main project includes the public resource offline package and the main project offline package; the sub-project includes the sub-project offline package; The instruction response module 113 is used to determine the target sub-project corresponding to the target function upon receiving an instruction from the user to click on the target function on the interface obtained after loading the offline package of the main project; The second loading module 114 is used to jump to the sub-project offline package corresponding to the target sub-project through the routing center and the designated interface, and load the sub-function offline package corresponding to the target sub-project to respond to the instruction; wherein, the sub-project offline package corresponding to the function not clicked by the user is prohibited from loading.
[0101] In one implementation, an application splitting module is further included, and the application splitting module includes: A data acquisition submodule, used to acquire a target application and a splitting rule corresponding to the target application; A generation submodule, used to process the target application based on the splitting rule, generate sub-project splitting information and a public resource identifier; the sub-project splitting information includes a global variable configuration file and a modified marking result; A splitting submodule, used to split the target application into a main project and multiple sub-projects according to the sub-project splitting information and the public resource identifier; A packaging submodule, used to decompose the main project into a public resource offline package and a main project offline package, and to package the sub-projects to obtain sub-project offline packages; The relationship establishment submodule is used to establish a logical relationship between the main project and the sub-project based on the public resource offline package, the main project offline package and the sub-project offline package.
[0102] In one implementation, the generating submodule includes: An analysis unit, configured to analyze the code structure of the target application based on the splitting rule to obtain a global variable configuration file; A frequency determination unit, used to determine the file resource call frequency of the file in the target application; A marking unit, used for identifying a public resource file based on the file resource calling frequency, marking the public resource file, and obtaining a public resource identifier of the public resource file; A reference unit, used for modifying and marking files that reference public resources in the target application to obtain modification and marking results; The combining unit is used to combine the global variable configuration file and the modified marking result to obtain sub-project splitting information.
[0103] In one implementation, the split submodule includes: Project creation unit, used to create multiple sub-projects; A first moving unit, configured to move the sub-project directory part and the files corresponding to the sub-project directory part in the directory of the target application to the corresponding sub-project according to the sub-project splitting information; A path modification unit, for modifying the import path of a file whose location has changed in a sub-project, to obtain multiple sub-projects after splitting; A second moving unit is used to move the file corresponding to the public resource identifier to a first designated directory of the main project; The third moving unit is used to move the contents of the main project in the target application except the file corresponding to the public resource identifier to the second designated directory of the main project to obtain a split main project.
[0104] In one implementation, the packaging submodule includes: An interface configuration unit, used to configure JS files in the main project; A first data processing unit is used to extract public resource information from the main project using the JS file as an entry, and to package the public resource information to obtain a public resource offline package; The second data processing unit is used to package the part of the main project except the public resource information into a main project offline package.
[0105] In one implementation, the relationship establishment submodule includes: An information generating unit, used for generating routing configuration information; A data import unit, used for importing the public resource offline package and the public configuration file into the main project offline package and the sub-project offline package; A path modification unit, used to modify the resource reference path according to the modification marking result; The relationship building unit is used to use the main project offline package as the only entry of the target application, build a linkage relationship between the main project offline package and each of the sub-project offline packages, so as to establish a logical relationship between the main project and the sub-projects.
[0106] In one implementation, the information generating unit includes: an attribution determination subunit, configured to determine attribution information of a function directory in the directory of the target application based on the splitting rule; A first configuration subunit is used to configure the internal jump relationship of the function directory in the routing configuration information of the offline package of the main project if the belonging information is the main project; The second configuration subunit is used to add the jump information of the sub-project offline package of the sub-project to which the function directory belongs to the routing configuration information of the main project offline package to obtain the routing configuration information if the belonging information is a sub-project.
[0107] In this embodiment, the target application is divided into a main project and multiple sub-projects, the main project includes a public resource offline package and a main project offline package; the sub-project includes a sub-project offline package. On this basis, if a user loading request is received, the main project offline package and the public resource offline package of the target application are loaded first. If the user clicks on the target function on the interface obtained after loading the main project offline package, the target sub-project corresponding to the target function is determined, and the sub-project offline package corresponding to the target sub-project is jumped to through the routing center and the designated interface, and the sub-function offline package is loaded to respond to the instruction. The sub-project offline package corresponding to the function that is not clicked by the user is prohibited from loading. That is, through the present invention, only the data required by the user is loaded, and the data not required by the user is temporarily not loaded, which can reduce the amount of loaded data, improve the one-time loading success rate, and thus improve the user experience.
[0108] It should be noted that, for the working process of each module, sub-module, unit and sub-unit in the embodiment of the present invention, please refer to the corresponding description in the above embodiment, which will not be repeated here.
[0109] An embodiment of the present application also provides an electronic device, including at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the above-mentioned request processing method.
[0110] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any one of the request processing methods provided in the embodiments of the present application.
[0111] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any request processing method provided in an embodiment of the present application.
[0112] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A request processing method, characterized in that: include: Receive user loading request; In response to the user loading request, the main project offline package and the public resource offline package of the target application are loaded; The target application is divided into a main project and multiple sub-projects, the main project includes a public resource offline package and a main project offline package; the sub-project includes a sub-project offline package; If an instruction is received from a user to click a target function on an interface obtained after loading the offline package of the main project, a target sub-project corresponding to the target function is determined; Jump to the sub-project offline package corresponding to the target sub-project through the routing center and the designated interface, load the sub-function offline package corresponding to the target sub-project to respond to the instruction; wherein, the sub-project offline package corresponding to the function not clicked by the user is prohibited from loading.
2. The request processing method according to claim 1, characterized in that: The target application splitting process includes: Obtain a target application and a splitting rule corresponding to the target application; Processing the target application based on the splitting rule to generate sub-project splitting information and a public resource identifier; the sub-project splitting information includes a global variable configuration file and a modified marking result; Splitting the target application into a main project and multiple sub-projects according to the sub-project splitting information and the public resource identifier; Decomposing the main project into a public resource offline package and a main project offline package, and packaging the sub-projects to obtain sub-project offline packages; Based on the public resource offline package, the main project offline package and the sub-project offline package, a logical relationship between the main project and the sub-project is established.
3. The request processing method according to claim 2, characterized in that: The target application is processed based on the splitting rule to generate sub-project splitting information and a public resource identifier, including: Based on the splitting rule, the code structure of the target application is analyzed to obtain a global variable configuration file; Determine the file resource call frequency of the file in the target application; Identify a public resource file based on the file resource call frequency, mark the public resource file, and obtain a public resource identifier of the public resource file; Perform modification marking processing on files that reference public resources in the target application to obtain modification marking results; The global variable configuration file and the modified marking result are combined to obtain sub-project splitting information.
4. The request processing method according to claim 2, characterized in that: According to the sub-project splitting information and the public resource identifier, the target application is split into a main project and multiple sub-projects, including: Create multiple sub-projects; According to the sub-project splitting information, move the sub-project directory part in the directory of the target application and the files corresponding to the sub-project directory part to the corresponding sub-project; For files whose locations have changed in a sub-project, modify the import path of the files to obtain multiple sub-projects after splitting; Move the file corresponding to the public resource identifier to the first designated directory of the main project; In the target application, the contents of the main project except the file corresponding to the public resource identifier are moved to the second designated directory of the main project to obtain a split main project.
5. The request processing method according to claim 2, characterized in that: Decompose the main project into a public resource offline package and a main project offline package, including: Configure the JS file in the main project; Using the JS file as an entry, extracting public resource information from the main project, and packaging the public resource information to obtain a public resource offline package; The part of the main project except the public resource information is packaged into a main project offline package.
6. The request processing method according to claim 2, characterized in that: Based on the public resource offline package, the main project offline package and the sub-project offline package, a logical relationship between the main project and the sub-project is established, including: Generate routing configuration information; Introducing the public resource offline package and the public configuration file into the main project offline package and the sub-project offline package; Modify the resource reference path according to the modification marking result; The main project offline package is used as the only entry to the target application, and a linkage relationship between the main project offline package and each of the sub-project offline packages is constructed to establish a logical relationship between the main project and the sub-projects.
7. The request processing method according to claim 6, characterized in that: Generate routing configuration information, including: Based on the splitting rule, determining the attribution information of the function directory in the directory of the target application; If the belonging information is a main project, configure the internal jump relationship of the function directory in the routing configuration information of the offline package of the main project; If the belonging information is a sub-project, the jump information of the sub-project offline package of the sub-project to which the function directory belongs is added to the routing configuration information of the main project offline package to obtain the routing configuration information.
8. A request processing device, characterized in that: include: A request receiving module, used for receiving a user loading request; A first loading module is used to respond to the user loading request and load the main project offline package and the public resource offline package of the target application; the target application is divided into a main project and multiple sub-projects, the main project includes the public resource offline package and the main project offline package; the sub-project includes the sub-project offline package; The instruction response module is used to determine the target sub-project corresponding to the target function upon receiving an instruction from the user to click on the target function on the interface obtained after loading the offline package of the main project; The second loading module is used to jump to the sub-project offline package corresponding to the target sub-project through the routing center and the designated interface, and load the sub-function offline package corresponding to the target sub-project to respond to the instruction; wherein, the sub-project offline package corresponding to the function not clicked by the user is prohibited from loading.
9. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the request processing method as described in any one of claims 1 to 7.
10. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the request processing method as described in any one of claims 1 to 7.